diff --git a/.gitignore b/.gitignore index 850a6e9fac..ee7a997dd5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ #idea /.idea +/classes *.iml #gradle @@ -20,7 +21,6 @@ /buildSrc #Patch rejects -*.rej /patches-/ # FML changelog diff --git a/LICENSE-new.txt b/LICENSE-new.txt new file mode 100644 index 0000000000..be2c9e66dc --- /dev/null +++ b/LICENSE-new.txt @@ -0,0 +1,483 @@ +Minecraft Forge is 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. + +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. + + + 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 diff --git a/build.gradle b/build.gradle index 64c092506b..285a7ea677 100644 --- a/build.gradle +++ b/build.gradle @@ -26,11 +26,11 @@ apply plugin: "net.minecraftforge.gradle.patcher" apply plugin: "net.minecraftforge.gradle.launch4j" minecraft { - version = "1.8.9" - mappings = 'stable_20' + version = "1.9" + mappings = 'snapshot_nodoc_20160312' //mappings = "snapshot_nodoc_20151122" workspaceDir = "projects" - versionJson = "jsons/1.8.9-dev.json" + versionJson = "jsons/1.9-dev.json" buildUserdev = true buildInstaller = true installerVersion = "1.4" @@ -66,7 +66,7 @@ extractForgeResources { exclude "**/log4j2.xml" } genGradleProjects { addTestCompileDep "junit:junit:4.12" } processJson { - releaseJson = "jsons/1.8.9-rel.json" + releaseJson = "jsons/1.9-rel.json" addReplacements([ "@minecraft_version@": project.minecraft.version, "@version@": project.version, @@ -171,25 +171,25 @@ task makeMdk(type: Zip) { from 'gradlew' from 'gradlew.bat' into ('gradle') { - from 'gradle' + from 'gradle' } into ('eclipse') { from 'mdk/eclipse' } from changelog.output from ('mdk') { - filter(ReplaceTokens, tokens: [ - VERSION: project.version, - MAPPINGS: minecraft.mappings.replace('nodoc_', '') - ]) - exclude 'eclipse' - rename 'gitignore\\.txt', '.gitignore' - from 'MinecraftForge-Credits.txt' - from 'MinecraftForge-License.txt' - from 'Paulscode IBXM Library License.txt' - from 'Paulscode SoundSystem CodecIBXM License.txt' - from 'CREDITS-fml.txt' - from 'LICENSE-fml.txt' + filter(ReplaceTokens, tokens: [ + VERSION: project.version, + MAPPINGS: minecraft.mappings.replace('nodoc_', '') + ]) + exclude 'eclipse' + rename 'gitignore\\.txt', '.gitignore' + from 'MinecraftForge-Credits.txt' + from 'MinecraftForge-License.txt' + from 'Paulscode IBXM Library License.txt' + from 'Paulscode SoundSystem CodecIBXM License.txt' + from 'CREDITS-fml.txt' + from 'LICENSE-fml.txt' } } tasks.build.dependsOn makeMdk @@ -374,3 +374,14 @@ String getVersionFromJava(File file) // should be remvoed, and the jenkisn fixed when no longer building with FG 1.2 task setupForge { dependsOn 'setup' } task buildPackages { dependsOn 'build' } + +//Temporary hack to fix compile errors caused by mappings shading in Bootstrap +task fixParams << { + logger.lifecycle('Fixing param names!') + def params = new File(extractMcpMappings.destinationDir, 'params.csv') + def text = params.text + text = text.replaceAll('p_82499_3_,stack,', 'p_82499_3_,stackIn,') + params.write(text) +} +fixParams.dependsOn('extractMcpMappings') +extractMcpMappings.finalizedBy('fixParams') diff --git a/jsons/1.9-dev.json b/jsons/1.9-dev.json new file mode 100644 index 0000000000..bcca6f1593 --- /dev/null +++ b/jsons/1.9-dev.json @@ -0,0 +1,95 @@ +{ + "id": "@minecraft_version@-@project@@version@", + "time": "@timestamp@", + "releaseTime": "1960-01-01T00:00:00-0700", + "type": "release", + "inheritsFrom": "1.9", + "minecraftArguments": "--version FML_DEV --tweakClass net.minecraftforge.fml.common.launcher.FMLTweaker", + "libraries": [ + { + "name": "net.minecraft:launchwrapper:1.12" + }, + { + "name": "jline:jline:2.13", + "children": ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "com.google.code.findbugs:jsr305:1.3.9", + "children": ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.ow2.asm:asm-debug-all:5.0.3", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "com.typesafe.akka:akka-actor_2.11:2.3.3", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "com.typesafe:config:1.2.1", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.scala-lang:scala-actors-migration_2.11:1.1.0", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.scala-lang:scala-compiler:2.11.1", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.scala-lang:scala-library:2.11.1", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.scala-lang:scala-reflect:2.11.1", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.scala-lang.modules:scala-swing_2.11:1.0.1", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "org.scala-lang.modules:scala-xml_2.11:1.0.2", + "children" : ["sources"], + "url" : "http://repo.maven.apache.org/maven2" + }, + { + "name": "lzma:lzma:0.0.1" + }, + { + "name": "java3d:vecmath:1.5.2" + }, + { + "name": "net.sf.trove4j:trove4j:3.0.3" + } + ], + "mainClass": "net.minecraft.launchwrapper.Launch", + "minimumLauncherVersion": 14, + "assets": "1.8" +} diff --git a/jsons/1.9-rel.json b/jsons/1.9-rel.json new file mode 100644 index 0000000000..dcf68dbab6 --- /dev/null +++ b/jsons/1.9-rel.json @@ -0,0 +1,144 @@ +{ +"install": { + "profileName": "@project@", + "target":"@minecraft_version@-@project@@version@", + "path":"@artifact@", + "version":"@project@ @version@", + "filePath":"@universal_jar@", + "welcome":"Welcome to the simple @project@ installer.", + "minecraft":"@minecraft_version@", + "mirrorList" : "http://files.minecraftforge.net/mirror-brand.list", + "logo":"/big_logo.png" +}, +"versionInfo": { + "id": "@minecraft_version@-@project@@version@", + "time": "@timestamp@", + "releaseTime": "1960-01-01T00:00:00-0700", + "type": "release", + "minecraftArguments": "--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userType ${user_type} --tweakClass net.minecraftforge.fml.common.launcher.FMLTweaker --versionType Forge", + "mainClass": "net.minecraft.launchwrapper.Launch", + "minimumLauncherVersion": 14, + "inheritsFrom": "1.9", + "libraries": [ + { + "name": "@artifact@", + "url": "http://files.minecraftforge.net/maven/" + }, + { + "comment": "Force the downgrade on dedicated server to match client. Netty bug: https://github.com/MinecraftForge/MinecraftForge/issues/1848", + "name": "io.netty:netty-all:4.0.23.Final", + "serverreq":true + }, + { + "name": "net.minecraft:launchwrapper:1.12", + "serverreq":true + }, + { + "name": "org.ow2.asm:asm-all:5.0.3", + "serverreq":true + }, + { + "name": "jline:jline:2.13", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "2d9530d0a25daffaffda7c35037b046b627bb171" ], + "serverreq":true, + "clientreq":false + }, + { + "name": "com.typesafe.akka:akka-actor_2.11:2.3.3", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "ed62e9fc709ca0f2ff1a3220daa8b70a2870078e", "25a86ccfdb6f6dfe08971f4825d0a01be83a6f2e" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "com.typesafe:config:1.2.1", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "f771f71fdae3df231bcd54d5ca2d57f0bf93f467", "7d7bc36df0989d72f2d5d057309675777acc528b" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "org.scala-lang:scala-actors-migration_2.11:1.1.0", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "dfa8bc42b181d5b9f1a5dd147f8ae308b893eb6f", "8c9aaeeb68487ca519411a14068e1b4d69739207" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "org.scala-lang:scala-compiler:2.11.1", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "56ea2e6c025e0821f28d73ca271218b8dd04926a", "1444992390544ba3780867a13ff696a89d7d1639" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "87213338cd5a153a7712cb574c0ddd2edfee0386", "0b4c1bf8d48993f138d6e10c0c144e50acfff581" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "1f7371605d4ba42aa26d3443440c0083c587b4e9", "1ea655dda4504ae0a367327e2340cd3beaee6c73" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "org.scala-lang:scala-library:2.11.1", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "0e11da23da3eabab9f4777b9220e60d44c1aab6a", "1e4df76e835201c6eabd43adca89ab11f225f134" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "org.scala-lang:scala-parser-combinators_2.11:1.0.1", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "f05d7345bf5a58924f2837c6c1f4d73a938e1ff0", "a1cbbcbde1dcc614f4253ed1aa0b320bc78d8f1d" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "org.scala-lang:scala-reflect:2.11.1", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "6580347e61cc7f8e802941e7fde40fa83b8badeb", "91ce0f0be20f4a536321724b4b3bbc6530ddcd88" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "org.scala-lang:scala-swing_2.11:1.0.1", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "b1cdd92bd47b1e1837139c1c53020e86bb9112ae", "d77152691dcf5bbdb00529af37aa7d3d887b3e63" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "org.scala-lang:scala-xml_2.11:1.0.2", + "url" : "http://files.minecraftforge.net/maven/", + "checksums" : [ "7a80ec00aec122fba7cd4e0d4cdd87ff7e4cb6d0", "62736b01689d56b6d09a0164b7ef9da2b0b9633d" ], + "serverreq":true, + "clientreq":true + }, + { + "name": "lzma:lzma:0.0.1", + "serverreq":true + }, + { + "name": "net.sf.jopt-simple:jopt-simple:4.6", + "serverreq":true + }, + { + "name": "java3d:vecmath:1.5.2", + "clientreq":true, + "serverreq":true + }, + { + "name": "net.sf.trove4j:trove4j:3.0.3", + "clientreq":true, + "serverreq":true + } + ] +} +} diff --git a/jsons/1.9.json b/jsons/1.9.json new file mode 100644 index 0000000000..f366dbe213 --- /dev/null +++ b/jsons/1.9.json @@ -0,0 +1,218 @@ +{ + "id": "1.9", + "time": "2016-02-29T08:50:46-05:00", + "releaseTime": "2016-02-29T08:49:54-05:00", + "type": "release", + "minecraftArguments": "--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userType ${user_type} --versionType ${version_type}", + "libraries": [ + { + "name": "oshi-project:oshi-core:1.1" + }, + { + "name": "net.java.dev.jna:jna:3.4.0" + }, + { + "name": "net.java.dev.jna:platform:3.4.0" + }, + { + "name": "com.ibm.icu:icu4j-core-mojang:51.2" + }, + { + "name": "net.sf.jopt-simple:jopt-simple:4.6" + }, + { + "name": "com.paulscode:codecjorbis:20101023" + }, + { + "name": "com.paulscode:codecwav:20101023" + }, + { + "name": "com.paulscode:libraryjavasound:20101123" + }, + { + "name": "com.paulscode:librarylwjglopenal:20100824" + }, + { + "name": "com.paulscode:soundsystem:20120107" + }, + { + "name": "io.netty:netty-all:4.0.23.Final" + }, + { + "name": "com.google.guava:guava:17.0" + }, + { + "name": "org.apache.commons:commons-lang3:3.3.2" + }, + { + "name": "commons-io:commons-io:2.4" + }, + { + "name": "commons-codec:commons-codec:1.9" + }, + { + "name": "net.java.jinput:jinput:2.0.5" + }, + { + "name": "net.java.jutils:jutils:1.0.0" + }, + { + "name": "com.google.code.gson:gson:2.2.4" + }, + { + "name": "com.mojang:authlib:1.5.22" + }, + { + "name": "com.mojang:realms:1.8.3" + }, + { + "name": "org.apache.commons:commons-compress:1.8.1" + }, + { + "name": "org.apache.httpcomponents:httpclient:4.3.3" + }, + { + "name": "commons-logging:commons-logging:1.1.3" + }, + { + "name": "org.apache.httpcomponents:httpcore:4.3.2" + }, + { + "name": "org.apache.logging.log4j:log4j-api:2.0-beta9" + }, + { + "name": "org.apache.logging.log4j:log4j-core:2.0-beta9" + }, + { + "name": "org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209", + "rules": [ + { + "action": "allow" + }, + { + "action": "disallow", + "os": { + "name": "osx" + } + } + ] + }, + { + "name": "org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209", + "rules": [ + { + "action": "allow" + }, + { + "action": "disallow", + "os": { + "name": "osx" + } + } + ] + }, + { + "name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209", + "rules": [ + { + "action": "allow" + }, + { + "action": "disallow", + "os": { + "name": "osx" + } + } + ], + "natives": { + "linux": "natives-linux", + "osx": "natives-osx", + "windows": "natives-windows" + }, + "extract": { + "exclude": [ + "META-INF/" + ] + } + }, + { + "name": "org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-20140822", + "rules": [ + { + "action": "allow", + "os": { + "name": "osx" + } + } + ] + }, + { + "name": "org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-20140822", + "rules": [ + { + "action": "allow", + "os": { + "name": "osx" + } + } + ] + }, + { + "name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.2-nightly-20140822", + "rules": [ + { + "action": "allow", + "os": { + "name": "osx" + } + } + ], + "natives": { + "linux": "natives-linux", + "osx": "natives-osx", + "windows": "natives-windows" + }, + "extract": { + "exclude": [ + "META-INF/" + ] + } + }, + { + "name": "net.java.jinput:jinput-platform:2.0.5", + "natives": { + "linux": "natives-linux", + "osx": "natives-osx", + "windows": "natives-windows" + }, + "extract": { + "exclude": [ + "META-INF/" + ] + } + } + ], + "mainClass": "net.minecraft.client.main.Main", + "minimumLauncherVersion": 18, + "assets": "1.9", + "downloads": { + "client": { + "url": "https://launcher.mojang.com/mc/game/1.9/client/2f67dfe8953299440d1902f9124f0f2c3a2c940f/client.jar", + "sha1": "2f67dfe8953299440d1902f9124f0f2c3a2c940f", + "size": 8697592 + }, + "server": { + "url": "https://launcher.mojang.com/mc/game/1.9/server/b4d449cf2918e0f3bd8aa18954b916a4d1880f0d/server.jar", + "sha1": "b4d449cf2918e0f3bd8aa18954b916a4d1880f0d", + "size": 8848015 + } + }, + "assetIndex": { + "totalSize": 119917473, + "id": "1.9", + "known": true, + "url": "https://launchermeta.mojang.com/mc-staging/assets/1.9/cde65b47a43f638653ab1da3848b53f8a7477b16/1.9.json", + "sha1": "cde65b47a43f638653ab1da3848b53f8a7477b16", + "size": 136916 + } +} \ No newline at end of file diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index 5b4a8fa04b..8e26daf20b 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -1,28 +1,22 @@ --- ../src-base/minecraft/net/minecraft/block/Block.java +++ ../src-work/minecraft/net/minecraft/block/Block.java -@@ -38,8 +38,9 @@ - public class Block +@@ -43,11 +43,12 @@ + import net.minecraftforge.fml.relauncher.Side; + import net.minecraftforge.fml.relauncher.SideOnly; + +-public class Block ++public class Block extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl { private static final ResourceLocation field_176230_a = new ResourceLocation("air"); - public static final RegistryNamespacedDefaultedByKey field_149771_c = new RegistryNamespacedDefaultedByKey(field_176230_a); - public static final ObjectIntIdentityMap field_176229_d = new ObjectIntIdentityMap(); -+ public static final RegistryNamespacedDefaultedByKey field_149771_c = net.minecraftforge.fml.common.registry.GameData.getBlockRegistry(); ++ public static final RegistryNamespacedDefaultedByKey field_149771_c = net.minecraftforge.fml.common.registry.GameData.getBlockRegistry(); + @Deprecated //Modders: DO NOT use this! Use GameRegistry + public static final ObjectIntIdentityMap field_176229_d = net.minecraftforge.fml.common.registry.GameData.getBlockStateIDMap(); + public static final AxisAlignedBB field_185505_j = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D); + public static final AxisAlignedBB field_185506_k = null; private CreativeTabs field_149772_a; - public static final Block.SoundType field_149769_e = new Block.SoundType("stone", 1.0F, 1.0F); - public static final Block.SoundType field_149766_f = new Block.SoundType("wood", 1.0F, 1.0F); -@@ -119,6 +120,9 @@ - private IBlockState field_176228_M; - private String field_149770_b; - -+ public final net.minecraftforge.fml.common.registry.RegistryDelegate delegate = -+ ((net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry)field_149771_c).getDelegate(this, Block.class); -+ - public static int func_149682_b(Block p_149682_0_) - { - return field_149771_c.func_148757_b(p_149682_0_); -@@ -132,7 +136,8 @@ +@@ -83,7 +84,8 @@ public static Block func_149729_e(int p_149729_0_) { @@ -32,16 +26,16 @@ } public static IBlockState func_176220_d(int p_176220_0_) -@@ -303,7 +308,7 @@ +@@ -268,7 +270,7 @@ - public boolean func_176200_f(World p_176200_1_, BlockPos p_176200_2_) + public boolean func_176200_f(IBlockAccess p_176200_1_, BlockPos p_176200_2_) { - return false; -+ return func_149688_o().func_76222_j(); ++ return p_176200_1_.func_180495_p(p_176200_2_).func_185904_a().func_76222_j(); } public Block func_149711_c(float p_149711_1_) -@@ -340,9 +345,10 @@ +@@ -305,9 +307,10 @@ return this.field_149789_z; } @@ -52,33 +46,33 @@ + return hasTileEntity(func_176223_P()); } - public final void func_149676_a(float p_149676_1_, float p_149676_2_, float p_149676_3_, float p_149676_4_, float p_149676_5_, float p_149676_6_) -@@ -359,13 +365,13 @@ - public int func_176207_c(IBlockAccess p_176207_1_, BlockPos p_176207_2_) + public AxisAlignedBB func_185496_a(IBlockState p_185496_1_, IBlockAccess p_185496_2_, BlockPos p_185496_3_) +@@ -346,13 +349,13 @@ + @SideOnly(Side.CLIENT) + public int func_185484_c(IBlockState p_185484_1_, IBlockAccess p_185484_2_, BlockPos p_185484_3_) { - Block block = p_176207_1_.func_180495_p(p_176207_2_).func_177230_c(); -- int i = p_176207_1_.func_175626_b(p_176207_2_, block.func_149750_m()); -+ int i = p_176207_1_.func_175626_b(p_176207_2_, block.getLightValue(p_176207_1_, p_176207_2_)); +- int i = p_185484_2_.func_175626_b(p_185484_3_, p_185484_1_.func_185906_d()); ++ int i = p_185484_2_.func_175626_b(p_185484_3_, p_185484_1_.getLightValue(p_185484_2_, p_185484_3_)); - if (i == 0 && block instanceof BlockSlab) + if (i == 0 && p_185484_1_.func_177230_c() instanceof BlockSlab) { - p_176207_2_ = p_176207_2_.func_177977_b(); - block = p_176207_1_.func_180495_p(p_176207_2_).func_177230_c(); -- return p_176207_1_.func_175626_b(p_176207_2_, block.func_149750_m()); -+ return p_176207_1_.func_175626_b(p_176207_2_, block.getLightValue(p_176207_1_, p_176207_2_)); + p_185484_3_ = p_185484_3_.func_177977_b(); + p_185484_1_ = p_185484_2_.func_180495_p(p_185484_3_); +- return p_185484_2_.func_175626_b(p_185484_3_, p_185484_1_.func_185906_d()); ++ return p_185484_2_.func_175626_b(p_185484_3_, p_185484_1_.getLightValue(p_185484_2_, p_185484_3_)); } else { -@@ -376,7 +382,7 @@ - @SideOnly(Side.CLIENT) - public boolean func_176225_a(IBlockAccess p_176225_1_, BlockPos p_176225_2_, EnumFacing p_176225_3_) - { -- return p_176225_3_ == EnumFacing.DOWN && this.field_149760_C > 0.0D ? true : (p_176225_3_ == EnumFacing.UP && this.field_149756_F < 1.0D ? true : (p_176225_3_ == EnumFacing.NORTH && this.field_149754_D > 0.0D ? true : (p_176225_3_ == EnumFacing.SOUTH && this.field_149757_G < 1.0D ? true : (p_176225_3_ == EnumFacing.WEST && this.field_149759_B > 0.0D ? true : (p_176225_3_ == EnumFacing.EAST && this.field_149755_E < 1.0D ? true : !p_176225_1_.func_180495_p(p_176225_2_).func_177230_c().func_149662_c()))))); -+ return p_176225_3_ == EnumFacing.DOWN && this.field_149760_C > 0.0D ? true : (p_176225_3_ == EnumFacing.UP && this.field_149756_F < 1.0D ? true : (p_176225_3_ == EnumFacing.NORTH && this.field_149754_D > 0.0D ? true : (p_176225_3_ == EnumFacing.SOUTH && this.field_149757_G < 1.0D ? true : (p_176225_3_ == EnumFacing.WEST && this.field_149759_B > 0.0D ? true : (p_176225_3_ == EnumFacing.EAST && this.field_149755_E < 1.0D ? true : !p_176225_1_.func_180495_p(p_176225_2_).func_177230_c().doesSideBlockRendering(p_176225_1_, p_176225_2_, p_176225_3_)))))); +@@ -415,7 +418,7 @@ + } + } + +- return !p_176225_2_.func_180495_p(p_176225_3_.func_177972_a(p_176225_4_)).func_185914_p(); ++ return !p_176225_2_.func_180495_p(p_176225_3_.func_177972_a(p_176225_4_)).doesSideBlockRendering(p_176225_2_, p_176225_3_.func_177972_a(p_176225_4_), p_176225_4_.func_176734_d()); } - public boolean func_176212_b(IBlockAccess p_176212_1_, BlockPos p_176212_2_, EnumFacing p_176212_3_) -@@ -453,6 +459,10 @@ + @SideOnly(Side.CLIENT) +@@ -472,6 +475,10 @@ public void func_180663_b(World p_180663_1_, BlockPos p_180663_2_, IBlockState p_180663_3_) { @@ -89,17 +83,17 @@ } public int func_149745_a(Random p_149745_1_) -@@ -467,8 +477,7 @@ +@@ -486,8 +493,7 @@ - public float func_180647_a(EntityPlayer p_180647_1_, World p_180647_2_, BlockPos p_180647_3_) + public float func_180647_a(IBlockState p_180647_1_, EntityPlayer p_180647_2_, World p_180647_3_, BlockPos p_180647_4_) { -- float f = this.func_176195_g(p_180647_2_, p_180647_3_); -- return f < 0.0F ? 0.0F : (!p_180647_1_.func_146099_a(this) ? p_180647_1_.func_180471_a(this) / f / 100.0F : p_180647_1_.func_180471_a(this) / f / 30.0F); -+ return net.minecraftforge.common.ForgeHooks.blockStrength(p_180647_2_.func_180495_p(p_180647_3_), p_180647_1_, p_180647_2_, p_180647_3_); +- float f = p_180647_1_.func_185887_b(p_180647_3_, p_180647_4_); +- return f < 0.0F ? 0.0F : (!p_180647_2_.func_184823_b(p_180647_1_) ? p_180647_2_.func_184813_a(p_180647_1_) / f / 100.0F : p_180647_2_.func_184813_a(p_180647_1_) / f / 30.0F); ++ return net.minecraftforge.common.ForgeHooks.blockStrength(p_180647_1_, p_180647_2_, p_180647_3_, p_180647_4_); } public final void func_176226_b(World p_176226_1_, BlockPos p_176226_2_, IBlockState p_176226_3_, int p_176226_4_) -@@ -478,20 +487,16 @@ +@@ -497,20 +503,16 @@ public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) { @@ -125,7 +119,7 @@ } } } -@@ -499,8 +504,13 @@ +@@ -518,8 +520,13 @@ public static void func_180635_a(World p_180635_0_, BlockPos p_180635_1_, ItemStack p_180635_2_) { @@ -140,7 +134,7 @@ float f = 0.5F; double d0 = (double)(p_180635_0_.field_73012_v.nextFloat() * f) + (double)(1.0F - f) * 0.5D; double d1 = (double)(p_180635_0_.field_73012_v.nextFloat() * f) + (double)(1.0F - f) * 0.5D; -@@ -687,7 +697,7 @@ +@@ -588,7 +595,7 @@ public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_) { @@ -148,15 +142,15 @@ + return p_176196_1_.func_180495_p(p_176196_2_).func_177230_c().func_176200_f(p_176196_1_, p_176196_2_); } - public boolean func_180639_a(World p_180639_1_, BlockPos p_180639_2_, IBlockState p_180639_3_, EntityPlayer p_180639_4_, EnumFacing p_180639_5_, float p_180639_6_, float p_180639_7_, float p_180639_8_) -@@ -799,25 +809,35 @@ - p_180657_2_.func_71029_a(StatList.field_75934_C[func_149682_b(this)]); + public boolean func_180639_a(World p_180639_1_, BlockPos p_180639_2_, IBlockState p_180639_3_, EntityPlayer p_180639_4_, EnumHand p_180639_5_, ItemStack p_180639_6_, EnumFacing p_180639_7_, float p_180639_8_, float p_180639_9_, float p_180639_10_) +@@ -638,25 +645,35 @@ + p_180657_2_.func_71029_a(StatList.func_188055_a(this)); p_180657_2_.func_71020_j(0.025F); -- if (this.func_149700_E() && EnchantmentHelper.func_77502_d(p_180657_2_)) -+ if (this.canSilkHarvest(p_180657_1_, p_180657_3_, p_180657_1_.func_180495_p(p_180657_3_), p_180657_2_) && EnchantmentHelper.func_77502_d(p_180657_2_)) +- if (this.func_149700_E() && EnchantmentHelper.func_77506_a(Enchantments.field_185306_r, p_180657_6_) > 0) ++ if (this.canSilkHarvest(p_180657_1_, p_180657_3_, p_180657_4_, p_180657_2_) && EnchantmentHelper.func_77506_a(Enchantments.field_185306_r, p_180657_6_) > 0) { -+ java.util.ArrayList items = new java.util.ArrayList(); ++ java.util.List items = new java.util.ArrayList(); ItemStack itemstack = this.func_180643_i(p_180657_4_); if (itemstack != null) @@ -165,16 +159,16 @@ + items.add(itemstack); } + -+ net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, p_180657_1_, p_180657_3_, p_180657_1_.func_180495_p(p_180657_3_), 0, 1.0f, true, p_180657_2_); -+ for (ItemStack stack : items) ++ net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, p_180657_1_, p_180657_3_, p_180657_4_, 0, 1.0f, true, p_180657_2_); ++ for (ItemStack item : items) + { -+ func_180635_a(p_180657_1_, p_180657_3_, stack); ++ func_180635_a(p_180657_1_, p_180657_3_, item); + } } else { + harvesters.set(p_180657_2_); - int i = EnchantmentHelper.func_77517_e(p_180657_2_); + int i = EnchantmentHelper.func_77506_a(Enchantments.field_185308_t, p_180657_6_); this.func_176226_b(p_180657_1_, p_180657_3_, p_180657_4_, i); + harvesters.set(null); } @@ -183,12 +177,25 @@ + @Deprecated //Forge: State sensitive version protected boolean func_149700_E() { -- return this.func_149686_d() && !this.field_149758_A; -+ return this.func_149686_d() && !this.hasTileEntity(silk_check_state.get()); +- return this.func_176223_P().func_185917_h() && !this.field_149758_A; ++ return this.func_176223_P().func_185917_h() && !this.hasTileEntity(silk_check_state.get()); } protected ItemStack func_180643_i(IBlockState p_180643_1_) -@@ -1010,6 +1030,1147 @@ +@@ -747,9 +764,11 @@ + p_176216_2_.field_70181_x = 0.0D; + } + ++ @Deprecated // Forge: Use more sensitive version below: getPickBlock + public ItemStack func_185473_a(World p_185473_1_, BlockPos p_185473_2_, IBlockState p_185473_3_) + { +- return new ItemStack(Item.func_150898_a(this), 1, this.func_180651_a(p_185473_3_)); ++ Item item = Item.func_150898_a(this); ++ return item == null ? null : new ItemStack(item, 1, this.func_180651_a(p_185473_3_)); + } + + @SideOnly(Side.CLIENT) +@@ -844,6 +863,1141 @@ return "Block{" + field_149771_c.func_177774_c(this) + "}"; } @@ -200,42 +207,45 @@ + /** + * Get a light value for the block at the specified coordinates, normal ranges are between 0 and 15 + * ++ * @param state Block state + * @param world The current world + * @param pos Block position in world + * @return The light value + */ -+ public int getLightValue(IBlockAccess world, BlockPos pos) ++ public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) + { -+ Block block = world.func_180495_p(pos).func_177230_c(); -+ if (block != this) ++ IBlockState other = world.func_180495_p(pos); ++ if (other.func_177230_c() != this) + { -+ return block.getLightValue(world, pos); ++ return other.getLightValue(world, pos); + } -+ return func_149750_m(); ++ return state.func_185906_d(); + } + + /** + * Checks if a player or entity can use this block to 'climb' like a ladder. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @param entity The entity trying to use the ladder, CAN be null. + * @return True if the block should act like a ladder + */ -+ public boolean isLadder(IBlockAccess world, BlockPos pos, EntityLivingBase entity) { return false; } ++ public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) { return false; } + + /** + * Return true if the block is a normal, solid cube. This + * determines indirect power state, entity ejection from blocks, and a few + * others. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @return True if the block is a full cube + */ -+ public boolean isNormalCube(IBlockAccess world, BlockPos pos) ++ public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) + { -+ return func_149688_o().func_76218_k() && func_149686_d() && !func_149744_f(); ++ return state.func_185904_a().func_76218_k() && state.func_185917_h() && !state.func_185897_m(); + } + + /** @@ -244,31 +254,35 @@ + * Faces which are fully opaque should return true, faces with transparency + * or faces which do not span the full size of the block should return false. + * ++ * @param state The current block state + * @param world The current world + * @param pos Block position in world -+ * @param side The side to check ++ * @param face The side to check + * @return True if the block is opaque on the specified side. + */ -+ public boolean doesSideBlockRendering(IBlockAccess world, BlockPos pos, EnumFacing face) ++ public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) + { -+ return func_149662_c(); ++ return state.func_185914_p(); + } + + /** + * Checks if the block is a solid face on the given side, used by placement logic. + * ++ * @param base_state The base state, getActualState should be called first + * @param world The current world + * @param pos Block position in world + * @param side The side to check + * @return True if the block is solid on the specified side. + */ -+ public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side) ++ public boolean isSideSolid(IBlockState base_state, IBlockAccess world, BlockPos pos, EnumFacing side) + { -+ IBlockState state = this.func_176221_a(world.func_180495_p(pos), world, pos); ++ if (base_state.func_185896_q() && side == EnumFacing.UP) // Short circuit to vanilla function if its true ++ return true; + + if (this instanceof BlockSlab) + { -+ return func_149730_j() ++ IBlockState state = this.func_176221_a(base_state, world, pos); ++ return base_state.func_185913_b() + || (state.func_177229_b(BlockSlab.field_176554_a) == BlockSlab.EnumBlockHalf.TOP && side == EnumFacing.UP ) + || (state.func_177229_b(BlockSlab.field_176554_a) == BlockSlab.EnumBlockHalf.BOTTOM && side == EnumFacing.DOWN); + } @@ -278,6 +292,7 @@ + } + else if (this instanceof BlockStairs) + { ++ IBlockState state = this.func_176221_a(base_state, world, pos); + boolean flipped = state.func_177229_b(BlockStairs.field_176308_b) == BlockStairs.EnumHalf.TOP; + BlockStairs.EnumShape shape = (BlockStairs.EnumShape)state.func_177229_b(BlockStairs.field_176310_M); + EnumFacing facing = (EnumFacing)state.func_177229_b(BlockStairs.field_176309_a); @@ -298,6 +313,7 @@ + } + else if (this instanceof BlockSnow) + { ++ IBlockState state = this.func_176221_a(base_state, world, pos); + return ((Integer)state.func_177229_b(BlockSnow.field_176315_a)) >= 8; + } + else if (this instanceof BlockHopper && side == EnumFacing.UP) @@ -308,7 +324,7 @@ + { + return true; + } -+ return isNormalCube(world, pos); ++ return isNormalCube(base_state, world, pos); + } + + /** @@ -330,13 +346,14 @@ + * useful for creating pure logic-blocks that will be invisible + * to the player and otherwise interact as air would. + * ++ * @param sata The current state + * @param world The current world + * @param pos Block position in world + * @return True if the block considered air + */ -+ public boolean isAir(IBlockAccess world, BlockPos pos) ++ public boolean isAir(IBlockState state, IBlockAccess world, BlockPos pos) + { -+ return func_149688_o() == Material.field_151579_a; ++ return state.func_185904_a() == Material.field_151579_a; + } + + /** @@ -362,6 +379,7 @@ + * Note: When used in multiplayer, this is called on both client and + * server sides! + * ++ * @param state The current state. + * @param world The current world + * @param player The player damaging the block, may be null + * @param pos Block position in world @@ -369,9 +387,10 @@ + * Can be useful to delay the destruction of tile entities till after harvestBlock + * @return True if the block is actually destroyed. + */ -+ public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) ++ public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) + { -+ return world.func_175698_g(pos); ++ this.func_176208_a(world, pos, state, player); ++ return world.func_180501_a(pos, net.minecraft.init.Blocks.field_150350_a.func_176223_P(), world.field_72995_K ? 11 : 3); + } + + /** @@ -535,23 +554,15 @@ + * Determines if a specified mob type can spawn on this block, returning false will + * prevent any mob from spawning on the block. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @param type The Mob Category Type + * @return True to allow a mob of the specified category to spawn, false to prevent it. + */ -+ public boolean canCreatureSpawn(IBlockAccess world, BlockPos pos, net.minecraft.entity.EntityLiving.SpawnPlacementType type) ++ public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, net.minecraft.entity.EntityLiving.SpawnPlacementType type) + { -+ IBlockState state = world.func_180495_p(pos); -+ if (this instanceof BlockSlab) -+ { -+ return (func_149730_j() || state.func_177229_b(BlockSlab.field_176554_a) == BlockSlab.EnumBlockHalf.TOP); -+ } -+ else if (this instanceof BlockStairs) -+ { -+ return state.func_177229_b(BlockStairs.field_176308_b) == BlockStairs.EnumHalf.TOP; -+ } -+ return isSideSolid(world, pos, EnumFacing.UP); ++ return isSideSolid(state, world, pos, EnumFacing.UP); + } + + /** @@ -559,12 +570,13 @@ + * players to sleep in it, though the block has to specifically + * perform the sleeping functionality in it's activated event. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @param player The player or camera entity, null in some cases. + * @return True to treat this as a bed + */ -+ public boolean isBed(IBlockAccess world, BlockPos pos, Entity player) ++ public boolean isBed(IBlockState state, IBlockAccess world, BlockPos pos, Entity player) + { + return this == net.minecraft.init.Blocks.field_150324_C; + } @@ -573,12 +585,13 @@ + * Returns the position that the player is moved to upon + * waking up, or respawning at the bed. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @param player The player or camera entity, null in some cases. + * @return The spawn position + */ -+ public BlockPos getBedSpawnPosition(IBlockAccess world, BlockPos pos, EntityPlayer player) ++ public BlockPos getBedSpawnPosition(IBlockState state, IBlockAccess world, BlockPos pos, EntityPlayer player) + { + if (world instanceof World) + return BlockBed.func_176468_a((World)world, pos, 0); @@ -608,13 +621,14 @@ + * Returns the direction of the block. Same values that + * are returned by BlockDirectional + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @return Bed direction + */ -+ public EnumFacing getBedDirection(IBlockAccess world, BlockPos pos) ++ public EnumFacing getBedDirection(IBlockState state, IBlockAccess world, BlockPos pos) + { -+ return (EnumFacing)func_176221_a(world.func_180495_p(pos), world, pos).func_177229_b(BlockDirectional.field_176387_N); ++ return (EnumFacing)func_176221_a(state, world, pos).func_177229_b(BlockHorizontal.field_185512_D); + } + + /** @@ -632,19 +646,20 @@ + /** + * Called when a leaf should start its decay process. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + */ -+ public void beginLeavesDecay(World world, BlockPos pos){} ++ public void beginLeavesDecay(IBlockState state, World world, BlockPos pos){} + + /** + * Determines if this block can prevent leaves connected to it from decaying. -+ * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @return true if the presence this block can prevent leaves from decaying. + */ -+ public boolean canSustainLeaves(IBlockAccess world, BlockPos pos) ++ public boolean canSustainLeaves(IBlockState state, IBlockAccess world, BlockPos pos) + { + return false; + } @@ -652,25 +667,27 @@ + /** + * Determines if this block is considered a leaf block, used to apply the leaf decay and generation system. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @return true if this block is considered leaves. + */ -+ public boolean isLeaves(IBlockAccess world, BlockPos pos) ++ public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos) + { -+ return func_149688_o() == Material.field_151584_j; ++ return state.func_185904_a() == Material.field_151584_j; + } + + /** + * Used during tree growth to determine if newly generated leaves can replace this block. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @return true if this block can be replaced by growing leaves. + */ -+ public boolean canBeReplacedByLeaves(IBlockAccess world, BlockPos pos) ++ public boolean canBeReplacedByLeaves(IBlockState state, IBlockAccess world, BlockPos pos) + { -+ return !func_149730_j(); ++ return !state.func_185913_b(); + } + + /** @@ -687,15 +704,16 @@ + /** + * Determines if the current block is replaceable by Ore veins during world generation. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @param target The generic target block the gen is looking for, Standards define stone + * for overworld generation, and neatherack for the nether. + * @return True to allow this block to be replaced by a ore + */ -+ public boolean isReplaceableOreGen(World world, BlockPos pos, com.google.common.base.Predicate target) ++ public boolean isReplaceableOreGen(IBlockState state, IBlockAccess world, BlockPos pos, com.google.common.base.Predicate target) + { -+ return target.apply(world.func_180495_p(pos)); ++ return target.apply(state); + } + + /** @@ -731,27 +749,29 @@ + * Determine if this block can make a redstone connection on the side provided, + * Useful to control which sides are inputs and outputs for redstone wires. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @param side The side that is trying to make the connection, CAN BE NULL + * @return True to make the connection + */ -+ public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, EnumFacing side) ++ public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) + { -+ return func_149744_f() && side != null; ++ return state.func_185897_m() && side != null; + } + + /** + * Determines if a torch can be placed on the top surface of this block. + * Useful for creating your own block that torches can be on, such as fences. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @return True to allow the torch to be placed + */ -+ public boolean canPlaceTorchOnTop(IBlockAccess world, BlockPos pos) ++ public boolean canPlaceTorchOnTop(IBlockState state, IBlockAccess world, BlockPos pos) + { -+ if (isSideSolid(world, pos, EnumFacing.UP)) ++ if (state.isSideSolid(world, pos, EnumFacing.UP)) + { + return true; + } @@ -780,22 +800,9 @@ + * @param target The full target the player is looking at + * @return A ItemStack to add to the player's inventory, Null if nothing should be added. + */ -+ public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) ++ public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) + { -+ return getPickBlock(target, world, pos); -+ } -+ @Deprecated -+ public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos) -+ { -+ Item item = func_180665_b(world, pos); -+ -+ if (item == null) -+ { -+ return null; -+ } -+ -+ Block block = item instanceof ItemBlock && !func_149648_K() ? Block.func_149634_a(item) : this; -+ return new ItemStack(item, 1, block.func_176222_j(world, pos)); ++ return func_185473_a(world, pos, state); + } + + /** @@ -821,7 +828,7 @@ + * @param numberOfParticles that vanilla would have spawned. + * @return True to prevent vanilla landing particles form spawning. + */ -+ public boolean addLandingEffects(net.minecraft.world.WorldServer worldObj, BlockPos blockPosition, IBlockState iblockstate, EntityLivingBase entity, int numberOfParticles ) ++ public boolean addLandingEffects(IBlockState state, net.minecraft.world.WorldServer worldObj, BlockPos blockPosition, IBlockState iblockstate, EntityLivingBase entity, int numberOfParticles ) + { + return false; + } @@ -832,13 +839,14 @@ + * control over the particles. Useful when you have entirely different + * texture sheets for different sides/locations in the world. + * ++ * @param state The current state + * @param world The current world + * @param target The target the player is looking at {x/y/z/side/sub} + * @param effectRenderer A reference to the current effect renderer. + * @return True to prevent vanilla digging particles form spawning. + */ + @SideOnly(Side.CLIENT) -+ public boolean addHitEffects(World worldObj, MovingObjectPosition target, net.minecraft.client.particle.EffectRenderer effectRenderer) ++ public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, net.minecraft.client.particle.EffectRenderer effectRenderer) + { + return false; + } @@ -871,15 +879,15 @@ + * Plains check if its grass or dirt + * Water check if its still water + * ++ * @param state The Current state + * @param world The current world + * @param pos Block position in world + * @param direction The direction relative to the given position the plant wants to be, typically its UP + * @param plantable The plant that wants to check + * @return True to allow the plant to be planted/stay. + */ -+ public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) ++ public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) + { -+ IBlockState state = world.func_180495_p(pos); + IBlockState plant = plantable.getPlant(world, pos.func_177972_a(direction)); + net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.func_177972_a(direction)); + @@ -893,7 +901,7 @@ + return true; + } + -+ if (plantable instanceof BlockBush && ((BlockBush)plantable).func_149854_a(this)) ++ if (plantable instanceof BlockBush && ((BlockBush)plantable).func_185514_i(state)) + { + return true; + } @@ -903,15 +911,15 @@ + case Desert: return this == net.minecraft.init.Blocks.field_150354_m || this == net.minecraft.init.Blocks.field_150405_ch || this == net.minecraft.init.Blocks.field_150406_ce || this == net.minecraft.init.Blocks.field_150346_d; + case Nether: return this == net.minecraft.init.Blocks.field_150425_aM; + case Crop: return this == net.minecraft.init.Blocks.field_150458_ak; -+ case Cave: return isSideSolid(world, pos, EnumFacing.UP); ++ case Cave: return state.isSideSolid(world, pos, EnumFacing.UP); + case Plains: return this == net.minecraft.init.Blocks.field_150349_c || this == net.minecraft.init.Blocks.field_150346_d || this == net.minecraft.init.Blocks.field_150458_ak; -+ case Water: return func_149688_o() == Material.field_151586_h && ((Integer)state.func_177229_b(BlockLiquid.field_176367_b)) == 0; ++ case Water: return state.func_185904_a() == Material.field_151586_h && state.func_177229_b(BlockLiquid.field_176367_b) == 0; + case Beach: + boolean isBeach = this == net.minecraft.init.Blocks.field_150349_c || this == net.minecraft.init.Blocks.field_150346_d || this == net.minecraft.init.Blocks.field_150354_m; -+ boolean hasWater = (world.func_180495_p(pos.func_177974_f()).func_177230_c().func_149688_o() == Material.field_151586_h || -+ world.func_180495_p(pos.func_177976_e()).func_177230_c().func_149688_o() == Material.field_151586_h || -+ world.func_180495_p(pos.func_177978_c()).func_177230_c().func_149688_o() == Material.field_151586_h || -+ world.func_180495_p(pos.func_177968_d()).func_177230_c().func_149688_o() == Material.field_151586_h); ++ boolean hasWater = (world.func_180495_p(pos.func_177974_f()).func_185904_a() == Material.field_151586_h || ++ world.func_180495_p(pos.func_177976_e()).func_185904_a() == Material.field_151586_h || ++ world.func_180495_p(pos.func_177978_c()).func_185904_a() == Material.field_151586_h || ++ world.func_180495_p(pos.func_177968_d()).func_185904_a() == Material.field_151586_h); + return isBeach && hasWater; + } + @@ -927,11 +935,12 @@ + * + * Note: This happens DURING the generation, the generation may not be complete when this is called. + * ++ * @param state The current state + * @param world Current world + * @param pos Block position in world + * @param source Source plant's position in world + */ -+ public void onPlantGrow(World world, BlockPos pos, BlockPos source) ++ public void onPlantGrow(IBlockState state, World world, BlockPos pos, BlockPos source) + { + if (this == net.minecraft.init.Blocks.field_150349_c || this == net.minecraft.init.Blocks.field_150458_ak) + { @@ -966,27 +975,43 @@ + * Recommended that you have your tile entity call relight after being placed if you + * rely on it for light info. + * ++ * @param state The Block state + * @param world The current world + * @param pos Block position in world + * @return The amount of light to block, 0 for air, 255 for fully opaque. + */ -+ public int getLightOpacity(IBlockAccess world, BlockPos pos) ++ public int getLightOpacity(IBlockState state, IBlockAccess world, BlockPos pos) + { -+ return func_149717_k(); ++ return state.func_185891_c(); + } + + /** + * Determines if this block is can be destroyed by the specified entities normal behavior. + * ++ * @param state The current state + * @param world The current world + * @param pos Block position in world + * @return True to allow the ender dragon to destroy this block + */ -+ public boolean canEntityDestroy(IBlockAccess world, BlockPos pos, Entity entity) ++ public boolean canEntityDestroy(IBlockState state, IBlockAccess world, BlockPos pos, Entity entity) + { + if (entity instanceof net.minecraft.entity.boss.EntityDragon) + { -+ return this != net.minecraft.init.Blocks.field_180401_cv && this != net.minecraft.init.Blocks.field_150343_Z && this != net.minecraft.init.Blocks.field_150377_bs && this != net.minecraft.init.Blocks.field_150357_h && this != net.minecraft.init.Blocks.field_150483_bI; ++ return this != net.minecraft.init.Blocks.field_180401_cv && ++ this != net.minecraft.init.Blocks.field_150343_Z && ++ this != net.minecraft.init.Blocks.field_150377_bs && ++ this != net.minecraft.init.Blocks.field_150357_h && ++ this != net.minecraft.init.Blocks.field_150384_bq && ++ this != net.minecraft.init.Blocks.field_150378_br && ++ this != net.minecraft.init.Blocks.field_150483_bI && ++ this != net.minecraft.init.Blocks.field_185776_dc && ++ this != net.minecraft.init.Blocks.field_185777_dd && ++ this != net.minecraft.init.Blocks.field_150411_aY && ++ this != net.minecraft.init.Blocks.field_185775_db; ++ } ++ else if (entity instanceof net.minecraft.entity.boss.EntityWither) ++ { ++ return net.minecraft.entity.boss.EntityWither.func_181033_a(this); + } + + return true; @@ -1019,7 +1044,7 @@ + public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) + { + IBlockState state = world.func_180495_p(pos); -+ for (IProperty prop : (java.util.Set)state.func_177228_b().keySet()) ++ for (IProperty prop : state.func_177228_b().keySet()) + { + if (prop.func_177701_a().equals("facing") || prop.func_177701_a().equals("rotation")) + { @@ -1040,10 +1065,11 @@ + public EnumFacing[] getValidRotations(World world, BlockPos pos) + { + IBlockState state = world.func_180495_p(pos); -+ for (IProperty prop : (java.util.Set)state.func_177228_b().keySet()) ++ for (IProperty prop : state.func_177228_b().keySet()) + { + if (prop.func_177701_a().equals("facing") && prop.func_177699_b() == EnumFacing.class) + { ++ @SuppressWarnings("unchecked") + java.util.Collection values = ((java.util.Collection)prop.func_177700_c()); + return values.toArray(new EnumFacing[values.size()]); + } @@ -1070,10 +1096,11 @@ + * @param color The color to change to + * @return If the recoloring was successful + */ ++ @SuppressWarnings({ "unchecked", "rawtypes" }) + public boolean recolorBlock(World world, BlockPos pos, EnumFacing side, net.minecraft.item.EnumDyeColor color) + { + IBlockState state = world.func_180495_p(pos); -+ for (IProperty prop : (java.util.Set)state.func_177228_b().keySet()) ++ for (IProperty prop : state.func_177228_b().keySet()) + { + if (prop.func_177701_a().equals("color") && prop.func_177699_b() == net.minecraft.item.EnumDyeColor.class) + { @@ -1091,12 +1118,13 @@ + /** + * Gathers how much experience this block drops when broken. + * ++ * @param state The current state + * @param world The world + * @param pos Block position + * @param fortune + * @return Amount of XP from breaking this block. + */ -+ public int getExpDrop(IBlockAccess world, BlockPos pos, int fortune) ++ public int getExpDrop(IBlockState state, IBlockAccess world, BlockPos pos, int fortune) + { + return 0; + } @@ -1116,9 +1144,9 @@ + * @param side The INPUT side of the block to be powered - ie the opposite of this block's output side + * @return Whether Block#isProvidingWeakPower should be called when determining indirect power + */ -+ public boolean shouldCheckWeakPower(IBlockAccess world, BlockPos pos, EnumFacing side) ++ public boolean shouldCheckWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) + { -+ return func_149721_r(); ++ return state.func_185915_l(); + } + + /** @@ -1220,7 +1248,7 @@ + /** + * Called when the entity is inside this block, may be used to determined if the entity can breathing, + * display material overlays, or if the entity can swim inside a block. -+ * ++ * + * @param world that is being tested. + * @param blockpos position thats being tested. + * @param iblockstate state at world/blockpos @@ -1230,15 +1258,15 @@ + * @param testingHead when true, its testing the entities head for vision, breathing ect... otherwise its testing the body, for swimming and movement adjustment. + * @return null for default behavior, true if the entity is within the material, false if it was not. + */ -+ public Boolean isEntityInsideMaterial(World world, BlockPos blockpos, IBlockState iblockstate, Entity entity, double yToTest, Material materialIn, boolean testingHead) ++ public Boolean isEntityInsideMaterial(IBlockAccess world, BlockPos blockpos, IBlockState iblockstate, Entity entity, double yToTest, Material materialIn, boolean testingHead) + { + return null; + } -+ ++ + /** + * Called when boats or fishing hooks are inside the block to check if they are inside + * the material requested. -+ * ++ * + * @param world world that is being tested. + * @param pos block thats being tested. + * @param boundingBox box to test, generally the bounds of an entity that are besting tested. @@ -1252,13 +1280,24 @@ + + /** + * Queries if this block should render in a given layer. -+ * ISmartBlockModel can use MinecraftForgeClient.getRenderLayer to alter their model based on layer ++ * ISmartBlockModel can use {@link MinecraftForgeClient#getRenderLayer()} to alter their model based on layer. ++ * ++ * @deprecated New method with state sensitivity: {@link #canRenderInLayer(IBlockState, BlockRenderLayer)} + */ -+ public boolean canRenderInLayer(EnumWorldBlockLayer layer) ++ @Deprecated ++ public boolean canRenderInLayer(BlockRenderLayer layer) + { + return func_180664_k() == layer; + } + ++ /** ++ * Queries if this block should render in a given layer. ++ * ISmartBlockModel can use {@link MinecraftForgeClient#getRenderLayer()} to alter their model based on layer. ++ */ ++ public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer) ++ { ++ return canRenderInLayer(layer); ++ } + // For Internal use only to capture droped items inside getDrops + protected static ThreadLocal captureDrops = new ThreadLocal() + { @@ -1283,53 +1322,15 @@ + } + } + -+ private ResourceLocation registryName = null; + /** -+ * Sets a unique name for this Block. This should be used for uniquely identify the instance of the Block. -+ * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does. -+ * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items. -+ * -+ * The supplied name will be prefixed with the currently active mod's modId. -+ * If the supplied name already has a prefix that is different, it will be used and a warning will be logged. -+ * -+ * If a name already exists, or this Block is already registered in a registry, then an IllegalStateException is thrown. -+ * -+ * Returns 'this' to allow for chaining. -+ * -+ * @param name Unique registry name -+ * @return This instance ++ * Add information to the blocks tooltip, called from the default implementation of {@link ItemBlock#addInformation(ItemStack, EntityPlayer, List, boolean)} ++ * @param stack The stack the tooltip is being retrieved for ++ * @param player The player retrieving the tooltip ++ * @param tooltip The lines to be displayed on the tooltip ++ * @param advanced If the client has advanced debug tooltips enabled + */ -+ public final Block setRegistryName(String name) ++ public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) + { -+ if (getRegistryName() != null) -+ throw new IllegalStateException("Attempted to set registry name on block with exisiting registry name! New: " + name + " Old: " + getRegistryName()); -+ int index = name.lastIndexOf(':'); -+ String oldPrefix = index == -1 ? "" : name.substring(0, index); -+ name = index == -1 ? name : name.substring(index + 1); -+ net.minecraftforge.fml.common.ModContainer mc = net.minecraftforge.fml.common.Loader.instance().activeModContainer(); -+ String prefix = mc == null ? "minecraft" : mc.getModId(); -+ if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0) -+ { -+ net.minecraftforge.fml.common.FMLLog.bigWarning("Dangerous alternative prefix %s for name %s, invalid registry invocation/invalid name?", oldPrefix, name); -+ prefix = oldPrefix; -+ } -+ this.registryName = new ResourceLocation(prefix, name); -+ return this; -+ } -+ public final Block setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); } -+ public final Block setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); } -+ -+ /** -+ * A unique identifier for this block, if this block is registered in the game registry it will return that name. -+ * Otherwise it will return the name set in setRegistryName(). -+ * If neither are valid null is returned. -+ * -+ * @return Unique identifier or null. -+ */ -+ public final String getRegistryName() -+ { -+ if (delegate.getResourceName() != null) return delegate.getResourceName().toString(); -+ return registryName != null ? registryName.toString() : null; + } + /* ========================================= FORGE END ======================================*/ + diff --git a/patches/minecraft/net/minecraft/block/BlockBanner.java.patch b/patches/minecraft/net/minecraft/block/BlockBanner.java.patch index 4aa9b6d55c..f2e82e73ed 100644 --- a/patches/minecraft/net/minecraft/block/BlockBanner.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockBanner.java.patch @@ -1,21 +1,13 @@ --- ../src-base/minecraft/net/minecraft/block/BlockBanner.java +++ ../src-work/minecraft/net/minecraft/block/BlockBanner.java -@@ -85,22 +85,7 @@ +@@ -104,14 +104,7 @@ public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) { -- TileEntity tileentity = p_180653_1_.func_175625_s(p_180653_2_); +- ItemStack itemstack = this.func_185549_e(p_180653_1_, p_180653_2_, p_180653_3_); - -- if (tileentity instanceof TileEntityBanner) +- if (itemstack != null) { -- ItemStack itemstack = new ItemStack(Items.field_179564_cE, 1, ((TileEntityBanner)tileentity).func_175115_b()); -- NBTTagCompound nbttagcompound = new NBTTagCompound(); -- tileentity.func_145841_b(nbttagcompound); -- nbttagcompound.func_82580_o("x"); -- nbttagcompound.func_82580_o("y"); -- nbttagcompound.func_82580_o("z"); -- nbttagcompound.func_82580_o("id"); -- itemstack.func_77983_a("BlockEntityTag", nbttagcompound); - func_180635_a(p_180653_1_, p_180653_2_, itemstack); - } - else @@ -23,7 +15,7 @@ super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, p_180653_5_); } } -@@ -133,6 +118,28 @@ +@@ -138,6 +131,28 @@ } } @@ -51,4 +43,4 @@ + public static class BlockBannerHanging extends BlockBanner { - public BlockBannerHanging() + protected static final AxisAlignedBB field_185551_d = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 0.78125D, 1.0D); diff --git a/patches/minecraft/net/minecraft/block/BlockBush.java.patch b/patches/minecraft/net/minecraft/block/BlockBush.java.patch index c8c22a6eb9..1bd0b0e43e 100644 --- a/patches/minecraft/net/minecraft/block/BlockBush.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockBush.java.patch @@ -1,40 +1,40 @@ --- ../src-base/minecraft/net/minecraft/block/BlockBush.java +++ ../src-work/minecraft/net/minecraft/block/BlockBush.java -@@ -13,7 +13,7 @@ +@@ -14,7 +14,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class BlockBush extends Block +public class BlockBush extends Block implements net.minecraftforge.common.IPlantable { - protected BlockBush() - { -@@ -36,7 +36,7 @@ + protected static final AxisAlignedBB field_185515_b = new AxisAlignedBB(0.30000001192092896D, 0.0D, 0.30000001192092896D, 0.699999988079071D, 0.6000000238418579D, 0.699999988079071D); + +@@ -37,7 +37,8 @@ public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_) { -- return super.func_176196_c(p_176196_1_, p_176196_2_) && this.func_149854_a(p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).func_177230_c()); -+ return super.func_176196_c(p_176196_1_, p_176196_2_) && p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).func_177230_c().canSustainPlant(p_176196_1_, p_176196_2_.func_177977_b(), net.minecraft.util.EnumFacing.UP, this); +- return super.func_176196_c(p_176196_1_, p_176196_2_) && this.func_185514_i(p_176196_1_.func_180495_p(p_176196_2_.func_177977_b())); ++ IBlockState soil = p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()); ++ return super.func_176196_c(p_176196_1_, p_176196_2_) && soil.func_177230_c().canSustainPlant(soil, p_176196_1_, p_176196_2_.func_177977_b(), net.minecraft.util.EnumFacing.UP, this); } - protected boolean func_149854_a(Block p_149854_1_) -@@ -66,7 +66,10 @@ + protected boolean func_185514_i(IBlockState p_185514_1_) +@@ -67,6 +68,11 @@ public boolean func_180671_f(World p_180671_1_, BlockPos p_180671_2_, IBlockState p_180671_3_) { -- return this.func_149854_a(p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()).func_177230_c()); -+ BlockPos down = p_180671_2_.func_177977_b(); -+ Block soil = p_180671_1_.func_180495_p(down).func_177230_c(); -+ if (p_180671_3_.func_177230_c() != this) return this.func_149854_a(soil); //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. -+ return soil.canSustainPlant(p_180671_1_, down, net.minecraft.util.EnumFacing.UP, this); ++ if (p_180671_3_.func_177230_c() == this) //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check. ++ { ++ IBlockState soil = p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()); ++ return soil.func_177230_c().canSustainPlant(soil, p_180671_1_, p_180671_2_.func_177977_b(), net.minecraft.util.EnumFacing.UP, this); ++ } + return this.func_185514_i(p_180671_1_.func_180495_p(p_180671_2_.func_177977_b())); } - public AxisAlignedBB func_180640_a(World p_180640_1_, BlockPos p_180640_2_, IBlockState p_180640_3_) -@@ -89,4 +92,33 @@ - { - return EnumWorldBlockLayer.CUTOUT; +@@ -90,6 +96,35 @@ + return false; } -+ + + @Override + public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos) + { @@ -63,4 +63,7 @@ + if (state.func_177230_c() != this) return func_176223_P(); + return state; + } - } ++ + @SideOnly(Side.CLIENT) + public BlockRenderLayer func_180664_k() + { diff --git a/patches/minecraft/net/minecraft/block/BlockButton.java.patch b/patches/minecraft/net/minecraft/block/BlockButton.java.patch index 58cd177066..984b01117d 100644 --- a/patches/minecraft/net/minecraft/block/BlockButton.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockButton.java.patch @@ -1,12 +1,11 @@ --- ../src-base/minecraft/net/minecraft/block/BlockButton.java +++ ../src-work/minecraft/net/minecraft/block/BlockButton.java -@@ -74,8 +74,7 @@ - +@@ -89,7 +89,7 @@ protected static boolean func_181088_a(World p_181088_0_, BlockPos p_181088_1_, EnumFacing p_181088_2_) { -- BlockPos blockpos = p_181088_1_.func_177972_a(p_181088_2_); -- return p_181088_2_ == EnumFacing.DOWN ? World.func_175683_a(p_181088_0_, blockpos) : p_181088_0_.func_180495_p(blockpos).func_177230_c().func_149721_r(); -+ return p_181088_2_ == EnumFacing.DOWN && World.func_175683_a(p_181088_0_, p_181088_1_.func_177977_b()) ? true : p_181088_0_.isSideSolid(p_181088_1_.func_177972_a(p_181088_2_), p_181088_2_.func_176734_d()); + BlockPos blockpos = p_181088_1_.func_177972_a(p_181088_2_); +- return p_181088_2_ == EnumFacing.DOWN ? p_181088_0_.func_180495_p(blockpos).func_185896_q() : p_181088_0_.func_180495_p(blockpos).func_185915_l(); ++ return p_181088_0_.func_180495_p(blockpos).isSideSolid(p_181088_0_, blockpos, p_181088_2_.func_176734_d()); } public IBlockState func_180642_a(World p_180642_1_, BlockPos p_180642_2_, EnumFacing p_180642_3_, float p_180642_4_, float p_180642_5_, float p_180642_6_, int p_180642_7_, EntityLivingBase p_180642_8_) diff --git a/patches/minecraft/net/minecraft/block/BlockCactus.java.patch b/patches/minecraft/net/minecraft/block/BlockCactus.java.patch index 17dfb0356e..7d568610dd 100644 --- a/patches/minecraft/net/minecraft/block/BlockCactus.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockCactus.java.patch @@ -8,21 +8,22 @@ +public class BlockCactus extends Block implements net.minecraftforge.common.IPlantable { public static final PropertyInteger field_176587_a = PropertyInteger.func_177719_a("age", 0, 15); - -@@ -109,7 +109,7 @@ + protected static final AxisAlignedBB field_185593_b = new AxisAlignedBB(0.0625D, 0.0D, 0.0625D, 0.9375D, 0.9375D, 0.9375D); +@@ -110,8 +110,8 @@ + } } - Block block = p_176586_1_.func_180495_p(p_176586_2_.func_177977_b()).func_177230_c(); -- return block == Blocks.field_150434_aF || block == Blocks.field_150354_m; -+ return block.canSustainPlant(p_176586_1_, p_176586_2_.func_177977_b(), EnumFacing.UP, this); +- Block block = p_176586_1_.func_180495_p(p_176586_2_.func_177977_b()).func_177230_c(); +- return block == Blocks.field_150434_aF || block == Blocks.field_150354_m && !p_176586_1_.func_180495_p(p_176586_2_.func_177984_a()).func_185904_a().func_76224_d(); ++ IBlockState state = p_176586_1_.func_180495_p(p_176586_2_.func_177977_b()); ++ return state.func_177230_c().canSustainPlant(state, p_176586_1_, p_176586_2_, EnumFacing.UP, this) && !p_176586_1_.func_180495_p(p_176586_2_.func_177984_a()).func_185904_a().func_76224_d(); } public void func_180634_a(World p_180634_1_, BlockPos p_180634_2_, IBlockState p_180634_3_, Entity p_180634_4_) -@@ -137,4 +137,16 @@ - { - return new BlockState(this, new IProperty[] {field_176587_a}); +@@ -135,6 +135,18 @@ + return ((Integer)p_176201_1_.func_177229_b(field_176587_a)).intValue(); } -+ + + @Override + public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos) + { @@ -34,4 +35,7 @@ + { + return func_176223_P(); + } - } ++ + protected BlockStateContainer func_180661_e() + { + return new BlockStateContainer(this, new IProperty[] {field_176587_a}); diff --git a/patches/minecraft/net/minecraft/block/BlockChest.java.patch b/patches/minecraft/net/minecraft/block/BlockChest.java.patch index 90f209e193..4141d144f0 100644 --- a/patches/minecraft/net/minecraft/block/BlockChest.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockChest.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/block/BlockChest.java +++ ../src-work/minecraft/net/minecraft/block/BlockChest.java -@@ -527,7 +527,7 @@ +@@ -506,7 +506,7 @@ private boolean func_176456_n(World p_176456_1_, BlockPos p_176456_2_) { -- return p_176456_1_.func_180495_p(p_176456_2_.func_177984_a()).func_177230_c().func_149721_r(); -+ return p_176456_1_.isSideSolid(p_176456_2_.func_177984_a(), EnumFacing.DOWN, false); +- return p_176456_1_.func_180495_p(p_176456_2_.func_177984_a()).func_185915_l(); ++ return p_176456_1_.func_180495_p(p_176456_2_.func_177984_a()).isSideSolid(p_176456_1_, p_176456_2_.func_177984_a(), EnumFacing.DOWN); } private boolean func_176453_o(World p_176453_1_, BlockPos p_176453_2_) diff --git a/patches/minecraft/net/minecraft/block/BlockCocoa.java.patch b/patches/minecraft/net/minecraft/block/BlockCocoa.java.patch index 5ecbf9a686..bbdb460ba9 100644 --- a/patches/minecraft/net/minecraft/block/BlockCocoa.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockCocoa.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockCocoa.java +++ ../src-work/minecraft/net/minecraft/block/BlockCocoa.java -@@ -137,7 +137,14 @@ +@@ -131,7 +131,14 @@ public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) { @@ -16,7 +16,7 @@ int j = 1; if (i >= 2) -@@ -147,8 +154,9 @@ +@@ -141,8 +148,9 @@ for (int k = 0; k < j; ++k) { @@ -26,4 +26,4 @@ + return dropped; } - @SideOnly(Side.CLIENT) + public ItemStack func_185473_a(World p_185473_1_, BlockPos p_185473_2_, IBlockState p_185473_3_) diff --git a/patches/minecraft/net/minecraft/block/BlockCrops.java.patch b/patches/minecraft/net/minecraft/block/BlockCrops.java.patch index ed9298153e..bd8c469962 100644 --- a/patches/minecraft/net/minecraft/block/BlockCrops.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockCrops.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/block/BlockCrops.java +++ ../src-work/minecraft/net/minecraft/block/BlockCrops.java -@@ -81,11 +81,11 @@ +@@ -116,11 +116,11 @@ float f1 = 0.0F; IBlockState iblockstate = p_180672_1_.func_180495_p(blockpos.func_177982_a(i, 0, j)); - if (iblockstate.func_177230_c() == Blocks.field_150458_ak) -+ if (iblockstate.func_177230_c().canSustainPlant(p_180672_1_, blockpos.func_177982_a(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable)p_180672_0_)) ++ if (iblockstate.func_177230_c().canSustainPlant(iblockstate, p_180672_1_, blockpos.func_177982_a(i, 0, j), net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable)p_180672_0_)) { f1 = 1.0F; @@ -14,59 +14,34 @@ { f1 = 3.0F; } -@@ -126,7 +126,7 @@ +@@ -161,7 +161,8 @@ public boolean func_180671_f(World p_180671_1_, BlockPos p_180671_2_, IBlockState p_180671_3_) { -- return (p_180671_1_.func_175699_k(p_180671_2_) >= 8 || p_180671_1_.func_175678_i(p_180671_2_)) && this.func_149854_a(p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()).func_177230_c()); -+ return (p_180671_1_.func_175699_k(p_180671_2_) >= 8 || p_180671_1_.func_175678_i(p_180671_2_)) && p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()).func_177230_c().canSustainPlant(p_180671_1_, p_180671_2_.func_177977_b(), net.minecraft.util.EnumFacing.UP, this); +- return (p_180671_1_.func_175699_k(p_180671_2_) >= 8 || p_180671_1_.func_175678_i(p_180671_2_)) && this.func_185514_i(p_180671_1_.func_180495_p(p_180671_2_.func_177977_b())); ++ IBlockState soil = p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()); ++ return (p_180671_1_.func_175699_k(p_180671_2_) >= 8 || p_180671_1_.func_175678_i(p_180671_2_)) && soil.func_177230_c().canSustainPlant(soil, p_180671_1_, p_180671_2_.func_177977_b(), net.minecraft.util.EnumFacing.UP, this); } protected Item func_149866_i() -@@ -142,24 +142,6 @@ - public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) - { - super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, 0); -- -- if (!p_180653_1_.field_72995_K) -- { -- int i = ((Integer)p_180653_3_.func_177229_b(field_176488_a)).intValue(); -- -- if (i >= 7) -- { -- int j = 3 + p_180653_5_; -- -- for (int k = 0; k < j; ++k) -- { -- if (p_180653_1_.field_73012_v.nextInt(15) <= i) -- { -- func_180635_a(p_180653_1_, p_180653_2_, new ItemStack(this.func_149866_i(), 1, 0)); -- } -- } -- } -- } +@@ -174,11 +175,33 @@ + return Items.field_151015_O; } - public Item func_180660_a(IBlockState p_180660_1_, Random p_180660_2_, int p_180660_3_) -@@ -202,4 +184,26 @@ - { - return new BlockState(this, new IProperty[] {field_176488_a}); - } -+ + @Override + public java.util.List getDrops(net.minecraft.world.IBlockAccess world, BlockPos pos, IBlockState state, int fortune) + { + java.util.List ret = super.getDrops(world, pos, state, fortune); -+ int age = ((Integer)state.func_177229_b(field_176488_a)).intValue(); ++ int age = func_185527_x(state); + Random rand = world instanceof World ? ((World)world).field_73012_v : new Random(); + -+ if (age >= 7) ++ if (age >= func_185526_g()) + { + int k = 3 + fortune; + + for (int i = 0; i < 3 + fortune; ++i) + { -+ if (rand.nextInt(15) <= age) ++ if (rand.nextInt(2 * func_185526_g()) <= age) + { + ret.add(new ItemStack(this.func_149866_i(), 1, 0)); + } @@ -74,4 +49,13 @@ + } + return ret; + } - } ++ + public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) + { + super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, 0); + +- if (!p_180653_1_.field_72995_K) ++ if (false && !p_180653_1_.field_72995_K) // Forge: NOP all this. + { + int i = this.func_185527_x(p_180653_3_); + diff --git a/patches/minecraft/net/minecraft/block/BlockDeadBush.java.patch b/patches/minecraft/net/minecraft/block/BlockDeadBush.java.patch index a350513b45..5ef70af15e 100644 --- a/patches/minecraft/net/minecraft/block/BlockDeadBush.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockDeadBush.java.patch @@ -1,26 +1,25 @@ --- ../src-base/minecraft/net/minecraft/block/BlockDeadBush.java +++ ../src-work/minecraft/net/minecraft/block/BlockDeadBush.java -@@ -14,7 +14,7 @@ - import net.minecraft.util.BlockPos; +@@ -16,7 +16,7 @@ + import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockDeadBush extends BlockBush +public class BlockDeadBush extends BlockBush implements net.minecraftforge.common.IShearable { - protected BlockDeadBush() - { -@@ -45,14 +45,15 @@ + protected static final AxisAlignedBB field_185516_a = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D); - public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_) +@@ -57,7 +57,7 @@ + + public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_, ItemStack p_180657_6_) { -- if (!p_180657_1_.field_72995_K && p_180657_2_.func_71045_bC() != null && p_180657_2_.func_71045_bC().func_77973_b() == Items.field_151097_aZ) +- if (!p_180657_1_.field_72995_K && p_180657_6_ != null && p_180657_6_.func_77973_b() == Items.field_151097_aZ) ++ if (false && !p_180657_1_.field_72995_K && p_180657_6_ != null && p_180657_6_.func_77973_b() == Items.field_151097_aZ) // Forge: Noop { -- p_180657_2_.func_71029_a(StatList.field_75934_C[Block.func_149682_b(this)]); -- func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Blocks.field_150330_I, 1, 0)); -- } -- else -- { - super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_); + p_180657_2_.func_71029_a(StatList.func_188055_a(this)); + func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Blocks.field_150330_I, 1, 0)); +@@ -67,4 +67,11 @@ + super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_, p_180657_6_); } } + @@ -28,6 +27,6 @@ + @Override + public java.util.List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) + { -+ return new java.util.ArrayList(java.util.Arrays.asList(new ItemStack(Blocks.field_150330_I))); ++ return java.util.Arrays.asList(new ItemStack(Blocks.field_150330_I)); + } } diff --git a/patches/minecraft/net/minecraft/block/BlockDoor.java.patch b/patches/minecraft/net/minecraft/block/BlockDoor.java.patch index de31efb01b..51d575be8a 100644 --- a/patches/minecraft/net/minecraft/block/BlockDoor.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockDoor.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockDoor.java +++ ../src-work/minecraft/net/minecraft/block/BlockDoor.java -@@ -154,7 +154,7 @@ +@@ -107,7 +107,7 @@ { if (this.field_149764_J == Material.field_151573_f) { @@ -9,12 +9,12 @@ } else { -@@ -272,7 +272,7 @@ +@@ -219,7 +219,7 @@ public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_) { -- return p_176196_2_.func_177956_o() >= 255 ? false : World.func_175683_a(p_176196_1_, p_176196_2_.func_177977_b()) && super.func_176196_c(p_176196_1_, p_176196_2_) && super.func_176196_c(p_176196_1_, p_176196_2_.func_177984_a()); -+ return p_176196_2_.func_177956_o() >= p_176196_1_.func_72800_K() - 1 ? false : World.func_175683_a(p_176196_1_, p_176196_2_.func_177977_b()) && super.func_176196_c(p_176196_1_, p_176196_2_) && super.func_176196_c(p_176196_1_, p_176196_2_.func_177984_a()); +- return p_176196_2_.func_177956_o() >= 255 ? false : p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).func_185896_q() && super.func_176196_c(p_176196_1_, p_176196_2_) && super.func_176196_c(p_176196_1_, p_176196_2_.func_177984_a()); ++ return p_176196_2_.func_177956_o() >= p_176196_1_.func_72800_K() - 1 ? false : p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).isSideSolid(p_176196_1_, p_176196_2_.func_177977_b(), EnumFacing.UP) && super.func_176196_c(p_176196_1_, p_176196_2_) && super.func_176196_c(p_176196_1_, p_176196_2_.func_177984_a()); } - public int func_149656_h() + public EnumPushReaction func_149656_h(IBlockState p_149656_1_) diff --git a/patches/minecraft/net/minecraft/block/BlockDoublePlant.java.patch b/patches/minecraft/net/minecraft/block/BlockDoublePlant.java.patch index 2218435af4..1a92f21a62 100644 --- a/patches/minecraft/net/minecraft/block/BlockDoublePlant.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockDoublePlant.java.patch @@ -9,7 +9,7 @@ { public static final PropertyEnum field_176493_a = PropertyEnum.func_177709_a("variant", BlockDoublePlant.EnumPlantType.class); public static final PropertyEnum field_176492_b = PropertyEnum.func_177709_a("half", BlockDoublePlant.EnumBlockHalf.class); -@@ -90,6 +90,8 @@ +@@ -88,6 +88,8 @@ Block block = (Block)(flag ? this : p_176475_1_.func_180495_p(blockpos).func_177230_c()); Block block1 = (Block)(flag ? p_176475_1_.func_180495_p(blockpos1).func_177230_c() : this); @@ -18,7 +18,7 @@ if (block == this) { p_176475_1_.func_180501_a(blockpos, Blocks.field_150350_a.func_176223_P(), 2); -@@ -98,17 +100,13 @@ +@@ -96,17 +98,13 @@ if (block1 == this) { p_176475_1_.func_180501_a(blockpos1, Blocks.field_150350_a.func_176223_P(), 3); @@ -37,24 +37,24 @@ if (p_180671_3_.func_177229_b(field_176492_b) == BlockDoublePlant.EnumBlockHalf.UPPER) { return p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()).func_177230_c() == this; -@@ -158,7 +156,6 @@ +@@ -149,7 +147,6 @@ - public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_) + public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_, ItemStack p_180657_6_) { -- if (p_180657_1_.field_72995_K || p_180657_2_.func_71045_bC() == null || p_180657_2_.func_71045_bC().func_77973_b() != Items.field_151097_aZ || p_180657_4_.func_177229_b(field_176492_b) != BlockDoublePlant.EnumBlockHalf.LOWER || !this.func_176489_b(p_180657_1_, p_180657_3_, p_180657_4_, p_180657_2_)) +- if (p_180657_1_.field_72995_K || p_180657_6_ == null || p_180657_6_.func_77973_b() != Items.field_151097_aZ || p_180657_4_.func_177229_b(field_176492_b) != BlockDoublePlant.EnumBlockHalf.LOWER || !this.func_176489_b(p_180657_1_, p_180657_3_, p_180657_4_, p_180657_2_)) { - super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_); + super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_, p_180657_6_); } -@@ -221,8 +218,6 @@ +@@ -212,8 +209,6 @@ else { - p_176489_4_.func_71029_a(StatList.field_75934_C[Block.func_149682_b(this)]); + p_176489_4_.func_71029_a(StatList.func_188055_a(this)); - int i = (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS ? BlockTallGrass.EnumType.GRASS : BlockTallGrass.EnumType.FERN).func_177044_a(); - func_180635_a(p_176489_1_, p_176489_2_, new ItemStack(Blocks.field_150329_H, 2, i)); return true; } } -@@ -293,6 +288,32 @@ +@@ -284,6 +279,33 @@ return Block.EnumOffsetType.XZ; } @@ -65,6 +65,7 @@ + EnumPlantType type = (EnumPlantType)state.func_177229_b(field_176493_a); + return state.func_177229_b(field_176492_b) == EnumBlockHalf.LOWER && (type == EnumPlantType.FERN || type == EnumPlantType.GRASS); + } ++ + @Override + public java.util.List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) + { @@ -74,11 +75,11 @@ + if (type == EnumPlantType.GRASS) ret.add(new ItemStack(Blocks.field_150329_H, 2, BlockTallGrass.EnumType.GRASS.func_177044_a())); + return ret; + } ++ + @Override -+ public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) ++ public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) + { + //Forge: Break both parts on the client to prevent the top part flickering as default type for a few frames. -+ IBlockState state = world.func_180495_p(pos); + if (state.func_177230_c() == this && state.func_177229_b(field_176492_b) == EnumBlockHalf.LOWER && world.func_180495_p(pos.func_177984_a()).func_177230_c() == this) + world.func_175698_g(pos.func_177984_a()); + return world.func_175698_g(pos); diff --git a/patches/minecraft/net/minecraft/block/BlockDragonEgg.java.patch b/patches/minecraft/net/minecraft/block/BlockDragonEgg.java.patch new file mode 100644 index 0000000000..2eb9dd2a20 --- /dev/null +++ b/patches/minecraft/net/minecraft/block/BlockDragonEgg.java.patch @@ -0,0 +1,20 @@ +--- ../src-base/minecraft/net/minecraft/block/BlockDragonEgg.java ++++ ../src-work/minecraft/net/minecraft/block/BlockDragonEgg.java +@@ -48,7 +48,7 @@ + + private void func_180683_d(World p_180683_1_, BlockPos p_180683_2_) + { +- if (BlockFalling.func_185759_i(p_180683_1_.func_180495_p(p_180683_2_.func_177977_b())) && p_180683_2_.func_177956_o() >= 0) ++ if (p_180683_1_.func_175623_d(p_180683_2_.func_177977_b()) && BlockFalling.func_185759_i(p_180683_1_.func_180495_p(p_180683_2_.func_177977_b())) && p_180683_2_.func_177956_o() >= 0) + { + int i = 32; + +@@ -61,7 +61,7 @@ + p_180683_1_.func_175698_g(p_180683_2_); + BlockPos blockpos; + +- for (blockpos = p_180683_2_; BlockFalling.func_185759_i(p_180683_1_.func_180495_p(blockpos)) && blockpos.func_177956_o() > 0; blockpos = blockpos.func_177977_b()) ++ for (blockpos = p_180683_2_; p_180683_1_.func_175623_d(blockpos) && BlockFalling.func_185759_i(p_180683_1_.func_180495_p(blockpos)) && blockpos.func_177956_o() > 0; blockpos = blockpos.func_177977_b()) + { + ; + } diff --git a/patches/minecraft/net/minecraft/block/BlockFalling.java.patch b/patches/minecraft/net/minecraft/block/BlockFalling.java.patch index 811cb1a2c5..6d9cfd9f47 100644 --- a/patches/minecraft/net/minecraft/block/BlockFalling.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockFalling.java.patch @@ -1,10 +1,20 @@ --- ../src-base/minecraft/net/minecraft/block/BlockFalling.java +++ ../src-work/minecraft/net/minecraft/block/BlockFalling.java -@@ -86,6 +86,7 @@ +@@ -44,7 +44,7 @@ - public static boolean func_180685_d(World p_180685_0_, BlockPos p_180685_1_) + private void func_176503_e(World p_176503_1_, BlockPos p_176503_2_) { -+ if (p_180685_0_.func_175623_d(p_180685_1_)) return true; - Block block = p_180685_0_.func_180495_p(p_180685_1_).func_177230_c(); - Material material = block.field_149764_J; - return block == Blocks.field_150480_ab || material == Material.field_151579_a || material == Material.field_151586_h || material == Material.field_151587_i; +- if (func_185759_i(p_176503_1_.func_180495_p(p_176503_2_.func_177977_b())) && p_176503_2_.func_177956_o() >= 0) ++ if ((p_176503_1_.func_175623_d(p_176503_2_.func_177977_b()) || func_185759_i(p_176503_1_.func_180495_p(p_176503_2_.func_177977_b()))) && p_176503_2_.func_177956_o() >= 0) + { + int i = 32; + +@@ -62,7 +62,7 @@ + p_176503_1_.func_175698_g(p_176503_2_); + BlockPos blockpos; + +- for (blockpos = p_176503_2_.func_177977_b(); func_185759_i(p_176503_1_.func_180495_p(blockpos)) && blockpos.func_177956_o() > 0; blockpos = blockpos.func_177977_b()) ++ for (blockpos = p_176503_2_.func_177977_b(); (p_176503_1_.func_175623_d(blockpos) || func_185759_i(p_176503_1_.func_180495_p(blockpos))) && blockpos.func_177956_o() > 0; blockpos = blockpos.func_177977_b()) + { + ; + } diff --git a/patches/minecraft/net/minecraft/block/BlockFarmland.java.patch b/patches/minecraft/net/minecraft/block/BlockFarmland.java.patch index 7547658d37..6332eeec8b 100644 --- a/patches/minecraft/net/minecraft/block/BlockFarmland.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockFarmland.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/block/BlockFarmland.java +++ ../src-work/minecraft/net/minecraft/block/BlockFarmland.java -@@ -89,7 +89,7 @@ +@@ -87,7 +87,7 @@ private boolean func_176529_d(World p_176529_1_, BlockPos p_176529_2_) { Block block = p_176529_1_.func_180495_p(p_176529_2_.func_177984_a()).func_177230_c(); - return block instanceof BlockCrops || block instanceof BlockStem; -+ return block instanceof net.minecraftforge.common.IPlantable && canSustainPlant(p_176529_1_, p_176529_2_, net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable)block); ++ return block instanceof net.minecraftforge.common.IPlantable && canSustainPlant(p_176529_1_.func_180495_p(p_176529_2_), p_176529_1_, p_176529_2_, net.minecraft.util.EnumFacing.UP, (net.minecraftforge.common.IPlantable)block); } private boolean func_176530_e(World p_176530_1_, BlockPos p_176530_2_) diff --git a/patches/minecraft/net/minecraft/block/BlockFire.java.patch b/patches/minecraft/net/minecraft/block/BlockFire.java.patch index 05ab962bc2..62f2ba905f 100644 --- a/patches/minecraft/net/minecraft/block/BlockFire.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockFire.java.patch @@ -1,34 +1,23 @@ --- ../src-base/minecraft/net/minecraft/block/BlockFire.java +++ ../src-work/minecraft/net/minecraft/block/BlockFire.java -@@ -41,18 +41,24 @@ - int j = p_176221_3_.func_177956_o(); - int k = p_176221_3_.func_177952_p(); +@@ -37,7 +37,15 @@ -- if (!World.func_175683_a(p_176221_2_, p_176221_3_.func_177977_b()) && !Blocks.field_150480_ab.func_176535_e(p_176221_2_, p_176221_3_.func_177977_b())) -+ if (!World.func_175683_a(p_176221_2_, p_176221_3_.func_177977_b()) && !Blocks.field_150480_ab.canCatchFire(p_176221_2_, p_176221_3_.func_177977_b(), EnumFacing.UP)) - { - boolean flag = (i + j + k & 1) == 1; - boolean flag1 = (i / 2 + j / 2 + k / 2 & 1) == 1; - int l = 0; + public IBlockState func_176221_a(IBlockState p_176221_1_, IBlockAccess p_176221_2_, BlockPos p_176221_3_) + { +- return !p_176221_2_.func_180495_p(p_176221_3_.func_177977_b()).func_185896_q() && !Blocks.field_150480_ab.func_176535_e(p_176221_2_, p_176221_3_.func_177977_b()) ? p_176221_1_.func_177226_a(field_176545_N, Boolean.valueOf(this.func_176535_e(p_176221_2_, p_176221_3_.func_177978_c()))).func_177226_a(field_176546_O, Boolean.valueOf(this.func_176535_e(p_176221_2_, p_176221_3_.func_177974_f()))).func_177226_a(field_176541_P, Boolean.valueOf(this.func_176535_e(p_176221_2_, p_176221_3_.func_177968_d()))).func_177226_a(field_176539_Q, Boolean.valueOf(this.func_176535_e(p_176221_2_, p_176221_3_.func_177976_e()))).func_177226_a(field_176542_R, Boolean.valueOf(this.func_176535_e(p_176221_2_, p_176221_3_.func_177984_a()))) : this.func_176223_P(); ++ if (!p_176221_2_.func_180495_p(p_176221_3_.func_177977_b()).isSideSolid(p_176221_2_, p_176221_3_.func_177977_b(), EnumFacing.UP) && !Blocks.field_150480_ab.canCatchFire(p_176221_2_, p_176221_3_.func_177977_b(), EnumFacing.UP)) ++ { ++ return p_176221_1_.func_177226_a(field_176545_N, this.canCatchFire(p_176221_2_, p_176221_3_.func_177978_c(), EnumFacing.SOUTH)) ++ .func_177226_a(field_176546_O, this.canCatchFire(p_176221_2_, p_176221_3_.func_177974_f(), EnumFacing.WEST)) ++ .func_177226_a(field_176541_P, this.canCatchFire(p_176221_2_, p_176221_3_.func_177968_d(), EnumFacing.NORTH)) ++ .func_177226_a(field_176539_Q, this.canCatchFire(p_176221_2_, p_176221_3_.func_177976_e(), EnumFacing.EAST)) ++ .func_177226_a(field_176542_R, this.canCatchFire(p_176221_2_, p_176221_3_.func_177984_a(), EnumFacing.DOWN)); ++ } ++ return this.func_176223_P(); + } -- if (this.func_176535_e(p_176221_2_, p_176221_3_.func_177984_a())) -+ if (this.canCatchFire(p_176221_2_, p_176221_3_.func_177984_a(), EnumFacing.DOWN)) - { - l = flag ? 1 : 2; - } - -- return p_176221_1_.func_177226_a(field_176545_N, Boolean.valueOf(this.func_176535_e(p_176221_2_, p_176221_3_.func_177978_c()))).func_177226_a(field_176546_O, Boolean.valueOf(this.func_176535_e(p_176221_2_, p_176221_3_.func_177974_f()))).func_177226_a(field_176541_P, Boolean.valueOf(this.func_176535_e(p_176221_2_, p_176221_3_.func_177968_d()))).func_177226_a(field_176539_Q, Boolean.valueOf(this.func_176535_e(p_176221_2_, p_176221_3_.func_177976_e()))).func_177226_a(field_176542_R, Integer.valueOf(l)).func_177226_a(field_176540_b, Boolean.valueOf(flag1)).func_177226_a(field_176544_M, Boolean.valueOf(flag)); -+ return p_176221_1_.func_177226_a(field_176545_N, Boolean.valueOf(this.canCatchFire(p_176221_2_, p_176221_3_.func_177978_c(), EnumFacing.SOUTH))) -+ .func_177226_a(field_176546_O, Boolean.valueOf(this.canCatchFire(p_176221_2_, p_176221_3_.func_177974_f(), EnumFacing.EAST ))) -+ .func_177226_a(field_176541_P, Boolean.valueOf(this.canCatchFire(p_176221_2_, p_176221_3_.func_177968_d(), EnumFacing.NORTH))) -+ .func_177226_a(field_176539_Q, Boolean.valueOf(this.canCatchFire(p_176221_2_, p_176221_3_.func_177976_e(), EnumFacing.EAST ))) -+ .func_177226_a(field_176542_R, Integer.valueOf(l)) -+ .func_177226_a(field_176540_b, Boolean.valueOf(flag1)) -+ .func_177226_a(field_176544_M, Boolean.valueOf(flag)); - } - else - { -@@ -108,6 +114,7 @@ + protected BlockFire() +@@ -90,6 +98,7 @@ public void func_180686_a(Block p_180686_1_, int p_180686_2_, int p_180686_3_) { @@ -36,7 +25,7 @@ this.field_149849_a.put(p_180686_1_, Integer.valueOf(p_180686_2_)); this.field_149848_b.put(p_180686_1_, Integer.valueOf(p_180686_3_)); } -@@ -147,13 +154,8 @@ +@@ -129,13 +138,8 @@ } Block block = p_180650_1_.func_180495_p(p_180650_2_.func_177977_b()).func_177230_c(); @@ -48,10 +37,19 @@ - flag = true; - } - - if (!flag && p_180650_1_.func_72896_J() && this.func_176537_d(p_180650_1_, p_180650_2_)) - { - p_180650_1_.func_175698_g(p_180650_2_); -@@ -182,7 +184,7 @@ + int i = ((Integer)p_180650_3_.func_177229_b(field_176543_a)).intValue(); + + if (!flag && p_180650_1_.func_72896_J() && this.func_176537_d(p_180650_1_, p_180650_2_) && p_180650_4_.nextFloat() < 0.2F + (float)i * 0.03F) +@@ -156,7 +160,7 @@ + { + if (!this.func_176533_e(p_180650_1_, p_180650_2_)) + { +- if (!p_180650_1_.func_180495_p(p_180650_2_.func_177977_b()).func_185896_q() || i > 3) ++ if (!p_180650_1_.func_180495_p(p_180650_2_.func_177977_b()).isSideSolid(p_180650_1_, p_180650_2_.func_177977_b(), EnumFacing.UP) || i > 3) + { + p_180650_1_.func_175698_g(p_180650_2_); + } +@@ -164,7 +168,7 @@ return; } @@ -60,7 +58,7 @@ { p_180650_1_.func_175698_g(p_180650_2_); return; -@@ -197,12 +199,12 @@ +@@ -179,12 +183,12 @@ j = -50; } @@ -79,7 +77,7 @@ for (int k = -1; k <= 1; ++k) { -@@ -261,22 +263,30 @@ +@@ -243,45 +247,53 @@ return false; } @@ -104,14 +102,44 @@ + this.tryCatchFire(p_176536_1_, p_176536_2_, p_176536_3_, p_176536_4_, p_176536_5_, EnumFacing.UP); + } -+ private void tryCatchFire(World p_176536_1_, BlockPos p_176536_2_, int p_176536_3_, Random p_176536_4_, int p_176536_5_, EnumFacing face) +- if (p_176536_4_.nextInt(p_176536_3_) < i) ++ private void tryCatchFire(World worldIn, BlockPos pos, int chance, Random random, int age, EnumFacing face) + { -+ int i = p_176536_1_.func_180495_p(p_176536_2_).func_177230_c().getFlammability(p_176536_1_, p_176536_2_, face); ++ int i = worldIn.func_180495_p(pos).func_177230_c().getFlammability(worldIn, pos, face); + - if (p_176536_4_.nextInt(p_176536_3_) < i) ++ if (random.nextInt(chance) < i) { - IBlockState iblockstate = p_176536_1_.func_180495_p(p_176536_2_); -@@ -308,7 +318,7 @@ +- IBlockState iblockstate = p_176536_1_.func_180495_p(p_176536_2_); ++ IBlockState iblockstate = worldIn.func_180495_p(pos); + +- if (p_176536_4_.nextInt(p_176536_5_ + 10) < 5 && !p_176536_1_.func_175727_C(p_176536_2_)) ++ if (random.nextInt(age + 10) < 5 && !worldIn.func_175727_C(pos)) + { +- int j = p_176536_5_ + p_176536_4_.nextInt(5) / 4; ++ int j = age + random.nextInt(5) / 4; + + if (j > 15) + { + j = 15; + } + +- p_176536_1_.func_180501_a(p_176536_2_, this.func_176223_P().func_177226_a(field_176543_a, Integer.valueOf(j)), 3); ++ worldIn.func_180501_a(pos, this.func_176223_P().func_177226_a(field_176543_a, Integer.valueOf(j)), 3); + } + else + { +- p_176536_1_.func_175698_g(p_176536_2_); ++ worldIn.func_175698_g(pos); + } + + if (iblockstate.func_177230_c() == Blocks.field_150335_W) + { +- Blocks.field_150335_W.func_176206_d(p_176536_1_, p_176536_2_, iblockstate.func_177226_a(BlockTNT.field_176246_a, Boolean.valueOf(true))); ++ Blocks.field_150335_W.func_176206_d(worldIn, pos, iblockstate.func_177226_a(BlockTNT.field_176246_a, Boolean.valueOf(true))); + } + } + } +@@ -290,7 +302,7 @@ { for (EnumFacing enumfacing : EnumFacing.values()) { @@ -120,7 +148,7 @@ { return true; } -@@ -329,7 +339,7 @@ +@@ -311,7 +323,7 @@ for (EnumFacing enumfacing : EnumFacing.values()) { @@ -129,7 +157,7 @@ } return i; -@@ -341,9 +351,10 @@ +@@ -323,9 +335,10 @@ return false; } @@ -141,57 +169,57 @@ } public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_) -@@ -382,9 +393,9 @@ - p_180655_1_.func_72980_b((double)((float)p_180655_2_.func_177958_n() + 0.5F), (double)((float)p_180655_2_.func_177956_o() + 0.5F), (double)((float)p_180655_2_.func_177952_p() + 0.5F), "fire.fire", 1.0F + p_180655_4_.nextFloat(), p_180655_4_.nextFloat() * 0.7F + 0.3F, false); +@@ -364,9 +377,9 @@ + p_180655_2_.func_184134_a((double)((float)p_180655_3_.func_177958_n() + 0.5F), (double)((float)p_180655_3_.func_177956_o() + 0.5F), (double)((float)p_180655_3_.func_177952_p() + 0.5F), SoundEvents.field_187643_bs, SoundCategory.BLOCKS, 1.0F + p_180655_4_.nextFloat(), p_180655_4_.nextFloat() * 0.7F + 0.3F, false); } -- if (!World.func_175683_a(p_180655_1_, p_180655_2_.func_177977_b()) && !Blocks.field_150480_ab.func_176535_e(p_180655_1_, p_180655_2_.func_177977_b())) -+ if (!World.func_175683_a(p_180655_1_, p_180655_2_.func_177977_b()) && !Blocks.field_150480_ab.canCatchFire(p_180655_1_, p_180655_2_.func_177977_b(), EnumFacing.UP)) +- if (!p_180655_2_.func_180495_p(p_180655_3_.func_177977_b()).func_185896_q() && !Blocks.field_150480_ab.func_176535_e(p_180655_2_, p_180655_3_.func_177977_b())) ++ if (!p_180655_2_.func_180495_p(p_180655_3_.func_177977_b()).isSideSolid(p_180655_2_, p_180655_3_.func_177977_b(), EnumFacing.UP) && !Blocks.field_150480_ab.canCatchFire(p_180655_2_, p_180655_3_.func_177977_b(), EnumFacing.UP)) { -- if (Blocks.field_150480_ab.func_176535_e(p_180655_1_, p_180655_2_.func_177976_e())) -+ if (Blocks.field_150480_ab.canCatchFire(p_180655_1_, p_180655_2_.func_177976_e(), EnumFacing.EAST)) +- if (Blocks.field_150480_ab.func_176535_e(p_180655_2_, p_180655_3_.func_177976_e())) ++ if (Blocks.field_150480_ab.canCatchFire(p_180655_2_, p_180655_3_.func_177976_e(), EnumFacing.EAST)) { for (int j = 0; j < 2; ++j) { -@@ -395,7 +406,7 @@ +@@ -377,7 +390,7 @@ } } -- if (Blocks.field_150480_ab.func_176535_e(p_180655_1_, p_180655_2_.func_177974_f())) -+ if (Blocks.field_150480_ab.canCatchFire(p_180655_1_, p_180655_2_.func_177974_f(), EnumFacing.WEST)) +- if (Blocks.field_150480_ab.func_176535_e(p_180655_2_, p_180655_3_.func_177974_f())) ++ if (Blocks.field_150480_ab.canCatchFire(p_180655_2_, p_180655_3_.func_177974_f(), EnumFacing.WEST)) { for (int k = 0; k < 2; ++k) { -@@ -406,7 +417,7 @@ +@@ -388,7 +401,7 @@ } } -- if (Blocks.field_150480_ab.func_176535_e(p_180655_1_, p_180655_2_.func_177978_c())) -+ if (Blocks.field_150480_ab.canCatchFire(p_180655_1_, p_180655_2_.func_177978_c(), EnumFacing.SOUTH)) +- if (Blocks.field_150480_ab.func_176535_e(p_180655_2_, p_180655_3_.func_177978_c())) ++ if (Blocks.field_150480_ab.canCatchFire(p_180655_2_, p_180655_3_.func_177978_c(), EnumFacing.SOUTH)) { for (int l = 0; l < 2; ++l) { -@@ -417,7 +428,7 @@ +@@ -399,7 +412,7 @@ } } -- if (Blocks.field_150480_ab.func_176535_e(p_180655_1_, p_180655_2_.func_177968_d())) -+ if (Blocks.field_150480_ab.canCatchFire(p_180655_1_, p_180655_2_.func_177968_d(), EnumFacing.NORTH)) +- if (Blocks.field_150480_ab.func_176535_e(p_180655_2_, p_180655_3_.func_177968_d())) ++ if (Blocks.field_150480_ab.canCatchFire(p_180655_2_, p_180655_3_.func_177968_d(), EnumFacing.NORTH)) { for (int i1 = 0; i1 < 2; ++i1) { -@@ -428,7 +439,7 @@ +@@ -410,7 +423,7 @@ } } -- if (Blocks.field_150480_ab.func_176535_e(p_180655_1_, p_180655_2_.func_177984_a())) -+ if (Blocks.field_150480_ab.canCatchFire(p_180655_1_, p_180655_2_.func_177984_a(), EnumFacing.DOWN)) +- if (Blocks.field_150480_ab.func_176535_e(p_180655_2_, p_180655_3_.func_177984_a())) ++ if (Blocks.field_150480_ab.canCatchFire(p_180655_2_, p_180655_3_.func_177984_a(), EnumFacing.DOWN)) { for (int j1 = 0; j1 < 2; ++j1) { -@@ -476,4 +487,19 @@ +@@ -458,4 +471,19 @@ { - return new BlockState(this, new IProperty[] {field_176543_a, field_176545_N, field_176546_O, field_176541_P, field_176539_Q, field_176542_R, field_176540_b, field_176544_M}); + return new BlockStateContainer(this, new IProperty[] {field_176543_a, field_176545_N, field_176546_O, field_176541_P, field_176539_Q, field_176542_R}); } + + /*================================= Forge Start ======================================*/ diff --git a/patches/minecraft/net/minecraft/block/BlockFlowerPot.java.patch b/patches/minecraft/net/minecraft/block/BlockFlowerPot.java.patch index 24229b07bf..cf36d9316f 100644 --- a/patches/minecraft/net/minecraft/block/BlockFlowerPot.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockFlowerPot.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockFlowerPot.java +++ ../src-work/minecraft/net/minecraft/block/BlockFlowerPot.java -@@ -169,13 +169,6 @@ +@@ -148,13 +148,6 @@ public void func_180663_b(World p_180663_1_, BlockPos p_180663_2_, IBlockState p_180663_3_) { @@ -14,8 +14,8 @@ super.func_180663_b(p_180663_1_, p_180663_2_, p_180663_3_); } -@@ -395,6 +388,31 @@ - return EnumWorldBlockLayer.CUTOUT; +@@ -374,6 +367,31 @@ + return BlockRenderLayer.CUTOUT; } + @@ -30,15 +30,15 @@ + return ret; + } + @Override -+ public boolean removedByPlayer(World world, BlockPos pos, EntityPlayer player, boolean willHarvest) ++ public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) + { + if (willHarvest) return true; //If it will harvest, delay deletion of the block until after getDrops -+ return super.removedByPlayer(world, pos, player, willHarvest); ++ return super.removedByPlayer(state, world, pos, player, willHarvest); + } + @Override -+ public void func_180657_a(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) ++ public void func_180657_a(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack tool) + { -+ super.func_180657_a(world, player, pos, state, te); ++ super.func_180657_a(world, player, pos, state, te, tool); + world.func_175698_g(pos); + } + /*===========================FORGE END==========================================*/ diff --git a/patches/minecraft/net/minecraft/block/BlockGrass.java.patch b/patches/minecraft/net/minecraft/block/BlockGrass.java.patch index 7f957e591d..d56f0539ba 100644 --- a/patches/minecraft/net/minecraft/block/BlockGrass.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockGrass.java.patch @@ -1,24 +1,24 @@ --- ../src-base/minecraft/net/minecraft/block/BlockGrass.java +++ ../src-work/minecraft/net/minecraft/block/BlockGrass.java -@@ -58,7 +58,7 @@ +@@ -38,7 +38,7 @@ { if (!p_180650_1_.field_72995_K) { -- if (p_180650_1_.func_175671_l(p_180650_2_.func_177984_a()) < 4 && p_180650_1_.func_180495_p(p_180650_2_.func_177984_a()).func_177230_c().func_149717_k() > 2) -+ if (p_180650_1_.func_175671_l(p_180650_2_.func_177984_a()) < 4 && p_180650_1_.func_180495_p(p_180650_2_.func_177984_a()).func_177230_c().getLightOpacity(p_180650_1_, p_180650_2_.func_177984_a()) > 2) +- if (p_180650_1_.func_175671_l(p_180650_2_.func_177984_a()) < 4 && p_180650_1_.func_180495_p(p_180650_2_.func_177984_a()).func_185891_c() > 2) ++ if (p_180650_1_.func_175671_l(p_180650_2_.func_177984_a()) < 4 && p_180650_1_.func_180495_p(p_180650_2_.func_177984_a()).getLightOpacity(p_180650_1_, p_180650_2_.func_177984_a()) > 2) { p_180650_1_.func_175656_a(p_180650_2_, Blocks.field_150346_d.func_176223_P()); } -@@ -72,7 +72,7 @@ - Block block = p_180650_1_.func_180495_p(blockpos.func_177984_a()).func_177230_c(); - IBlockState iblockstate = p_180650_1_.func_180495_p(blockpos); +@@ -58,7 +58,7 @@ + IBlockState iblockstate = p_180650_1_.func_180495_p(blockpos.func_177984_a()); + IBlockState iblockstate1 = p_180650_1_.func_180495_p(blockpos); -- if (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.DIRT && p_180650_1_.func_175671_l(blockpos.func_177984_a()) >= 4 && block.func_149717_k() <= 2) -+ if (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.DIRT && p_180650_1_.func_175671_l(blockpos.func_177984_a()) >= 4 && block.getLightOpacity(p_180650_1_, blockpos.func_177984_a()) <= 2) +- if (iblockstate1.func_177230_c() == Blocks.field_150346_d && iblockstate1.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.DIRT && p_180650_1_.func_175671_l(blockpos.func_177984_a()) >= 4 && iblockstate.func_185891_c() <= 2) ++ if (iblockstate1.func_177230_c() == Blocks.field_150346_d && iblockstate1.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.DIRT && p_180650_1_.func_175671_l(blockpos.func_177984_a()) >= 4 && iblockstate.getLightOpacity(p_180650_1_, p_180650_2_.func_177984_a()) <= 2) { p_180650_1_.func_175656_a(blockpos, Blocks.field_150349_c.func_176223_P()); } -@@ -110,7 +110,7 @@ +@@ -96,7 +96,7 @@ { if (j >= i / 16) { diff --git a/patches/minecraft/net/minecraft/block/BlockHugeMushroom.java.patch b/patches/minecraft/net/minecraft/block/BlockHugeMushroom.java.patch index cfc4d531f6..c4f0ba3963 100644 --- a/patches/minecraft/net/minecraft/block/BlockHugeMushroom.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockHugeMushroom.java.patch @@ -1,13 +1,13 @@ --- ../src-base/minecraft/net/minecraft/block/BlockHugeMushroom.java +++ ../src-work/minecraft/net/minecraft/block/BlockHugeMushroom.java -@@ -79,6 +79,20 @@ - return new BlockState(this, new IProperty[] {field_176380_a}); +@@ -221,6 +221,20 @@ + return new BlockStateContainer(this, new IProperty[] {field_176380_a}); } + public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) + { + IBlockState state = world.func_180495_p(pos); -+ for (IProperty prop : (java.util.Set)state.func_177228_b().keySet()) ++ for (IProperty prop : (java.util.Set>)state.func_177228_b().keySet()) + { + if (prop.func_177701_a().equals("variant")) + { diff --git a/patches/minecraft/net/minecraft/block/BlockIce.java.patch b/patches/minecraft/net/minecraft/block/BlockIce.java.patch index b2ff04fe65..e7570c6932 100644 --- a/patches/minecraft/net/minecraft/block/BlockIce.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockIce.java.patch @@ -1,35 +1,34 @@ --- ../src-base/minecraft/net/minecraft/block/BlockIce.java +++ ../src-work/minecraft/net/minecraft/block/BlockIce.java -@@ -38,14 +38,17 @@ - p_180657_2_.func_71029_a(StatList.field_75934_C[Block.func_149682_b(this)]); +@@ -40,14 +40,19 @@ + p_180657_2_.func_71029_a(StatList.func_188055_a(this)); p_180657_2_.func_71020_j(0.025F); -- if (this.func_149700_E() && EnchantmentHelper.func_77502_d(p_180657_2_)) -+ if (this.canSilkHarvest(p_180657_1_, p_180657_3_, p_180657_1_.func_180495_p(p_180657_3_), p_180657_2_) && EnchantmentHelper.func_77502_d(p_180657_2_)) +- if (this.func_149700_E() && EnchantmentHelper.func_77506_a(Enchantments.field_185306_r, p_180657_6_) > 0) ++ if (this.canSilkHarvest(p_180657_1_, p_180657_3_, p_180657_4_, p_180657_2_) && EnchantmentHelper.func_77506_a(Enchantments.field_185306_r, p_180657_6_) > 0) { + java.util.List items = new java.util.ArrayList(); ItemStack itemstack = this.func_180643_i(p_180657_4_); -- if (itemstack != null) -- { + if (itemstack != null) + { - func_180635_a(p_180657_1_, p_180657_3_, itemstack); -- } -+ if (itemstack != null) items.add(itemstack); -+ -+ net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, p_180657_1_, p_180657_3_, p_180657_1_.func_180495_p(p_180657_3_), 0, 1.0f, true, p_180657_2_); ++ items.add(itemstack); + } + ++ net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, p_180657_1_, p_180657_3_, p_180657_4_, 0, 1.0f, true, p_180657_2_); + for (ItemStack is : items) + func_180635_a(p_180657_1_, p_180657_3_, is); } else { -@@ -56,7 +59,9 @@ +@@ -58,7 +63,9 @@ } - int i = EnchantmentHelper.func_77517_e(p_180657_2_); + int i = EnchantmentHelper.func_77506_a(Enchantments.field_185308_t, p_180657_6_); + harvesters.set(p_180657_2_); this.func_176226_b(p_180657_1_, p_180657_3_, p_180657_4_, i); + harvesters.set(null); - Material material = p_180657_1_.func_180495_p(p_180657_3_.func_177977_b()).func_177230_c().func_149688_o(); + Material material = p_180657_1_.func_180495_p(p_180657_3_.func_177977_b()).func_185904_a(); if (material.func_76230_c() || material.func_76224_d()) diff --git a/patches/minecraft/net/minecraft/block/BlockLadder.java.patch b/patches/minecraft/net/minecraft/block/BlockLadder.java.patch index 84fa2d3dbb..4251c5bd57 100644 --- a/patches/minecraft/net/minecraft/block/BlockLadder.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockLadder.java.patch @@ -1,30 +1,30 @@ --- ../src-base/minecraft/net/minecraft/block/BlockLadder.java +++ ../src-work/minecraft/net/minecraft/block/BlockLadder.java -@@ -78,7 +78,10 @@ +@@ -61,7 +61,10 @@ public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_) { -- return p_176196_1_.func_180495_p(p_176196_2_.func_177976_e()).func_177230_c().func_149721_r() ? true : (p_176196_1_.func_180495_p(p_176196_2_.func_177974_f()).func_177230_c().func_149721_r() ? true : (p_176196_1_.func_180495_p(p_176196_2_.func_177978_c()).func_177230_c().func_149721_r() ? true : p_176196_1_.func_180495_p(p_176196_2_.func_177968_d()).func_177230_c().func_149721_r())); -+ return p_176196_1_.isSideSolid(p_176196_2_.func_177976_e(), EnumFacing.EAST, true) || -+ p_176196_1_.isSideSolid(p_176196_2_.func_177974_f(), EnumFacing.WEST, true) || -+ p_176196_1_.isSideSolid(p_176196_2_.func_177978_c(), EnumFacing.SOUTH, true) || -+ p_176196_1_.isSideSolid(p_176196_2_.func_177968_d(), EnumFacing.NORTH, true); +- return p_176196_1_.func_180495_p(p_176196_2_.func_177976_e()).func_185915_l() ? true : (p_176196_1_.func_180495_p(p_176196_2_.func_177974_f()).func_185915_l() ? true : (p_176196_1_.func_180495_p(p_176196_2_.func_177978_c()).func_185915_l() ? true : p_176196_1_.func_180495_p(p_176196_2_.func_177968_d()).func_185915_l())); ++ return p_176196_1_.func_180495_p(p_176196_2_.func_177976_e()).isSideSolid(p_176196_1_, p_176196_2_.func_177976_e(), EnumFacing.EAST) || ++ p_176196_1_.func_180495_p(p_176196_2_.func_177974_f()).isSideSolid(p_176196_1_, p_176196_2_.func_177974_f(), EnumFacing.WEST) || ++ p_176196_1_.func_180495_p(p_176196_2_.func_177978_c()).isSideSolid(p_176196_1_, p_176196_2_.func_177978_c(), EnumFacing.SOUTH) || ++ p_176196_1_.func_180495_p(p_176196_2_.func_177968_d()).isSideSolid(p_176196_1_, p_176196_2_.func_177968_d(), EnumFacing.NORTH); } public IBlockState func_180642_a(World p_180642_1_, BlockPos p_180642_2_, EnumFacing p_180642_3_, float p_180642_4_, float p_180642_5_, float p_180642_6_, int p_180642_7_, EntityLivingBase p_180642_8_) -@@ -116,7 +119,7 @@ +@@ -99,7 +102,7 @@ protected boolean func_176381_b(World p_176381_1_, BlockPos p_176381_2_, EnumFacing p_176381_3_) { -- return p_176381_1_.func_180495_p(p_176381_2_.func_177972_a(p_176381_3_.func_176734_d())).func_177230_c().func_149721_r(); -+ return p_176381_1_.isSideSolid(p_176381_2_.func_177972_a(p_176381_3_.func_176734_d()), p_176381_3_, true); +- return p_176381_1_.func_180495_p(p_176381_2_.func_177972_a(p_176381_3_.func_176734_d())).func_185915_l(); ++ return p_176381_1_.func_180495_p(p_176381_2_.func_177972_a(p_176381_3_.func_176734_d())).isSideSolid(p_176381_1_, p_176381_2_.func_177972_a(p_176381_3_.func_176734_d()), p_176381_3_); } public IBlockState func_176203_a(int p_176203_1_) -@@ -146,4 +149,6 @@ +@@ -139,4 +142,6 @@ { - return new BlockState(this, new IProperty[] {field_176382_a}); + return new BlockStateContainer(this, new IProperty[] {field_176382_a}); } + -+ @Override public boolean isLadder(IBlockAccess world, BlockPos pos, EntityLivingBase entity) { return true; } ++ @Override public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) { return true; } } diff --git a/patches/minecraft/net/minecraft/block/BlockLeaves.java.patch b/patches/minecraft/net/minecraft/block/BlockLeaves.java.patch index 4dcb42a4dc..201fd60135 100644 --- a/patches/minecraft/net/minecraft/block/BlockLeaves.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockLeaves.java.patch @@ -1,39 +1,39 @@ --- ../src-base/minecraft/net/minecraft/block/BlockLeaves.java +++ ../src-work/minecraft/net/minecraft/block/BlockLeaves.java -@@ -18,7 +18,7 @@ +@@ -17,7 +17,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; --public abstract class BlockLeaves extends BlockLeavesBase -+public abstract class BlockLeaves extends BlockLeavesBase implements net.minecraftforge.common.IShearable +-public abstract class BlockLeaves extends Block ++public abstract class BlockLeaves extends Block implements net.minecraftforge.common.IShearable { public static final PropertyBool field_176237_a = PropertyBool.func_177716_a("decayable"); public static final PropertyBool field_176236_b = PropertyBool.func_177716_a("check_decay"); -@@ -75,9 +75,9 @@ +@@ -53,9 +53,9 @@ BlockPos blockpos = p_180663_2_.func_177982_a(j1, k1, l1); IBlockState iblockstate = p_180663_1_.func_180495_p(blockpos); -- if (iblockstate.func_177230_c().func_149688_o() == Material.field_151584_j && !((Boolean)iblockstate.func_177229_b(field_176236_b)).booleanValue()) -+ if (iblockstate.func_177230_c().isLeaves(p_180663_1_, blockpos)) +- if (iblockstate.func_185904_a() == Material.field_151584_j && !((Boolean)iblockstate.func_177229_b(field_176236_b)).booleanValue()) ++ if (iblockstate.func_177230_c().isLeaves(iblockstate, p_180663_1_, blockpos)) { - p_180663_1_.func_180501_a(blockpos, iblockstate.func_177226_a(field_176236_b, Boolean.valueOf(true)), 4); -+ iblockstate.func_177230_c().beginLeavesDecay(p_180663_1_, blockpos); ++ iblockstate.func_177230_c().beginLeavesDecay(iblockstate, p_180663_1_, blockpos); } } } -@@ -117,9 +117,9 @@ - { - Block block = p_180650_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(k + i2, l + j2, i1 + k2)).func_177230_c(); +@@ -96,9 +96,9 @@ + IBlockState iblockstate = p_180650_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(k + i2, l + j2, i1 + k2)); + Block block = iblockstate.func_177230_c(); - if (block != Blocks.field_150364_r && block != Blocks.field_150363_s) -+ if (!block.canSustainLeaves(p_180650_1_, blockpos$mutableblockpos.func_181079_c(k + i2, l + j2, i1 + k2))) ++ if (!block.canSustainLeaves(iblockstate, p_180650_1_, blockpos$mutableblockpos.func_181079_c(k + i2, l + j2, i1 + k2))) { -- if (block.func_149688_o() == Material.field_151584_j) -+ if (block.isLeaves(p_180650_1_, blockpos$mutableblockpos.func_181079_c(k + i2, l + j2, i1 + k2))) +- if (iblockstate.func_185904_a() == Material.field_151584_j) ++ if (block.isLeaves(iblockstate, p_180650_1_, blockpos$mutableblockpos.func_181079_c(k + i2, l + j2, i1 + k2))) { this.field_150128_a[(i2 + l1) * k1 + (j2 + l1) * j1 + k2 + l1] = -2; } -@@ -226,40 +226,7 @@ +@@ -205,40 +205,7 @@ public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) { @@ -75,18 +75,16 @@ } protected void func_176234_a(World p_176234_1_, BlockPos p_176234_2_, IBlockState p_176234_3_, int p_176234_4_) -@@ -296,4 +263,48 @@ - } +@@ -274,6 +241,49 @@ public abstract BlockPlanks.EnumType func_176233_b(int p_176233_1_); -+ + + @Override public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos){ return true; } -+ @Override public boolean isLeaves(IBlockAccess world, BlockPos pos){ return true; } ++ @Override public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos){ return true; } + + @Override -+ public void beginLeavesDecay(World world, BlockPos pos) ++ public void beginLeavesDecay(IBlockState state, World world, BlockPos pos) + { -+ IBlockState state = world.func_180495_p(pos); + if (!(Boolean)state.func_177229_b(field_176236_b)) + { + world.func_180501_a(pos, state.func_177226_a(field_176236_b, true), 4); @@ -123,4 +121,7 @@ + return ret; + } + - } ++ + @SideOnly(Side.CLIENT) + public boolean func_176225_a(IBlockState p_176225_1_, IBlockAccess p_176225_2_, BlockPos p_176225_3_, EnumFacing p_176225_4_) + { diff --git a/patches/minecraft/net/minecraft/block/BlockLever.java.patch b/patches/minecraft/net/minecraft/block/BlockLever.java.patch index 7bee933219..b3e399cd01 100644 --- a/patches/minecraft/net/minecraft/block/BlockLever.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockLever.java.patch @@ -1,7 +1,7 @@ --- ../src-base/minecraft/net/minecraft/block/BlockLever.java +++ ../src-work/minecraft/net/minecraft/block/BlockLever.java -@@ -237,6 +237,12 @@ - return new BlockState(this, new IProperty[] {field_176360_a, field_176359_b}); +@@ -295,6 +295,12 @@ + return new BlockStateContainer(this, new IProperty[] {field_176360_a, field_176359_b}); } + diff --git a/patches/minecraft/net/minecraft/block/BlockLog.java.patch b/patches/minecraft/net/minecraft/block/BlockLog.java.patch index a6247c0c2b..6268339217 100644 --- a/patches/minecraft/net/minecraft/block/BlockLog.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockLog.java.patch @@ -1,22 +1,22 @@ --- ../src-base/minecraft/net/minecraft/block/BlockLog.java +++ ../src-work/minecraft/net/minecraft/block/BlockLog.java -@@ -33,9 +33,9 @@ +@@ -34,9 +34,9 @@ { IBlockState iblockstate = p_180663_1_.func_180495_p(blockpos); -- if (iblockstate.func_177230_c().func_149688_o() == Material.field_151584_j && !((Boolean)iblockstate.func_177229_b(BlockLeaves.field_176236_b)).booleanValue()) -+ if (iblockstate.func_177230_c().isLeaves(p_180663_1_, blockpos)) +- if (iblockstate.func_185904_a() == Material.field_151584_j && !((Boolean)iblockstate.func_177229_b(BlockLeaves.field_176236_b)).booleanValue()) ++ if (iblockstate.func_177230_c().isLeaves(iblockstate, p_180663_1_, blockpos)) { - p_180663_1_.func_180501_a(blockpos, iblockstate.func_177226_a(BlockLeaves.field_176236_b, Boolean.valueOf(true)), 4); -+ iblockstate.func_177230_c().beginLeavesDecay(p_180663_1_, blockpos); ++ iblockstate.func_177230_c().beginLeavesDecay(iblockstate, p_180663_1_, blockpos); } } } -@@ -46,6 +46,9 @@ - return super.func_180642_a(p_180642_1_, p_180642_2_, p_180642_3_, p_180642_4_, p_180642_5_, p_180642_6_, p_180642_7_, p_180642_8_).func_177226_a(field_176299_a, BlockLog.EnumAxis.func_176870_a(p_180642_3_.func_176740_k())); +@@ -69,6 +69,9 @@ + } } -+ @Override public boolean canSustainLeaves(net.minecraft.world.IBlockAccess world, BlockPos pos){ return true; } ++ @Override public boolean canSustainLeaves(IBlockState state, net.minecraft.world.IBlockAccess world, BlockPos pos){ return true; } + @Override public boolean isWood(net.minecraft.world.IBlockAccess world, BlockPos pos){ return true; } + public static enum EnumAxis implements IStringSerializable diff --git a/patches/minecraft/net/minecraft/block/BlockMobSpawner.java.patch b/patches/minecraft/net/minecraft/block/BlockMobSpawner.java.patch index 89062cf381..49d79f3fce 100644 --- a/patches/minecraft/net/minecraft/block/BlockMobSpawner.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockMobSpawner.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockMobSpawner.java +++ ../src-work/minecraft/net/minecraft/block/BlockMobSpawner.java -@@ -37,10 +37,14 @@ +@@ -39,10 +39,14 @@ public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) { super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, p_180653_5_); @@ -9,11 +9,11 @@ } + @Override -+ public int getExpDrop(net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) ++ public int getExpDrop(IBlockState state, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) + { + return 15 + RANDOM.nextInt(15) + RANDOM.nextInt(15); + } + - public boolean func_149662_c() + public boolean func_149662_c(IBlockState p_149662_1_) { return false; diff --git a/patches/minecraft/net/minecraft/block/BlockMushroom.java.patch b/patches/minecraft/net/minecraft/block/BlockMushroom.java.patch index c78e7fc1da..ff671be04e 100644 --- a/patches/minecraft/net/minecraft/block/BlockMushroom.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockMushroom.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/block/BlockMushroom.java +++ ../src-work/minecraft/net/minecraft/block/BlockMushroom.java -@@ -71,7 +71,7 @@ +@@ -78,7 +78,7 @@ if (p_180671_2_.func_177956_o() >= 0 && p_180671_2_.func_177956_o() < 256) { IBlockState iblockstate = p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()); -- return iblockstate.func_177230_c() == Blocks.field_150391_bh ? true : (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.PODZOL ? true : p_180671_1_.func_175699_k(p_180671_2_) < 13 && this.func_149854_a(iblockstate.func_177230_c())); -+ return iblockstate.func_177230_c() == Blocks.field_150391_bh ? true : (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.PODZOL ? true : p_180671_1_.func_175699_k(p_180671_2_) < 13 && iblockstate.func_177230_c().canSustainPlant(p_180671_1_, p_180671_2_.func_177977_b(), net.minecraft.util.EnumFacing.UP, this)); +- return iblockstate.func_177230_c() == Blocks.field_150391_bh ? true : (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.PODZOL ? true : p_180671_1_.func_175699_k(p_180671_2_) < 13 && this.func_185514_i(iblockstate)); ++ return iblockstate.func_177230_c() == Blocks.field_150391_bh ? true : (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.PODZOL ? true : p_180671_1_.func_175699_k(p_180671_2_) < 13 && iblockstate.func_177230_c().canSustainPlant(iblockstate, p_180671_1_, p_180671_2_.func_177977_b(), net.minecraft.util.EnumFacing.UP, this)); } else { diff --git a/patches/minecraft/net/minecraft/block/BlockMycelium.java.patch b/patches/minecraft/net/minecraft/block/BlockMycelium.java.patch index c7bd1a280d..f97644492f 100644 --- a/patches/minecraft/net/minecraft/block/BlockMycelium.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockMycelium.java.patch @@ -4,17 +4,17 @@ { if (!p_180650_1_.field_72995_K) { -- if (p_180650_1_.func_175671_l(p_180650_2_.func_177984_a()) < 4 && p_180650_1_.func_180495_p(p_180650_2_.func_177984_a()).func_177230_c().func_149717_k() > 2) -+ if (p_180650_1_.func_175671_l(p_180650_2_.func_177984_a()) < 4 && p_180650_1_.func_180495_p(p_180650_2_.func_177984_a()).func_177230_c().getLightOpacity(p_180650_1_, p_180650_2_.func_177984_a()) > 2) +- if (p_180650_1_.func_175671_l(p_180650_2_.func_177984_a()) < 4 && p_180650_1_.func_180495_p(p_180650_2_.func_177984_a()).func_185891_c() > 2) ++ if (p_180650_1_.func_175671_l(p_180650_2_.func_177984_a()) < 4 && p_180650_1_.func_180495_p(p_180650_2_.func_177984_a()).getLightOpacity(p_180650_1_, p_180650_2_.func_177984_a()) > 2) { p_180650_1_.func_175656_a(p_180650_2_, Blocks.field_150346_d.func_176223_P().func_177226_a(BlockDirt.field_176386_a, BlockDirt.DirtType.DIRT)); } @@ -53,7 +53,7 @@ IBlockState iblockstate = p_180650_1_.func_180495_p(blockpos); - Block block = p_180650_1_.func_180495_p(blockpos.func_177984_a()).func_177230_c(); + IBlockState iblockstate1 = p_180650_1_.func_180495_p(blockpos.func_177984_a()); -- if (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.DIRT && p_180650_1_.func_175671_l(blockpos.func_177984_a()) >= 4 && block.func_149717_k() <= 2) -+ if (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.DIRT && p_180650_1_.func_175671_l(blockpos.func_177984_a()) >= 4 && block.getLightOpacity(p_180650_1_, blockpos.func_177984_a()) <= 2) +- if (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.DIRT && p_180650_1_.func_175671_l(blockpos.func_177984_a()) >= 4 && iblockstate1.func_185891_c() <= 2) ++ if (iblockstate.func_177230_c() == Blocks.field_150346_d && iblockstate.func_177229_b(BlockDirt.field_176386_a) == BlockDirt.DirtType.DIRT && p_180650_1_.func_175671_l(blockpos.func_177984_a()) >= 4 && iblockstate1.getLightOpacity(p_180650_1_, blockpos.func_177984_a()) <= 2) { p_180650_1_.func_175656_a(blockpos, this.func_176223_P()); } diff --git a/patches/minecraft/net/minecraft/block/BlockNetherWart.java.patch b/patches/minecraft/net/minecraft/block/BlockNetherWart.java.patch index 959b41a0be..3424c6cd86 100644 --- a/patches/minecraft/net/minecraft/block/BlockNetherWart.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockNetherWart.java.patch @@ -1,15 +1,15 @@ --- ../src-base/minecraft/net/minecraft/block/BlockNetherWart.java +++ ../src-work/minecraft/net/minecraft/block/BlockNetherWart.java -@@ -38,7 +38,7 @@ +@@ -42,7 +42,7 @@ public boolean func_180671_f(World p_180671_1_, BlockPos p_180671_2_, IBlockState p_180671_3_) { -- return this.func_149854_a(p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()).func_177230_c()); +- return this.func_185514_i(p_180671_1_.func_180495_p(p_180671_2_.func_177977_b())); + return super.func_180671_f(p_180671_1_, p_180671_2_, p_180671_3_); } public void func_180650_b(World p_180650_1_, BlockPos p_180650_2_, IBlockState p_180650_3_, Random p_180650_4_) -@@ -54,9 +54,11 @@ +@@ -58,9 +58,11 @@ super.func_180650_b(p_180650_1_, p_180650_2_, p_180650_3_, p_180650_4_); } @@ -22,11 +22,10 @@ { int i = 1; -@@ -107,4 +109,24 @@ - { - return new BlockState(this, new IProperty[] {field_176486_a}); +@@ -106,6 +108,26 @@ + return ((Integer)p_176201_1_.func_177229_b(field_176486_a)).intValue(); } -+ + + @Override + public java.util.List getDrops(net.minecraft.world.IBlockAccess world, BlockPos pos, IBlockState state, int fortune) + { @@ -46,4 +45,7 @@ + + return ret; + } - } ++ + protected BlockStateContainer func_180661_e() + { + return new BlockStateContainer(this, new IProperty[] {field_176486_a}); diff --git a/patches/minecraft/net/minecraft/block/BlockNewLeaf.java.patch b/patches/minecraft/net/minecraft/block/BlockNewLeaf.java.patch index 9cfc326686..7efe335afe 100644 --- a/patches/minecraft/net/minecraft/block/BlockNewLeaf.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockNewLeaf.java.patch @@ -1,24 +1,22 @@ --- ../src-base/minecraft/net/minecraft/block/BlockNewLeaf.java +++ ../src-work/minecraft/net/minecraft/block/BlockNewLeaf.java -@@ -99,14 +99,15 @@ +@@ -98,7 +98,7 @@ - public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_) + public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_, ItemStack p_180657_6_) { -- if (!p_180657_1_.field_72995_K && p_180657_2_.func_71045_bC() != null && p_180657_2_.func_71045_bC().func_77973_b() == Items.field_151097_aZ) +- if (!p_180657_1_.field_72995_K && p_180657_6_ != null && p_180657_6_.func_77973_b() == Items.field_151097_aZ) ++ if (false && !p_180657_1_.field_72995_K && p_180657_6_ != null && p_180657_6_.func_77973_b() == Items.field_151097_aZ) //Forge: Noop this { -- p_180657_2_.func_71029_a(StatList.field_75934_C[Block.func_149682_b(this)]); -- func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Item.func_150898_a(this), 1, ((BlockPlanks.EnumType)p_180657_4_.func_177229_b(field_176240_P)).func_176839_a() - 4)); -- } -- else -- { - super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_); + p_180657_2_.func_71029_a(StatList.func_188055_a(this)); + func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Item.func_150898_a(this), 1, ((BlockPlanks.EnumType)p_180657_4_.func_177229_b(field_176240_P)).func_176839_a() - 4)); +@@ -108,4 +108,10 @@ + super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_, p_180657_6_); } } + + @Override + public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) + { -+ IBlockState state = world.func_180495_p(pos); -+ return new java.util.ArrayList(java.util.Arrays.asList(new ItemStack(this, 1, ((BlockPlanks.EnumType)state.func_177229_b(field_176240_P)).func_176839_a() - 4))); ++ return java.util.Arrays.asList(new ItemStack(this, 1, world.func_180495_p(pos).func_177229_b(field_176240_P).func_176839_a() - 4)); + } } diff --git a/patches/minecraft/net/minecraft/block/BlockNote.java.patch b/patches/minecraft/net/minecraft/block/BlockNote.java.patch index 6899eb8770..68bc8aa6d5 100644 --- a/patches/minecraft/net/minecraft/block/BlockNote.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockNote.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockNote.java +++ ../src-work/minecraft/net/minecraft/block/BlockNote.java -@@ -58,7 +58,9 @@ +@@ -64,7 +64,9 @@ if (tileentity instanceof TileEntityNote) { TileEntityNote tileentitynote = (TileEntityNote)tileentity; @@ -8,16 +8,16 @@ tileentitynote.func_145877_a(); + if (old == tileentitynote.field_145879_a) return false; tileentitynote.func_175108_a(p_180639_1_, p_180639_2_); - p_180639_4_.func_71029_a(StatList.field_181735_S); + p_180639_4_.func_71029_a(StatList.field_188087_U); } -@@ -98,6 +100,10 @@ +@@ -104,6 +106,10 @@ public boolean func_180648_a(World p_180648_1_, BlockPos p_180648_2_, IBlockState p_180648_3_, int p_180648_4_, int p_180648_5_) { + net.minecraftforge.event.world.NoteBlockEvent.Play e = new net.minecraftforge.event.world.NoteBlockEvent.Play(p_180648_1_, p_180648_2_, p_180648_3_, p_180648_5_, p_180648_4_); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e)) return false; -+ p_180648_4_ = e.instrument.ordinal(); ++ p_180648_4_ = e.getInstrument().ordinal(); + p_180648_5_ = e.getVanillaNoteId(); float f = (float)Math.pow(2.0D, (double)(p_180648_5_ - 12) / 12.0D); - p_180648_1_.func_72908_a((double)p_180648_2_.func_177958_n() + 0.5D, (double)p_180648_2_.func_177956_o() + 0.5D, (double)p_180648_2_.func_177952_p() + 0.5D, "note." + this.func_176433_b(p_180648_4_), 3.0F, f); + p_180648_1_.func_184133_a((EntityPlayer)null, p_180648_2_, this.func_185576_e(p_180648_4_), SoundCategory.BLOCKS, 3.0F, f); p_180648_1_.func_175688_a(EnumParticleTypes.NOTE, (double)p_180648_2_.func_177958_n() + 0.5D, (double)p_180648_2_.func_177956_o() + 1.2D, (double)p_180648_2_.func_177952_p() + 0.5D, (double)p_180648_5_ / 24.0D, 0.0D, 0.0D, new int[0]); diff --git a/patches/minecraft/net/minecraft/block/BlockOldLeaf.java.patch b/patches/minecraft/net/minecraft/block/BlockOldLeaf.java.patch index c81ddd5619..a9f19415b0 100644 --- a/patches/minecraft/net/minecraft/block/BlockOldLeaf.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockOldLeaf.java.patch @@ -1,21 +1,20 @@ --- ../src-base/minecraft/net/minecraft/block/BlockOldLeaf.java +++ ../src-work/minecraft/net/minecraft/block/BlockOldLeaf.java -@@ -142,11 +142,17 @@ - if (!p_180657_1_.field_72995_K && p_180657_2_.func_71045_bC() != null && p_180657_2_.func_71045_bC().func_77973_b() == Items.field_151097_aZ) +@@ -103,11 +103,16 @@ + if (!p_180657_1_.field_72995_K && p_180657_6_ != null && p_180657_6_.func_77973_b() == Items.field_151097_aZ) { - p_180657_2_.func_71029_a(StatList.field_75934_C[Block.func_149682_b(this)]); + p_180657_2_.func_71029_a(StatList.func_188055_a(this)); - func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Item.func_150898_a(this), 1, ((BlockPlanks.EnumType)p_180657_4_.func_177229_b(field_176239_P)).func_176839_a())); } else { - super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_); + super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_, p_180657_6_); } } + + @Override -+ public List onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) ++ public List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) + { -+ IBlockState state = world.func_180495_p(pos); -+ return new java.util.ArrayList(java.util.Arrays.asList(new ItemStack(this, 1, ((BlockPlanks.EnumType)state.func_177229_b(field_176239_P)).func_176839_a()))); ++ return java.util.Arrays.asList(new ItemStack(this, 1, world.func_180495_p(pos).func_177229_b(field_176239_P).func_176839_a())); + } } diff --git a/patches/minecraft/net/minecraft/block/BlockOre.java.patch b/patches/minecraft/net/minecraft/block/BlockOre.java.patch index a08f33decc..15b1046bc1 100644 --- a/patches/minecraft/net/minecraft/block/BlockOre.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockOre.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockOre.java +++ ../src-work/minecraft/net/minecraft/block/BlockOre.java -@@ -58,34 +58,40 @@ +@@ -59,34 +59,39 @@ public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) { super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, p_180653_5_); @@ -8,9 +8,8 @@ - if (this.func_180660_a(p_180653_3_, p_180653_1_.field_73012_v, p_180653_5_) != Item.func_150898_a(this)) + } + @Override -+ public int getExpDrop(net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) ++ public int getExpDrop(IBlockState state, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) + { -+ IBlockState state = world.func_180495_p(pos); + Random rand = world instanceof World ? ((World)world).field_73012_v : new Random(); + if (this.func_180660_a(state, rand, fortune) != Item.func_150898_a(this)) { @@ -48,4 +47,4 @@ + return 0; } - public int func_176222_j(World p_176222_1_, BlockPos p_176222_2_) + public ItemStack func_185473_a(World p_185473_1_, BlockPos p_185473_2_, IBlockState p_185473_3_) diff --git a/patches/minecraft/net/minecraft/block/BlockPane.java.patch b/patches/minecraft/net/minecraft/block/BlockPane.java.patch index bf26e9fafc..0d9d74407a 100644 --- a/patches/minecraft/net/minecraft/block/BlockPane.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockPane.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockPane.java +++ ../src-work/minecraft/net/minecraft/block/BlockPane.java -@@ -38,7 +38,10 @@ +@@ -105,7 +105,10 @@ public IBlockState func_176221_a(IBlockState p_176221_1_, IBlockAccess p_176221_2_, BlockPos p_176221_3_) { @@ -12,30 +12,15 @@ } public Item func_180660_a(IBlockState p_180660_1_, Random p_180660_2_, int p_180660_3_) -@@ -64,10 +67,10 @@ - - public void func_180638_a(World p_180638_1_, BlockPos p_180638_2_, IBlockState p_180638_3_, AxisAlignedBB p_180638_4_, List p_180638_5_, Entity p_180638_6_) +@@ -182,4 +185,11 @@ { -- boolean flag = this.func_150098_a(p_180638_1_.func_180495_p(p_180638_2_.func_177978_c()).func_177230_c()); -- boolean flag1 = this.func_150098_a(p_180638_1_.func_180495_p(p_180638_2_.func_177968_d()).func_177230_c()); -- boolean flag2 = this.func_150098_a(p_180638_1_.func_180495_p(p_180638_2_.func_177976_e()).func_177230_c()); -- boolean flag3 = this.func_150098_a(p_180638_1_.func_180495_p(p_180638_2_.func_177974_f()).func_177230_c()); -+ boolean flag = this.canPaneConnectTo(p_180638_1_, p_180638_2_, EnumFacing.NORTH); -+ boolean flag1 = this.canPaneConnectTo(p_180638_1_, p_180638_2_, EnumFacing.SOUTH); -+ boolean flag2 = this.canPaneConnectTo(p_180638_1_, p_180638_2_, EnumFacing.WEST); -+ boolean flag3 = this.canPaneConnectTo(p_180638_1_, p_180638_2_, EnumFacing.EAST); - - if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) - { -@@ -186,4 +189,11 @@ - { - return new BlockState(this, new IProperty[] {field_176241_b, field_176242_M, field_176244_O, field_176243_N}); + return new BlockStateContainer(this, new IProperty[] {field_176241_b, field_176242_M, field_176244_O, field_176243_N}); } + + public boolean canPaneConnectTo(IBlockAccess world, BlockPos pos, EnumFacing dir) + { + BlockPos off = pos.func_177972_a(dir); -+ Block block = world.func_180495_p(off).func_177230_c(); -+ return func_150098_a(block) || block.isSideSolid(world, off, dir.func_176734_d()); ++ IBlockState state = world.func_180495_p(off); ++ return func_150098_a(state.func_177230_c()) || state.isSideSolid(world, off, dir.func_176734_d()); + } } diff --git a/patches/minecraft/net/minecraft/block/BlockPistonBase.java.patch b/patches/minecraft/net/minecraft/block/BlockPistonBase.java.patch index db2e7cfaea..d3d13188c0 100644 --- a/patches/minecraft/net/minecraft/block/BlockPistonBase.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockPistonBase.java.patch @@ -1,31 +1,31 @@ --- ../src-base/minecraft/net/minecraft/block/BlockPistonBase.java +++ ../src-work/minecraft/net/minecraft/block/BlockPistonBase.java -@@ -189,7 +189,7 @@ +@@ -235,7 +235,7 @@ } } -- if (!flag1 && block.func_149688_o() != Material.field_151579_a && func_180696_a(block, p_180648_1_, blockpos, enumfacing.func_176734_d(), false) && (block.func_149656_h() == 0 || block == Blocks.field_150331_J || block == Blocks.field_150320_F)) -+ if (!flag1 && !block.isAir(p_180648_1_, blockpos) && func_180696_a(block, p_180648_1_, blockpos, enumfacing.func_176734_d(), false) && (block.func_149656_h() == 0 || block == Blocks.field_150331_J || block == Blocks.field_150320_F)) +- if (!flag1 && iblockstate.func_185904_a() != Material.field_151579_a && func_185646_a(iblockstate, p_180648_1_, blockpos, enumfacing.func_176734_d(), false) && (iblockstate.func_185905_o() == EnumPushReaction.NORMAL || block == Blocks.field_150331_J || block == Blocks.field_150320_F)) ++ if (!flag1 && !iblockstate.func_177230_c().isAir(iblockstate, p_180648_1_, blockpos) && func_185646_a(iblockstate, p_180648_1_, blockpos, enumfacing.func_176734_d(), false) && (iblockstate.func_185905_o() == EnumPushReaction.NORMAL || block == Blocks.field_150331_J || block == Blocks.field_150320_F)) { this.func_176319_a(p_180648_1_, p_180648_2_, enumfacing, false); } -@@ -333,7 +333,7 @@ +@@ -320,7 +320,7 @@ return false; } -- return !(p_180696_0_ instanceof ITileEntityProvider); -+ return !(p_180696_0_.hasTileEntity(p_180696_1_.func_180495_p(p_180696_2_))); +- return !block.func_149716_u(); ++ return !block.hasTileEntity(p_185646_0_); } else { -@@ -371,7 +371,9 @@ +@@ -366,7 +366,9 @@ { - BlockPos blockpos = (BlockPos)list1.get(j); - Block block = p_176319_1_.func_180495_p(blockpos).func_177230_c(); -- block.func_176226_b(p_176319_1_, blockpos, p_176319_1_.func_180495_p(blockpos), 0); -+ //With our change to how snowballs are dropped this needs to disallow to mimic vanilla behavior. -+ float chance = block instanceof BlockSnow ? -1.0f : 1.0f; -+ block.func_180653_a(p_176319_1_, blockpos, p_176319_1_.func_180495_p(blockpos), chance, 0); - p_176319_1_.func_175698_g(blockpos); - --i; - ablock[i] = block; + BlockPos blockpos1 = (BlockPos)list2.get(j); + IBlockState iblockstate = p_176319_1_.func_180495_p(blockpos1); +- iblockstate.func_177230_c().func_176226_b(p_176319_1_, blockpos1, iblockstate, 0); ++ // Forge: With our change to how snowballs are dropped this needs to disallow to mimic vanilla behavior. ++ float chance = iblockstate.func_177230_c() instanceof BlockSnow ? -1.0f : 1.0f; ++ iblockstate.func_177230_c().func_180653_a(p_176319_1_, blockpos1, iblockstate, chance, 0); + p_176319_1_.func_175698_g(blockpos1); + --k; + aiblockstate[k] = iblockstate; diff --git a/patches/minecraft/net/minecraft/block/BlockPistonMoving.java.patch b/patches/minecraft/net/minecraft/block/BlockPistonMoving.java.patch index 3ba28b443d..9cbc42a5da 100644 --- a/patches/minecraft/net/minecraft/block/BlockPistonMoving.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockPistonMoving.java.patch @@ -1,32 +1,31 @@ --- ../src-base/minecraft/net/minecraft/block/BlockPistonMoving.java +++ ../src-work/minecraft/net/minecraft/block/BlockPistonMoving.java -@@ -109,16 +109,7 @@ +@@ -110,7 +110,7 @@ public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) { - if (!p_180653_1_.field_72995_K) -- { -- TileEntityPiston tileentitypiston = this.func_176422_e(p_180653_1_, p_180653_2_); -- -- if (tileentitypiston != null) -- { -- IBlockState iblockstate = tileentitypiston.func_174927_b(); -- iblockstate.func_177230_c().func_176226_b(p_180653_1_, p_180653_2_, iblockstate, 0); -- } -- } ++ if (false && !p_180653_1_.field_72995_K) // Forge: Noop this out + { + TileEntityPiston tileentitypiston = this.func_185589_c(p_180653_1_, p_180653_2_); + +@@ -120,6 +120,7 @@ + iblockstate.func_177230_c().func_176226_b(p_180653_1_, p_180653_2_, iblockstate, 0); + } + } + super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, p_180653_5_); } - public MovingObjectPosition func_180636_a(World p_180636_1_, BlockPos p_180636_2_, Vec3 p_180636_3_, Vec3 p_180636_4_) -@@ -282,4 +273,16 @@ + public RayTraceResult func_180636_a(IBlockState p_180636_1_, World p_180636_2_, BlockPos p_180636_3_, Vec3d p_180636_4_, Vec3d p_180636_5_) +@@ -190,4 +191,16 @@ { - return new BlockState(this, new IProperty[] {field_176426_a, field_176425_b}); + return new BlockStateContainer(this, new IProperty[] {field_176426_a, field_176425_b}); } + + @Override + public java.util.List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) + { -+ TileEntityPiston tileentitypiston = this.func_176422_e(world, pos); ++ TileEntityPiston tileentitypiston = this.func_185589_c(world, pos); + if (tileentitypiston != null) + { + IBlockState pushed = tileentitypiston.func_174927_b(); diff --git a/patches/minecraft/net/minecraft/block/BlockPotato.java.patch b/patches/minecraft/net/minecraft/block/BlockPotato.java.patch index f507e33360..1e39263618 100644 --- a/patches/minecraft/net/minecraft/block/BlockPotato.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockPotato.java.patch @@ -1,24 +1,24 @@ --- ../src-base/minecraft/net/minecraft/block/BlockPotato.java +++ ../src-work/minecraft/net/minecraft/block/BlockPotato.java -@@ -22,13 +22,14 @@ - public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) +@@ -27,7 +27,7 @@ { super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, p_180653_5_); -- + - if (!p_180653_1_.field_72995_K) -- { -- if (((Integer)p_180653_3_.func_177229_b(field_176488_a)).intValue() >= 7 && p_180653_1_.field_73012_v.nextInt(50) == 0) -- { -- func_180635_a(p_180653_1_, p_180653_2_, new ItemStack(Items.field_151170_bI)); -- } -- } ++ if (false && !p_180653_1_.field_72995_K) //Forge: Moved to getDrops + { + if (this.func_185525_y(p_180653_3_) && p_180653_1_.field_73012_v.nextInt(50) == 0) + { +@@ -40,4 +40,13 @@ + { + return field_185534_a[((Integer)p_185496_1_.func_177229_b(this.func_185524_e())).intValue()]; } ++ + @Override -+ public java.util.List getDrops(net.minecraft.world.IBlockAccess world, BlockPos pos, IBlockState state, int fortune) ++ public java.util.List getDrops(net.minecraft.world.IBlockAccess world, BlockPos pos, IBlockState state, int fortune) + { + java.util.List ret = super.getDrops(world, pos, state, fortune); -+ java.util.Random rand = world instanceof World ? ((World)world).field_73012_v : new java.util.Random(); -+ if (((Integer)state.func_177229_b(field_176488_a)) >= 7 && rand.nextInt(50) == 0) ++ if (this.func_185525_y(state) && RANDOM.nextInt(50) == 0) + ret.add(new ItemStack(Items.field_151170_bI)); + return ret; + } diff --git a/patches/minecraft/net/minecraft/block/BlockPumpkin.java.patch b/patches/minecraft/net/minecraft/block/BlockPumpkin.java.patch index 256bace073..1d4332d11d 100644 --- a/patches/minecraft/net/minecraft/block/BlockPumpkin.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockPumpkin.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/block/BlockPumpkin.java +++ ../src-work/minecraft/net/minecraft/block/BlockPumpkin.java -@@ -115,7 +115,7 @@ +@@ -117,7 +117,7 @@ public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_) { -- return p_176196_1_.func_180495_p(p_176196_2_).func_177230_c().field_149764_J.func_76222_j() && World.func_175683_a(p_176196_1_, p_176196_2_.func_177977_b()); -+ return p_176196_1_.func_180495_p(p_176196_2_).func_177230_c().func_176200_f(p_176196_1_, p_176196_2_) && World.func_175683_a(p_176196_1_, p_176196_2_.func_177977_b()); +- return p_176196_1_.func_180495_p(p_176196_2_).func_177230_c().field_149764_J.func_76222_j() && p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).func_185896_q(); ++ return p_176196_1_.func_180495_p(p_176196_2_).func_177230_c().func_176200_f(p_176196_1_, p_176196_2_) && p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).isSideSolid(p_176196_1_, p_176196_2_, EnumFacing.UP); } - public IBlockState func_180642_a(World p_180642_1_, BlockPos p_180642_2_, EnumFacing p_180642_3_, float p_180642_4_, float p_180642_5_, float p_180642_6_, int p_180642_7_, EntityLivingBase p_180642_8_) + public IBlockState func_185499_a(IBlockState p_185499_1_, Rotation p_185499_2_) diff --git a/patches/minecraft/net/minecraft/block/BlockQuartz.java.patch b/patches/minecraft/net/minecraft/block/BlockQuartz.java.patch index b78be41ea8..5bc96aff1d 100644 --- a/patches/minecraft/net/minecraft/block/BlockQuartz.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockQuartz.java.patch @@ -1,13 +1,13 @@ --- ../src-base/minecraft/net/minecraft/block/BlockQuartz.java +++ ../src-work/minecraft/net/minecraft/block/BlockQuartz.java -@@ -90,6 +90,26 @@ - return new BlockState(this, new IProperty[] {field_176335_a}); +@@ -113,6 +113,26 @@ + return new BlockStateContainer(this, new IProperty[] {field_176335_a}); } + public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) + { + IBlockState state = world.func_180495_p(pos); -+ for (IProperty prop : (java.util.Set)state.func_177228_b().keySet()) ++ for (IProperty prop : state.func_177228_b().keySet()) + { + if (prop.func_177701_a().equals("variant") && prop.func_177699_b() == EnumType.class) + { diff --git a/patches/minecraft/net/minecraft/block/BlockRailBase.java.patch b/patches/minecraft/net/minecraft/block/BlockRailBase.java.patch index d4566a8edf..6607f173ca 100644 --- a/patches/minecraft/net/minecraft/block/BlockRailBase.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockRailBase.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockRailBase.java +++ ../src-work/minecraft/net/minecraft/block/BlockRailBase.java -@@ -31,7 +31,7 @@ +@@ -32,7 +32,7 @@ public static boolean func_176563_d(IBlockState p_176563_0_) { Block block = p_176563_0_.func_177230_c(); @@ -9,7 +9,46 @@ } protected BlockRailBase(boolean p_i45389_1_) -@@ -175,6 +175,98 @@ +@@ -65,7 +65,7 @@ + + public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_) + { +- return p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).func_185896_q(); ++ return p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).isSideSolid(p_176196_1_, p_176196_2_, EnumFacing.UP); + } + + public void func_176213_c(World p_176213_1_, BlockPos p_176213_2_, IBlockState p_176213_3_) +@@ -88,24 +88,24 @@ + BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_176204_3_.func_177229_b(this.func_176560_l()); + boolean flag = false; + +- if (!p_176204_1_.func_180495_p(p_176204_2_.func_177977_b()).func_185896_q()) ++ if (!p_176204_1_.func_180495_p(p_176204_2_.func_177977_b()).isSideSolid(p_176204_1_, p_176204_2_.func_177977_b(), EnumFacing.UP)) + { + flag = true; + } + +- if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_EAST && !p_176204_1_.func_180495_p(p_176204_2_.func_177974_f()).func_185896_q()) ++ if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_EAST && !p_176204_1_.func_180495_p(p_176204_2_.func_177974_f()).isSideSolid(p_176204_1_, p_176204_2_.func_177974_f(), EnumFacing.UP)) + { + flag = true; + } +- else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_WEST && !p_176204_1_.func_180495_p(p_176204_2_.func_177976_e()).func_185896_q()) ++ else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_WEST && !p_176204_1_.func_180495_p(p_176204_2_.func_177976_e()).isSideSolid(p_176204_1_, p_176204_2_.func_177976_e(), EnumFacing.UP)) + { + flag = true; + } +- else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_NORTH && !p_176204_1_.func_180495_p(p_176204_2_.func_177978_c()).func_185896_q()) ++ else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_NORTH && !p_176204_1_.func_180495_p(p_176204_2_.func_177978_c()).isSideSolid(p_176204_1_, p_176204_2_.func_177978_c(), EnumFacing.UP)) + { + flag = true; + } +- else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_SOUTH && !p_176204_1_.func_180495_p(p_176204_2_.func_177968_d()).func_185896_q()) ++ else if (blockrailbase$enumraildirection == BlockRailBase.EnumRailDirection.ASCENDING_SOUTH && !p_176204_1_.func_180495_p(p_176204_2_.func_177968_d()).isSideSolid(p_176204_1_, p_176204_2_.func_177968_d(), EnumFacing.UP)) + { + flag = true; + } +@@ -160,6 +160,81 @@ public abstract IProperty func_176560_l(); @@ -92,7 +131,7 @@ + public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) + { + IBlockState state = world.func_180495_p(pos); -+ for (IProperty prop : (java.util.Set)state.func_177228_b().keySet()) ++ for (IProperty prop : state.func_177228_b().keySet()) + { + if (prop.func_177701_a().equals("shape")) + { @@ -108,7 +147,7 @@ public static enum EnumRailDirection implements IStringSerializable { NORTH_SOUTH(0, "north_south"), -@@ -245,6 +337,7 @@ +@@ -230,6 +305,7 @@ private IBlockState field_180366_e; private final boolean field_150656_f; private final List field_150657_g = Lists.newArrayList(); @@ -116,19 +155,18 @@ public Rail(World p_i45739_2_, BlockPos p_i45739_3_, IBlockState p_i45739_4_) { -@@ -252,8 +345,9 @@ - this.field_180367_c = p_i45739_3_; +@@ -238,7 +314,8 @@ this.field_180366_e = p_i45739_4_; this.field_180365_d = (BlockRailBase)p_i45739_4_.func_177230_c(); -- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_i45739_4_.func_177229_b(BlockRailBase.this.func_176560_l()); + BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_i45739_4_.func_177229_b(this.field_180365_d.func_176560_l()); - this.field_150656_f = this.field_180365_d.field_150053_a; + BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = field_180365_d.getRailDirection(p_i45739_2_, p_i45739_3_, p_i45739_4_, null); + this.field_150656_f = !this.field_180365_d.isFlexibleRail(p_i45739_2_, p_i45739_3_); -+ canMakeSlopes = this.field_180365_d.canMakeSlopes(p_i45739_2_, p_i45739_3_); ++ this.canMakeSlopes = this.field_180365_d.canMakeSlopes(p_i45739_2_, p_i45739_3_); this.func_180360_a(blockrailbase$enumraildirection); } -@@ -439,7 +533,7 @@ +@@ -429,7 +506,7 @@ } } @@ -137,7 +175,7 @@ { if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos.func_177984_a())) { -@@ -452,7 +546,7 @@ +@@ -442,7 +519,7 @@ } } @@ -146,7 +184,7 @@ { if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos3.func_177984_a())) { -@@ -595,7 +689,7 @@ +@@ -585,7 +662,7 @@ } } @@ -155,7 +193,7 @@ { if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos.func_177984_a())) { -@@ -608,7 +702,7 @@ +@@ -598,7 +675,7 @@ } } diff --git a/patches/minecraft/net/minecraft/block/BlockRedstoneComparator.java.patch b/patches/minecraft/net/minecraft/block/BlockRedstoneComparator.java.patch index 1ad9b4abf0..84a6de664c 100644 --- a/patches/minecraft/net/minecraft/block/BlockRedstoneComparator.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockRedstoneComparator.java.patch @@ -1,7 +1,7 @@ --- ../src-base/minecraft/net/minecraft/block/BlockRedstoneComparator.java +++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneComparator.java -@@ -295,6 +295,21 @@ - return this.func_176223_P().func_177226_a(field_176387_N, p_180642_8_.func_174811_aO().func_176734_d()).func_177226_a(field_176464_a, Boolean.valueOf(false)).func_177226_a(field_176463_b, BlockRedstoneComparator.Mode.COMPARE); +@@ -310,6 +310,21 @@ + return this.func_176223_P().func_177226_a(field_185512_D, p_180642_8_.func_174811_aO().func_176734_d()).func_177226_a(field_176464_a, Boolean.valueOf(false)).func_177226_a(field_176463_b, BlockRedstoneComparator.Mode.COMPARE); } + @Override diff --git a/patches/minecraft/net/minecraft/block/BlockRedstoneDiode.java.patch b/patches/minecraft/net/minecraft/block/BlockRedstoneDiode.java.patch index fe20ed8f63..f9a8730485 100644 --- a/patches/minecraft/net/minecraft/block/BlockRedstoneDiode.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockRedstoneDiode.java.patch @@ -1,8 +1,8 @@ --- ../src-base/minecraft/net/minecraft/block/BlockRedstoneDiode.java +++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneDiode.java -@@ -198,6 +198,8 @@ +@@ -204,6 +204,8 @@ { - EnumFacing enumfacing = (EnumFacing)p_176400_3_.func_177229_b(field_176387_N); + EnumFacing enumfacing = (EnumFacing)p_176400_3_.func_177229_b(field_185512_D); BlockPos blockpos = p_176400_2_.func_177972_a(enumfacing.func_176734_d()); + if(net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(p_176400_1_, p_176400_2_, p_176400_1_.func_180495_p(p_176400_2_), java.util.EnumSet.of(enumfacing.func_176734_d())).isCanceled()) + return; diff --git a/patches/minecraft/net/minecraft/block/BlockRedstoneOre.java.patch b/patches/minecraft/net/minecraft/block/BlockRedstoneOre.java.patch index daefa904ed..7762d1ea3c 100644 --- a/patches/minecraft/net/minecraft/block/BlockRedstoneOre.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockRedstoneOre.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockRedstoneOre.java +++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneOre.java -@@ -91,12 +91,16 @@ +@@ -92,12 +92,16 @@ public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) { super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, p_180653_5_); @@ -8,9 +8,9 @@ - if (this.func_180660_a(p_180653_3_, p_180653_1_.field_73012_v, p_180653_5_) != Item.func_150898_a(this)) + @Override -+ public int getExpDrop(net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) ++ public int getExpDrop(IBlockState state, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune) + { -+ if (this.func_180660_a(world.func_180495_p(pos), RANDOM, fortune) != Item.func_150898_a(this)) ++ if (this.func_180660_a(state, RANDOM, fortune) != Item.func_150898_a(this)) { - int i = 1 + p_180653_1_.field_73012_v.nextInt(5); - this.func_180637_b(p_180653_1_, p_180653_2_, i); diff --git a/patches/minecraft/net/minecraft/block/BlockRedstoneWire.java.patch b/patches/minecraft/net/minecraft/block/BlockRedstoneWire.java.patch index 69aa76b4dc..e824763bca 100644 --- a/patches/minecraft/net/minecraft/block/BlockRedstoneWire.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockRedstoneWire.java.patch @@ -1,59 +1,65 @@ --- ../src-base/minecraft/net/minecraft/block/BlockRedstoneWire.java +++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneWire.java -@@ -58,10 +58,10 @@ +@@ -97,15 +97,15 @@ BlockPos blockpos = p_176341_2_.func_177972_a(p_176341_3_); - Block block = p_176341_1_.func_180495_p(p_176341_2_.func_177972_a(p_176341_3_)).func_177230_c(); + IBlockState iblockstate = p_176341_1_.func_180495_p(p_176341_2_.func_177972_a(p_176341_3_)); -- if (!func_176343_a(p_176341_1_.func_180495_p(blockpos), p_176341_3_) && (block.func_149637_q() || !func_176346_d(p_176341_1_.func_180495_p(blockpos.func_177977_b())))) -+ if (!canRestoneConnect(p_176341_1_, blockpos, p_176341_3_) && (block.func_149637_q() || !canRestoneConnect(p_176341_1_, blockpos.func_177977_b(), null))) +- if (!func_176343_a(p_176341_1_.func_180495_p(blockpos), p_176341_3_) && (iblockstate.func_185915_l() || !func_176346_d(p_176341_1_.func_180495_p(blockpos.func_177977_b())))) ++ if (!canConnectTo(p_176341_1_.func_180495_p(blockpos), p_176341_3_, p_176341_1_, blockpos) && (iblockstate.func_185915_l() || !func_176340_e(p_176341_1_, blockpos.func_177977_b()))) { - Block block1 = p_176341_1_.func_180495_p(p_176341_2_.func_177984_a()).func_177230_c(); -- return !block1.func_149637_q() && block.func_149637_q() && func_176346_d(p_176341_1_.func_180495_p(blockpos.func_177984_a())) ? BlockRedstoneWire.EnumAttachPosition.UP : BlockRedstoneWire.EnumAttachPosition.NONE; -+ return !block1.func_149637_q() && block.func_149637_q() && canRestoneConnect(p_176341_1_, blockpos.func_177984_a(), null) ? BlockRedstoneWire.EnumAttachPosition.UP : BlockRedstoneWire.EnumAttachPosition.NONE; - } - else - { -@@ -359,35 +359,24 @@ - Block block = iblockstate.func_177230_c(); - boolean flag = block.func_149721_r(); - boolean flag1 = p_176339_1_.func_180495_p(p_176339_2_.func_177984_a()).func_177230_c().func_149721_r(); -- return !flag1 && flag && func_176340_e(p_176339_1_, blockpos.func_177984_a()) ? true : (func_176343_a(iblockstate, p_176339_3_) ? true : (block == Blocks.field_150416_aS && iblockstate.func_177229_b(BlockRedstoneDiode.field_176387_N) == p_176339_3_ ? true : !flag && func_176340_e(p_176339_1_, blockpos.func_177977_b()))); -+ return !flag1 && flag && canRestoneConnect(p_176339_1_, blockpos.func_177984_a(), null) ? true : (canRestoneConnect(p_176339_1_, blockpos, p_176339_3_) ? true : (block == Blocks.field_150416_aS && iblockstate.func_177229_b(BlockRedstoneDiode.field_176387_N) == p_176339_3_ ? true : !flag && canRestoneConnect(p_176339_1_, blockpos.func_177977_b(), null))); + IBlockState iblockstate1 = p_176341_1_.func_180495_p(p_176341_2_.func_177984_a()); + + if (!iblockstate1.func_185915_l()) + { +- boolean flag = p_176341_1_.func_180495_p(blockpos).func_185896_q() || p_176341_1_.func_180495_p(blockpos).func_177230_c() == Blocks.field_150426_aN; ++ boolean flag = p_176341_1_.func_180495_p(blockpos).isSideSolid(p_176341_1_, blockpos, EnumFacing.UP) || p_176341_1_.func_180495_p(blockpos).func_177230_c() == Blocks.field_150426_aN; + +- if (flag && func_176346_d(p_176341_1_.func_180495_p(blockpos.func_177984_a()))) ++ if (flag && func_176340_e(p_176341_1_, blockpos.func_177984_a())) + { + if (iblockstate.func_185898_k()) + { +@@ -406,35 +406,30 @@ + IBlockState iblockstate = p_176339_1_.func_180495_p(blockpos); + boolean flag = iblockstate.func_185915_l(); + boolean flag1 = p_176339_1_.func_180495_p(p_176339_2_.func_177984_a()).func_185915_l(); +- return !flag1 && flag && func_176340_e(p_176339_1_, blockpos.func_177984_a()) ? true : (func_176343_a(iblockstate, p_176339_3_) ? true : (iblockstate.func_177230_c() == Blocks.field_150416_aS && iblockstate.func_177229_b(BlockRedstoneDiode.field_185512_D) == p_176339_3_ ? true : !flag && func_176340_e(p_176339_1_, blockpos.func_177977_b()))); ++ return !flag1 && flag && func_176340_e(p_176339_1_, blockpos.func_177984_a()) ? true : (canConnectTo(iblockstate, p_176339_3_, p_176339_1_, p_176339_2_) ? true : (iblockstate.func_177230_c() == Blocks.field_150416_aS && iblockstate.func_177229_b(BlockRedstoneDiode.field_185512_D) == p_176339_3_ ? true : !flag && func_176340_e(p_176339_1_, blockpos.func_177977_b()))); } -- protected static boolean func_176340_e(IBlockAccess p_176340_0_, BlockPos p_176340_1_) -+ protected static boolean canRestoneConnect(IBlockAccess world, BlockPos pos, EnumFacing side) + protected static boolean func_176340_e(IBlockAccess p_176340_0_, BlockPos p_176340_1_) { - return func_176346_d(p_176340_0_.func_180495_p(p_176340_1_)); -- } -- ++ return canConnectTo(p_176340_0_.func_180495_p(p_176340_1_), null, p_176340_0_, p_176340_1_); + } + - protected static boolean func_176346_d(IBlockState p_176346_0_) -- { ++ protected static boolean canConnectTo(IBlockState blockState, EnumFacing side, IBlockAccess world, BlockPos pos) + { - return func_176343_a(p_176346_0_, (EnumFacing)null); - } -- ++ Block block = blockState.func_177230_c(); + - protected static boolean func_176343_a(IBlockState p_176343_0_, EnumFacing p_176343_1_) - { - Block block = p_176343_0_.func_177230_c(); - -- if (block == Blocks.field_150488_af) -+ IBlockState state = world.func_180495_p(pos); -+ if (state.func_177230_c() == Blocks.field_150488_af) + if (block == Blocks.field_150488_af) { return true; } -- else if (Blocks.field_150413_aR.func_149907_e(block)) -+ else if (Blocks.field_150413_aR.func_149907_e(state.func_177230_c())) +- else if (Blocks.field_150413_aR.func_185547_C(p_176343_0_)) ++ else if (Blocks.field_150413_aR.func_185547_C(blockState)) { -- EnumFacing enumfacing = (EnumFacing)p_176343_0_.func_177229_b(BlockRedstoneRepeater.field_176387_N); +- EnumFacing enumfacing = (EnumFacing)p_176343_0_.func_177229_b(BlockRedstoneRepeater.field_185512_D); - return enumfacing == p_176343_1_ || enumfacing.func_176734_d() == p_176343_1_; -+ EnumFacing direction = (EnumFacing)state.func_177229_b(BlockRedstoneRepeater.field_176387_N); -+ return direction == side || direction.func_176734_d() == side; ++ EnumFacing enumfacing = (EnumFacing)blockState.func_177229_b(BlockRedstoneRepeater.field_185512_D); ++ return enumfacing == side || enumfacing.func_176734_d() == side; } else { -- return block.func_149744_f() && p_176343_1_ != null; -+ return state.func_177230_c().canConnectRedstone(world, pos, side); +- return p_176343_0_.func_185897_m() && p_176343_1_ != null; ++ return blockState.func_177230_c().canConnectRedstone(blockState, world, pos, side); } } diff --git a/patches/minecraft/net/minecraft/block/BlockReed.java.patch b/patches/minecraft/net/minecraft/block/BlockReed.java.patch index 95f05667f0..3fccec1b8f 100644 --- a/patches/minecraft/net/minecraft/block/BlockReed.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockReed.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockReed.java +++ ../src-work/minecraft/net/minecraft/block/BlockReed.java -@@ -18,7 +18,7 @@ +@@ -19,7 +19,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -8,20 +8,22 @@ +public class BlockReed extends Block implements net.minecraftforge.common.IPlantable { public static final PropertyInteger field_176355_a = PropertyInteger.func_177719_a("age", 0, 15); + protected static final AxisAlignedBB field_185701_b = new AxisAlignedBB(0.125D, 0.0D, 0.125D, 0.875D, 1.0D, 0.875D); +@@ -69,7 +69,9 @@ -@@ -65,6 +65,7 @@ public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_) { - Block block = p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).func_177230_c(); -+ if (block.canSustainPlant(p_176196_1_, p_176196_2_.func_177977_b(), EnumFacing.UP, this)) return true; +- Block block = p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()).func_177230_c(); ++ IBlockState state = p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()); ++ Block block = state.func_177230_c(); ++ if (block.canSustainPlant(state, p_176196_1_, p_176196_2_.func_177977_b(), EnumFacing.UP, this)) return true; if (block == this) { -@@ -164,4 +165,15 @@ - { - return new BlockState(this, new IProperty[] {field_176355_a}); +@@ -162,6 +164,17 @@ + return ((Integer)p_176201_1_.func_177229_b(field_176355_a)).intValue(); } -+ + + @Override + public net.minecraftforge.common.EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) + { @@ -32,4 +34,7 @@ + { + return this.func_176223_P(); + } - } ++ + protected BlockStateContainer func_180661_e() + { + return new BlockStateContainer(this, new IProperty[] {field_176355_a}); diff --git a/patches/minecraft/net/minecraft/block/BlockRotatedPillar.java.patch b/patches/minecraft/net/minecraft/block/BlockRotatedPillar.java.patch index bd37149277..d4e280aaf8 100644 --- a/patches/minecraft/net/minecraft/block/BlockRotatedPillar.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockRotatedPillar.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/block/BlockRotatedPillar.java +++ ../src-work/minecraft/net/minecraft/block/BlockRotatedPillar.java -@@ -18,4 +18,18 @@ - { +@@ -28,6 +28,21 @@ super(p_i46385_1_, p_i46385_2_); } -+ -+ public boolean rotateBlock(net.minecraft.world.World world, net.minecraft.util.BlockPos pos, EnumFacing axis) + ++ @Override ++ public boolean rotateBlock(net.minecraft.world.World world, BlockPos pos, EnumFacing axis) + { + net.minecraft.block.state.IBlockState state = world.func_180495_p(pos); + for (net.minecraft.block.properties.IProperty prop : state.func_177228_b().keySet()) @@ -18,4 +18,7 @@ + } + return false; + } - } ++ + public IBlockState func_185499_a(IBlockState p_185499_1_, Rotation p_185499_2_) + { + switch (p_185499_2_) diff --git a/patches/minecraft/net/minecraft/block/BlockSapling.java.patch b/patches/minecraft/net/minecraft/block/BlockSapling.java.patch index 1bef67eb0b..752aa85b64 100644 --- a/patches/minecraft/net/minecraft/block/BlockSapling.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockSapling.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockSapling.java +++ ../src-work/minecraft/net/minecraft/block/BlockSapling.java -@@ -71,6 +71,7 @@ +@@ -77,6 +77,7 @@ public void func_176476_e(World p_176476_1_, BlockPos p_176476_2_, IBlockState p_176476_3_, Random p_176476_4_) { diff --git a/patches/minecraft/net/minecraft/block/BlockSkull.java.patch b/patches/minecraft/net/minecraft/block/BlockSkull.java.patch index 3ec9807b9c..a7327502a5 100644 --- a/patches/minecraft/net/minecraft/block/BlockSkull.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockSkull.java.patch @@ -1,7 +1,7 @@ --- ../src-base/minecraft/net/minecraft/block/BlockSkull.java +++ ../src-work/minecraft/net/minecraft/block/BlockSkull.java -@@ -121,10 +121,6 @@ - return tileentity instanceof TileEntitySkull ? ((TileEntitySkull)tileentity).func_145904_a() : super.func_176222_j(p_176222_1_, p_176222_2_); +@@ -116,10 +116,6 @@ + return new ItemStack(Items.field_151144_bL, 1, i); } - public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) @@ -11,7 +11,7 @@ public void func_176208_a(World p_176208_1_, BlockPos p_176208_2_, IBlockState p_176208_3_, EntityPlayer p_176208_4_) { if (p_176208_4_.field_71075_bZ.field_75098_d) -@@ -132,13 +128,18 @@ +@@ -127,22 +123,27 @@ p_176208_3_ = p_176208_3_.func_177226_a(field_176417_b, Boolean.valueOf(true)); p_176208_1_.func_180501_a(p_176208_2_, p_176208_3_, 4); } @@ -25,22 +25,25 @@ - if (!p_180663_1_.field_72995_K) + super.func_180663_b(p_180663_1_, p_180663_2_, p_180663_3_); + } -+ public java.util.List getDrops(IBlockAccess p_180663_1_, BlockPos p_180663_2_, IBlockState p_180663_3_, int fortune) ++ public java.util.List getDrops(IBlockAccess worldIn, BlockPos pos, IBlockState state, int fortune) + { + java.util.List ret = new java.util.ArrayList(); { - if (!((Boolean)p_180663_3_.func_177229_b(field_176417_b)).booleanValue()) +- if (!((Boolean)p_180663_3_.func_177229_b(field_176417_b)).booleanValue()) ++ if (!((Boolean)state.func_177229_b(field_176417_b)).booleanValue()) { -@@ -147,7 +148,7 @@ +- TileEntity tileentity = p_180663_1_.func_175625_s(p_180663_2_); ++ TileEntity tileentity = worldIn.func_175625_s(pos); + if (tileentity instanceof TileEntitySkull) { TileEntitySkull tileentityskull = (TileEntitySkull)tileentity; -- ItemStack itemstack = new ItemStack(Items.field_151144_bL, 1, this.func_176222_j(p_180663_1_, p_180663_2_)); +- ItemStack itemstack = this.func_185473_a(p_180663_1_, p_180663_2_, p_180663_3_); + ItemStack itemstack = new ItemStack(Items.field_151144_bL, 1, tileentityskull.func_145904_a()); if (tileentityskull.func_145904_a() == 3 && tileentityskull.func_152108_a() != null) { -@@ -157,12 +158,11 @@ +@@ -152,12 +153,11 @@ itemstack.func_77978_p().func_74782_a("SkullOwner", nbttagcompound); } diff --git a/patches/minecraft/net/minecraft/block/BlockSlab.java.patch b/patches/minecraft/net/minecraft/block/BlockSlab.java.patch index 56f1865a14..c3f6a8f109 100644 --- a/patches/minecraft/net/minecraft/block/BlockSlab.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockSlab.java.patch @@ -1,38 +1,35 @@ --- ../src-base/minecraft/net/minecraft/block/BlockSlab.java +++ ../src-work/minecraft/net/minecraft/block/BlockSlab.java -@@ -91,6 +91,17 @@ +@@ -50,6 +50,16 @@ return this.func_176552_j(); } + @Override -+ public boolean doesSideBlockRendering(IBlockAccess world, BlockPos pos, EnumFacing face) -+ { -+ if ( func_149662_c() ) ++ public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) ++ { ++ if ( state.func_185914_p() ) + return true; -+ -+ // face is on the block being rendered, not this block. -+ EnumBlockHalf side = world.func_180495_p(pos).func_177229_b(field_176554_a); -+ return (side == EnumBlockHalf.TOP && face == EnumFacing.DOWN) || (side == EnumBlockHalf.BOTTOM && face == EnumFacing.UP); ++ ++ EnumBlockHalf side = state.func_177229_b(field_176554_a); ++ return (side == EnumBlockHalf.TOP && face == EnumFacing.UP) || (side == EnumBlockHalf.BOTTOM && face == EnumFacing.DOWN); + } + public IBlockState func_180642_a(World p_180642_1_, BlockPos p_180642_2_, EnumFacing p_180642_3_, float p_180642_4_, float p_180642_5_, float p_180642_6_, int p_180642_7_, EntityLivingBase p_180642_8_) { IBlockState iblockstate = super.func_180642_a(p_180642_1_, p_180642_2_, p_180642_3_, p_180642_4_, p_180642_5_, p_180642_6_, p_180642_7_, p_180642_8_).func_177226_a(field_176554_a, BlockSlab.EnumBlockHalf.BOTTOM); -@@ -118,15 +129,8 @@ +@@ -77,13 +87,14 @@ { return false; } - else -- { -- BlockPos blockpos = p_176225_2_.func_177972_a(p_176225_3_.func_176734_d()); -- IBlockState iblockstate = p_176225_1_.func_180495_p(p_176225_2_); -- IBlockState iblockstate1 = p_176225_1_.func_180495_p(blockpos); -- boolean flag = func_150003_a(iblockstate.func_177230_c()) && iblockstate.func_177229_b(field_176554_a) == BlockSlab.EnumBlockHalf.TOP; -- boolean flag1 = func_150003_a(iblockstate1.func_177230_c()) && iblockstate1.func_177229_b(field_176554_a) == BlockSlab.EnumBlockHalf.TOP; -- return flag1 ? (p_176225_3_ == EnumFacing.DOWN ? true : (p_176225_3_ == EnumFacing.UP && super.func_176225_a(p_176225_1_, p_176225_2_, p_176225_3_) ? true : !func_150003_a(iblockstate.func_177230_c()) || !flag)) : (p_176225_3_ == EnumFacing.UP ? true : (p_176225_3_ == EnumFacing.DOWN && super.func_176225_a(p_176225_1_, p_176225_2_, p_176225_3_) ? true : !func_150003_a(iblockstate.func_177230_c()) || flag)); -- } -+ // additional logic breaks doesSideBlockRendering and is no longer useful. -+ return super.func_176225_a(p_176225_1_, p_176225_2_, p_176225_3_); ++ else if (false) // Forge: Additional logic breaks doesSideBlockRendering and is no longer useful. + { + IBlockState iblockstate = p_176225_2_.func_180495_p(p_176225_3_.func_177972_a(p_176225_4_)); + boolean flag = func_185675_i(iblockstate) && iblockstate.func_177229_b(field_176554_a) == BlockSlab.EnumBlockHalf.TOP; + boolean flag1 = func_185675_i(p_176225_1_) && p_176225_1_.func_177229_b(field_176554_a) == BlockSlab.EnumBlockHalf.TOP; + return flag1 ? (p_176225_4_ == EnumFacing.DOWN ? true : (p_176225_4_ == EnumFacing.UP && super.func_176225_a(p_176225_1_, p_176225_2_, p_176225_3_, p_176225_4_) ? true : !func_185675_i(iblockstate) || !flag)) : (p_176225_4_ == EnumFacing.UP ? true : (p_176225_4_ == EnumFacing.DOWN && super.func_176225_a(p_176225_1_, p_176225_2_, p_176225_3_, p_176225_4_) ? true : !func_185675_i(iblockstate) || flag)); + } ++ return super.func_176225_a(p_176225_1_, p_176225_2_, p_176225_3_, p_176225_4_); } @SideOnly(Side.CLIENT) diff --git a/patches/minecraft/net/minecraft/block/BlockSnow.java.patch b/patches/minecraft/net/minecraft/block/BlockSnow.java.patch index cc8659d20d..9561436743 100644 --- a/patches/minecraft/net/minecraft/block/BlockSnow.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockSnow.java.patch @@ -1,15 +1,15 @@ --- ../src-base/minecraft/net/minecraft/block/BlockSnow.java +++ ../src-work/minecraft/net/minecraft/block/BlockSnow.java -@@ -79,7 +79,7 @@ +@@ -73,7 +73,7 @@ { IBlockState iblockstate = p_176196_1_.func_180495_p(p_176196_2_.func_177977_b()); Block block = iblockstate.func_177230_c(); -- return block != Blocks.field_150432_aD && block != Blocks.field_150403_cj ? (block.func_149688_o() == Material.field_151584_j ? true : (block == this && ((Integer)iblockstate.func_177229_b(field_176315_a)).intValue() >= 7 ? true : block.func_149662_c() && block.field_149764_J.func_76230_c())) : false; -+ return block != Blocks.field_150432_aD && block != Blocks.field_150403_cj ? (block.isLeaves(p_176196_1_, p_176196_2_.func_177977_b()) ? true : (block == this && ((Integer)iblockstate.func_177229_b(field_176315_a)).intValue() >= 7 ? true : block.func_149662_c() && block.field_149764_J.func_76230_c())) : false; +- return block != Blocks.field_150432_aD && block != Blocks.field_150403_cj ? (iblockstate.func_185904_a() == Material.field_151584_j ? true : (block == this && ((Integer)iblockstate.func_177229_b(field_176315_a)).intValue() >= 7 ? true : iblockstate.func_185914_p() && iblockstate.func_185904_a().func_76230_c())) : false; ++ return block != Blocks.field_150432_aD && block != Blocks.field_150403_cj ? (iblockstate.func_177230_c().isLeaves(iblockstate, p_176196_1_, p_176196_2_.func_177977_b()) ? true : (block == this && ((Integer)iblockstate.func_177229_b(field_176315_a)).intValue() >= 7 ? true : iblockstate.func_185914_p() && iblockstate.func_185904_a().func_76230_c())) : false; } public void func_176204_a(World p_176204_1_, BlockPos p_176204_2_, IBlockState p_176204_3_, Block p_176204_4_) -@@ -91,7 +91,6 @@ +@@ -85,7 +85,6 @@ { if (!this.func_176196_c(p_176314_1_, p_176314_2_)) { @@ -17,18 +17,18 @@ p_176314_1_.func_175698_g(p_176314_2_); return false; } -@@ -103,9 +102,8 @@ +@@ -97,9 +96,8 @@ - public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_) + public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_, ItemStack p_180657_6_) { - func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Items.field_151126_ay, ((Integer)p_180657_4_.func_177229_b(field_176315_a)).intValue() + 1, 0)); -+ super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_); ++ super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_, p_180657_6_); p_180657_1_.func_175698_g(p_180657_3_); -- p_180657_2_.func_71029_a(StatList.field_75934_C[Block.func_149682_b(this)]); +- p_180657_2_.func_71029_a(StatList.func_188055_a(this)); } public Item func_180660_a(IBlockState p_180660_1_, Random p_180660_2_, int p_180660_3_) -@@ -115,14 +113,13 @@ +@@ -109,14 +107,13 @@ public int func_149745_a(Random p_149745_1_) { @@ -44,10 +44,12 @@ p_180650_1_.func_175698_g(p_180650_2_); } } -@@ -152,4 +149,6 @@ - { - return new BlockState(this, new IProperty[] {field_176315_a}); +@@ -150,6 +147,8 @@ + return ((Integer)p_176201_1_.func_177229_b(field_176315_a)).intValue() - 1; } -+ + + @Override public int quantityDropped(IBlockState state, int fortune, Random random){ return ((Integer)state.func_177229_b(field_176315_a)) + 1; } - } ++ + protected BlockStateContainer func_180661_e() + { + return new BlockStateContainer(this, new IProperty[] {field_176315_a}); diff --git a/patches/minecraft/net/minecraft/block/BlockStairs.java.patch b/patches/minecraft/net/minecraft/block/BlockStairs.java.patch index dccaada1d6..239394de81 100644 --- a/patches/minecraft/net/minecraft/block/BlockStairs.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockStairs.java.patch @@ -1,22 +1,20 @@ --- ../src-base/minecraft/net/minecraft/block/BlockStairs.java +++ ../src-work/minecraft/net/minecraft/block/BlockStairs.java -@@ -68,6 +68,19 @@ - return false; +@@ -443,6 +443,17 @@ + return new BlockStateContainer(this, new IProperty[] {field_176309_a, field_176308_b, field_176310_M}); } + @Override -+ public boolean doesSideBlockRendering(IBlockAccess world, BlockPos pos, EnumFacing face) -+ { -+ if ( func_149662_c() ) ++ public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) ++ { ++ if ( state.func_185914_p() ) + return true; -+ -+ // face is on the block being rendered, not this block. -+ IBlockState iblockstate = world.func_180495_p(pos); -+ EnumHalf half = iblockstate.func_177229_b(field_176308_b); -+ EnumFacing side = iblockstate.func_177229_b(field_176309_a); -+ return side == face.func_176734_d() || (half == EnumHalf.TOP && face == EnumFacing.DOWN) || (half == EnumHalf.BOTTOM && face == EnumFacing.UP); ++ ++ EnumHalf half = state.func_177229_b(field_176308_b); ++ EnumFacing side = state.func_177229_b(field_176309_a); ++ return side == face || (half == EnumHalf.TOP && face == EnumFacing.UP) || (half == EnumHalf.BOTTOM && face == EnumFacing.DOWN); + } + - public boolean func_149686_d() + public static enum EnumHalf implements IStringSerializable { - return false; + TOP("top"), diff --git a/patches/minecraft/net/minecraft/block/BlockStaticLiquid.java.patch b/patches/minecraft/net/minecraft/block/BlockStaticLiquid.java.patch new file mode 100644 index 0000000000..f6973261e7 --- /dev/null +++ b/patches/minecraft/net/minecraft/block/BlockStaticLiquid.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/net/minecraft/block/BlockStaticLiquid.java ++++ ../src-work/minecraft/net/minecraft/block/BlockStaticLiquid.java +@@ -52,7 +52,7 @@ + { + blockpos = blockpos.func_177982_a(p_180650_4_.nextInt(3) - 1, 1, p_180650_4_.nextInt(3) - 1); + +- if (blockpos.func_177956_o() >= 0 && blockpos.func_177956_o() < 256 && !p_180650_1_.func_175667_e(blockpos)) ++ if (blockpos.func_177956_o() >= 0 && blockpos.func_177956_o() < p_180650_1_.func_72800_K() && !p_180650_1_.func_175667_e(blockpos)) + { + return; + } diff --git a/patches/minecraft/net/minecraft/block/BlockStem.java.patch b/patches/minecraft/net/minecraft/block/BlockStem.java.patch index 90fd806ba9..2b37ff3d33 100644 --- a/patches/minecraft/net/minecraft/block/BlockStem.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockStem.java.patch @@ -1,15 +1,19 @@ --- ../src-base/minecraft/net/minecraft/block/BlockStem.java +++ ../src-work/minecraft/net/minecraft/block/BlockStem.java -@@ -94,7 +94,7 @@ +@@ -89,9 +89,10 @@ + } + p_180650_2_ = p_180650_2_.func_177972_a(EnumFacing.Plane.HORIZONTAL.func_179518_a(p_180650_4_)); - Block block = p_180650_1_.func_180495_p(p_180650_2_.func_177977_b()).func_177230_c(); +- Block block = p_180650_1_.func_180495_p(p_180650_2_.func_177977_b()).func_177230_c(); ++ IBlockState soil = p_180650_1_.func_180495_p(p_180650_2_.func_177977_b()); ++ Block block = soil.func_177230_c(); - if (p_180650_1_.func_180495_p(p_180650_2_).func_177230_c().field_149764_J == Material.field_151579_a && (block == Blocks.field_150458_ak || block == Blocks.field_150346_d || block == Blocks.field_150349_c)) -+ if (p_180650_1_.func_175623_d(p_180650_2_) && (block.canSustainPlant(p_180650_1_, p_180650_2_.func_177977_b(), EnumFacing.UP, this) || block == Blocks.field_150346_d || block == Blocks.field_150349_c)) ++ if (p_180650_1_.func_175623_d(p_180650_2_) && (block.canSustainPlant(soil, p_180650_1_, p_180650_2_.func_177977_b(), EnumFacing.UP, this) || block == Blocks.field_150346_d || block == Blocks.field_150349_c)) { p_180650_1_.func_175656_a(p_180650_2_, this.field_149877_a.func_176223_P()); } -@@ -148,24 +148,29 @@ +@@ -109,24 +110,29 @@ public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_) { super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, p_180653_5_); diff --git a/patches/minecraft/net/minecraft/block/BlockTallGrass.java.patch b/patches/minecraft/net/minecraft/block/BlockTallGrass.java.patch index e9629da029..2327fb98d7 100644 --- a/patches/minecraft/net/minecraft/block/BlockTallGrass.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockTallGrass.java.patch @@ -8,17 +8,17 @@ +public class BlockTallGrass extends BlockBush implements IGrowable, net.minecraftforge.common.IShearable { public static final PropertyEnum field_176497_a = PropertyEnum.func_177709_a("type", BlockTallGrass.EnumType.class); - -@@ -43,7 +43,7 @@ + protected static final AxisAlignedBB field_185522_c = new AxisAlignedBB(0.09999999403953552D, 0.0D, 0.09999999403953552D, 0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D); +@@ -41,7 +41,7 @@ public boolean func_180671_f(World p_180671_1_, BlockPos p_180671_2_, IBlockState p_180671_3_) { -- return this.func_149854_a(p_180671_1_.func_180495_p(p_180671_2_.func_177977_b()).func_177230_c()); +- return this.func_185514_i(p_180671_1_.func_180495_p(p_180671_2_.func_177977_b())); + return super.func_180671_f(p_180671_1_, p_180671_2_, p_180671_3_); } - public boolean func_176200_f(World p_176200_1_, BlockPos p_176200_2_) -@@ -53,7 +53,7 @@ + public boolean func_176200_f(IBlockAccess p_176200_1_, BlockPos p_176200_2_) +@@ -51,7 +51,7 @@ public Item func_180660_a(IBlockState p_180660_1_, Random p_180660_2_, int p_180660_3_) { @@ -27,21 +27,16 @@ } public int func_149679_a(int p_149679_1_, Random p_149679_2_) -@@ -63,13 +63,7 @@ +@@ -61,7 +61,7 @@ - public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_) + public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_, ItemStack p_180657_6_) { -- if (!p_180657_1_.field_72995_K && p_180657_2_.func_71045_bC() != null && p_180657_2_.func_71045_bC().func_77973_b() == Items.field_151097_aZ) +- if (!p_180657_1_.field_72995_K && p_180657_6_ != null && p_180657_6_.func_77973_b() == Items.field_151097_aZ) ++ if (false && !p_180657_1_.field_72995_K && p_180657_6_ != null && p_180657_6_.func_77973_b() == Items.field_151097_aZ) // Forge: Noop Taken care of by IShearable { -- p_180657_2_.func_71029_a(StatList.field_75934_C[Block.func_149682_b(this)]); -- func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Blocks.field_150329_H, 1, ((BlockTallGrass.EnumType)p_180657_4_.func_177229_b(field_176497_a)).func_177044_a())); -- } -- else -- { - super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_); - } - } -@@ -204,4 +198,22 @@ + p_180657_2_.func_71029_a(StatList.func_188055_a(this)); + func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Blocks.field_150329_H, 1, ((BlockTallGrass.EnumType)p_180657_4_.func_177229_b(field_176497_a)).func_177044_a())); +@@ -181,4 +181,22 @@ } } } @@ -59,7 +54,7 @@ + { + List ret = new java.util.ArrayList(); + if (RANDOM.nextInt(8) != 0) return ret; -+ ItemStack seed = net.minecraftforge.common.ForgeHooks.getGrassSeed(RANDOM); ++ ItemStack seed = net.minecraftforge.common.ForgeHooks.getGrassSeed(RANDOM, fortune); + if (seed != null) ret.add(seed); + return ret; + } diff --git a/patches/minecraft/net/minecraft/block/BlockTorch.java.patch b/patches/minecraft/net/minecraft/block/BlockTorch.java.patch index ec723e30dc..2b6f02aa29 100644 --- a/patches/minecraft/net/minecraft/block/BlockTorch.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockTorch.java.patch @@ -1,15 +1,24 @@ --- ../src-base/minecraft/net/minecraft/block/BlockTorch.java +++ ../src-work/minecraft/net/minecraft/block/BlockTorch.java -@@ -63,7 +63,7 @@ +@@ -79,14 +79,14 @@ + + private boolean func_176594_d(World p_176594_1_, BlockPos p_176594_2_) + { +- if (p_176594_1_.func_180495_p(p_176594_2_).func_185896_q()) ++ IBlockState state = p_176594_1_.func_180495_p(p_176594_2_); ++ if (state.isSideSolid(p_176594_1_, p_176594_2_, EnumFacing.UP)) + { + return true; + } else { - Block block = p_176594_1_.func_180495_p(p_176594_2_).func_177230_c(); +- Block block = p_176594_1_.func_180495_p(p_176594_2_).func_177230_c(); - return block instanceof BlockFence || block == Blocks.field_150359_w || block == Blocks.field_150463_bK || block == Blocks.field_150399_cn; -+ return block.canPlaceTorchOnTop(p_176594_1_, p_176594_2_); ++ return state.func_177230_c().canPlaceTorchOnTop(state, p_176594_1_, p_176594_2_); } } -@@ -84,7 +84,7 @@ +@@ -107,7 +107,7 @@ { BlockPos blockpos = p_176595_2_.func_177972_a(p_176595_3_.func_176734_d()); boolean flag = p_176595_3_.func_176740_k().func_176722_c(); @@ -18,7 +27,7 @@ } public IBlockState func_180642_a(World p_180642_1_, BlockPos p_180642_2_, EnumFacing p_180642_3_, float p_180642_4_, float p_180642_5_, float p_180642_6_, int p_180642_7_, EntityLivingBase p_180642_8_) -@@ -97,7 +97,7 @@ +@@ -120,7 +120,7 @@ { for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { @@ -27,7 +36,7 @@ { return this.func_176223_P().func_177226_a(field_176596_a, enumfacing); } -@@ -130,7 +130,7 @@ +@@ -153,7 +153,7 @@ EnumFacing enumfacing1 = enumfacing.func_176734_d(); boolean flag = false; diff --git a/patches/minecraft/net/minecraft/block/BlockTrapDoor.java.patch b/patches/minecraft/net/minecraft/block/BlockTrapDoor.java.patch index 0eb19ae31f..92f9775918 100644 --- a/patches/minecraft/net/minecraft/block/BlockTrapDoor.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockTrapDoor.java.patch @@ -1,43 +1,21 @@ --- ../src-base/minecraft/net/minecraft/block/BlockTrapDoor.java +++ ../src-work/minecraft/net/minecraft/block/BlockTrapDoor.java -@@ -25,6 +25,8 @@ - - public class BlockTrapDoor extends Block - { -+ /** Set this to allow trapdoors to remain free-floating */ -+ public static boolean disableValidation = false; - public static final PropertyDirection field_176284_a = PropertyDirection.func_177712_a("facing", EnumFacing.Plane.HORIZONTAL); - public static final PropertyBool field_176283_b = PropertyBool.func_177716_a("open"); - public static final PropertyEnum field_176285_M = PropertyEnum.func_177709_a("half", BlockTrapDoor.DoorHalf.class); -@@ -140,9 +142,10 @@ - { - if (!p_176204_1_.field_72995_K) - { -+ EnumFacing direction = (EnumFacing)p_176204_3_.func_177229_b(field_176284_a); - BlockPos blockpos = p_176204_2_.func_177972_a(((EnumFacing)p_176204_3_.func_177229_b(field_176284_a)).func_176734_d()); - -- if (!func_150119_a(p_176204_1_.func_180495_p(blockpos).func_177230_c())) -+ if (!(func_150119_a(p_176204_1_.func_180495_p(blockpos).func_177230_c()) || p_176204_1_.isSideSolid(blockpos, direction, true))) - { - p_176204_1_.func_175698_g(p_176204_2_); - this.func_176226_b(p_176204_1_, p_176204_2_, p_176204_3_, 0); -@@ -186,7 +189,10 @@ - - public boolean func_176198_a(World p_176198_1_, BlockPos p_176198_2_, EnumFacing p_176198_3_) - { -- return !p_176198_3_.func_176740_k().func_176720_b() && func_150119_a(p_176198_1_.func_180495_p(p_176198_2_.func_177972_a(p_176198_3_.func_176734_d())).func_177230_c()); -+ if (disableValidation) return true; -+ EnumFacing dir = p_176198_3_.func_176734_d(); -+ p_176198_2_ = p_176198_2_.func_177972_a(dir); -+ return !p_176198_3_.func_176740_k().func_176720_b() && (func_150119_a(p_176198_1_.func_180495_p(p_176198_2_).func_177230_c()) || p_176198_1_.isSideSolid(p_176198_2_, p_176198_3_, true)); +@@ -241,6 +241,18 @@ + return new BlockStateContainer(this, new IProperty[] {field_176284_a, field_176283_b, field_176285_M}); } - protected static EnumFacing func_176281_b(int p_176281_0_) -@@ -223,6 +229,7 @@ - - private static boolean func_150119_a(Block p_150119_0_) ++ @Override ++ public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity) ++ { ++ if (state.func_177229_b(field_176283_b)) ++ { ++ IBlockState down = world.func_180495_p(pos.func_177977_b()); ++ if (down.func_177230_c() == net.minecraft.init.Blocks.field_150468_ap) ++ return down.func_177229_b(BlockLadder.field_176382_a) == state.func_177229_b(field_176284_a); ++ } ++ return false; ++ } ++ + public static enum DoorHalf implements IStringSerializable { -+ if (disableValidation) return true; - return p_150119_0_.field_149764_J.func_76218_k() && p_150119_0_.func_149686_d() || p_150119_0_ == Blocks.field_150426_aN || p_150119_0_ instanceof BlockSlab || p_150119_0_ instanceof BlockStairs; - } - + TOP("top"), diff --git a/patches/minecraft/net/minecraft/block/BlockTripWireHook.java.patch b/patches/minecraft/net/minecraft/block/BlockTripWireHook.java.patch index 6a6ba2054f..6850b831b4 100644 --- a/patches/minecraft/net/minecraft/block/BlockTripWireHook.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockTripWireHook.java.patch @@ -1,28 +1,28 @@ --- ../src-base/minecraft/net/minecraft/block/BlockTripWireHook.java +++ ../src-work/minecraft/net/minecraft/block/BlockTripWireHook.java -@@ -58,14 +58,14 @@ +@@ -77,14 +77,14 @@ public boolean func_176198_a(World p_176198_1_, BlockPos p_176198_2_, EnumFacing p_176198_3_) { -- return p_176198_3_.func_176740_k().func_176722_c() && p_176198_1_.func_180495_p(p_176198_2_.func_177972_a(p_176198_3_.func_176734_d())).func_177230_c().func_149721_r(); -+ return p_176198_3_.func_176740_k().func_176722_c() && p_176198_1_.isSideSolid(p_176198_2_.func_177972_a(p_176198_3_.func_176734_d()), p_176198_3_, true); +- return p_176198_3_.func_176740_k().func_176722_c() && p_176198_1_.func_180495_p(p_176198_2_.func_177972_a(p_176198_3_.func_176734_d())).func_185915_l(); ++ return p_176198_3_.func_176740_k().func_176722_c() && p_176198_1_.func_180495_p(p_176198_2_.func_177972_a(p_176198_3_.func_176734_d())).isSideSolid(p_176198_1_, p_176198_2_.func_177972_a(p_176198_3_.func_176734_d()), p_176198_3_); } public boolean func_176196_c(World p_176196_1_, BlockPos p_176196_2_) { for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { -- if (p_176196_1_.func_180495_p(p_176196_2_.func_177972_a(enumfacing)).func_177230_c().func_149721_r()) -+ if (p_176196_1_.isSideSolid(p_176196_2_.func_177972_a(enumfacing), enumfacing.func_176734_d(), true)) +- if (p_176196_1_.func_180495_p(p_176196_2_.func_177972_a(enumfacing)).func_185915_l()) ++ if (p_176196_1_.func_180495_p(p_176196_2_.func_177972_a(enumfacing)).isSideSolid(p_176196_1_, p_176196_2_.func_177972_a(enumfacing), enumfacing.func_176734_d())) { return true; } -@@ -99,7 +99,7 @@ +@@ -118,7 +118,7 @@ { EnumFacing enumfacing = (EnumFacing)p_176204_3_.func_177229_b(field_176264_a); -- if (!p_176204_1_.func_180495_p(p_176204_2_.func_177972_a(enumfacing.func_176734_d())).func_177230_c().func_149721_r()) -+ if (!p_176204_1_.isSideSolid(p_176204_2_.func_177972_a(enumfacing.func_176734_d()), enumfacing, true)) +- if (!p_176204_1_.func_180495_p(p_176204_2_.func_177972_a(enumfacing.func_176734_d())).func_185915_l()) ++ if (!p_176204_1_.func_180495_p(p_176204_2_.func_177972_a(enumfacing.func_176734_d())).isSideSolid(p_176204_1_, p_176204_2_.func_177972_a(enumfacing.func_176734_d()), enumfacing)) { this.func_176226_b(p_176204_1_, p_176204_2_, p_176204_3_, 0); p_176204_1_.func_175698_g(p_176204_2_); diff --git a/patches/minecraft/net/minecraft/block/BlockVine.java.patch b/patches/minecraft/net/minecraft/block/BlockVine.java.patch index e64d0dd18a..f4f42e06c9 100644 --- a/patches/minecraft/net/minecraft/block/BlockVine.java.patch +++ b/patches/minecraft/net/minecraft/block/BlockVine.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/block/BlockVine.java +++ ../src-work/minecraft/net/minecraft/block/BlockVine.java -@@ -25,7 +25,7 @@ +@@ -26,7 +26,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -9,26 +9,21 @@ { public static final PropertyBool field_176277_a = PropertyBool.func_177716_a("up"); public static final PropertyBool field_176273_b = PropertyBool.func_177716_a("north"); -@@ -387,13 +387,7 @@ +@@ -342,7 +342,7 @@ - public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_) + public void func_180657_a(World p_180657_1_, EntityPlayer p_180657_2_, BlockPos p_180657_3_, IBlockState p_180657_4_, TileEntity p_180657_5_, ItemStack p_180657_6_) { -- if (!p_180657_1_.field_72995_K && p_180657_2_.func_71045_bC() != null && p_180657_2_.func_71045_bC().func_77973_b() == Items.field_151097_aZ) +- if (!p_180657_1_.field_72995_K && p_180657_6_ != null && p_180657_6_.func_77973_b() == Items.field_151097_aZ) ++ if (false && !p_180657_1_.field_72995_K && p_180657_6_ != null && p_180657_6_.func_77973_b() == Items.field_151097_aZ) // Forge: Noop, Covered by IShearable { -- p_180657_2_.func_71029_a(StatList.field_75934_C[Block.func_149682_b(this)]); -- func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Blocks.field_150395_bd, 1, 0)); -- } -- else -- { - super.func_180657_a(p_180657_1_, p_180657_2_, p_180657_3_, p_180657_4_, p_180657_5_); - } - } -@@ -474,4 +468,14 @@ + p_180657_2_.func_71029_a(StatList.func_188055_a(this)); + func_180635_a(p_180657_1_, p_180657_3_, new ItemStack(Blocks.field_150395_bd, 1, 0)); +@@ -457,4 +457,14 @@ return i; } + /*************************FORGE START***********************************/ -+ @Override public boolean isLadder(IBlockAccess world, BlockPos pos, EntityLivingBase entity){ return true; } ++ @Override public boolean isLadder(IBlockState state, IBlockAccess world, BlockPos pos, EntityLivingBase entity){ return true; } + @Override public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos){ return true; } + @Override + public java.util.List onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) diff --git a/patches/minecraft/net/minecraft/block/state/BlockPistonStructureHelper.java.patch b/patches/minecraft/net/minecraft/block/state/BlockPistonStructureHelper.java.patch index 9b66c108cb..7d8c103108 100644 --- a/patches/minecraft/net/minecraft/block/state/BlockPistonStructureHelper.java.patch +++ b/patches/minecraft/net/minecraft/block/state/BlockPistonStructureHelper.java.patch @@ -1,29 +1,29 @@ --- ../src-base/minecraft/net/minecraft/block/state/BlockPistonStructureHelper.java +++ ../src-work/minecraft/net/minecraft/block/state/BlockPistonStructureHelper.java -@@ -78,7 +78,7 @@ - { - Block block = this.field_177261_a.func_180495_p(p_177251_1_).func_177230_c(); +@@ -80,7 +80,7 @@ + IBlockState iblockstate = this.field_177261_a.func_180495_p(p_177251_1_); + Block block = iblockstate.func_177230_c(); -- if (block.func_149688_o() == Material.field_151579_a) -+ if (block.isAir(field_177261_a, p_177251_1_)) +- if (iblockstate.func_185904_a() == Material.field_151579_a) ++ if (iblockstate.func_177230_c().isAir(iblockstate, this.field_177261_a, p_177251_1_)) { return true; } -@@ -109,7 +109,7 @@ - BlockPos blockpos = p_177251_1_.func_177967_a(this.field_177257_d.func_176734_d(), i); - block = this.field_177261_a.func_180495_p(blockpos).func_177230_c(); +@@ -112,7 +112,7 @@ + iblockstate = this.field_177261_a.func_180495_p(blockpos); + block = iblockstate.func_177230_c(); -- if (block.func_149688_o() == Material.field_151579_a || !BlockPistonBase.func_180696_a(block, this.field_177261_a, blockpos, this.field_177257_d, false) || blockpos.equals(this.field_177259_b)) -+ if (block.isAir(field_177261_a, blockpos)|| !BlockPistonBase.func_180696_a(block, this.field_177261_a, blockpos, this.field_177257_d, false) || blockpos.equals(this.field_177259_b)) +- if (iblockstate.func_185904_a() == Material.field_151579_a || !BlockPistonBase.func_185646_a(iblockstate, this.field_177261_a, blockpos, this.field_177257_d, false) || blockpos.equals(this.field_177259_b)) ++ if (iblockstate.func_177230_c().isAir(iblockstate, this.field_177261_a, blockpos) || !BlockPistonBase.func_185646_a(iblockstate, this.field_177261_a, blockpos, this.field_177257_d, false) || blockpos.equals(this.field_177259_b)) { break; } -@@ -156,7 +156,7 @@ +@@ -159,7 +159,7 @@ - block = this.field_177261_a.func_180495_p(blockpos1).func_177230_c(); + iblockstate = this.field_177261_a.func_180495_p(blockpos1); -- if (block.func_149688_o() == Material.field_151579_a) -+ if (block.isAir(field_177261_a, blockpos1)) +- if (iblockstate.func_185904_a() == Material.field_151579_a) ++ if (iblockstate.func_177230_c().isAir(iblockstate, this.field_177261_a, blockpos1)) { return true; } diff --git a/patches/minecraft/net/minecraft/block/state/BlockState.java.patch b/patches/minecraft/net/minecraft/block/state/BlockState.java.patch deleted file mode 100644 index 8d775ed119..0000000000 --- a/patches/minecraft/net/minecraft/block/state/BlockState.java.patch +++ /dev/null @@ -1,53 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/block/state/BlockState.java -+++ ../src-work/minecraft/net/minecraft/block/state/BlockState.java -@@ -38,6 +38,16 @@ - - public BlockState(Block p_i45663_1_, IProperty... p_i45663_2_) - { -+ this(p_i45663_1_, p_i45663_2_, null); -+ } -+ -+ protected StateImplementation createState(Block block, ImmutableMap properties, ImmutableMap, com.google.common.base.Optional> unlistedProperties) -+ { -+ return new StateImplementation(block, properties); -+ } -+ -+ protected BlockState(Block p_i45663_1_, IProperty[] p_i45663_2_, ImmutableMap, com.google.common.base.Optional> unlistedProperties) -+ { - this.field_177627_c = p_i45663_1_; - Arrays.sort(p_i45663_2_, new Comparator() - { -@@ -53,7 +63,7 @@ - for (List list1 : Cartesian.func_179321_a(this.func_177620_e())) - { - Map map1 = MapPopulator.func_179400_b(this.field_177624_d, list1); -- BlockState.StateImplementation blockstate$stateimplementation = new BlockState.StateImplementation(p_i45663_1_, ImmutableMap.copyOf(map1)); -+ BlockState.StateImplementation blockstate$stateimplementation = createState(p_i45663_1_, ImmutableMap.copyOf(map1), unlistedProperties); - map.put(map1, blockstate$stateimplementation); - list.add(blockstate$stateimplementation); - } -@@ -132,6 +142,13 @@ - } - } - -+ protected StateImplementation(Block blockIn, ImmutableMap propertiesIn, ImmutableTable propertyValueTable) -+ { -+ this.field_177239_a = blockIn; -+ this.field_177237_b = propertiesIn; -+ this.field_177238_c = propertyValueTable; -+ } -+ - public , V extends T> IBlockState func_177226_a(IProperty p_177226_1_, V p_177226_2_) - { - if (!this.field_177237_b.containsKey(p_177226_1_)) -@@ -199,5 +216,10 @@ - map.put(p_177236_1_, p_177236_2_); - return map; - } -+ -+ public ImmutableTable getPropertyValueTable() -+ { -+ return field_177238_c; -+ } - } - } diff --git a/patches/minecraft/net/minecraft/block/state/BlockStateBase.java.patch b/patches/minecraft/net/minecraft/block/state/BlockStateBase.java.patch index a8c5028636..e6d4fff7f3 100644 --- a/patches/minecraft/net/minecraft/block/state/BlockStateBase.java.patch +++ b/patches/minecraft/net/minecraft/block/state/BlockStateBase.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/block/state/BlockStateBase.java +++ ../src-work/minecraft/net/minecraft/block/state/BlockStateBase.java -@@ -67,4 +67,9 @@ +@@ -71,4 +71,9 @@ return stringbuilder.toString(); } -+ -+ public com.google.common.collect.ImmutableTable getPropertyValueTable() ++ ++ public com.google.common.collect.ImmutableTable, Comparable, IBlockState> getPropertyValueTable() + { + return null; + } diff --git a/patches/minecraft/net/minecraft/block/state/BlockStateContainer.java.patch b/patches/minecraft/net/minecraft/block/state/BlockStateContainer.java.patch new file mode 100644 index 0000000000..fa321efa14 --- /dev/null +++ b/patches/minecraft/net/minecraft/block/state/BlockStateContainer.java.patch @@ -0,0 +1,138 @@ +--- ../src-base/minecraft/net/minecraft/block/state/BlockStateContainer.java ++++ ../src-work/minecraft/net/minecraft/block/state/BlockStateContainer.java +@@ -55,12 +55,22 @@ + + public BlockStateContainer(Block p_i45663_1_, IProperty... p_i45663_2_) + { +- this.field_177627_c = p_i45663_1_; ++ this(p_i45663_1_, p_i45663_2_, null); ++ } ++ ++ protected StateImplementation createState(Block block, ImmutableMap, Comparable> properties, ImmutableMap, com.google.common.base.Optional> unlistedProperties) ++ { ++ return new StateImplementation(block, properties); ++ } ++ ++ protected BlockStateContainer(Block blockIn, IProperty[] properties, ImmutableMap, com.google.common.base.Optional> unlistedProperties) ++ { ++ this.field_177627_c = blockIn; + Map < String, IProperty> map = Maps. < String, IProperty> newHashMap(); + +- for (IProperty iproperty : p_i45663_2_) ++ for (IProperty iproperty : properties) + { +- func_185919_a(p_i45663_1_, iproperty); ++ func_185919_a(blockIn, iproperty); + map.put(iproperty.func_177701_a(), iproperty); + } + +@@ -71,7 +81,7 @@ + for (List < Comparable> list : Cartesian.func_179321_a(this.func_177620_e())) + { + Map < IProperty, Comparable> map1 = MapPopulator. < IProperty, Comparable> func_179400_b(this.field_177624_d.values(), list); +- BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation = new BlockStateContainer.StateImplementation(p_i45663_1_, ImmutableMap.copyOf(map1)); ++ BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation = createState(blockIn, ImmutableMap.copyOf(map1), unlistedProperties); + map2.put(map1, blockstatecontainer$stateimplementation); + list1.add(blockstatecontainer$stateimplementation); + } +@@ -163,6 +173,13 @@ + this.field_177237_b = p_i45660_2_; + } + ++ protected StateImplementation(Block blockIn, ImmutableMap, Comparable> propertiesIn, ImmutableTable, Comparable, IBlockState> propertyValueTable) ++ { ++ this.field_177239_a = blockIn; ++ this.field_177237_b = propertiesIn; ++ this.field_177238_c = propertyValueTable; ++ } ++ + public Collection < IProperty> func_177227_a() + { + return Collections. < IProperty> unmodifiableCollection(this.field_177237_b.keySet()); +@@ -414,5 +431,86 @@ + { + return this.field_177239_a.func_185481_k(this); + } ++ ++ //Forge Start ++ public ImmutableTable, Comparable, IBlockState> getPropertyValueTable() ++ { ++ return field_177238_c; ++ } ++ ++ @Override ++ public int getLightOpacity(IBlockAccess world, BlockPos pos) ++ { ++ return this.field_177239_a.getLightOpacity(this, world, pos); ++ } ++ ++ @Override ++ public int getLightValue(IBlockAccess world, BlockPos pos) ++ { ++ return this.field_177239_a.getLightValue(this, world, pos); ++ } ++ ++ public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side) ++ { ++ return this.field_177239_a.isSideSolid(this, world, pos, side); ++ } ++ ++ @Override ++ public boolean doesSideBlockRendering(IBlockAccess world, BlockPos pos, EnumFacing side) ++ { ++ return this.field_177239_a.doesSideBlockRendering(this, world, pos, side); ++ } + } ++ ++ /** ++ * Forge added class to make building things easier. ++ * Will return an instance of BlockStateContainer appropriate for ++ * the list of properties passed in. ++ * ++ * Example usage: ++ * ++ * protected BlockStateContainer createBlockState() ++ * { ++ * return (new BlockStateContainer.Builder(this)).add(FACING).add(SOME_UNLISTED).build(); ++ * } ++ * ++ */ ++ public static class Builder ++ { ++ private final Block block; ++ private final List> listed = Lists.newArrayList(); ++ private final List> unlisted = Lists.newArrayList(); ++ ++ public Builder(Block block) ++ { ++ this.block = block; ++ } ++ ++ public Builder add(IProperty... props) ++ { ++ for (IProperty prop : props) ++ this.listed.add(prop); ++ return this; ++ } ++ ++ public Builder add(net.minecraftforge.common.property.IUnlistedProperty... props) ++ { ++ for (net.minecraftforge.common.property.IUnlistedProperty prop : props) ++ this.unlisted.add(prop); ++ return this; ++ } ++ ++ public BlockStateContainer build() ++ { ++ IProperty[] listed = new IProperty[this.listed.size()]; ++ listed = this.listed.toArray(listed); ++ if (this.unlisted.size() == 0) ++ return new BlockStateContainer(this.block, listed); ++ ++ net.minecraftforge.common.property.IUnlistedProperty[] unlisted = new net.minecraftforge.common.property.IUnlistedProperty[this.unlisted.size()]; ++ unlisted = this.unlisted.toArray(unlisted); ++ ++ return new net.minecraftforge.common.property.ExtendedBlockState(this.block, listed, unlisted); ++ } ++ } + } diff --git a/patches/minecraft/net/minecraft/block/state/IBlockProperties.java.patch b/patches/minecraft/net/minecraft/block/state/IBlockProperties.java.patch new file mode 100644 index 0000000000..e90318ea8f --- /dev/null +++ b/patches/minecraft/net/minecraft/block/state/IBlockProperties.java.patch @@ -0,0 +1,27 @@ +--- ../src-base/minecraft/net/minecraft/block/state/IBlockProperties.java ++++ ../src-work/minecraft/net/minecraft/block/state/IBlockProperties.java +@@ -25,9 +25,13 @@ + + boolean func_185913_b(); + ++ @Deprecated //Forge location aware version below + int func_185891_c(); ++ int getLightOpacity(IBlockAccess world, BlockPos pos); + ++ @Deprecated //Forge location aware version below + int func_185906_d(); ++ int getLightValue(IBlockAccess world, BlockPos pos); + + @SideOnly(Side.CLIENT) + boolean func_185895_e(); +@@ -88,5 +92,10 @@ + + RayTraceResult func_185910_a(World p_185910_1_, BlockPos p_185910_2_, Vec3d p_185910_3_, Vec3d p_185910_4_); + ++ @Deprecated // Forge: Use isSideSolid(IBlockAccess, BlockPos, EnumFacing.UP) instead + boolean func_185896_q(); ++ ++ //Forge added functions ++ boolean doesSideBlockRendering(IBlockAccess world, BlockPos pos, EnumFacing side); ++ boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side); + } diff --git a/patches/minecraft/net/minecraft/client/LoadingScreenRenderer.java.patch b/patches/minecraft/net/minecraft/client/LoadingScreenRenderer.java.patch index 2d8b6e47e0..176c164749 100644 --- a/patches/minecraft/net/minecraft/client/LoadingScreenRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/LoadingScreenRenderer.java.patch @@ -9,10 +9,10 @@ + if (!net.minecraftforge.fml.client.FMLClientHandler.instance().handleLoadingScreen(scaledresolution)) //FML Don't render while FML's pre-screen is rendering + { Tessellator tessellator = Tessellator.func_178181_a(); - WorldRenderer worldrenderer = tessellator.func_178180_c(); + VertexBuffer vertexbuffer = tessellator.func_178180_c(); this.field_73725_b.func_110434_K().func_110577_a(Gui.field_110325_k); @@ -174,6 +178,12 @@ - GlStateManager.func_179120_a(770, 771, 1, 0); + GlStateManager.func_187428_a(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); this.field_73725_b.field_71466_p.func_175063_a(this.field_73726_c, (float)((k - this.field_73725_b.field_71466_p.func_78256_a(this.field_73726_c)) / 2), (float)(l / 2 - 4 - 16), 16777215); this.field_73725_b.field_71466_p.func_175063_a(this.field_73727_a, (float)((k - this.field_73725_b.field_71466_p.func_78256_a(this.field_73727_a)) / 2), (float)(l / 2 - 4 + 8), 16777215); + } diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 30d858ec0a..3d7c29f989 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -1,14 +1,14 @@ --- ../src-base/minecraft/net/minecraft/client/Minecraft.java +++ ../src-work/minecraft/net/minecraft/client/Minecraft.java -@@ -301,7 +301,6 @@ - this.field_152355_az = (new YggdrasilAuthenticationService(p_i45547_1_.field_178745_a.field_178751_c, UUID.randomUUID().toString())).createMinecraftSessionService(); +@@ -318,7 +318,6 @@ + this.field_152355_az = (new YggdrasilAuthenticationService(this.field_110453_aa, UUID.randomUUID().toString())).createMinecraftSessionService(); this.field_71449_j = p_i45547_1_.field_178745_a.field_178752_a; field_147123_G.info("Setting user: " + this.field_71449_j.func_111285_a()); - field_147123_G.info("(Session ID is " + this.field_71449_j.func_111286_b() + ")"); this.field_71459_aj = p_i45547_1_.field_178741_d.field_178756_a; this.field_71443_c = p_i45547_1_.field_178743_b.field_178764_a > 0 ? p_i45547_1_.field_178743_b.field_178764_a : 1; this.field_71440_d = p_i45547_1_.field_178743_b.field_178762_b > 0 ? p_i45547_1_.field_178743_b.field_178762_b : 1; -@@ -415,10 +414,10 @@ +@@ -432,10 +431,10 @@ this.field_110451_am = new SimpleReloadableResourceManager(this.field_110452_an); this.field_135017_as = new LanguageManager(this.field_110452_an, this.field_71474_y.field_74363_ab); this.field_110451_am.func_110542_a(this.field_135017_as); @@ -18,10 +18,19 @@ this.field_110451_am.func_110542_a(this.field_71446_o); - this.func_180510_a(this.field_71446_o); + net.minecraftforge.fml.client.SplashProgress.drawVanillaScreen(this.field_71446_o); - this.func_175595_al(); this.field_152350_aA = new SkinManager(this.field_71446_o, new File(this.field_110446_Y, "skins"), this.field_152355_az); - this.field_71469_aa = new AnvilSaveConverter(new File(this.field_71412_D, "saves")); -@@ -453,6 +452,8 @@ + this.field_71469_aa = new AnvilSaveConverter(new File(this.field_71412_D, "saves"), this.field_184131_U); + this.field_147127_av = new SoundHandler(this.field_110451_am, this.field_71474_y); +@@ -460,7 +459,7 @@ + { + try + { +- return String.format(p_74535_1_, new Object[] {GameSettings.func_74298_c(Minecraft.this.field_71474_y.field_151445_Q.func_151463_i())}); ++ return String.format(p_74535_1_, new Object[] {Minecraft.this.field_71474_y.field_151445_Q.getDisplayName()}); + } + catch (Exception exception) + { +@@ -469,6 +468,8 @@ } }); this.field_71417_B = new MouseHelper(); @@ -30,13 +39,13 @@ this.func_71361_d("Pre startup"); GlStateManager.func_179098_w(); GlStateManager.func_179103_j(7425); -@@ -466,17 +467,21 @@ +@@ -482,19 +483,23 @@ GlStateManager.func_179096_D(); GlStateManager.func_179128_n(5888); this.func_71361_d("Startup"); - this.field_147128_au = new TextureMap("textures"); + bar.step("Loading Texture Map"); -+ this.field_147128_au = new TextureMap("textures",true); ++ this.field_147128_au = new TextureMap("textures", true); this.field_147128_au.func_147633_a(this.field_71474_y.field_151442_I); this.field_71446_o.func_110580_a(TextureMap.field_110575_b, this.field_147128_au); this.field_71446_o.func_110577_a(TextureMap.field_110575_b); @@ -44,16 +53,18 @@ + bar.step("Loading Model Manager"); this.field_175617_aL = new ModelManager(this.field_147128_au); this.field_110451_am.func_110542_a(this.field_175617_aL); + this.field_184127_aH = BlockColors.func_186723_a(); + this.field_184128_aI = ItemColors.func_186729_a(this.field_184127_aH); + bar.step("Loading Item Renderer"); - this.field_175621_X = new RenderItem(this.field_71446_o, this.field_175617_aL); + this.field_175621_X = new RenderItem(this.field_71446_o, this.field_175617_aL, this.field_184128_aI); this.field_175616_W = new RenderManager(this.field_71446_o, this.field_175621_X); this.field_175620_Y = new ItemRenderer(this); this.field_110451_am.func_110542_a(this.field_175621_X); + bar.step("Loading Entity Renderer"); this.field_71460_t = new EntityRenderer(this, this.field_110451_am); this.field_110451_am.func_110542_a(this.field_71460_t); - this.field_175618_aM = new BlockRendererDispatcher(this.field_175617_aL.func_174954_c(), this.field_71474_y); -@@ -486,22 +491,25 @@ + this.field_175618_aM = new BlockRendererDispatcher(this.field_175617_aL.func_174954_c(), this.field_184127_aH); +@@ -504,23 +509,26 @@ this.field_71458_u = new GuiAchievement(this); GlStateManager.func_179083_b(0, 0, this.field_71443_c, this.field_71440_d); this.field_71452_i = new EffectRenderer(this.field_71441_e, this.field_71446_o); @@ -77,12 +88,13 @@ + net.minecraftforge.fml.client.SplashProgress.clearVanillaResources(field_71446_o, field_152354_ay); this.field_152354_ay = null; this.field_71461_s = new LoadingScreenRenderer(this); + this.field_184132_p = new DebugRenderer(this); + net.minecraftforge.fml.client.FMLClientHandler.instance().onInitializationComplete(); if (this.field_71474_y.field_74353_u && !this.field_71431_Q) { this.func_71352_k(); -@@ -681,21 +689,23 @@ +@@ -692,21 +700,23 @@ File file2 = new File(file1, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-client.txt"); Bootstrap.func_179870_a(p_71377_1_.func_71502_e()); @@ -109,7 +121,7 @@ } public boolean func_152349_b() -@@ -883,11 +893,6 @@ +@@ -899,11 +909,6 @@ public void func_147108_a(GuiScreen p_147108_1_) { @@ -121,8 +133,8 @@ if (p_147108_1_ == null && this.field_71441_e == null) { p_147108_1_ = new GuiMainMenu(); -@@ -897,6 +902,17 @@ - p_147108_1_ = new GuiGameOver(); +@@ -913,6 +918,17 @@ + p_147108_1_ = new GuiGameOver((ITextComponent)null); } + GuiScreen old = this.field_71462_r; @@ -130,16 +142,16 @@ + + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; + -+ p_147108_1_ = event.gui; ++ p_147108_1_ = event.getGui(); + if (old != null && p_147108_1_ != old) + { + old.func_146281_b(); + } + - if (p_147108_1_ instanceof GuiMainMenu) + if (p_147108_1_ instanceof GuiMainMenu || p_147108_1_ instanceof GuiMultiplayer) { this.field_71474_y.field_74330_P = false; -@@ -1030,9 +1046,11 @@ +@@ -1051,9 +1067,11 @@ if (!this.field_71454_w) { @@ -151,47 +163,46 @@ } this.field_71424_I.func_76319_b(); -@@ -1377,7 +1395,7 @@ +@@ -1393,9 +1411,9 @@ + { + BlockPos blockpos = this.field_71476_x.func_178782_a(); - if (this.field_71441_e.func_180495_p(blockpos).func_177230_c().func_149688_o() != Material.field_151579_a && this.field_71442_b.func_180512_c(blockpos, this.field_71476_x.field_178784_b)) +- if (this.field_71441_e.func_180495_p(blockpos).func_185904_a() != Material.field_151579_a && this.field_71442_b.func_180512_c(blockpos, this.field_71476_x.field_178784_b)) ++ if (!this.field_71441_e.func_175623_d(blockpos) && this.field_71442_b.func_180512_c(blockpos, this.field_71476_x.field_178784_b)) { - this.field_71452_i.func_180532_a(blockpos, this.field_71476_x.field_178784_b); + this.field_71452_i.addBlockHitEffects(blockpos, this.field_71476_x); - this.field_71439_g.func_71038_i(); + this.field_71439_g.func_184609_a(EnumHand.MAIN_HAND); } } -@@ -1463,15 +1481,19 @@ +@@ -1429,7 +1447,7 @@ case BLOCK: BlockPos blockpos = this.field_71476_x.func_178782_a(); -- if (this.field_71441_e.func_180495_p(blockpos).func_177230_c().func_149688_o() != Material.field_151579_a) +- if (this.field_71441_e.func_180495_p(blockpos).func_185904_a() != Material.field_151579_a) + if (!this.field_71441_e.func_175623_d(blockpos)) { - int i = itemstack != null ? itemstack.field_77994_a : 0; + this.field_71442_b.func_180511_b(blockpos, this.field_71476_x.field_178784_b); + break; +@@ -1473,7 +1491,7 @@ + switch (this.field_71476_x.field_72313_a) + { + case ENTITY: +- ++ if(!net.minecraftforge.common.ForgeHooks.onInteractEntityAt(field_71439_g, field_71476_x.field_72308_g, field_71476_x, field_71439_g.func_184586_b(enumhand), enumhand)) + if (this.field_71442_b.func_187102_a(this.field_71439_g, this.field_71476_x.field_72308_g, this.field_71476_x, this.field_71439_g.func_184586_b(enumhand), enumhand) == EnumActionResult.SUCCESS) + { + return; +@@ -1516,7 +1534,7 @@ + } -+ -+ boolean result = !net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_71439_g, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, this.field_71441_e, blockpos, this.field_71476_x.field_178784_b, this.field_71476_x.field_72307_f).isCanceled(); -+ if (result) { //Forge: Kept separate to simplify patch - if (this.field_71442_b.func_178890_a(this.field_71439_g, this.field_71441_e, itemstack, blockpos, this.field_71476_x.field_178784_b, this.field_71476_x.field_72307_f)) - { - flag = false; - this.field_71439_g.func_71038_i(); - } -+ } - - if (itemstack == null) - { -@@ -1494,7 +1516,8 @@ - { - ItemStack itemstack1 = this.field_71439_g.field_71071_by.func_70448_g(); - -- if (itemstack1 != null && this.field_71442_b.func_78769_a(this.field_71439_g, this.field_71441_e, itemstack1)) -+ boolean result = !net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_71439_g, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_AIR, field_71441_e, null, null, null).isCanceled(); -+ if (result && itemstack1 != null && this.field_71442_b.func_78769_a(this.field_71439_g, this.field_71441_e, itemstack1)) - { - this.field_71460_t.field_78516_c.func_78445_c(); - } -@@ -1598,6 +1621,8 @@ + ItemStack itemstack1 = this.field_71439_g.func_184586_b(enumhand); +- ++ if (itemstack1 == null) net.minecraftforge.common.ForgeHooks.onEmptyClick(this.field_71439_g, enumhand); + if (itemstack1 != null && this.field_71442_b.func_187101_a(this.field_71439_g, this.field_71441_e, itemstack1, enumhand) == EnumActionResult.SUCCESS) + { + this.field_71460_t.field_78516_c.func_187460_a(enumhand); +@@ -1623,6 +1641,8 @@ --this.field_71467_ac; } @@ -200,40 +211,40 @@ this.field_71424_I.func_76320_a("gui"); if (!this.field_71445_n) -@@ -1690,6 +1715,8 @@ - - while (Mouse.next()) - { -+ if (net.minecraftforge.client.ForgeHooksClient.postMouseEvent()) continue; -+ - int i = Mouse.getEventButton(); - KeyBinding.func_74510_a(i - 100, Mouse.getEventButtonState()); - -@@ -1745,6 +1772,7 @@ - this.field_71462_r.func_146274_d(); - } +@@ -1734,6 +1754,7 @@ + this.field_71457_ai = 0; + this.field_71441_e.func_72897_h(this.field_71439_g); } + net.minecraftforge.fml.common.FMLCommonHandler.instance().fireMouseInput(); } - if (this.field_71429_W > 0) -@@ -1923,6 +1951,7 @@ - } - } - } -+ net.minecraftforge.fml.common.FMLCommonHandler.instance().fireKeyInput(); - } - - for (int l = 0; l < 9; ++l) -@@ -2119,12 +2148,15 @@ + this.field_71424_I.func_76318_c("gameRenderer"); +@@ -1821,6 +1842,7 @@ this.field_71453_ak.func_74428_b(); } + net.minecraftforge.fml.common.FMLCommonHandler.instance().onPostClientTick(); -+ this.field_71424_I.func_76319_b(); this.field_71423_H = func_71386_F(); } +@@ -1927,6 +1949,7 @@ + } + } + } ++ net.minecraftforge.fml.common.FMLCommonHandler.instance().fireKeyInput(); + } + + this.func_184117_aA(); +@@ -2166,6 +2189,8 @@ + { + while (Mouse.next()) + { ++ if (net.minecraftforge.client.ForgeHooksClient.postMouseEvent()) continue; ++ + int i = Mouse.getEventButton(); + KeyBinding.func_74510_a(i - 100, Mouse.getEventButtonState()); + +@@ -2231,6 +2256,7 @@ public void func_71371_a(String p_71371_1_, String p_71371_2_, WorldSettings p_71371_3_) { @@ -241,7 +252,7 @@ this.func_71403_a((WorldClient)null); System.gc(); ISaveHandler isavehandler = this.field_71469_aa.func_75804_a(p_71371_1_, false); -@@ -2160,6 +2192,12 @@ +@@ -2273,6 +2299,12 @@ while (!this.field_71437_Z.func_71200_ad()) { @@ -254,24 +265,24 @@ String s = this.field_71437_Z.func_71195_b_(); if (s != null) -@@ -2185,8 +2223,14 @@ +@@ -2298,8 +2330,14 @@ SocketAddress socketaddress = this.field_71437_Z.func_147137_ag().func_151270_a(); NetworkManager networkmanager = NetworkManager.func_150722_a(socketaddress); networkmanager.func_150719_a(new NetHandlerLoginClient(networkmanager, this, (GuiScreen)null)); -- networkmanager.func_179290_a(new C00Handshake(47, socketaddress.toString(), 0, EnumConnectionState.LOGIN)); -- networkmanager.func_179290_a(new C00PacketLoginStart(this.func_110432_I().func_148256_e())); -+ networkmanager.func_179290_a(new C00Handshake(47, socketaddress.toString(), 0, EnumConnectionState.LOGIN, true)); +- networkmanager.func_179290_a(new C00Handshake(107, socketaddress.toString(), 0, EnumConnectionState.LOGIN)); +- networkmanager.func_179290_a(new CPacketLoginStart(this.func_110432_I().func_148256_e())); ++ networkmanager.func_179290_a(new C00Handshake(107, socketaddress.toString(), 0, EnumConnectionState.LOGIN, true)); + com.mojang.authlib.GameProfile gameProfile = this.func_110432_I().func_148256_e(); + if (!this.func_110432_I().hasCachedProperties()) + { + gameProfile = field_152355_az.fillProfileProperties(gameProfile, true); //Forge: Fill profile properties upon game load. Fixes MC-52974. + this.func_110432_I().setProperties(gameProfile.getProperties()); + } -+ networkmanager.func_179290_a(new C00PacketLoginStart(gameProfile)); ++ networkmanager.func_179290_a(new CPacketLoginStart(gameProfile)); this.field_71453_ak = networkmanager; } -@@ -2197,6 +2241,8 @@ +@@ -2310,6 +2348,8 @@ public void func_71353_a(WorldClient p_71353_1_, String p_71353_2_) { @@ -280,10 +291,10 @@ if (p_71353_1_ == null) { NetHandlerPlayClient nethandlerplayclient = this.func_147114_u(); -@@ -2210,6 +2256,18 @@ +@@ -2322,6 +2362,18 @@ + if (this.field_71437_Z != null && this.field_71437_Z.func_175578_N()) { this.field_71437_Z.func_71263_m(); - this.field_71437_Z.func_175592_a(); + if (field_71461_s != null) + { + this.field_71461_s.func_73719_c(I18n.func_135052_a("forge.client.shutdown.internal")); @@ -299,7 +310,7 @@ } this.field_71437_Z = null; -@@ -2232,6 +2290,7 @@ +@@ -2345,6 +2397,7 @@ this.field_71456_v.func_181029_i(); this.func_71351_a((ServerData)null); this.field_71455_al = false; @@ -307,77 +318,72 @@ } this.field_147127_av.func_147690_c(); -@@ -2336,126 +2395,10 @@ - if (this.field_71476_x != null) +@@ -2461,159 +2514,8 @@ + { + if (this.field_71476_x != null && this.field_71476_x.field_72313_a != RayTraceResult.Type.MISS) { - boolean flag = this.field_71439_g.field_71075_bZ.field_75098_d; -- int i = 0; -- boolean flag1 = false; +- boolean flag = this.field_71439_g.field_71075_bZ.field_75098_d; - TileEntity tileentity = null; -- Item item; +- ItemStack itemstack; - -- if (this.field_71476_x.field_72313_a == MovingObjectPosition.MovingObjectType.BLOCK) +- if (this.field_71476_x.field_72313_a == RayTraceResult.Type.BLOCK) - { - BlockPos blockpos = this.field_71476_x.func_178782_a(); -- Block block = this.field_71441_e.func_180495_p(blockpos).func_177230_c(); +- IBlockState iblockstate = this.field_71441_e.func_180495_p(blockpos); +- Block block = iblockstate.func_177230_c(); - -- if (block.func_149688_o() == Material.field_151579_a) +- if (iblockstate.func_185904_a() == Material.field_151579_a) - { - return; - } - -- item = block.func_180665_b(this.field_71441_e, blockpos); +- itemstack = block.func_185473_a(this.field_71441_e, blockpos, iblockstate); - -- if (item == null) +- if (itemstack == null) - { - return; - } - -- if (flag && GuiScreen.func_146271_m()) +- if (flag && GuiScreen.func_146271_m() && block.func_149716_u()) - { - tileentity = this.field_71441_e.func_175625_s(blockpos); - } -- -- Block block1 = item instanceof ItemBlock && !block.func_149648_K() ? Block.func_149634_a(item) : block; -- i = block1.func_176222_j(this.field_71441_e, blockpos); -- flag1 = item.func_77614_k(); - } - else - { -- if (this.field_71476_x.field_72313_a != MovingObjectPosition.MovingObjectType.ENTITY || this.field_71476_x.field_72308_g == null || !flag) +- if (this.field_71476_x.field_72313_a != RayTraceResult.Type.ENTITY || this.field_71476_x.field_72308_g == null || !flag) - { - return; - } - - if (this.field_71476_x.field_72308_g instanceof EntityPainting) - { -- item = Items.field_151159_an; +- itemstack = new ItemStack(Items.field_151159_an); - } - else if (this.field_71476_x.field_72308_g instanceof EntityLeashKnot) - { -- item = Items.field_151058_ca; +- itemstack = new ItemStack(Items.field_151058_ca); - } - else if (this.field_71476_x.field_72308_g instanceof EntityItemFrame) - { - EntityItemFrame entityitemframe = (EntityItemFrame)this.field_71476_x.field_72308_g; -- ItemStack itemstack = entityitemframe.func_82335_i(); +- ItemStack itemstack1 = entityitemframe.func_82335_i(); - -- if (itemstack == null) +- if (itemstack1 == null) - { -- item = Items.field_151160_bD; +- itemstack = new ItemStack(Items.field_151160_bD); - } - else - { -- item = itemstack.func_77973_b(); -- i = itemstack.func_77960_j(); -- flag1 = true; +- itemstack = ItemStack.func_77944_b(itemstack1); - } - } - else if (this.field_71476_x.field_72308_g instanceof EntityMinecart) - { - EntityMinecart entityminecart = (EntityMinecart)this.field_71476_x.field_72308_g; +- Item item; - -- switch (entityminecart.func_180456_s()) +- switch (entityminecart.func_184264_v()) - { - case FURNACE: - item = Items.field_151109_aJ; @@ -397,53 +403,91 @@ - default: - item = Items.field_151143_au; - } +- +- itemstack = new ItemStack(item); - } - else if (this.field_71476_x.field_72308_g instanceof EntityBoat) - { -- item = Items.field_151124_az; +- itemstack = new ItemStack(((EntityBoat)this.field_71476_x.field_72308_g).func_184455_j()); - } - else if (this.field_71476_x.field_72308_g instanceof EntityArmorStand) - { -- item = Items.field_179565_cj; +- itemstack = new ItemStack(Items.field_179565_cj); +- } +- else if (this.field_71476_x.field_72308_g instanceof EntityEnderCrystal) +- { +- itemstack = new ItemStack(Items.field_185158_cP); - } - else - { -- item = Items.field_151063_bx; -- i = EntityList.func_75619_a(this.field_71476_x.field_72308_g); -- flag1 = true; +- String s = EntityList.func_75621_b(this.field_71476_x.field_72308_g); - -- if (!EntityList.field_75627_a.containsKey(Integer.valueOf(i))) +- if (!EntityList.field_75627_a.containsKey(s)) - { - return; - } +- +- itemstack = new ItemStack(Items.field_151063_bx); +- ItemMonsterPlacer.func_185078_a(itemstack, s); - } - } - - InventoryPlayer inventoryplayer = this.field_71439_g.field_71071_by; - -- if (tileentity == null) +- if (itemstack.func_77973_b() == null) - { -- inventoryplayer.func_146030_a(item, i, flag1, flag); +- String s1 = ""; +- +- if (this.field_71476_x.field_72313_a == RayTraceResult.Type.BLOCK) +- { +- s1 = ((ResourceLocation)Block.field_149771_c.func_177774_c(this.field_71441_e.func_180495_p(this.field_71476_x.func_178782_a()).func_177230_c())).toString(); +- } +- else if (this.field_71476_x.field_72313_a == RayTraceResult.Type.ENTITY) +- { +- s1 = EntityList.func_75621_b(this.field_71476_x.field_72308_g); +- } +- +- field_147123_G.warn("Picking on: [{}] {} gave null item", new Object[] {this.field_71476_x.field_72313_a, s1}); - } - else - { -- ItemStack itemstack1 = this.func_181036_a(item, i, tileentity); -- inventoryplayer.func_70299_a(inventoryplayer.field_70461_c, itemstack1); -- } +- InventoryPlayer inventoryplayer = this.field_71439_g.field_71071_by; - -+ if (!net.minecraftforge.common.ForgeHooks.onPickBlock(this.field_71476_x, this.field_71439_g, this.field_71441_e)) return; +- if (tileentity != null) +- { +- this.func_184119_a(itemstack, tileentity); +- } +- +- int i = inventoryplayer.func_184429_b(itemstack); +- +- if (flag) +- { +- inventoryplayer.func_184434_a(itemstack); +- this.field_71442_b.func_78761_a(this.field_71439_g.func_184586_b(EnumHand.MAIN_HAND), 36 + inventoryplayer.field_70461_c); +- } +- else if (i != -1) +- { +- if (InventoryPlayer.func_184435_e(i)) +- { +- inventoryplayer.field_70461_c = i; +- } +- else +- { +- this.field_71442_b.func_187100_a(i); +- } +- } +- } ++ net.minecraftforge.common.ForgeHooks.onPickBlock(this.field_71476_x, this.field_71439_g, this.field_71441_e); + // We delete this code wholly instead of commenting it out, to make sure we detect changes in it between MC versions - if (flag) - { - int j = this.field_71439_g.field_71069_bz.field_75151_b.size() - 9 + inventoryplayer.field_70461_c; -@@ -2756,18 +2699,8 @@ + } + } + +@@ -2909,18 +2811,8 @@ public static int func_71369_N() { - for (int i = 16384; i > 0; i >>= 1) - { -- GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)((ByteBuffer)null)); -- int j = GL11.glGetTexLevelParameteri(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH); +- GlStateManager.func_187419_a(32868, 0, 6408, i, i, 0, 6408, 5121, (IntBuffer)null); +- int j = GlStateManager.func_187411_c(32868, 0, 4096); - - if (j != 0) - { @@ -457,15 +501,33 @@ } public boolean func_70002_Q() -@@ -2924,9 +2857,9 @@ - { - this.func_147108_a(new GuiYesNo(new GuiYesNoCallback() - { -- public void func_73878_a(boolean p_73878_1_, int p_73878_2_) -+ public void func_73878_a(boolean result, int id) - { -- if (p_73878_1_) -+ if (result) - { - Minecraft.this.func_152346_Z().func_152930_t(); - } +@@ -3057,15 +2949,16 @@ + { + if (Keyboard.getEventKeyState()) + { +- if (i == this.field_71474_y.field_152395_am.func_151463_i()) ++ if (this.field_71474_y.field_152395_am.isActiveAndMatches(i)) + { + this.func_71352_k(); + } +- else if (i == this.field_71474_y.field_151447_Z.func_151463_i()) ++ else if (this.field_71474_y.field_151447_Z.isActiveAndMatches(i)) + { + this.field_71456_v.func_146158_b().func_146227_a(ScreenShotHelper.func_148260_a(this.field_71412_D, this.field_71443_c, this.field_71440_d, this.field_147124_at)); + } + } ++ else if (this.field_71462_r instanceof GuiControls) ((GuiControls)this.field_71462_r).field_146491_f = null; + } + } + } +@@ -3192,4 +3085,10 @@ + { + return this.field_184127_aH; + } ++ ++ // FORGE ++ public ItemColors getItemColors() ++ { ++ return this.field_184128_aI; ++ } + } diff --git a/patches/minecraft/net/minecraft/client/audio/SoundManager.java.patch b/patches/minecraft/net/minecraft/client/audio/SoundManager.java.patch index 90c31e7915..462f42c8c2 100644 --- a/patches/minecraft/net/minecraft/client/audio/SoundManager.java.patch +++ b/patches/minecraft/net/minecraft/client/audio/SoundManager.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/audio/SoundManager.java +++ ../src-work/minecraft/net/minecraft/client/audio/SoundManager.java -@@ -69,6 +69,7 @@ +@@ -76,6 +76,7 @@ { SoundSystemConfig.addLibrary(LibraryLWJGLOpenAL.class); SoundSystemConfig.setCodec("ogg", CodecJOrbis.class); @@ -8,34 +8,34 @@ } catch (SoundSystemException soundsystemexception) { -@@ -80,6 +81,7 @@ - { +@@ -100,6 +101,7 @@ + this.func_148613_b(); this.func_148608_i(); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.SoundLoadEvent(this)); } private synchronized void func_148608_i() -@@ -316,6 +318,9 @@ - } - else - { -+ p_148611_1_ = net.minecraftforge.client.ForgeHooksClient.playSound(this, p_148611_1_); -+ if (p_148611_1_ == null) return; +@@ -338,6 +340,9 @@ + { + if (this.field_148617_f) + { ++ p_148611_1_ = net.minecraftforge.client.ForgeHooksClient.playSound(this, p_148611_1_); ++ if (p_148611_1_ == null) return; + - SoundEventAccessorComposite soundeventaccessorcomposite = this.field_148622_c.func_147680_a(p_148611_1_.func_147650_b()); + SoundEventAccessor soundeventaccessor = p_148611_1_.func_184366_a(this.field_148622_c); + ResourceLocation resourcelocation = p_148611_1_.func_147650_b(); - if (soundeventaccessorcomposite == null) -@@ -357,10 +362,12 @@ - if (soundpoolentry.func_148648_d()) +@@ -400,10 +405,12 @@ + if (sound.func_188723_h()) { - this.field_148620_e.newStreamingSource(false, s, func_148612_a(resourcelocation), resourcelocation.toString(), flag, p_148611_1_.func_147649_g(), p_148611_1_.func_147654_h(), p_148611_1_.func_147651_i(), p_148611_1_.func_147656_j().func_148586_a(), f1); + this.field_148620_e.newStreamingSource(false, s, func_148612_a(resourcelocation1), resourcelocation1.toString(), flag, p_148611_1_.func_147649_g(), p_148611_1_.func_147654_h(), p_148611_1_.func_147651_i(), p_148611_1_.func_147656_j().func_148586_a(), f); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlayStreamingSourceEvent(this, p_148611_1_, s)); } else { - this.field_148620_e.newSource(false, s, func_148612_a(resourcelocation), resourcelocation.toString(), flag, p_148611_1_.func_147649_g(), p_148611_1_.func_147654_h(), p_148611_1_.func_147651_i(), p_148611_1_.func_147656_j().func_148586_a(), f1); + this.field_148620_e.newSource(false, s, func_148612_a(resourcelocation1), resourcelocation1.toString(), flag, p_148611_1_.func_147649_g(), p_148611_1_.func_147654_h(), p_148611_1_.func_147651_i(), p_148611_1_.func_147656_j().func_148586_a(), f); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.sound.PlaySoundSourceEvent(this, p_148611_1_, s)); } - field_148621_b.debug(field_148623_a, "Playing sound {} for event {} as channel {}", new Object[] {soundpoolentry.func_148652_a(), soundeventaccessorcomposite.func_148729_c(), s}); + field_148621_b.debug(field_148623_a, "Playing sound {} for event {} as channel {}", new Object[] {sound.func_188719_a(), resourcelocation1, s}); diff --git a/patches/minecraft/net/minecraft/client/entity/AbstractClientPlayer.java.patch b/patches/minecraft/net/minecraft/client/entity/AbstractClientPlayer.java.patch index 840d193e0f..74fca0297a 100644 --- a/patches/minecraft/net/minecraft/client/entity/AbstractClientPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/entity/AbstractClientPlayer.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/entity/AbstractClientPlayer.java +++ ../src-work/minecraft/net/minecraft/client/entity/AbstractClientPlayer.java -@@ -128,6 +128,6 @@ +@@ -148,6 +148,6 @@ f *= 1.0F - f1 * 0.15F; } diff --git a/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.java.patch b/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.java.patch index 71d1ca222f..107cb5f350 100644 --- a/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.java.patch +++ b/patches/minecraft/net/minecraft/client/entity/EntityPlayerSP.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/entity/EntityPlayerSP.java +++ ../src-work/minecraft/net/minecraft/client/entity/EntityPlayerSP.java -@@ -345,6 +345,15 @@ +@@ -400,6 +400,15 @@ this.field_71159_c.field_71456_v.func_146158_b().func_146227_a(p_146105_1_); } @@ -16,7 +16,7 @@ protected boolean func_145771_j(double p_145771_1_, double p_145771_3_, double p_145771_5_) { if (this.field_70145_X) -@@ -357,30 +366,34 @@ +@@ -412,30 +421,34 @@ double d0 = p_145771_1_ - (double)blockpos.func_177958_n(); double d1 = p_145771_5_ - (double)blockpos.func_177952_p(); @@ -56,25 +56,27 @@ { d2 = 1.0D - d1; i = 5; -@@ -415,7 +428,7 @@ +@@ -470,7 +483,7 @@ private boolean func_175162_d(BlockPos p_175162_1_) { -- return !this.field_70170_p.func_180495_p(p_175162_1_).func_177230_c().func_149721_r() && !this.field_70170_p.func_180495_p(p_175162_1_.func_177984_a()).func_177230_c().func_149721_r(); -+ return !this.field_70170_p.func_180495_p(p_175162_1_).func_177230_c().func_149721_r(); +- return !this.field_70170_p.func_180495_p(p_175162_1_).func_185915_l() && !this.field_70170_p.func_180495_p(p_175162_1_.func_177984_a()).func_185915_l(); ++ return !this.field_70170_p.func_180495_p(p_175162_1_).func_185915_l(); } public void func_70031_b(boolean p_70031_1_) -@@ -448,6 +461,12 @@ +@@ -515,7 +528,13 @@ - public void func_85030_a(String p_85030_1_, float p_85030_2_, float p_85030_3_) + public void func_184185_a(SoundEvent p_184185_1_, float p_184185_2_, float p_184185_3_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this, p_85030_1_, p_85030_2_, p_85030_3_); -+ if (event.isCanceled() || event.name == null) return; -+ p_85030_1_ = event.name; -+ p_85030_2_ = event.newVolume; -+ p_85030_3_ = event.newPitch; +- this.field_70170_p.func_184134_a(this.field_70165_t, this.field_70163_u, this.field_70161_v, p_184185_1_, this.func_184176_by(), p_184185_2_, p_184185_3_, false); ++ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(this, p_184185_1_, this.func_184176_by(), p_184185_2_, p_184185_3_); ++ if (event.isCanceled() || event.getSound() == null) return; ++ p_184185_1_ = event.getSound(); ++ p_184185_2_ = event.getVolume(); ++ p_184185_3_ = event.getPitch(); + - this.field_70170_p.func_72980_b(this.field_70165_t, this.field_70163_u, this.field_70161_v, p_85030_1_, p_85030_2_, p_85030_3_, false); ++ this.field_70170_p.func_184134_a(this.field_70165_t, this.field_70163_u, this.field_70161_v, p_184185_1_, event.getCategory(), p_184185_2_, p_184185_3_, false); } + public boolean func_70613_aW() diff --git a/patches/minecraft/net/minecraft/client/gui/FontRenderer.java.patch b/patches/minecraft/net/minecraft/client/gui/FontRenderer.java.patch index 1e1f1185d1..284b9d37a7 100644 --- a/patches/minecraft/net/minecraft/client/gui/FontRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/FontRenderer.java.patch @@ -17,25 +17,25 @@ } private void func_111272_d() -@@ -105,7 +106,7 @@ +@@ -106,7 +107,7 @@ try { -- bufferedimage = TextureUtil.func_177053_a(Minecraft.func_71410_x().func_110442_L().func_110536_a(this.field_111273_g).func_110527_b()); -+ bufferedimage = TextureUtil.func_177053_a(getResourceInputStream(this.field_111273_g)); +- iresource = Minecraft.func_71410_x().func_110442_L().func_110536_a(this.field_111273_g); ++ iresource = getResource(this.field_111273_g); + bufferedimage = TextureUtil.func_177053_a(iresource.func_110527_b()); } catch (IOException ioexception) - { -@@ -165,7 +166,7 @@ +@@ -171,7 +172,7 @@ try { -- inputstream = Minecraft.func_71410_x().func_110442_L().func_110536_a(new ResourceLocation("font/glyph_sizes.bin")).func_110527_b(); -+ inputstream = getResourceInputStream(new ResourceLocation("font/glyph_sizes.bin")); - inputstream.read(this.field_78287_e); +- iresource = Minecraft.func_71410_x().func_110442_L().func_110536_a(new ResourceLocation("font/glyph_sizes.bin")); ++ iresource = getResource(new ResourceLocation("font/glyph_sizes.bin")); + iresource.func_110527_b().read(this.field_78287_e); } catch (IOException ioexception) -@@ -196,7 +197,7 @@ +@@ -202,7 +203,7 @@ int i = p_78266_1_ % 16 * 8; int j = p_78266_1_ / 16 * 8; int k = p_78266_2_ ? 1 : 0; @@ -43,8 +43,8 @@ + bindTexture(this.field_111273_g); int l = this.field_78286_d[p_78266_1_]; float f = (float)l - 0.01F; - GL11.glBegin(GL11.GL_TRIANGLE_STRIP); -@@ -224,7 +225,7 @@ + GlStateManager.func_187447_r(5); +@@ -230,7 +231,7 @@ private void func_78257_a(int p_78257_1_) { @@ -53,7 +53,7 @@ } protected float func_78277_a(char p_78277_1_, boolean p_78277_2_) -@@ -271,7 +272,7 @@ +@@ -279,7 +280,7 @@ public int func_175065_a(String p_175065_1_, float p_175065_2_, float p_175065_3_, int p_175065_4_, boolean p_175065_5_) { @@ -62,7 +62,7 @@ this.func_78265_b(); int i; -@@ -341,7 +342,7 @@ +@@ -349,7 +350,7 @@ int j1 = this.field_78285_g[i1]; this.field_78304_r = j1; @@ -71,7 +71,7 @@ } else if (i1 == 16) { -@@ -370,7 +371,7 @@ +@@ -378,7 +379,7 @@ this.field_78299_w = false; this.field_78300_v = false; this.field_78301_u = false; @@ -80,7 +80,7 @@ } ++i; -@@ -398,7 +399,7 @@ +@@ -406,7 +407,7 @@ c0 = c1; } @@ -89,7 +89,7 @@ boolean flag = (c0 == 0 || j == -1 || this.field_78293_l) && p_78255_2_; if (flag) -@@ -436,7 +437,16 @@ +@@ -444,7 +445,16 @@ ++f; } @@ -106,7 +106,7 @@ if (this.field_78299_w) { Tessellator tessellator = Tessellator.func_178181_a(); -@@ -509,7 +519,7 @@ +@@ -517,7 +527,7 @@ this.field_78292_o = (float)(p_180455_4_ >> 8 & 255) / 255.0F; this.field_78306_p = (float)(p_180455_4_ & 255) / 255.0F; this.field_78305_q = (float)(p_180455_4_ >> 24 & 255) / 255.0F; @@ -115,19 +115,7 @@ this.field_78295_j = p_180455_2_; this.field_78296_k = p_180455_3_; this.func_78255_a(p_180455_1_, p_180455_5_); -@@ -588,11 +598,6 @@ - int j = this.field_78287_e[p_78263_1_] >>> 4; - int k = this.field_78287_e[p_78263_1_] & 15; - -- if (k > 7) -- { -- k = 15; -- j = 0; -- } - - ++k; - return (k - j) / 2 + 1; -@@ -846,6 +851,26 @@ +@@ -848,6 +858,26 @@ return this.field_78294_m; } @@ -146,11 +134,11 @@ + field_78298_i.func_110577_a(location); + } + -+ protected InputStream getResourceInputStream(ResourceLocation location) throws IOException ++ protected IResource getResource(ResourceLocation location) throws IOException + { -+ return Minecraft.func_71410_x().func_110442_L().func_110536_a(location).func_110527_b(); ++ return Minecraft.func_71410_x().func_110442_L().func_110536_a(location); + } + public int func_175064_b(char p_175064_1_) { - return this.field_78285_g["0123456789abcdef".indexOf(p_175064_1_)]; + int i = "0123456789abcdef".indexOf(p_175064_1_); diff --git a/patches/minecraft/net/minecraft/client/gui/GuiBossOverlay.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiBossOverlay.java.patch new file mode 100644 index 0000000000..2acdca22ce --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/GuiBossOverlay.java.patch @@ -0,0 +1,22 @@ +--- ../src-base/minecraft/net/minecraft/client/gui/GuiBossOverlay.java ++++ ../src-work/minecraft/net/minecraft/client/gui/GuiBossOverlay.java +@@ -35,13 +35,18 @@ + for (BossInfoLerping bossinfolerping : this.field_184060_g.values()) + { + int k = i / 2 - 91; ++ net.minecraftforge.client.event.RenderGameOverlayEvent.BossInfo event = ++ net.minecraftforge.client.ForgeHooksClient.bossBarRenderPre(scaledresolution, bossinfolerping, k, j, 10 + this.field_184059_f.field_71466_p.field_78288_b); ++ if (!event.isCanceled()) { + GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); + this.field_184059_f.func_110434_K().func_110577_a(field_184058_a); + this.func_184052_a(k, j, bossinfolerping); + String s = bossinfolerping.func_186744_e().func_150254_d(); + this.field_184059_f.field_71466_p.func_175063_a(s, (float)(i / 2 - this.field_184059_f.field_71466_p.func_78256_a(s) / 2), (float)(j - 9), 16777215); +- j += 10 + this.field_184059_f.field_71466_p.field_78288_b; ++ } ++ j += event.getIncrement(); + ++ net.minecraftforge.client.ForgeHooksClient.bossBarRenderPost(scaledresolution); + if (j >= scaledresolution.func_78328_b() / 3) + { + break; diff --git a/patches/minecraft/net/minecraft/client/gui/GuiButton.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiButton.java.patch index b212709d6d..4d2f4ad58c 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiButton.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiButton.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/gui/GuiButton.java +++ ../src-work/minecraft/net/minecraft/client/gui/GuiButton.java -@@ -21,6 +21,7 @@ +@@ -22,6 +22,7 @@ public boolean field_146124_l; public boolean field_146125_m; protected boolean field_146123_n; @@ -8,7 +8,7 @@ public GuiButton(int p_i1020_1_, int p_i1020_2_, int p_i1020_3_, String p_i1020_4_) { -@@ -74,6 +75,11 @@ +@@ -75,6 +76,11 @@ this.func_146119_b(p_146112_1_, p_146112_2_, p_146112_3_); int j = 14737632; diff --git a/patches/minecraft/net/minecraft/client/gui/GuiChat.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiChat.java.patch index 799a580d0a..afbde6bafd 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiChat.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiChat.java.patch @@ -1,39 +1,10 @@ --- ../src-base/minecraft/net/minecraft/client/gui/GuiChat.java +++ ../src-work/minecraft/net/minecraft/client/gui/GuiChat.java -@@ -215,13 +215,14 @@ - this.field_146297_k.field_71456_v.func_146158_b().func_146234_a(new ChatComponentText(stringbuilder.toString()), 1); - } +@@ -250,6 +250,7 @@ -- this.field_146415_a.func_146191_b((String)this.field_146412_t.get(this.field_146413_s++)); -+ this.field_146415_a.func_146191_b(net.minecraft.util.EnumChatFormatting.func_110646_a((String)this.field_146412_t.get(this.field_146413_s++))); - } - - private void func_146405_a(String p_146405_1_, String p_146405_2_) - { - if (p_146405_1_.length() >= 1) - { -+ net.minecraftforge.client.ClientCommandHandler.instance.autoComplete(p_146405_1_, p_146405_2_); - BlockPos blockpos = null; - - if (this.field_146297_k.field_71476_x != null && this.field_146297_k.field_71476_x.field_72313_a == MovingObjectPosition.MovingObjectType.BLOCK) -@@ -281,6 +282,12 @@ - this.field_146417_i = false; - this.field_146412_t.clear(); - -+ String[] complete = net.minecraftforge.client.ClientCommandHandler.instance.latestAutoComplete; -+ if (complete != null) -+ { -+ p_146406_1_ = com.google.common.collect.ObjectArrays.concat(complete, p_146406_1_, String.class); -+ } + public BlockPos func_186839_b() + { + - for (String s : p_146406_1_) - { - if (s.length() > 0) -@@ -291,6 +298,7 @@ + BlockPos blockpos = null; - String s1 = this.field_146415_a.func_146179_b().substring(this.field_146415_a.func_146197_a(-1, this.field_146415_a.func_146198_h(), false)); - String s2 = StringUtils.getCommonPrefix(p_146406_1_); -+ s2 = net.minecraft.util.EnumChatFormatting.func_110646_a(s2); - - if (s2.length() > 0 && !s1.equalsIgnoreCase(s2)) - { + if (this.field_186853_g.field_71476_x != null && this.field_186853_g.field_71476_x.field_72313_a == RayTraceResult.Type.BLOCK) diff --git a/patches/minecraft/net/minecraft/client/gui/GuiControls.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiControls.java.patch new file mode 100644 index 0000000000..5a9cdd75b6 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/GuiControls.java.patch @@ -0,0 +1,50 @@ +--- ../src-base/minecraft/net/minecraft/client/gui/GuiControls.java ++++ ../src-work/minecraft/net/minecraft/client/gui/GuiControls.java +@@ -65,7 +65,7 @@ + { + for (KeyBinding keybinding : this.field_146297_k.field_71474_y.field_74324_K) + { +- keybinding.func_151462_b(keybinding.func_151469_h()); ++ keybinding.setToDefault(); + } + + KeyBinding.func_74508_b(); +@@ -81,6 +81,7 @@ + { + if (this.field_146491_f != null) + { ++ this.field_146491_f.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), -100 + p_73864_3_); + this.field_146497_i.func_151440_a(this.field_146491_f, -100 + p_73864_3_); + this.field_146491_f = null; + KeyBinding.func_74508_b(); +@@ -105,17 +106,21 @@ + { + if (p_73869_2_ == 1) + { ++ this.field_146491_f.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.NONE, 0); + this.field_146497_i.func_151440_a(this.field_146491_f, 0); + } + else if (p_73869_2_ != 0) + { ++ this.field_146491_f.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), p_73869_2_); + this.field_146497_i.func_151440_a(this.field_146491_f, p_73869_2_); + } + else if (p_73869_1_ > 0) + { ++ this.field_146491_f.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), p_73869_1_ + 256); + this.field_146497_i.func_151440_a(this.field_146491_f, p_73869_1_ + 256); + } + ++ if (!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(p_73869_2_)) + this.field_146491_f = null; + this.field_152177_g = Minecraft.func_71386_F(); + KeyBinding.func_74508_b(); +@@ -135,7 +140,7 @@ + + for (KeyBinding keybinding : this.field_146497_i.field_74324_K) + { +- if (keybinding.func_151463_i() != keybinding.func_151469_h()) ++ if (!keybinding.isSetToDefaultValue()) + { + flag = false; + break; diff --git a/patches/minecraft/net/minecraft/client/gui/GuiCreateWorld.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiCreateWorld.java.patch index 4f9d297f4d..5261e6fa95 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiCreateWorld.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiCreateWorld.java.patch @@ -6,10 +6,10 @@ + WorldType.field_77139_a[this.field_146331_K].onGUICreateWorldPress(); + - WorldSettings.GameType worldsettings$gametype = WorldSettings.GameType.func_77142_a(this.field_146342_r); - WorldSettings worldsettings = new WorldSettings(i, worldsettings$gametype, this.field_146341_s, this.field_146337_w, WorldType.field_77139_a[this.field_146331_K]); + WorldSettings worldsettings = new WorldSettings(i, WorldSettings.GameType.func_77142_a(this.field_146342_r), this.field_146341_s, this.field_146337_w, WorldType.field_77139_a[this.field_146331_K]); worldsettings.func_82750_a(this.field_146334_a); -@@ -312,14 +314,7 @@ + +@@ -311,14 +313,7 @@ } else if (p_146284_1_.field_146127_k == 8) { @@ -25,7 +25,7 @@ } } } -@@ -371,7 +366,7 @@ +@@ -370,7 +365,7 @@ this.field_146326_C.field_146125_m = this.field_146344_y; this.field_146320_D.field_146125_m = this.field_146344_y; this.field_146321_E.field_146125_m = this.field_146344_y; diff --git a/patches/minecraft/net/minecraft/client/gui/GuiIngame.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiIngame.java.patch new file mode 100644 index 0000000000..9d96734bcd --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/GuiIngame.java.patch @@ -0,0 +1,35 @@ +--- ../src-base/minecraft/net/minecraft/client/gui/GuiIngame.java ++++ ../src-work/minecraft/net/minecraft/client/gui/GuiIngame.java +@@ -360,7 +360,8 @@ + + BlockPos blockpos = raytraceresult.func_178782_a(); + +- if (!this.field_73839_d.field_71441_e.func_180495_p(blockpos).func_177230_c().func_149716_u() || !(this.field_73839_d.field_71441_e.func_175625_s(blockpos) instanceof IInventory)) ++ net.minecraft.block.state.IBlockState state = this.field_73839_d.field_71441_e.func_180495_p(blockpos); ++ if (!state.func_177230_c().hasTileEntity(state) || !(this.field_73839_d.field_71441_e.func_175625_s(blockpos) instanceof IInventory)) + { + return; + } +@@ -418,7 +419,10 @@ + { + Potion potion = potioneffect.func_188419_a(); + +- if (potion.func_76400_d() && potioneffect.func_188418_e()) ++ if (!potion.shouldRenderHUD(potioneffect)) continue; ++ // Rebind in case previous renderHUDEffect changed texture ++ this.field_73839_d.func_110434_K().func_110577_a(GuiContainer.field_147001_a); ++ if (potioneffect.func_188418_e()) + { + int k = p_184048_1_.func_78326_a(); + int l = 1; +@@ -455,7 +459,10 @@ + } + + GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, f); ++ // FORGE - Move status icon check down from above so renderHUDEffect will still be called without a status icon ++ if (potion.func_76400_d()) + this.func_73729_b(k + 3, l + 3, i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18); ++ potion.renderHUDEffect(k, l, potioneffect, field_73839_d, f); + } + } + } diff --git a/patches/minecraft/net/minecraft/client/gui/GuiKeyBindingList.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiKeyBindingList.java.patch new file mode 100644 index 0000000000..2471d1bf9b --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/GuiKeyBindingList.java.patch @@ -0,0 +1,67 @@ +--- ../src-base/minecraft/net/minecraft/client/gui/GuiKeyBindingList.java ++++ ../src-work/minecraft/net/minecraft/client/gui/GuiKeyBindingList.java +@@ -62,7 +62,7 @@ + + protected int func_148137_d() + { +- return super.func_148137_d() + 15; ++ return super.func_148137_d() + 35; + } + + public int func_148139_c() +@@ -113,7 +113,7 @@ + { + this.field_148282_b = p_i45029_2_; + this.field_148283_c = I18n.func_135052_a(p_i45029_2_.func_151464_g(), new Object[0]); +- this.field_148280_d = new GuiButton(0, 0, 0, 75, 20, I18n.func_135052_a(p_i45029_2_.func_151464_g(), new Object[0])); ++ this.field_148280_d = new GuiButton(0, 0, 0, 95, 20, I18n.func_135052_a(p_i45029_2_.func_151464_g(), new Object[0])); + this.field_148281_e = new GuiButton(0, 0, 0, 50, 20, I18n.func_135052_a("controls.reset", new Object[0])); + } + +@@ -121,23 +121,24 @@ + { + boolean flag = GuiKeyBindingList.this.field_148191_k.field_146491_f == this.field_148282_b; + GuiKeyBindingList.this.field_148189_l.field_71466_p.func_78276_b(this.field_148283_c, p_180790_2_ + 90 - GuiKeyBindingList.this.field_148188_n, p_180790_3_ + p_180790_5_ / 2 - GuiKeyBindingList.this.field_148189_l.field_71466_p.field_78288_b / 2, 16777215); +- this.field_148281_e.field_146128_h = p_180790_2_ + 190; ++ this.field_148281_e.field_146128_h = p_180790_2_ + 210; + this.field_148281_e.field_146129_i = p_180790_3_; +- this.field_148281_e.field_146124_l = this.field_148282_b.func_151463_i() != this.field_148282_b.func_151469_h(); ++ this.field_148281_e.field_146124_l = !this.field_148282_b.isSetToDefaultValue(); + this.field_148281_e.func_146112_a(GuiKeyBindingList.this.field_148189_l, p_180790_6_, p_180790_7_); + this.field_148280_d.field_146128_h = p_180790_2_ + 105; + this.field_148280_d.field_146129_i = p_180790_3_; +- this.field_148280_d.field_146126_j = GameSettings.func_74298_c(this.field_148282_b.func_151463_i()); ++ this.field_148280_d.field_146126_j = this.field_148282_b.getDisplayName(); + boolean flag1 = false; ++ boolean keyCodeModifierConflict = true; // less severe form of conflict, like SHIFT conflicting with SHIFT+G + + if (this.field_148282_b.func_151463_i() != 0) + { + for (KeyBinding keybinding : GuiKeyBindingList.this.field_148189_l.field_71474_y.field_74324_K) + { +- if (keybinding != this.field_148282_b && keybinding.func_151463_i() == this.field_148282_b.func_151463_i()) ++ if (keybinding != this.field_148282_b && keybinding.conflicts(this.field_148282_b)) + { + flag1 = true; +- break; ++ keyCodeModifierConflict &= keybinding.hasKeyCodeModifierConflict(this.field_148282_b); + } + } + } +@@ -148,7 +149,7 @@ + } + else if (flag1) + { +- this.field_148280_d.field_146126_j = TextFormatting.RED + this.field_148280_d.field_146126_j; ++ this.field_148280_d.field_146126_j = (keyCodeModifierConflict ? TextFormatting.GOLD : TextFormatting.RED) + this.field_148280_d.field_146126_j; + } + + this.field_148280_d.func_146112_a(GuiKeyBindingList.this.field_148189_l, p_180790_6_, p_180790_7_); +@@ -163,6 +164,7 @@ + } + else if (this.field_148281_e.func_146116_c(GuiKeyBindingList.this.field_148189_l, p_148278_2_, p_148278_3_)) + { ++ this.field_148282_b.setToDefault(); + GuiKeyBindingList.this.field_148189_l.field_71474_y.func_151440_a(this.field_148282_b, this.field_148282_b.func_151469_h()); + KeyBinding.func_74508_b(); + return true; diff --git a/patches/minecraft/net/minecraft/client/gui/GuiListWorldSelectionEntry.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiListWorldSelectionEntry.java.patch new file mode 100644 index 0000000000..67dff1d65e --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/GuiListWorldSelectionEntry.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/net/minecraft/client/gui/GuiListWorldSelectionEntry.java ++++ ../src-work/minecraft/net/minecraft/client/gui/GuiListWorldSelectionEntry.java +@@ -242,7 +242,7 @@ + + if (this.field_186784_e.func_71359_d().func_90033_f(this.field_186786_g.func_75786_a())) + { +- this.field_186784_e.func_71371_a(this.field_186786_g.func_75786_a(), this.field_186786_g.func_75788_b(), (WorldSettings)null); ++ net.minecraftforge.fml.client.FMLClientHandler.instance().tryLoadExistingWorld(field_186785_f, this.field_186786_g); + } + } + diff --git a/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.java.patch index 76e92d8274..22dec2e57b 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.java.patch @@ -1,16 +1,32 @@ --- ../src-base/minecraft/net/minecraft/client/gui/GuiMainMenu.java +++ ../src-work/minecraft/net/minecraft/client/gui/GuiMainMenu.java -@@ -223,7 +223,8 @@ +@@ -67,6 +67,8 @@ + private GuiButton field_175372_K; + private boolean field_183502_L; + private GuiScreen field_183503_M; ++ private GuiButton modButton; ++ private net.minecraftforge.client.gui.NotificationModUpdateScreen modUpdateNotification; + + public GuiMainMenu() + { +@@ -210,13 +212,15 @@ + this.field_183503_M.func_183500_a(this.field_146294_l, this.field_146295_m); + this.field_183503_M.func_73866_w_(); + } ++ modUpdateNotification = net.minecraftforge.client.gui.NotificationModUpdateScreen.init(this, modButton); + } + + private void func_73969_a(int p_73969_1_, int p_73969_2_) { this.field_146292_n.add(new GuiButton(1, this.field_146294_l / 2 - 100, p_73969_1_, I18n.func_135052_a("menu.singleplayer", new Object[0]))); this.field_146292_n.add(new GuiButton(2, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 1, I18n.func_135052_a("menu.multiplayer", new Object[0]))); - this.field_146292_n.add(this.field_175372_K = new GuiButton(14, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, I18n.func_135052_a("menu.online", new Object[0]))); + this.field_146292_n.add(this.field_175372_K = new GuiButton(14, this.field_146294_l / 2 + 2, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.func_135052_a("menu.online", new Object[0]).replace("Minecraft", "").trim())); -+ this.field_146292_n.add(new GuiButton(6, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.func_135052_a("fml.menu.mods"))); ++ this.field_146292_n.add(modButton = new GuiButton(6, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.func_135052_a("fml.menu.mods"))); } private void func_73972_b(int p_73972_1_, int p_73972_2_) -@@ -271,6 +272,11 @@ +@@ -264,6 +268,11 @@ this.field_146297_k.func_71400_g(); } @@ -22,8 +38,17 @@ if (p_146284_1_.field_146127_k == 11) { this.field_146297_k.func_71371_a("Demo_World", "Demo_World", DemoWorldServer.field_73071_a); -@@ -516,7 +522,16 @@ - s = s + " Demo"; +@@ -493,6 +502,8 @@ + this.func_73729_b(j + 155, k + 0, 0, 45, 155, 44); + } + ++ this.field_73975_c = net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, this.field_146289_q, this.field_146294_l, this.field_146295_m, this.field_73975_c); ++ + GlStateManager.func_179094_E(); + GlStateManager.func_179109_b((float)(this.field_146294_l / 2 + 90), 70.0F, 0.0F); + GlStateManager.func_179114_b(-20.0F, 0.0F, 0.0F, 1.0F); +@@ -512,7 +523,15 @@ + s = s + ("release".equalsIgnoreCase(this.field_146297_k.func_184123_d()) ? "" : "/" + this.field_146297_k.func_184123_d()); } - this.func_73731_b(this.field_146289_q, s, 2, this.field_146295_m - 10, -1); @@ -36,7 +61,23 @@ + this.func_73731_b(this.field_146289_q, brd, 2, this.field_146295_m - ( 10 + brdline * (this.field_146289_q.field_78288_b + 1)), 16777215); + } + } -+ net.minecraftforge.client.ForgeHooksClient.renderMainMenu(this, this.field_146289_q, this.field_146294_l, this.field_146295_m); String s1 = "Copyright Mojang AB. Do not distribute!"; this.func_73731_b(this.field_146289_q, s1, this.field_146294_l - this.field_146289_q.func_78256_a(s1) - 2, this.field_146295_m - 10, -1); +@@ -529,6 +548,7 @@ + { + this.field_183503_M.func_73863_a(p_73863_1_, p_73863_2_, p_73863_3_); + } ++ modUpdateNotification.func_73863_a(p_73863_1_, p_73863_2_, p_73863_3_); + } + + protected void func_73864_a(int p_73864_1_, int p_73864_2_, int p_73864_3_) throws IOException +@@ -549,6 +569,8 @@ + { + this.field_183503_M.func_73864_a(p_73864_1_, p_73864_2_, p_73864_3_); + } ++ ++ net.minecraftforge.client.ForgeHooksClient.mainMenuMouseClick(p_73864_1_, p_73864_2_, p_73864_3_, this.field_146289_q, this.field_146294_l); + } + + public void func_146281_b() diff --git a/patches/minecraft/net/minecraft/client/gui/GuiOverlayDebug.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiOverlayDebug.java.patch index 0841e6d3c8..689452fc8f 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiOverlayDebug.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiOverlayDebug.java.patch @@ -1,8 +1,8 @@ --- ../src-base/minecraft/net/minecraft/client/gui/GuiOverlayDebug.java +++ ../src-work/minecraft/net/minecraft/client/gui/GuiOverlayDebug.java -@@ -176,6 +176,9 @@ +@@ -190,6 +190,9 @@ long l = j - k; - List list = Lists.newArrayList(new String[] {String.format("Java: %s %dbit", new Object[]{System.getProperty("java.version"), Integer.valueOf(this.field_175242_a.func_147111_S() ? 64 : 32)}), String.format("Mem: % 2d%% %03d/%03dMB", new Object[]{Long.valueOf(l * 100L / i), Long.valueOf(func_175240_a(l)), Long.valueOf(func_175240_a(i))}), String.format("Allocated: % 2d%% %03dMB", new Object[]{Long.valueOf(j * 100L / i), Long.valueOf(func_175240_a(j))}), "", String.format("CPU: %s", new Object[]{OpenGlHelper.func_183029_j()}), "", String.format("Display: %dx%d (%s)", new Object[]{Integer.valueOf(Display.getWidth()), Integer.valueOf(Display.getHeight()), GL11.glGetString(GL11.GL_VENDOR)}), GL11.glGetString(GL11.GL_RENDERER), GL11.glGetString(GL11.GL_VERSION)}); + List list = Lists.newArrayList(new String[] {String.format("Java: %s %dbit", new Object[]{System.getProperty("java.version"), Integer.valueOf(this.field_175242_a.func_147111_S() ? 64 : 32)}), String.format("Mem: % 2d%% %03d/%03dMB", new Object[]{Long.valueOf(l * 100L / i), Long.valueOf(func_175240_a(l)), Long.valueOf(func_175240_a(i))}), String.format("Allocated: % 2d%% %03dMB", new Object[]{Long.valueOf(j * 100L / i), Long.valueOf(func_175240_a(j))}), "", String.format("CPU: %s", new Object[]{OpenGlHelper.func_183029_j()}), "", String.format("Display: %dx%d (%s)", new Object[]{Integer.valueOf(Display.getWidth()), Integer.valueOf(Display.getHeight()), GlStateManager.func_187416_u(7936)}), GlStateManager.func_187416_u(7937), GlStateManager.func_187416_u(7938)}); + list.add(""); + list.addAll(net.minecraftforge.fml.common.FMLCommonHandler.instance().getBrandings(false)); diff --git a/patches/minecraft/net/minecraft/client/gui/GuiScreen.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiScreen.java.patch index 1bc220d25c..3110c8976f 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiScreen.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiScreen.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/gui/GuiScreen.java +++ ../src-work/minecraft/net/minecraft/client/gui/GuiScreen.java -@@ -143,7 +143,8 @@ +@@ -141,7 +141,8 @@ } } @@ -10,7 +10,7 @@ } protected void func_146279_a(String p_146279_1_, int p_146279_2_, int p_146279_3_) -@@ -153,7 +154,13 @@ +@@ -151,7 +152,13 @@ protected void func_146283_a(List p_146283_1_, int p_146283_2_, int p_146283_3_) { @@ -25,7 +25,7 @@ { GlStateManager.func_179101_C(); RenderHelper.func_74518_a(); -@@ -436,6 +443,7 @@ +@@ -421,6 +428,7 @@ { this.field_146297_k.field_71456_v.func_146158_b().func_146239_a(p_175281_1_); } @@ -33,23 +33,23 @@ this.field_146297_k.field_71439_g.func_71165_d(p_175281_1_); } -@@ -450,9 +458,15 @@ +@@ -435,9 +443,15 @@ if (guibutton.func_146116_c(this.field_146297_k, p_73864_1_, p_73864_2_)) { + net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre event = new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre(this, guibutton, this.field_146292_n); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) + break; -+ guibutton = event.button; ++ guibutton = event.getButton(); this.field_146290_a = guibutton; guibutton.func_146113_a(this.field_146297_k.func_147118_V()); this.func_146284_a(guibutton); + if (this.equals(this.field_146297_k.field_71462_r)) -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post(this, event.button, this.field_146292_n)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post(this, event.getButton(), this.field_146292_n)); } } } -@@ -482,8 +496,12 @@ +@@ -467,8 +481,12 @@ this.field_146289_q = p_146280_1_.field_71466_p; this.field_146294_l = p_146280_2_; this.field_146295_m = p_146280_3_; @@ -62,7 +62,7 @@ } public void func_183500_a(int p_183500_1_, int p_183500_2_) -@@ -502,7 +520,9 @@ +@@ -487,7 +505,9 @@ { while (Mouse.next()) { @@ -72,7 +72,7 @@ } } -@@ -510,7 +530,9 @@ +@@ -495,7 +515,9 @@ { while (Keyboard.next()) { @@ -82,7 +82,7 @@ } } } -@@ -570,6 +592,7 @@ +@@ -557,6 +579,7 @@ public void func_146276_q_() { this.func_146270_b(0); diff --git a/patches/minecraft/net/minecraft/client/gui/GuiScreenDemo.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiScreenDemo.java.patch new file mode 100644 index 0000000000..bc1953025b --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/GuiScreenDemo.java.patch @@ -0,0 +1,16 @@ +--- ../src-base/minecraft/net/minecraft/client/gui/GuiScreenDemo.java ++++ ../src-work/minecraft/net/minecraft/client/gui/GuiScreenDemo.java +@@ -73,10 +73,10 @@ + this.field_146289_q.func_78276_b(I18n.func_135052_a("demo.help.title", new Object[0]), i, j, 2039583); + j = j + 12; + GameSettings gamesettings = this.field_146297_k.field_71474_y; +- this.field_146289_q.func_78276_b(I18n.func_135052_a("demo.help.movementShort", new Object[] {GameSettings.func_74298_c(gamesettings.field_74351_w.func_151463_i()), GameSettings.func_74298_c(gamesettings.field_74370_x.func_151463_i()), GameSettings.func_74298_c(gamesettings.field_74368_y.func_151463_i()), GameSettings.func_74298_c(gamesettings.field_74366_z.func_151463_i())}), i, j, 5197647); ++ this.field_146289_q.func_78276_b(I18n.func_135052_a("demo.help.movementShort", new Object[] {gamesettings.field_74351_w.getDisplayName(), gamesettings.field_74370_x.getDisplayName(), gamesettings.field_74368_y.getDisplayName(), gamesettings.field_74366_z.getDisplayName()}), i, j, 5197647); + this.field_146289_q.func_78276_b(I18n.func_135052_a("demo.help.movementMouse", new Object[0]), i, j + 12, 5197647); +- this.field_146289_q.func_78276_b(I18n.func_135052_a("demo.help.jump", new Object[] {GameSettings.func_74298_c(gamesettings.field_74314_A.func_151463_i())}), i, j + 24, 5197647); +- this.field_146289_q.func_78276_b(I18n.func_135052_a("demo.help.inventory", new Object[] {GameSettings.func_74298_c(gamesettings.field_151445_Q.func_151463_i())}), i, j + 36, 5197647); ++ this.field_146289_q.func_78276_b(I18n.func_135052_a("demo.help.jump", new Object[] {gamesettings.field_74314_A.getDisplayName()}), i, j + 24, 5197647); ++ this.field_146289_q.func_78276_b(I18n.func_135052_a("demo.help.inventory", new Object[] {gamesettings.field_151445_Q.getDisplayName()}), i, j + 36, 5197647); + this.field_146289_q.func_78279_b(I18n.func_135052_a("demo.help.fullWrapped", new Object[0]), i, j + 68, 218, 2039583); + super.func_73863_a(p_73863_1_, p_73863_2_, p_73863_3_); + } diff --git a/patches/minecraft/net/minecraft/client/gui/GuiSelectWorld.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiSelectWorld.java.patch deleted file mode 100644 index d1ee636567..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/GuiSelectWorld.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/client/gui/GuiSelectWorld.java -+++ ../src-work/minecraft/net/minecraft/client/gui/GuiSelectWorld.java -@@ -186,7 +186,7 @@ - - if (this.field_146297_k.func_71359_d().func_90033_f(s)) - { -- this.field_146297_k.func_71371_a(s, s1, (WorldSettings)null); -+ net.minecraftforge.fml.client.FMLClientHandler.instance().tryLoadExistingWorld(this, s, s1); - } - } - } diff --git a/patches/minecraft/net/minecraft/client/gui/GuiSlot.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiSlot.java.patch index d4b2b22e59..fa8d3be0eb 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiSlot.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiSlot.java.patch @@ -3,15 +3,15 @@ @@ -181,15 +181,8 @@ GlStateManager.func_179106_n(); Tessellator tessellator = Tessellator.func_178181_a(); - WorldRenderer worldrenderer = tessellator.func_178180_c(); + VertexBuffer vertexbuffer = tessellator.func_178180_c(); - this.field_148161_k.func_110434_K().func_110577_a(Gui.field_110325_k); - GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); - float f = 32.0F; -- worldrenderer.func_181668_a(7, DefaultVertexFormats.field_181709_i); -- worldrenderer.func_181662_b((double)this.field_148152_e, (double)this.field_148154_c, 0.0D).func_181673_a((double)((float)this.field_148152_e / f), (double)((float)(this.field_148154_c + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); -- worldrenderer.func_181662_b((double)this.field_148151_d, (double)this.field_148154_c, 0.0D).func_181673_a((double)((float)this.field_148151_d / f), (double)((float)(this.field_148154_c + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); -- worldrenderer.func_181662_b((double)this.field_148151_d, (double)this.field_148153_b, 0.0D).func_181673_a((double)((float)this.field_148151_d / f), (double)((float)(this.field_148153_b + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); -- worldrenderer.func_181662_b((double)this.field_148152_e, (double)this.field_148153_b, 0.0D).func_181673_a((double)((float)this.field_148152_e / f), (double)((float)(this.field_148153_b + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); +- vertexbuffer.func_181668_a(7, DefaultVertexFormats.field_181709_i); +- vertexbuffer.func_181662_b((double)this.field_148152_e, (double)this.field_148154_c, 0.0D).func_187315_a((double)((float)this.field_148152_e / f), (double)((float)(this.field_148154_c + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); +- vertexbuffer.func_181662_b((double)this.field_148151_d, (double)this.field_148154_c, 0.0D).func_187315_a((double)((float)this.field_148151_d / f), (double)((float)(this.field_148154_c + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); +- vertexbuffer.func_181662_b((double)this.field_148151_d, (double)this.field_148153_b, 0.0D).func_187315_a((double)((float)this.field_148151_d / f), (double)((float)(this.field_148153_b + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); +- vertexbuffer.func_181662_b((double)this.field_148152_e, (double)this.field_148153_b, 0.0D).func_187315_a((double)((float)this.field_148152_e / f), (double)((float)(this.field_148153_b + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); - tessellator.func_78381_a(); + // Forge: background rendering moved into separate method. + this.drawContainerBackground(tessellator); @@ -25,15 +25,15 @@ + + protected void drawContainerBackground(Tessellator tessellator) + { -+ WorldRenderer worldrenderer = tessellator.func_178180_c(); ++ VertexBuffer buffer = tessellator.func_178180_c(); + this.field_148161_k.func_110434_K().func_110577_a(Gui.field_110325_k); + GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); + float f = 32.0F; -+ worldrenderer.func_181668_a(7, DefaultVertexFormats.field_181709_i); -+ worldrenderer.func_181662_b((double)this.field_148152_e, (double)this.field_148154_c, 0.0D).func_181673_a((double)((float)this.field_148152_e / f), (double)((float)(this.field_148154_c + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); -+ worldrenderer.func_181662_b((double)this.field_148151_d, (double)this.field_148154_c, 0.0D).func_181673_a((double)((float)this.field_148151_d / f), (double)((float)(this.field_148154_c + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); -+ worldrenderer.func_181662_b((double)this.field_148151_d, (double)this.field_148153_b, 0.0D).func_181673_a((double)((float)this.field_148151_d / f), (double)((float)(this.field_148153_b + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); -+ worldrenderer.func_181662_b((double)this.field_148152_e, (double)this.field_148153_b, 0.0D).func_181673_a((double)((float)this.field_148152_e / f), (double)((float)(this.field_148153_b + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); ++ buffer.func_181668_a(7, DefaultVertexFormats.field_181709_i); ++ buffer.func_181662_b((double)this.field_148152_e, (double)this.field_148154_c, 0.0D).func_187315_a((double)((float)this.field_148152_e / f), (double)((float)(this.field_148154_c + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); ++ buffer.func_181662_b((double)this.field_148151_d, (double)this.field_148154_c, 0.0D).func_187315_a((double)((float)this.field_148151_d / f), (double)((float)(this.field_148154_c + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); ++ buffer.func_181662_b((double)this.field_148151_d, (double)this.field_148153_b, 0.0D).func_187315_a((double)((float)this.field_148151_d / f), (double)((float)(this.field_148153_b + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); ++ buffer.func_181662_b((double)this.field_148152_e, (double)this.field_148153_b, 0.0D).func_187315_a((double)((float)this.field_148152_e / f), (double)((float)(this.field_148153_b + (int)this.field_148169_q) / f)).func_181669_b(32, 32, 32, 255).func_181675_d(); + tessellator.func_78381_a(); + } } diff --git a/patches/minecraft/net/minecraft/client/gui/GuiSpectator.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiSpectator.java.patch new file mode 100644 index 0000000000..75838aea9a --- /dev/null +++ b/patches/minecraft/net/minecraft/client/gui/GuiSpectator.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/net/minecraft/client/gui/GuiSpectator.java ++++ ../src-work/minecraft/net/minecraft/client/gui/GuiSpectator.java +@@ -109,7 +109,7 @@ + GlStateManager.func_179131_c(f, f, f, p_175266_4_); + p_175266_5_.func_178663_a(f, i); + GlStateManager.func_179121_F(); +- String s = String.valueOf((Object)GameSettings.func_74298_c(this.field_175268_g.field_71474_y.field_151456_ac[p_175266_1_].func_151463_i())); ++ String s = String.valueOf(this.field_175268_g.field_71474_y.field_151456_ac[p_175266_1_].getDisplayName()); + + if (i > 3 && p_175266_5_.func_178662_A_()) + { diff --git a/patches/minecraft/net/minecraft/client/gui/GuiUtilRenderComponents.java.patch b/patches/minecraft/net/minecraft/client/gui/GuiUtilRenderComponents.java.patch index be5f0a5aae..90631f9ae5 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiUtilRenderComponents.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/GuiUtilRenderComponents.java.patch @@ -5,6 +5,6 @@ } + s3 = FontRenderer.func_78282_e(s2) + s3; //Forge: Fix chat formatting not surviving line wrapping. - ChatComponentText chatcomponenttext2 = new ChatComponentText(s3); - chatcomponenttext2.func_150255_a(ichatcomponent1.func_150256_b().func_150232_l()); - list1.add(j + 1, chatcomponenttext2); + TextComponentString textcomponentstring2 = new TextComponentString(s3); + textcomponentstring2.func_150255_a(itextcomponent1.func_150256_b().func_150232_l()); + list1.add(j + 1, textcomponentstring2); diff --git a/patches/minecraft/net/minecraft/client/gui/ServerListEntryNormal.java.patch b/patches/minecraft/net/minecraft/client/gui/ServerListEntryNormal.java.patch index a79cd9dd2e..e3f9b78edd 100644 --- a/patches/minecraft/net/minecraft/client/gui/ServerListEntryNormal.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/ServerListEntryNormal.java.patch @@ -1,7 +1,7 @@ --- ../src-base/minecraft/net/minecraft/client/gui/ServerListEntryNormal.java +++ ../src-work/minecraft/net/minecraft/client/gui/ServerListEntryNormal.java @@ -82,7 +82,7 @@ - boolean flag1 = this.field_148301_e.field_82821_f < 47; + boolean flag1 = this.field_148301_e.field_82821_f < 107; boolean flag2 = flag || flag1; this.field_148300_d.field_71466_p.func_78276_b(this.field_148301_e.field_78847_a, p_180790_2_ + 32 + 3, p_180790_3_ + 1, 16777215); - List list = this.field_148300_d.field_71466_p.func_78271_c(this.field_148301_e.field_78843_d, p_180790_4_ - 32 - 2); diff --git a/patches/minecraft/net/minecraft/client/gui/achievement/GuiAchievements.java.patch b/patches/minecraft/net/minecraft/client/gui/achievement/GuiAchievements.java.patch index 5512b3cdcd..0155153ef3 100644 --- a/patches/minecraft/net/minecraft/client/gui/achievement/GuiAchievements.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/achievement/GuiAchievements.java.patch @@ -13,10 +13,10 @@ this.field_146562_a = p_i45026_1_; @@ -57,6 +61,14 @@ int j = 141; - this.field_146569_s = this.field_146567_u = this.field_146565_w = (double)(AchievementList.field_76004_f.field_75993_a * 24 - i / 2 - 12); - this.field_146568_t = this.field_146566_v = this.field_146573_x = (double)(AchievementList.field_76004_f.field_75991_b * 24 - j / 2); + this.field_146569_s = this.field_146567_u = this.field_146565_w = (double)(AchievementList.field_187982_f.field_75993_a * 24 - i / 2 - 12); + this.field_146568_t = this.field_146566_v = this.field_146573_x = (double)(AchievementList.field_187982_f.field_75991_b * 24 - j / 2); + minecraftAchievements.clear(); -+ for (Achievement achievement : AchievementList.field_76007_e) ++ for (Achievement achievement : AchievementList.field_187981_e) + { + if (!net.minecraftforge.common.AchievementPage.isAchievementInPages(achievement)) + { @@ -27,14 +27,14 @@ public void func_73866_w_() @@ -64,6 +76,7 @@ - this.field_146297_k.func_147114_u().func_147297_a(new C16PacketClientStatus(C16PacketClientStatus.EnumState.REQUEST_STATS)); + this.field_146297_k.func_147114_u().func_147297_a(new CPacketClientStatus(CPacketClientStatus.State.REQUEST_STATS)); this.field_146292_n.clear(); this.field_146292_n.add(new GuiOptionButton(1, this.field_146294_l / 2 + 24, this.field_146295_m / 2 + 74, 80, 20, I18n.func_135052_a("gui.done", new Object[0]))); + this.field_146292_n.add(button = new GuiButton(2, (field_146294_l - field_146555_f) / 2 + 24, field_146295_m / 2 + 74, 125, 20, net.minecraftforge.common.AchievementPage.getTitle(currentPage))); } protected void func_146284_a(GuiButton p_146284_1_) throws IOException -@@ -74,6 +87,16 @@ +@@ -74,12 +87,22 @@ { this.field_146297_k.func_147108_a(this.field_146562_a); } @@ -51,6 +51,13 @@ } } + protected void func_73869_a(char p_73869_1_, int p_73869_2_) throws IOException + { +- if (p_73869_2_ == this.field_146297_k.field_71474_y.field_151445_Q.func_151463_i()) ++ if (this.field_146297_k.field_71474_y.field_151445_Q.isActiveAndMatches(p_73869_2_)) + { + this.field_146297_k.func_147108_a((GuiScreen)null); + this.field_146297_k.func_71381_h(); @@ -257,7 +280,9 @@ GlStateManager.func_179143_c(518); GlStateManager.func_179094_E(); @@ -66,12 +73,11 @@ GlStateManager.func_179143_c(515); this.field_146297_k.func_110434_K().func_110577_a(field_146561_C); -- for (int j5 = 0; j5 < AchievementList.field_76007_e.size(); ++j5) +- for (int j5 = 0; j5 < AchievementList.field_187981_e.size(); ++j5) + java.util.List achievementList = (currentPage == -1 ? minecraftAchievements : net.minecraftforge.common.AchievementPage.getAchievementPage(currentPage).getAchievements()); + for (int j5 = 0; j5 < achievementList.size(); ++j5) { -- Achievement achievement1 = (Achievement)AchievementList.field_76007_e.get(j5); -+ Achievement achievement1 = achievementList.get(j5); + Achievement achievement1 = (Achievement)AchievementList.field_187981_e.get(j5); - if (achievement1.field_75992_c != null) + if (achievement1.field_75992_c != null && achievementList.contains(achievement1.field_75992_c)) @@ -82,10 +88,10 @@ GlStateManager.func_179091_B(); GlStateManager.func_179142_g(); -- for (int i6 = 0; i6 < AchievementList.field_76007_e.size(); ++i6) +- for (int i6 = 0; i6 < AchievementList.field_187981_e.size(); ++i6) + for (int i6 = 0; i6 < achievementList.size(); ++i6) { -- Achievement achievement2 = (Achievement)AchievementList.field_76007_e.get(i6); +- Achievement achievement2 = (Achievement)AchievementList.field_187981_e.get(i6); + Achievement achievement2 = achievementList.get(i6); int l6 = achievement2.field_75993_a * 24 - i; int j7 = achievement2.field_75991_b * 24 - j; @@ -114,4 +120,4 @@ + GlStateManager.func_179140_f(); //Forge: Make sure Lighting is disabled. Fixes MC-33065 GlStateManager.func_179089_o(); this.field_146296_j.func_180450_b(achievement2.field_75990_d, l6 + 3, j7 + 3); - GlStateManager.func_179112_b(770, 771); + GlStateManager.func_187401_a(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); diff --git a/patches/minecraft/net/minecraft/client/gui/achievement/GuiStats.java.patch b/patches/minecraft/net/minecraft/client/gui/achievement/GuiStats.java.patch deleted file mode 100644 index f2890750df..0000000000 --- a/patches/minecraft/net/minecraft/client/gui/achievement/GuiStats.java.patch +++ /dev/null @@ -1,69 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/client/gui/achievement/GuiStats.java -+++ ../src-work/minecraft/net/minecraft/client/gui/achievement/GuiStats.java -@@ -5,6 +5,8 @@ - import java.util.Collections; - import java.util.Comparator; - import java.util.List; -+ -+import net.minecraft.block.Block; - import net.minecraft.client.Minecraft; - import net.minecraft.client.audio.PositionedSoundRecord; - import net.minecraft.client.gui.GuiButton; -@@ -443,17 +445,18 @@ - for (StatCrafting statcrafting : StatList.field_75939_e) - { - boolean flag = false; -- int i = Item.func_150891_b(statcrafting.func_150959_a()); -+ int i = Block.func_149682_b(Block.func_149634_a(statcrafting.func_150959_a())); -+ int itemId = Item.func_150891_b(statcrafting.func_150959_a()); - - if (GuiStats.this.field_146546_t.func_77444_a(statcrafting) > 0) - { - flag = true; - } -- else if (StatList.field_75929_E[i] != null && GuiStats.this.field_146546_t.func_77444_a(StatList.field_75929_E[i]) > 0) -+ else if (StatList.field_75929_E[itemId] != null && GuiStats.this.field_146546_t.func_77444_a(StatList.field_75929_E[itemId]) > 0) - { - flag = true; - } -- else if (StatList.field_75928_D[i] != null && GuiStats.this.field_146546_t.func_77444_a(StatList.field_75928_D[i]) > 0) -+ else if (StatList.field_75928_D[itemId] != null && GuiStats.this.field_146546_t.func_77444_a(StatList.field_75928_D[itemId]) > 0) - { - flag = true; - } -@@ -468,8 +471,15 @@ - { - public int compare(StatCrafting p_compare_1_, StatCrafting p_compare_2_) - { -- int j = Item.func_150891_b(p_compare_1_.func_150959_a()); -- int k = Item.func_150891_b(p_compare_2_.func_150959_a()); -+ int j; -+ int k; -+ if (StatsBlock.this.field_148217_o == 2) { -+ j = Block.func_149682_b(Block.func_149634_a(p_compare_1_.func_150959_a())); -+ k = Block.func_149682_b(Block.func_149634_a(p_compare_2_.func_150959_a())); -+ } else { -+ j = Item.func_150891_b(p_compare_1_.func_150959_a()); -+ k = Item.func_150891_b(p_compare_2_.func_150959_a()); -+ } - StatBase statbase = null; - StatBase statbase1 = null; - -@@ -748,7 +758,7 @@ - super(p_i45510_2_, GuiStats.this.field_146294_l, GuiStats.this.field_146295_m, 32, GuiStats.this.field_146295_m - 64, GuiStats.this.field_146289_q.field_78288_b * 4); - this.func_148130_a(false); - -- for (EntityList.EntityEggInfo entitylist$entityegginfo : EntityList.field_75627_a.values()) -+ for (EntityList.EntityEggInfo entitylist$entityegginfo : com.google.common.collect.Iterables.concat(EntityList.field_75627_a.values(), net.minecraftforge.fml.common.registry.EntityRegistry.getEggs().values())) - { - if (GuiStats.this.field_146546_t.func_77444_a(entitylist$entityegginfo.field_151512_d) > 0 || GuiStats.this.field_146546_t.func_77444_a(entitylist$entityegginfo.field_151513_e) > 0) - { -@@ -784,7 +794,7 @@ - protected void func_180791_a(int p_180791_1_, int p_180791_2_, int p_180791_3_, int p_180791_4_, int p_180791_5_, int p_180791_6_) - { - EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)this.field_148222_l.get(p_180791_1_); -- String s = I18n.func_135052_a("entity." + EntityList.func_75617_a(entitylist$entityegginfo.field_75613_a) + ".name", new Object[0]); -+ String s = I18n.func_135052_a("entity." + entitylist$entityegginfo.name + ".name", new Object[0]); - int i = GuiStats.this.field_146546_t.func_77444_a(entitylist$entityegginfo.field_151512_d); - int j = GuiStats.this.field_146546_t.func_77444_a(entitylist$entityegginfo.field_151513_e); - String s1 = I18n.func_135052_a("stat.entityKills", new Object[] {Integer.valueOf(i), s}); diff --git a/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java.patch b/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java.patch index 2e03fc6d36..f557789781 100644 --- a/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java +++ ../src-work/minecraft/net/minecraft/client/gui/inventory/GuiContainer.java -@@ -175,8 +175,11 @@ +@@ -176,8 +176,11 @@ GlStateManager.func_179109_b(0.0F, 0.0F, 32.0F); this.field_73735_i = 200.0F; this.field_146296_j.field_77023_b = 200.0F; @@ -13,9 +13,9 @@ this.field_73735_i = 0.0F; this.field_146296_j.field_77023_b = 0.0F; } -@@ -239,13 +242,12 @@ +@@ -240,13 +243,12 @@ - if (itemstack == null) + if (itemstack == null && p_146977_1_.func_111238_b()) { - String s1 = p_146977_1_.func_178171_c(); + TextureAtlasSprite textureatlassprite = p_146977_1_.getBackgroundSprite(); @@ -30,7 +30,16 @@ this.func_175175_a(i, j, textureatlassprite, 16, 16); GlStateManager.func_179145_e(); flag1 = true; -@@ -326,6 +328,7 @@ +@@ -316,7 +318,7 @@ + protected void func_73864_a(int p_73864_1_, int p_73864_2_, int p_73864_3_) throws IOException + { + super.func_73864_a(p_73864_1_, p_73864_2_, p_73864_3_); +- boolean flag = p_73864_3_ == this.field_146297_k.field_71474_y.field_74322_I.func_151463_i() + 100; ++ boolean flag = this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(p_73864_3_ - 100); + Slot slot = this.func_146975_c(p_73864_1_, p_73864_2_); + long i = Minecraft.func_71386_F(); + this.field_146993_M = this.field_146998_K == slot && i - this.field_146997_J < 250L && this.field_146992_L == p_73864_3_; +@@ -327,6 +329,7 @@ int j = this.field_147003_i; int k = this.field_147009_r; boolean flag1 = p_73864_1_ < j || p_73864_2_ < k || p_73864_1_ >= j + this.field_146999_f || p_73864_2_ >= k + this.field_147000_g; @@ -38,7 +47,25 @@ int l = -1; if (slot != null) -@@ -463,10 +466,12 @@ +@@ -364,7 +367,7 @@ + { + if (this.field_146297_k.field_71439_g.field_71071_by.func_70445_o() == null) + { +- if (p_73864_3_ == this.field_146297_k.field_71474_y.field_74322_I.func_151463_i() + 100) ++ if (this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(p_73864_3_ - 100)) + { + this.func_184098_a(slot, l, p_73864_3_, ClickType.CLONE); + } +@@ -402,7 +405,7 @@ + { + this.field_146987_F = 1; + } +- else if (p_73864_3_ == this.field_146297_k.field_71474_y.field_74322_I.func_151463_i() + 100) ++ else if (this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(p_73864_3_ - 100)) + { + this.field_146987_F = 2; + } +@@ -464,10 +467,12 @@ protected void func_146286_b(int p_146286_1_, int p_146286_2_, int p_146286_3_) { @@ -51,7 +78,48 @@ int k = -1; if (slot != null) -@@ -685,4 +690,16 @@ +@@ -575,7 +580,7 @@ + } + else if (this.field_146297_k.field_71439_g.field_71071_by.func_70445_o() != null) + { +- if (p_146286_3_ == this.field_146297_k.field_71474_y.field_74322_I.func_151463_i() + 100) ++ if (this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(p_146286_3_ - 100)) + { + this.func_184098_a(slot, k, p_146286_3_, ClickType.CLONE); + } +@@ -627,7 +632,7 @@ + + protected void func_73869_a(char p_73869_1_, int p_73869_2_) throws IOException + { +- if (p_73869_2_ == 1 || p_73869_2_ == this.field_146297_k.field_71474_y.field_151445_Q.func_151463_i()) ++ if (p_73869_2_ == 1 || this.field_146297_k.field_71474_y.field_151445_Q.isActiveAndMatches(p_73869_2_)) + { + this.field_146297_k.field_71439_g.func_71053_j(); + } +@@ -636,11 +641,11 @@ + + if (this.field_147006_u != null && this.field_147006_u.func_75216_d()) + { +- if (p_73869_2_ == this.field_146297_k.field_71474_y.field_74322_I.func_151463_i()) ++ if (this.field_146297_k.field_71474_y.field_74322_I.isActiveAndMatches(p_73869_2_)) + { + this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, 0, ClickType.CLONE); + } +- else if (p_73869_2_ == this.field_146297_k.field_71474_y.field_74316_C.func_151463_i()) ++ else if (this.field_146297_k.field_71474_y.field_74316_C.isActiveAndMatches(p_73869_2_)) + { + this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, func_146271_m() ? 1 : 0, ClickType.THROW); + } +@@ -653,7 +658,7 @@ + { + for (int i = 0; i < 9; ++i) + { +- if (p_146983_1_ == this.field_146297_k.field_71474_y.field_151456_ac[i].func_151463_i()) ++ if (this.field_146297_k.field_71474_y.field_151456_ac[i].isActiveAndMatches(p_146983_1_)) + { + this.func_184098_a(this.field_147006_u, this.field_147006_u.field_75222_d, i, ClickType.SWAP); + return true; +@@ -686,4 +691,16 @@ this.field_146297_k.field_71439_g.func_71053_j(); } } diff --git a/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainerCreative.java.patch b/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainerCreative.java.patch index 671aff30bd..a4786eeeb2 100644 --- a/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainerCreative.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/inventory/GuiContainerCreative.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/gui/inventory/GuiContainerCreative.java +++ ../src-work/minecraft/net/minecraft/client/gui/inventory/GuiContainerCreative.java -@@ -48,6 +48,8 @@ +@@ -49,6 +49,8 @@ private Slot field_147064_C; private boolean field_147057_D; private CreativeCrafting field_147059_E; @@ -9,16 +9,7 @@ public GuiContainerCreative(EntityPlayer p_i1088_1_) { -@@ -175,7 +177,7 @@ - return; - } - -- if (itemstack1 != null && itemstack2 != null && itemstack1.func_77969_a(itemstack2)) -+ if (itemstack1 != null && itemstack2 != null && itemstack1.func_77969_a(itemstack2) && ItemStack.func_77970_a(itemstack1, itemstack2)) //Forge: Bugfix, Compare NBT data, allow for deletion of enchanted books, MC-12770 - { - if (p_146984_3_ == 0) - { -@@ -259,6 +261,13 @@ +@@ -258,6 +260,13 @@ this.func_147050_b(CreativeTabs.field_78032_a[i]); this.field_147059_E = new CreativeCrafting(this.field_146297_k); this.field_146297_k.field_71439_g.field_71069_bz.func_75132_a(this.field_147059_E); @@ -32,7 +23,7 @@ } else { -@@ -280,7 +289,7 @@ +@@ -279,7 +288,7 @@ protected void func_73869_a(char p_73869_1_, int p_73869_2_) throws IOException { @@ -41,7 +32,7 @@ { if (GameSettings.func_100015_a(this.field_146297_k.field_71474_y.field_74310_D)) { -@@ -318,6 +327,14 @@ +@@ -317,6 +326,14 @@ GuiContainerCreative.ContainerCreative guicontainercreative$containercreative = (GuiContainerCreative.ContainerCreative)this.field_147002_h; guicontainercreative$containercreative.field_148330_a.clear(); @@ -56,7 +47,7 @@ for (Item item : Item.field_150901_e) { if (item != null && item.func_77640_w() != null) -@@ -325,7 +342,13 @@ +@@ -324,7 +341,13 @@ item.func_150895_a(item, (CreativeTabs)null, guicontainercreative$containercreative.field_148330_a); } } @@ -66,11 +57,11 @@ + //split from above for custom search tabs + private void updateFilteredItems(GuiContainerCreative.ContainerCreative guicontainercreative$containercreative) + { -+ if (CreativeTabs.field_78032_a[field_147058_w] == CreativeTabs.field_78027_g) // FORGE: Only add enchanted books to the regular search - for (Enchantment enchantment : Enchantment.field_77331_b) ++ if (CreativeTabs.field_78032_a[field_147058_w] == CreativeTabs.field_78027_g) // FORGE: Only add enchanted books to the regular search + for (Enchantment enchantment : Enchantment.field_185264_b) { if (enchantment != null && enchantment.field_77351_y != null) -@@ -333,7 +356,6 @@ +@@ -332,7 +355,6 @@ Items.field_151134_bR.func_92113_a(enchantment, guicontainercreative$containercreative.field_148330_a); } } @@ -78,7 +69,7 @@ Iterator iterator = guicontainercreative$containercreative.field_148330_a.iterator(); String s1 = this.field_147062_A.func_146179_b().toLowerCase(); -@@ -365,7 +387,7 @@ +@@ -364,7 +386,7 @@ { CreativeTabs creativetabs = CreativeTabs.field_78032_a[field_147058_w]; @@ -87,7 +78,7 @@ { GlStateManager.func_179084_k(); this.field_146289_q.func_78276_b(I18n.func_135052_a(creativetabs.func_78024_c(), new Object[0]), 8, 6, 4210752); -@@ -400,7 +422,7 @@ +@@ -399,7 +421,7 @@ for (CreativeTabs creativetabs : CreativeTabs.field_78032_a) { @@ -96,7 +87,7 @@ { this.func_147050_b(creativetabs); return; -@@ -413,11 +435,13 @@ +@@ -412,11 +434,13 @@ private boolean func_147055_p() { @@ -110,7 +101,7 @@ int i = field_147058_w; field_147058_w = p_147050_1_.func_78021_a(); GuiContainerCreative.ContainerCreative guicontainercreative$containercreative = (GuiContainerCreative.ContainerCreative)this.field_147002_h; -@@ -483,12 +507,14 @@ +@@ -487,12 +511,14 @@ if (this.field_147062_A != null) { @@ -126,7 +117,7 @@ this.func_147053_i(); } else -@@ -558,20 +584,43 @@ +@@ -562,20 +588,43 @@ } super.func_73863_a(p_73863_1_, p_73863_2_, p_73863_3_); @@ -171,7 +162,7 @@ GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.func_179140_f(); } -@@ -633,16 +682,35 @@ +@@ -637,16 +686,35 @@ RenderHelper.func_74520_c(); CreativeTabs creativetabs = CreativeTabs.field_78032_a[field_147058_w]; @@ -208,7 +199,7 @@ this.field_146297_k.func_110434_K().func_110577_a(new ResourceLocation("textures/gui/container/creative_inventory/tab_" + creativetabs.func_78015_f())); this.func_73729_b(this.field_147003_i, this.field_147009_r, 0, 0, this.field_146999_f, this.field_147000_g); this.field_147062_A.func_146194_f(); -@@ -657,6 +725,14 @@ +@@ -661,6 +729,14 @@ this.func_73729_b(i, j + (int)((float)(k - j - 17) * this.field_147067_x), 232 + (this.func_147055_p() ? 0 : 12), 0, 12, 15); } @@ -223,7 +214,7 @@ this.func_147051_a(creativetabs); if (creativetabs == CreativeTabs.field_78036_m) -@@ -667,6 +743,14 @@ +@@ -671,6 +747,14 @@ protected boolean func_147049_a(CreativeTabs p_147049_1_, int p_147049_2_, int p_147049_3_) { @@ -238,7 +229,7 @@ int i = p_147049_1_.func_78020_k(); int j = 28 * i; int k = 0; -@@ -763,6 +847,8 @@ +@@ -767,6 +851,8 @@ } GlStateManager.func_179140_f(); @@ -247,7 +238,7 @@ this.func_73729_b(l, i1, j, k, 28, j1); this.field_73735_i = 100.0F; this.field_146296_j.field_77023_b = 100.0F; -@@ -789,6 +875,15 @@ +@@ -793,6 +879,15 @@ { this.field_146297_k.func_147108_a(new GuiStats(this, this.field_146297_k.field_71439_g.func_146107_m())); } diff --git a/patches/minecraft/net/minecraft/client/model/ModelBox.java.patch b/patches/minecraft/net/minecraft/client/model/ModelBox.java.patch index d91355e164..387c496162 100644 --- a/patches/minecraft/net/minecraft/client/model/ModelBox.java.patch +++ b/patches/minecraft/net/minecraft/client/model/ModelBox.java.patch @@ -13,6 +13,6 @@ } + @SideOnly(Side.CLIENT) - public void func_178780_a(WorldRenderer p_178780_1_, float p_178780_2_) + public void func_178780_a(VertexBuffer p_178780_1_, float p_178780_2_) { for (int i = 0; i < this.field_78254_i.length; ++i) diff --git a/patches/minecraft/net/minecraft/client/model/ModelRenderer.java.patch b/patches/minecraft/net/minecraft/client/model/ModelRenderer.java.patch index 77e0a42cb2..4962d8769a 100644 --- a/patches/minecraft/net/minecraft/client/model/ModelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/model/ModelRenderer.java.patch @@ -1,14 +1,14 @@ --- ../src-base/minecraft/net/minecraft/client/model/ModelRenderer.java +++ ../src-work/minecraft/net/minecraft/client/model/ModelRenderer.java -@@ -10,7 +10,6 @@ +@@ -9,7 +9,6 @@ + import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; - import org.lwjgl.opengl.GL11; -@SideOnly(Side.CLIENT) public class ModelRenderer { public float field_78801_a; -@@ -109,6 +108,7 @@ +@@ -108,6 +107,7 @@ this.field_78798_e = p_78793_3_; } @@ -16,7 +16,7 @@ public void func_78785_a(float p_78785_1_) { if (!this.field_78807_k) -@@ -190,6 +190,7 @@ +@@ -189,6 +189,7 @@ } } @@ -24,7 +24,7 @@ public void func_78791_b(float p_78791_1_) { if (!this.field_78807_k) -@@ -225,6 +226,7 @@ +@@ -224,6 +225,7 @@ } } @@ -32,7 +32,7 @@ public void func_78794_c(float p_78794_1_) { if (!this.field_78807_k) -@@ -266,6 +268,7 @@ +@@ -265,6 +267,7 @@ } } diff --git a/patches/minecraft/net/minecraft/client/model/PositionTextureVertex.java.patch b/patches/minecraft/net/minecraft/client/model/PositionTextureVertex.java.patch index dbe66e3035..307bb90b30 100644 --- a/patches/minecraft/net/minecraft/client/model/PositionTextureVertex.java.patch +++ b/patches/minecraft/net/minecraft/client/model/PositionTextureVertex.java.patch @@ -3,11 +3,11 @@ @@ -1,10 +1,7 @@ package net.minecraft.client.model; - import net.minecraft.util.Vec3; + import net.minecraft.util.math.Vec3d; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -@SideOnly(Side.CLIENT) public class PositionTextureVertex { - public Vec3 field_78243_a; + public Vec3d field_78243_a; diff --git a/patches/minecraft/net/minecraft/client/model/TexturedQuad.java.patch b/patches/minecraft/net/minecraft/client/model/TexturedQuad.java.patch index ea7d9cd311..860a67a8b8 100644 --- a/patches/minecraft/net/minecraft/client/model/TexturedQuad.java.patch +++ b/patches/minecraft/net/minecraft/client/model/TexturedQuad.java.patch @@ -1,13 +1,18 @@ --- ../src-base/minecraft/net/minecraft/client/model/TexturedQuad.java +++ ../src-work/minecraft/net/minecraft/client/model/TexturedQuad.java -@@ -4,10 +4,7 @@ - import net.minecraft.client.renderer.WorldRenderer; - import net.minecraft.client.renderer.vertex.DefaultVertexFormats; - import net.minecraft.util.Vec3; --import net.minecraftforge.fml.relauncher.Side; --import net.minecraftforge.fml.relauncher.SideOnly; +@@ -7,7 +7,6 @@ + import net.minecraftforge.fml.relauncher.Side; + import net.minecraftforge.fml.relauncher.SideOnly; -@SideOnly(Side.CLIENT) public class TexturedQuad { public PositionTextureVertex[] field_78239_a; +@@ -43,6 +42,7 @@ + this.field_78239_a = apositiontexturevertex; + } + ++ @SideOnly(Side.CLIENT) + public void func_178765_a(VertexBuffer p_178765_1_, float p_178765_2_) + { + Vec3d vec3d = this.field_78239_a[1].field_78243_a.func_72444_a(this.field_78239_a[0].field_78243_a); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/ChunkProviderClient.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/ChunkProviderClient.java.patch index feb70661e7..97d95aea61 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/ChunkProviderClient.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/ChunkProviderClient.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/multiplayer/ChunkProviderClient.java +++ ../src-work/minecraft/net/minecraft/client/multiplayer/ChunkProviderClient.java -@@ -55,6 +55,7 @@ +@@ -52,6 +52,7 @@ Chunk chunk = new Chunk(this.field_73235_d, p_73158_1_, p_73158_2_); this.field_73236_b.func_76163_a(ChunkCoordIntPair.func_77272_a(p_73158_1_, p_73158_2_), chunk); this.field_73237_c.add(chunk); diff --git a/patches/minecraft/net/minecraft/client/multiplayer/GuiConnecting.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/GuiConnecting.java.patch index fbd519d254..0d82da59b0 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/GuiConnecting.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/GuiConnecting.java.patch @@ -4,8 +4,8 @@ inetaddress = InetAddress.getByName(p_146367_1_); GuiConnecting.this.field_146371_g = NetworkManager.func_181124_a(inetaddress, p_146367_2_, GuiConnecting.this.field_146297_k.field_71474_y.func_181148_f()); GuiConnecting.this.field_146371_g.func_150719_a(new NetHandlerLoginClient(GuiConnecting.this.field_146371_g, GuiConnecting.this.field_146297_k, GuiConnecting.this.field_146374_i)); -- GuiConnecting.this.field_146371_g.func_179290_a(new C00Handshake(47, p_146367_1_, p_146367_2_, EnumConnectionState.LOGIN)); -+ GuiConnecting.this.field_146371_g.func_179290_a(new C00Handshake(47, p_146367_1_, p_146367_2_, EnumConnectionState.LOGIN, true)); - GuiConnecting.this.field_146371_g.func_179290_a(new C00PacketLoginStart(GuiConnecting.this.field_146297_k.func_110432_I().func_148256_e())); +- GuiConnecting.this.field_146371_g.func_179290_a(new C00Handshake(107, p_146367_1_, p_146367_2_, EnumConnectionState.LOGIN)); ++ GuiConnecting.this.field_146371_g.func_179290_a(new C00Handshake(107, p_146367_1_, p_146367_2_, EnumConnectionState.LOGIN, true)); + GuiConnecting.this.field_146371_g.func_179290_a(new CPacketLoginStart(GuiConnecting.this.field_146297_k.func_110432_I().func_148256_e())); } catch (UnknownHostException unknownhostexception) diff --git a/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch index 891b51bc7c..b9fcfafa15 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java.patch @@ -1,87 +1,156 @@ --- ../src-base/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java +++ ../src-work/minecraft/net/minecraft/client/multiplayer/PlayerControllerMP.java -@@ -111,6 +111,12 @@ +@@ -121,6 +121,12 @@ } } -+ ItemStack stack = field_78776_a.field_71439_g.func_71045_bC(); -+ if (stack != null && stack.func_77973_b() != null && stack.func_77973_b().onBlockStartBreak(stack, p_178888_1_, field_78776_a.field_71439_g)) ++ ItemStack stack = field_78776_a.field_71439_g.func_184614_ca(); ++ if (stack != null && stack.func_77973_b() != null && stack.func_77973_b().onBlockStartBreak(stack, p_187103_1_, field_78776_a.field_71439_g)) + { + return false; + } + - if (this.field_78779_k.func_77145_d() && this.field_78776_a.field_71439_g.func_70694_bm() != null && this.field_78776_a.field_71439_g.func_70694_bm().func_77973_b() instanceof ItemSword) + if (this.field_78779_k.func_77145_d() && this.field_78776_a.field_71439_g.func_184614_ca() != null && this.field_78776_a.field_71439_g.func_184614_ca().func_77973_b() instanceof ItemSword) { return false; -@@ -128,13 +134,7 @@ +@@ -142,14 +148,7 @@ else { - world.func_175718_b(2001, p_178888_1_, Block.func_176210_f(iblockstate)); -- boolean flag = world.func_175698_g(p_178888_1_); + world.func_175718_b(2001, p_187103_1_, Block.func_176210_f(iblockstate)); +- block.func_176208_a(world, p_187103_1_, iblockstate, this.field_78776_a.field_71439_g); +- boolean flag = world.func_180501_a(p_187103_1_, Blocks.field_150350_a.func_176223_P(), 11); - if (flag) - { -- block1.func_176206_d(world, p_178888_1_, iblockstate); +- block.func_176206_d(world, p_187103_1_, iblockstate); - } - this.field_178895_c = new BlockPos(this.field_178895_c.func_177958_n(), -1, this.field_178895_c.func_177952_p()); if (!this.field_78779_k.func_77145_d()) -@@ -152,6 +152,12 @@ +@@ -160,13 +159,20 @@ + { + itemstack1.func_179548_a(world, iblockstate, p_187103_1_, this.field_78776_a.field_71439_g); + +- if (itemstack1.field_77994_a == 0) ++ if (itemstack1.field_77994_a <= 0) + { ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.field_78776_a.field_71439_g, itemstack1, EnumHand.MAIN_HAND); + this.field_78776_a.field_71439_g.func_184611_a(EnumHand.MAIN_HAND, (ItemStack)null); + } } } -+ boolean flag = block1.removedByPlayer(world, p_178888_1_, field_78776_a.field_71439_g, false); ++ boolean flag = block.removedByPlayer(iblockstate, world, p_187103_1_, field_78776_a.field_71439_g, false); + + if (flag) + { -+ block1.func_176206_d(world, p_178888_1_, iblockstate); ++ block.func_176206_d(world, p_187103_1_, iblockstate); + } return flag; } } -@@ -356,11 +362,19 @@ - { - if (this.field_78779_k != WorldSettings.GameType.SPECTATOR) - { -+ -+ if (p_178890_3_ != null && -+ p_178890_3_.func_77973_b() != null && -+ p_178890_3_.func_77973_b().onItemUseFirst(p_178890_3_, p_178890_1_, p_178890_2_, p_178890_4_, p_178890_5_, f, f1, f2)) -+ { -+ return true; -+ } -+ - IBlockState iblockstate = p_178890_2_.func_180495_p(p_178890_4_); - -- if ((!p_178890_1_.func_70093_af() || p_178890_1_.func_70694_bm() == null) && iblockstate.func_177230_c().func_180639_a(p_178890_2_, p_178890_4_, iblockstate, p_178890_1_, p_178890_5_, f, f1, f2)) -+ if ((!p_178890_1_.func_70093_af() || p_178890_1_.func_70694_bm() == null || p_178890_1_.func_70694_bm().func_77973_b().doesSneakBypassUse(p_178890_2_, p_178890_4_, p_178890_1_))) - { -- flag = true; -+ flag = iblockstate.func_177230_c().func_180639_a(p_178890_2_, p_178890_4_, iblockstate, p_178890_1_, p_178890_5_, f, f1, f2); +@@ -217,14 +223,17 @@ } - if (!flag && p_178890_3_ != null && p_178890_3_.func_77973_b() instanceof ItemBlock) -@@ -393,7 +407,9 @@ + this.field_78774_b.func_147297_a(new CPacketPlayerDigging(CPacketPlayerDigging.Action.START_DESTROY_BLOCK, p_180511_1_, p_180511_2_)); ++ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(this.field_78776_a.field_71439_g, p_180511_1_, p_180511_2_, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(this.field_78776_a.field_71439_g, func_78757_d() + 1)); ++ + IBlockState iblockstate = this.field_78776_a.field_71441_e.func_180495_p(p_180511_1_); + boolean flag = iblockstate.func_185904_a() != Material.field_151579_a; + + if (flag && this.field_78770_f == 0.0F) + { ++ if (event.getUseBlock() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) + iblockstate.func_177230_c().func_180649_a(this.field_78776_a.field_71441_e, p_180511_1_, this.field_78776_a.field_71439_g); + } +- ++ if (event.getUseItem() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return true; + if (flag && iblockstate.func_185903_a(this.field_78776_a.field_71439_g, this.field_78776_a.field_71439_g.field_70170_p, p_180511_1_) >= 1.0F) + { + this.func_187103_a(p_180511_1_); +@@ -371,13 +380,32 @@ + } + else + { ++ net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks ++ .onRightClickBlock(p_187099_1_, p_187099_7_, p_187099_3_, p_187099_4_, p_187099_5_, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(p_187099_1_, func_78757_d() + 1)); ++ if (event.isCanceled()) ++ { ++ // Give the server a chance to fire event as well. That way server event is not dependant on client event. ++ this.field_78774_b.func_147297_a(new CPacketPlayerTryUseItem(p_187099_4_, p_187099_5_, p_187099_7_, f, f1, f2)); ++ return EnumActionResult.PASS; ++ } ++ EnumActionResult result = EnumActionResult.PASS; ++ + if (this.field_78779_k != WorldSettings.GameType.SPECTATOR) + { ++ net.minecraft.item.Item item = p_187099_3_ == null ? null : p_187099_3_.func_77973_b(); ++ EnumActionResult ret = item == null ? EnumActionResult.PASS : item.onItemUseFirst(p_187099_3_, p_187099_1_, p_187099_2_, p_187099_4_, p_187099_5_, f, f1, f2, p_187099_7_); ++ if (ret != EnumActionResult.PASS) return ret; ++ + IBlockState iblockstate = p_187099_2_.func_180495_p(p_187099_4_); ++ boolean bypass = true; ++ for (ItemStack s : new ItemStack[]{p_187099_1_.func_184614_ca(), p_187099_1_.func_184592_cb()}) //TODO: Expand to more hands? player.inv.getHands()? ++ bypass = bypass && (s == null || s.func_77973_b().doesSneakBypassUse(s, p_187099_2_, p_187099_4_, p_187099_1_)); + +- if ((!p_187099_1_.func_70093_af() || p_187099_1_.func_184614_ca() == null && p_187099_1_.func_184592_cb() == null) && iblockstate.func_177230_c().func_180639_a(p_187099_2_, p_187099_4_, iblockstate, p_187099_1_, p_187099_7_, p_187099_3_, p_187099_5_, f, f1, f2)) ++ if (!p_187099_1_.func_70093_af() || bypass || event.getUseBlock() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW) + { +- flag = true; ++ if(event.getUseBlock() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) ++ flag = iblockstate.func_177230_c().func_180639_a(p_187099_2_, p_187099_4_, iblockstate, p_187099_1_, p_187099_7_, p_187099_3_, p_187099_5_, f, f1, f2); ++ if(flag) result = EnumActionResult.SUCCESS; + } + + if (!flag && p_187099_3_ != null && p_187099_3_.func_77973_b() instanceof ItemBlock) +@@ -393,7 +421,7 @@ + + this.field_78774_b.func_147297_a(new CPacketPlayerTryUseItem(p_187099_4_, p_187099_5_, p_187099_7_, f, f1, f2)); + +- if (!flag && this.field_78779_k != WorldSettings.GameType.SPECTATOR) ++ if (!flag && this.field_78779_k != WorldSettings.GameType.SPECTATOR || event.getUseItem() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW) + { + if (p_187099_3_ == null) + { +@@ -411,14 +439,19 @@ + { + int i = p_187099_3_.func_77960_j(); + int j = p_187099_3_.field_77994_a; ++ if (event.getUseItem() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) { + EnumActionResult enumactionresult = p_187099_3_.func_179546_a(p_187099_1_, p_187099_2_, p_187099_4_, p_187099_7_, p_187099_5_, f, f1, f2); + p_187099_3_.func_77964_b(i); + p_187099_3_.field_77994_a = j; + return enumactionresult; ++ } else return result; } else { -- return p_178890_3_.func_179546_a(p_178890_1_, p_178890_2_, p_178890_4_, p_178890_5_, f, f1, f2); -+ if (!p_178890_3_.func_179546_a(p_178890_1_, p_178890_2_, p_178890_4_, p_178890_5_, f, f1, f2)) return false; -+ if (p_178890_3_.field_77994_a <= 0) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_178890_1_, p_178890_3_); -+ return true; +- return p_187099_3_.func_179546_a(p_187099_1_, p_187099_2_, p_187099_4_, p_187099_7_, p_187099_5_, f, f1, f2); ++ if (event.getUseItem() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) ++ result = p_187099_3_.func_179546_a(p_187099_1_, p_187099_2_, p_187099_4_, p_187099_7_, p_187099_5_, f, f1, f2); ++ if (p_187099_3_.field_77994_a <= 0) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_187099_1_, p_187099_3_, p_187099_7_); ++ return result; } } else -@@ -420,9 +436,10 @@ +@@ -445,6 +478,7 @@ + } + else { - p_78769_1_.field_71071_by.field_70462_a[p_78769_1_.field_71071_by.field_70461_c] = itemstack; - -- if (itemstack.field_77994_a == 0) -+ if (itemstack.field_77994_a <= 0) ++ if (net.minecraftforge.common.ForgeHooks.onItemRightClick(p_187101_1_, p_187101_4_, p_187101_3_)) return net.minecraft.util.EnumActionResult.PASS; + int i = p_187101_3_.field_77994_a; + ActionResult actionresult = p_187101_3_.func_77957_a(p_187101_2_, p_187101_1_, p_187101_4_); + ItemStack itemstack = (ItemStack)actionresult.func_188398_b(); +@@ -453,9 +487,10 @@ { - p_78769_1_.field_71071_by.field_70462_a[p_78769_1_.field_71071_by.field_70461_c] = null; -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_78769_1_, itemstack); + p_187101_1_.func_184611_a(p_187101_4_, itemstack); + +- if (itemstack.field_77994_a == 0) ++ if (itemstack.field_77994_a <= 0) + { + p_187101_1_.func_184611_a(p_187101_4_, (ItemStack)null); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_187101_1_, itemstack, p_187101_4_); + } } - return true; diff --git a/patches/minecraft/net/minecraft/client/multiplayer/WorldClient.java.patch b/patches/minecraft/net/minecraft/client/multiplayer/WorldClient.java.patch index 0996e6ecd5..8d7f15464f 100644 --- a/patches/minecraft/net/minecraft/client/multiplayer/WorldClient.java.patch +++ b/patches/minecraft/net/minecraft/client/multiplayer/WorldClient.java.patch @@ -1,7 +1,13 @@ --- ../src-base/minecraft/net/minecraft/client/multiplayer/WorldClient.java +++ ../src-work/minecraft/net/minecraft/client/multiplayer/WorldClient.java -@@ -52,12 +52,13 @@ - super(new SaveHandlerMP(), new WorldInfo(p_i45063_2_, "MpServer"), WorldProvider.func_76570_a(p_i45063_3_), p_i45063_5_, true); +@@ -58,17 +58,18 @@ + + public WorldClient(NetHandlerPlayClient p_i45063_1_, WorldSettings p_i45063_2_, int p_i45063_3_, EnumDifficulty p_i45063_4_, Profiler p_i45063_5_) + { +- super(new SaveHandlerMP(), new WorldInfo(p_i45063_2_, "MpServer"), DimensionType.func_186069_a(p_i45063_3_).func_186070_d(), p_i45063_5_, true); ++ super(new SaveHandlerMP(), new WorldInfo(p_i45063_2_, "MpServer"), net.minecraftforge.common.DimensionManager.createProviderFor(p_i45063_3_), p_i45063_5_, true); + this.field_184158_M = this.field_73012_v.nextInt(12000); + this.field_184157_a = Sets.newHashSet(); this.field_73035_a = p_i45063_1_; this.func_72912_H().func_176144_a(p_i45063_4_); - this.func_175652_B(new BlockPos(8, 64, 8)); diff --git a/patches/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java.patch b/patches/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java.patch index 4456528880..5d54f059fe 100644 --- a/patches/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java.patch +++ b/patches/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java +++ ../src-work/minecraft/net/minecraft/client/network/NetHandlerLoginClient.java -@@ -104,7 +104,10 @@ +@@ -106,7 +106,10 @@ { this.field_175091_e = p_147390_1_.func_179730_a(); this.field_147393_d.func_150723_a(EnumConnectionState.PLAY); @@ -11,4 +11,4 @@ + net.minecraftforge.fml.client.FMLClientHandler.instance().setPlayClient(nhpc); } - public void func_147231_a(IChatComponent p_147231_1_) + public void func_147231_a(ITextComponent p_147231_1_) diff --git a/patches/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java.patch b/patches/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java.patch index 4fa630f5fd..61b8bd175b 100644 --- a/patches/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java.patch +++ b/patches/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java +++ ../src-work/minecraft/net/minecraft/client/network/NetHandlerPlayClient.java -@@ -246,7 +246,7 @@ +@@ -267,7 +267,7 @@ { PacketThreadUtil.func_180031_a(p_147282_1_, this, this.field_147299_f); this.field_147299_f.field_71442_b = new PlayerControllerMP(this.field_147299_f, this); @@ -9,11 +9,11 @@ this.field_147299_f.field_71474_y.field_74318_M = p_147282_1_.func_149192_g(); this.field_147299_f.func_71403_a(this.field_147300_g); this.field_147299_f.field_71439_g.field_71093_bK = p_147282_1_.func_149194_f(); -@@ -750,14 +750,16 @@ - public void func_147251_a(S02PacketChat p_147251_1_) +@@ -785,14 +785,16 @@ + public void func_147251_a(SPacketChat p_147251_1_) { PacketThreadUtil.func_180031_a(p_147251_1_, this, this.field_147299_f); -+ net.minecraft.util.IChatComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(p_147251_1_.func_179841_c(), p_147251_1_.func_148915_c()); ++ net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(p_147251_1_.func_179841_c(), p_147251_1_.func_148915_c()); + if (message == null) return; if (p_147251_1_.func_179841_c() == 2) @@ -28,7 +28,7 @@ } } -@@ -808,6 +810,11 @@ +@@ -848,6 +850,11 @@ float f = (float)(p_147281_1_.func_149028_l() * 360) / 256.0F; float f1 = (float)(p_147281_1_.func_149030_m() * 360) / 256.0F; EntityLivingBase entitylivingbase = (EntityLivingBase)EntityList.func_75616_a(p_147281_1_.func_149025_e(), this.field_147299_f.field_71441_e); @@ -37,10 +37,19 @@ + net.minecraftforge.fml.common.FMLLog.info("Server attempted to spawn an unknown entity using ID: {0} at ({1}, {2}, {3}) Skipping!", p_147281_1_.func_149025_e(), d0, d1, d2); + return; + } - entitylivingbase.field_70118_ct = p_147281_1_.func_149023_f(); - entitylivingbase.field_70117_cu = p_147281_1_.func_149034_g(); - entitylivingbase.field_70116_cv = p_147281_1_.func_149029_h(); -@@ -1133,6 +1140,10 @@ + EntityTracker.func_187254_a(entitylivingbase, d0, d1, d2); + entitylivingbase.field_70761_aq = entitylivingbase.field_70759_as = (float)(p_147281_1_.func_149032_n() * 360) / 256.0F; + Entity[] aentity = entitylivingbase.func_70021_al(); +@@ -919,7 +926,7 @@ + + if (entity1 == this.field_147299_f.field_71439_g && !flag) + { +- this.field_147299_f.field_71456_v.func_110326_a(I18n.func_135052_a("mount.onboard", new Object[] {GameSettings.func_74298_c(this.field_147299_f.field_71474_y.field_74311_E.func_151463_i())}), false); ++ this.field_147299_f.field_71456_v.func_110326_a(I18n.func_135052_a("mount.onboard", new Object[] {this.field_147299_f.field_71474_y.field_74311_E.getDisplayName()}), false); + } + } + } +@@ -1179,6 +1186,10 @@ { tileentity.func_145839_a(p_147273_1_.func_148857_g()); } @@ -48,15 +57,34 @@ + { + tileentity.onDataPacket(field_147302_e, p_147273_1_); + } - } - } -@@ -1341,7 +1352,7 @@ + if (flag && this.field_147299_f.field_71462_r instanceof GuiCommandBlock) + { +@@ -1276,15 +1287,15 @@ + } + else if (f == 101.0F) + { +- this.field_147299_f.field_71456_v.func_146158_b().func_146227_a(new TextComponentTranslation("demo.help.movement", new Object[] {GameSettings.func_74298_c(gamesettings.field_74351_w.func_151463_i()), GameSettings.func_74298_c(gamesettings.field_74370_x.func_151463_i()), GameSettings.func_74298_c(gamesettings.field_74368_y.func_151463_i()), GameSettings.func_74298_c(gamesettings.field_74366_z.func_151463_i())})); ++ this.field_147299_f.field_71456_v.func_146158_b().func_146227_a(new TextComponentTranslation("demo.help.movement", new Object[] {gamesettings.field_74351_w.getDisplayName(), gamesettings.field_74370_x.getDisplayName(), gamesettings.field_74368_y.getDisplayName(), gamesettings.field_74366_z.getDisplayName()})); + } + else if (f == 102.0F) + { +- this.field_147299_f.field_71456_v.func_146158_b().func_146227_a(new TextComponentTranslation("demo.help.jump", new Object[] {GameSettings.func_74298_c(gamesettings.field_74314_A.func_151463_i())})); ++ this.field_147299_f.field_71456_v.func_146158_b().func_146227_a(new TextComponentTranslation("demo.help.jump", new Object[] {gamesettings.field_74314_A.getDisplayName()})); + } + else if (f == 103.0F) + { +- this.field_147299_f.field_71456_v.func_146158_b().func_146227_a(new TextComponentTranslation("demo.help.inventory", new Object[] {GameSettings.func_74298_c(gamesettings.field_151445_Q.func_151463_i())})); ++ this.field_147299_f.field_71456_v.func_146158_b().func_146227_a(new TextComponentTranslation("demo.help.inventory", new Object[] {gamesettings.field_151445_Q.getDisplayName()})); + } + } + else if (i == 6) +@@ -1378,7 +1389,7 @@ if (entity instanceof EntityLivingBase) { -- PotionEffect potioneffect = new PotionEffect(p_147260_1_.func_149427_e(), p_147260_1_.func_180755_e(), p_147260_1_.func_149428_f(), false, p_147260_1_.func_179707_f()); -+ PotionEffect potioneffect = new PotionEffect(p_147260_1_.func_149427_e() & 0xff, p_147260_1_.func_180755_e(), p_147260_1_.func_149428_f(), false, p_147260_1_.func_179707_f()); - potioneffect.func_100012_b(p_147260_1_.func_149429_c()); - ((EntityLivingBase)entity).func_70690_d(potioneffect); - } +- Potion potion = Potion.func_188412_a(p_147260_1_.func_149427_e()); ++ Potion potion = Potion.func_188412_a(p_147260_1_.func_149427_e() & 0xFF); + + if (potion != null) + { diff --git a/patches/minecraft/net/minecraft/client/network/OldServerPinger.java.patch b/patches/minecraft/net/minecraft/client/network/ServerPinger.java.patch similarity index 59% rename from patches/minecraft/net/minecraft/client/network/OldServerPinger.java.patch rename to patches/minecraft/net/minecraft/client/network/ServerPinger.java.patch index d7aad9ec1e..0168e2cc5f 100644 --- a/patches/minecraft/net/minecraft/client/network/OldServerPinger.java.patch +++ b/patches/minecraft/net/minecraft/client/network/ServerPinger.java.patch @@ -1,10 +1,10 @@ ---- ../src-base/minecraft/net/minecraft/client/network/OldServerPinger.java -+++ ../src-work/minecraft/net/minecraft/client/network/OldServerPinger.java +--- ../src-base/minecraft/net/minecraft/client/network/ServerPinger.java ++++ ../src-work/minecraft/net/minecraft/client/network/ServerPinger.java @@ -150,6 +150,7 @@ p_147224_1_.func_147407_a((String)null); } + net.minecraftforge.fml.client.FMLClientHandler.instance().bindServerListData(p_147224_1_, serverstatusresponse); this.field_175092_e = Minecraft.func_71386_F(); - networkmanager.func_179290_a(new C01PacketPing(this.field_175092_e)); + networkmanager.func_179290_a(new CPacketPing(this.field_175092_e)); this.field_147403_d = true; diff --git a/patches/minecraft/net/minecraft/client/particle/EffectRenderer.java.patch b/patches/minecraft/net/minecraft/client/particle/EffectRenderer.java.patch index 08e6f7261a..d3cfc56bc3 100644 --- a/patches/minecraft/net/minecraft/client/particle/EffectRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/particle/EffectRenderer.java.patch @@ -1,31 +1,31 @@ --- ../src-base/minecraft/net/minecraft/client/particle/EffectRenderer.java +++ ../src-work/minecraft/net/minecraft/client/particle/EffectRenderer.java -@@ -133,6 +133,7 @@ +@@ -143,6 +143,7 @@ public void func_78873_a(EntityFX p_78873_1_) { + if (p_78873_1_ == null) return; //Forge: Prevent modders from being bad and adding nulls causing untraceable NPEs. - int i = p_78873_1_.func_70537_b(); - int j = p_78873_1_.func_174838_j() != 1.0F ? 0 : 1; + this.field_187241_h.add(p_78873_1_); + } -@@ -351,7 +352,7 @@ +@@ -376,7 +377,7 @@ public void func_180533_a(BlockPos p_180533_1_, IBlockState p_180533_2_) { -- if (p_180533_2_.func_177230_c().func_149688_o() != Material.field_151579_a) -+ if (!p_180533_2_.func_177230_c().isAir(field_78878_a, p_180533_1_) && !p_180533_2_.func_177230_c().addDestroyEffects(field_78878_a, p_180533_1_, this)) +- if (p_180533_2_.func_185904_a() != Material.field_151579_a) ++ if (!p_180533_2_.func_177230_c().isAir(p_180533_2_, field_78878_a, p_180533_1_) && !p_180533_2_.func_177230_c().addDestroyEffects(field_78878_a, p_180533_1_, this)) { - p_180533_2_ = p_180533_2_.func_177230_c().func_176221_a(p_180533_2_, this.field_78878_a, p_180533_1_); + p_180533_2_ = p_180533_2_.func_185899_b(this.field_78878_a, p_180533_1_); int i = 4; -@@ -457,4 +458,13 @@ +@@ -460,4 +461,13 @@ return "" + i; } + -+ public void addBlockHitEffects(BlockPos pos, net.minecraft.util.MovingObjectPosition target) ++ public void addBlockHitEffects(BlockPos pos, net.minecraft.util.math.RayTraceResult target) + { -+ Block block = field_78878_a.func_180495_p(pos).func_177230_c(); -+ if (block != null && !block.addHitEffects(field_78878_a, target, this)) ++ IBlockState state = field_78878_a.func_180495_p(pos); ++ if (state != null && !state.func_177230_c().addHitEffects(state, field_78878_a, target, this)) + { + func_180532_a(pos, target.field_178784_b); + } diff --git a/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch index 39f2cb1698..be9bcb78fb 100644 --- a/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java.patch @@ -1,24 +1,45 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java +++ ../src-work/minecraft/net/minecraft/client/renderer/BlockModelRenderer.java -@@ -533,8 +533,19 @@ - @SideOnly(Side.CLIENT) - public static enum EnumNeighborInfo - { -- DOWN(new EnumFacing[]{EnumFacing.WEST, EnumFacing.EAST, EnumFacing.NORTH, EnumFacing.SOUTH}, 0.5F, false, new BlockModelRenderer.Orientation[0], new BlockModelRenderer.Orientation[0], new BlockModelRenderer.Orientation[0], new BlockModelRenderer.Orientation[0]), -- UP(new EnumFacing[]{EnumFacing.EAST, EnumFacing.WEST, EnumFacing.NORTH, EnumFacing.SOUTH}, 1.0F, false, new BlockModelRenderer.Orientation[0], new BlockModelRenderer.Orientation[0], new BlockModelRenderer.Orientation[0], new BlockModelRenderer.Orientation[0]), -+ // -- Forge Patch to Fix Top/Bottom Lighting Interpolation -- -+ // Forge PR - https://github.com/MinecraftForge/MinecraftForge/pull/1892 -+ // Mojang Bug - https://bugs.mojang.com/browse/MC-80148 -+ DOWN( new EnumFacing[]{ EnumFacing.WEST, EnumFacing.EAST, EnumFacing.NORTH, EnumFacing.SOUTH }, 0.5F, true, -+ new Orientation[]{ Orientation.FLIP_WEST, Orientation.SOUTH, Orientation.FLIP_WEST, Orientation.FLIP_SOUTH, Orientation.WEST, Orientation.FLIP_SOUTH, Orientation.WEST, Orientation.SOUTH }, -+ new Orientation[]{ Orientation.FLIP_WEST, Orientation.NORTH, Orientation.FLIP_WEST, Orientation.FLIP_NORTH, Orientation.WEST, Orientation.FLIP_NORTH, Orientation.WEST, Orientation.NORTH }, -+ new Orientation[]{ Orientation.FLIP_EAST, Orientation.NORTH, Orientation.FLIP_EAST, Orientation.FLIP_NORTH, Orientation.EAST, Orientation.FLIP_NORTH, Orientation.EAST, Orientation.NORTH }, -+ new Orientation[]{ Orientation.FLIP_EAST, Orientation.SOUTH, Orientation.FLIP_EAST, Orientation.FLIP_SOUTH, Orientation.EAST, Orientation.FLIP_SOUTH, Orientation.EAST, Orientation.SOUTH } ), -+ UP( new EnumFacing[]{ EnumFacing.EAST, EnumFacing.WEST, EnumFacing.NORTH, EnumFacing.SOUTH }, 1.0F, true, -+ new Orientation[]{ Orientation.EAST, Orientation.SOUTH, Orientation.EAST, Orientation.FLIP_SOUTH, Orientation.FLIP_EAST, Orientation.FLIP_SOUTH, Orientation.FLIP_EAST, Orientation.SOUTH }, -+ new Orientation[]{ Orientation.EAST, Orientation.NORTH, Orientation.EAST, Orientation.FLIP_NORTH, Orientation.FLIP_EAST, Orientation.FLIP_NORTH, Orientation.FLIP_EAST, Orientation.NORTH }, -+ new Orientation[]{ Orientation.WEST, Orientation.NORTH, Orientation.WEST, Orientation.FLIP_NORTH, Orientation.FLIP_WEST, Orientation.FLIP_NORTH, Orientation.FLIP_WEST, Orientation.NORTH }, -+ new Orientation[]{ Orientation.WEST, Orientation.SOUTH, Orientation.WEST, Orientation.FLIP_SOUTH, Orientation.FLIP_WEST, Orientation.FLIP_SOUTH, Orientation.FLIP_WEST, Orientation.SOUTH } ), - NORTH(new EnumFacing[]{EnumFacing.UP, EnumFacing.DOWN, EnumFacing.EAST, EnumFacing.WEST}, 0.8F, true, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.FLIP_WEST, BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.WEST, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.WEST, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.FLIP_WEST}, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.FLIP_EAST, BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.EAST, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.EAST, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.FLIP_EAST}, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.FLIP_EAST, BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.EAST, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.EAST, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.FLIP_EAST}, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.FLIP_WEST, BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.WEST, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.WEST, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.FLIP_WEST}), - SOUTH(new EnumFacing[]{EnumFacing.WEST, EnumFacing.EAST, EnumFacing.DOWN, EnumFacing.UP}, 0.8F, true, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.FLIP_WEST, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.FLIP_WEST, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.WEST, BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.WEST}, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.FLIP_WEST, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.FLIP_WEST, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.WEST, BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.WEST}, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.FLIP_EAST, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.FLIP_EAST, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.EAST, BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.EAST}, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.FLIP_EAST, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.FLIP_EAST, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.EAST, BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.EAST}), - WEST(new EnumFacing[]{EnumFacing.UP, EnumFacing.DOWN, EnumFacing.NORTH, EnumFacing.SOUTH}, 0.6F, true, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.SOUTH, BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.FLIP_SOUTH, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.FLIP_SOUTH, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.SOUTH}, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.NORTH, BlockModelRenderer.Orientation.UP, BlockModelRenderer.Orientation.FLIP_NORTH, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.FLIP_NORTH, BlockModelRenderer.Orientation.FLIP_UP, BlockModelRenderer.Orientation.NORTH}, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.NORTH, BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.FLIP_NORTH, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.FLIP_NORTH, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.NORTH}, new BlockModelRenderer.Orientation[]{BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.SOUTH, BlockModelRenderer.Orientation.DOWN, BlockModelRenderer.Orientation.FLIP_SOUTH, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.FLIP_SOUTH, BlockModelRenderer.Orientation.FLIP_DOWN, BlockModelRenderer.Orientation.SOUTH}), +@@ -140,7 +140,14 @@ + p_187492_8_.func_187491_a(p_187492_1_, p_187492_2_, p_187492_3_, bakedquad.func_178210_d(), p_187492_6_, p_187492_7_); + p_187492_4_.func_178981_a(bakedquad.func_178209_a()); + p_187492_4_.func_178962_a(p_187492_8_.field_178207_c[0], p_187492_8_.field_178207_c[1], p_187492_8_.field_178207_c[2], p_187492_8_.field_178207_c[3]); +- ++ if(bakedquad.shouldApplyDiffuseLighting()) ++ { ++ float diffuse = net.minecraftforge.client.model.pipeline.LightUtil.diffuseLight(bakedquad.func_178210_d()); ++ p_187492_8_.field_178206_b[0] *= diffuse; ++ p_187492_8_.field_178206_b[1] *= diffuse; ++ p_187492_8_.field_178206_b[2] *= diffuse; ++ p_187492_8_.field_178206_b[3] *= diffuse; ++ } + if (bakedquad.func_178212_b()) + { + int k = this.field_187499_a.func_186724_a(p_187492_2_, p_187492_1_, p_187492_3_, bakedquad.func_178211_c()); +@@ -289,11 +296,26 @@ + float f = (float)(l >> 16 & 255) / 255.0F; + float f1 = (float)(l >> 8 & 255) / 255.0F; + float f2 = (float)(l & 255) / 255.0F; ++ if(bakedquad.shouldApplyDiffuseLighting()) ++ { ++ float diffuse = net.minecraftforge.client.model.pipeline.LightUtil.diffuseLight(bakedquad.func_178210_d()); ++ f *= diffuse; ++ f1 *= diffuse; ++ f2 *= diffuse; ++ } + p_187496_6_.func_178978_a(f, f1, f2, 4); + p_187496_6_.func_178978_a(f, f1, f2, 3); + p_187496_6_.func_178978_a(f, f1, f2, 2); + p_187496_6_.func_178978_a(f, f1, f2, 1); + } ++ else if(bakedquad.shouldApplyDiffuseLighting()) ++ { ++ float diffuse = net.minecraftforge.client.model.pipeline.LightUtil.diffuseLight(bakedquad.func_178210_d()); ++ p_187496_6_.func_178978_a(diffuse, diffuse, diffuse, 4); ++ p_187496_6_.func_178978_a(diffuse, diffuse, diffuse, 3); ++ p_187496_6_.func_178978_a(diffuse, diffuse, diffuse, 2); ++ p_187496_6_.func_178978_a(diffuse, diffuse, diffuse, 1); ++ } + + p_187496_6_.func_178987_a(d0, d1, d2); + } diff --git a/patches/minecraft/net/minecraft/client/renderer/BlockModelShapes.java.patch b/patches/minecraft/net/minecraft/client/renderer/BlockModelShapes.java.patch index af6ec831d7..6ff9d53b7f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/BlockModelShapes.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/BlockModelShapes.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/BlockModelShapes.java +++ ../src-work/minecraft/net/minecraft/client/renderer/BlockModelShapes.java -@@ -309,5 +309,6 @@ +@@ -307,5 +307,6 @@ return new ModelResourceLocation(s + "_double_slab", s1); } }); diff --git a/patches/minecraft/net/minecraft/client/renderer/BlockRendererDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/BlockRendererDispatcher.java.patch index 72ea50b40f..3b5e95d380 100644 --- a/patches/minecraft/net/minecraft/client/renderer/BlockRendererDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/BlockRendererDispatcher.java.patch @@ -1,49 +1,31 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/BlockRendererDispatcher.java +++ ../src-work/minecraft/net/minecraft/client/renderer/BlockRendererDispatcher.java -@@ -24,7 +24,7 @@ - { - private BlockModelShapes field_175028_a; - private final GameSettings field_175026_b; -- private final BlockModelRenderer field_175027_c = new BlockModelRenderer(); -+ private final BlockModelRenderer field_175027_c = new net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer(); - private final ChestRenderer field_175024_d = new ChestRenderer(); - private final BlockFluidRenderer field_175025_e = new BlockFluidRenderer(); - -@@ -48,6 +48,24 @@ - { - p_175020_1_ = block.func_176221_a(p_175020_1_, p_175020_4_, p_175020_2_); - IBakedModel ibakedmodel = this.field_175028_a.func_178125_b(p_175020_1_); -+ -+ if(ibakedmodel instanceof net.minecraftforge.client.model.ISmartBlockModel) -+ { -+ IBlockState extendedState = block.getExtendedState(p_175020_1_, p_175020_4_, p_175020_2_); -+ for ( net.minecraft.util.EnumWorldBlockLayer layer : net.minecraft.util.EnumWorldBlockLayer.values() ) -+ { -+ if ( block.canRenderInLayer( layer ) ) -+ { -+ net.minecraftforge.client.ForgeHooksClient.setRenderLayer(layer); -+ -+ IBakedModel targetLayer = ((net.minecraftforge.client.model.ISmartBlockModel)ibakedmodel).handleBlockState(extendedState); -+ IBakedModel damageModel = (new SimpleBakedModel.Builder(targetLayer, p_175020_3_)).func_177645_b(); -+ this.field_175027_c.func_178259_a(p_175020_4_, damageModel, p_175020_1_, p_175020_2_, Tessellator.func_178181_a().func_178180_c()); -+ } -+ } -+ return; -+ } -+ - IBakedModel ibakedmodel1 = (new SimpleBakedModel.Builder(ibakedmodel, p_175020_3_)).func_177645_b(); - this.field_175027_c.func_178259_a(p_175020_4_, ibakedmodel1, p_175020_1_, p_175020_2_, Tessellator.func_178181_a().func_178180_c()); - } -@@ -128,6 +146,12 @@ - ibakedmodel = ((WeightedBakedModel)ibakedmodel).func_177564_a(MathHelper.func_180186_a(p_175022_3_)); - } - -+ if(ibakedmodel instanceof net.minecraftforge.client.model.ISmartBlockModel) -+ { -+ IBlockState extendedState = block.getExtendedState(p_175022_1_, p_175022_2_, p_175022_3_); -+ ibakedmodel = ((net.minecraftforge.client.model.ISmartBlockModel)ibakedmodel).handleBlockState(extendedState); -+ } -+ - return ibakedmodel; +@@ -29,7 +29,7 @@ + public BlockRendererDispatcher(BlockModelShapes p_i46577_1_, BlockColors p_i46577_2_) + { + this.field_175028_a = p_i46577_1_; +- this.field_175027_c = new BlockModelRenderer(p_i46577_2_); ++ this.field_175027_c = new net.minecraftforge.client.model.pipeline.ForgeBlockModelRenderer(p_i46577_2_); + this.field_175025_e = new BlockFluidRenderer(p_i46577_2_); } +@@ -44,7 +44,7 @@ + { + p_175020_1_ = p_175020_1_.func_185899_b(p_175020_4_, p_175020_2_); + IBakedModel ibakedmodel = this.field_175028_a.func_178125_b(p_175020_1_); +- IBakedModel ibakedmodel1 = (new SimpleBakedModel.Builder(p_175020_1_, ibakedmodel, p_175020_3_, p_175020_2_)).func_177645_b(); ++ IBakedModel ibakedmodel1 = net.minecraftforge.client.ForgeHooksClient.getDamageModel(ibakedmodel, p_175020_3_, p_175020_1_, p_175020_4_, p_175020_2_); + this.field_175027_c.func_178267_a(p_175020_4_, ibakedmodel1, p_175020_1_, p_175020_2_, Tessellator.func_178181_a().func_178180_c(), true); + } + } +@@ -76,7 +76,9 @@ + switch (enumblockrendertype) + { + case MODEL: +- return this.field_175027_c.func_178267_a(p_175018_3_, this.func_184389_a(p_175018_1_), p_175018_1_, p_175018_2_, p_175018_4_, true); ++ IBakedModel model = this.func_184389_a(p_175018_1_); ++ p_175018_1_ = p_175018_1_.func_177230_c().getExtendedState(p_175018_1_, p_175018_3_, p_175018_2_); ++ return this.field_175027_c.func_178267_a(p_175018_3_, model, p_175018_1_, p_175018_2_, p_175018_4_, true); + case ENTITYBLOCK_ANIMATED: + return false; + case LIQUID: diff --git a/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch index 6bc47e6d17..eec1cf045f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/EntityRenderer.java +++ ../src-work/minecraft/net/minecraft/client/renderer/EntityRenderer.java -@@ -200,6 +200,7 @@ +@@ -207,6 +207,7 @@ { this.func_175069_a(new ResourceLocation("shaders/post/invert.json")); } @@ -8,25 +8,25 @@ } } -@@ -419,7 +420,7 @@ +@@ -398,7 +399,7 @@ if (d3 < d2 || d2 == 0.0D) { -- if (entity1 == entity.field_70154_o) -+ if (entity1 == entity.field_70154_o && !entity.canRiderInteract()) +- if (entity1.func_184208_bv() == entity.func_184208_bv()) ++ if (entity1.func_184208_bv() == entity.func_184208_bv() && !entity.canRiderInteract()) { if (d2 == 0.0D) { -@@ -512,7 +513,7 @@ +@@ -491,7 +492,7 @@ f = f * 60.0F / 70.0F; } - return f; -+ return net.minecraftforge.client.ForgeHooksClient.getFOVModifier(this, entity, block, p_78481_1_, f); ++ return net.minecraftforge.client.ForgeHooksClient.getFOVModifier(this, entity, iblockstate, p_78481_1_, f); } } -@@ -576,14 +577,8 @@ +@@ -555,14 +556,8 @@ { BlockPos blockpos = new BlockPos(entity); IBlockState iblockstate = this.field_78531_r.field_71441_e.func_180495_p(blockpos); @@ -35,14 +35,14 @@ - if (block == Blocks.field_150324_C) - { -- int j = ((EnumFacing)iblockstate.func_177229_b(BlockBed.field_176387_N)).func_176736_b(); +- int j = ((EnumFacing)iblockstate.func_177229_b(BlockBed.field_185512_D)).func_176736_b(); - GlStateManager.func_179114_b((float)(j * 90), 0.0F, 1.0F, 0.0F); - } - GlStateManager.func_179114_b(entity.field_70126_B + (entity.field_70177_z - entity.field_70126_B) * p_78467_1_ + 180.0F, 0.0F, -1.0F, 0.0F); GlStateManager.func_179114_b(entity.field_70127_C + (entity.field_70125_A - entity.field_70127_C) * p_78467_1_, -1.0F, 0.0F, 0.0F); } -@@ -650,17 +645,20 @@ +@@ -629,17 +624,20 @@ if (!this.field_78531_r.field_71474_y.field_74325_U) { @@ -61,16 +61,24 @@ - { - GlStateManager.func_179114_b(entity.field_70126_B + (entity.field_70177_z - entity.field_70126_B) * p_78467_1_ + 180.0F, 0.0F, 1.0F, 0.0F); - } -+ Block block = ActiveRenderInfo.func_180786_a(this.field_78531_r.field_71441_e, entity, p_78467_1_); -+ net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup event = new net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup(this, entity, block, p_78467_1_, yaw, pitch, roll); ++ IBlockState state = ActiveRenderInfo.func_186703_a(this.field_78531_r.field_71441_e, entity, p_78467_1_); ++ net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup event = new net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup(this, entity, state, p_78467_1_, yaw, pitch, roll); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ GlStateManager.func_179114_b(event.roll, 0.0F, 0.0F, 1.0F); -+ GlStateManager.func_179114_b(event.pitch, 1.0F, 0.0F, 0.0F); -+ GlStateManager.func_179114_b(event.yaw, 0.0F, 1.0F, 0.0F); ++ GlStateManager.func_179114_b(event.getRoll(), 0.0F, 0.0F, 1.0F); ++ GlStateManager.func_179114_b(event.getPitch(), 1.0F, 0.0F, 0.0F); ++ GlStateManager.func_179114_b(event.getYaw(), 0.0F, 1.0F, 0.0F); } GlStateManager.func_179109_b(0.0F, -f, 0.0F); -@@ -1103,7 +1101,7 @@ +@@ -757,6 +755,7 @@ + + boolean flag = this.field_78531_r.func_175606_aa() instanceof EntityLivingBase && ((EntityLivingBase)this.field_78531_r.func_175606_aa()).func_70608_bn(); + ++ if (!net.minecraftforge.client.ForgeHooksClient.renderFirstPersonHand(field_78531_r.field_71438_f, p_78476_1_, p_78476_2_)) + if (this.field_78531_r.field_71474_y.field_74320_O == 0 && !flag && !this.field_78531_r.field_71474_y.field_74319_N && !this.field_78531_r.field_71442_b.func_78747_a()) + { + this.func_180436_i(); +@@ -1092,7 +1091,7 @@ try { @@ -79,7 +87,7 @@ } catch (Throwable throwable) { -@@ -1164,7 +1162,7 @@ +@@ -1187,7 +1186,7 @@ if (this.field_78531_r.field_71442_b.func_178889_l() == WorldSettings.GameType.SPECTATOR) { @@ -88,7 +96,7 @@ } else { -@@ -1314,7 +1312,9 @@ +@@ -1312,7 +1311,9 @@ GlStateManager.func_179094_E(); RenderHelper.func_74519_b(); this.field_78531_r.field_71424_I.func_76318_c("entities"); @@ -97,40 +105,34 @@ + net.minecraftforge.client.ForgeHooksClient.setRenderPass(0); RenderHelper.func_74518_a(); this.func_175072_h(); - GlStateManager.func_179128_n(5888); -@@ -1326,6 +1326,7 @@ - EntityPlayer entityplayer = (EntityPlayer)entity; - GlStateManager.func_179118_c(); - this.field_78531_r.field_71424_I.func_76318_c("outline"); -+ if (!net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(renderglobal, entityplayer, field_78531_r.field_71476_x, 0, entityplayer.func_70694_bm(), p_175068_2_)) - renderglobal.func_72731_b(entityplayer, this.field_78531_r.field_71476_x, 0, p_175068_2_); - GlStateManager.func_179141_d(); - } -@@ -1339,6 +1340,7 @@ - EntityPlayer entityplayer1 = (EntityPlayer)entity; + } +@@ -1325,6 +1326,7 @@ + EntityPlayer entityplayer = (EntityPlayer)entity; GlStateManager.func_179118_c(); this.field_78531_r.field_71424_I.func_76318_c("outline"); -+ if (!net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(renderglobal, entityplayer1, field_78531_r.field_71476_x, 0, entityplayer1.func_70694_bm(), p_175068_2_)) - renderglobal.func_72731_b(entityplayer1, this.field_78531_r.field_71476_x, 0, p_175068_2_); ++ if (!net.minecraftforge.client.ForgeHooksClient.onDrawBlockHighlight(renderglobal, entityplayer, field_78531_r.field_71476_x, 0, p_175068_2_)) + renderglobal.func_72731_b(entityplayer, this.field_78531_r.field_71476_x, 0, p_175068_2_); GlStateManager.func_179141_d(); } -@@ -1380,6 +1382,15 @@ +@@ -1366,6 +1368,17 @@ GlStateManager.func_179103_j(7425); this.field_78531_r.field_71424_I.func_76318_c("translucent"); - renderglobal.func_174977_a(EnumWorldBlockLayer.TRANSLUCENT, (double)p_175068_2_, p_175068_1_, entity); + renderglobal.func_174977_a(BlockRenderLayer.TRANSLUCENT, (double)p_175068_2_, p_175068_1_, entity); + if (!this.field_175078_W) //Only render if render pass 0 happens as well. + { + RenderHelper.func_74519_b(); + this.field_78531_r.field_71424_I.func_76318_c("entities"); + net.minecraftforge.client.ForgeHooksClient.setRenderPass(1); + renderglobal.func_180446_a(entity, icamera, p_175068_2_); ++ // restore blending function changed by RenderGlobal.preRenderDamagedBlocks ++ GlStateManager.func_187428_a(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + net.minecraftforge.client.ForgeHooksClient.setRenderPass(-1); + RenderHelper.func_74518_a(); + } GlStateManager.func_179103_j(7424); GlStateManager.func_179132_a(true); GlStateManager.func_179089_o(); -@@ -1392,8 +1403,12 @@ +@@ -1378,6 +1391,9 @@ this.func_180437_a(renderglobal, p_175068_2_, p_175068_1_); } @@ -139,11 +141,8 @@ + this.field_78531_r.field_71424_I.func_76318_c("hand"); -+ if (!net.minecraftforge.client.ForgeHooksClient.renderFirstPersonHand(renderglobal, p_175068_2_, p_175068_1_)) if (this.field_175074_C) - { - GlStateManager.func_179086_m(256); -@@ -1505,6 +1520,13 @@ +@@ -1490,6 +1506,13 @@ protected void func_78474_d(float p_78474_1_) { @@ -157,36 +156,36 @@ float f = this.field_78531_r.field_71441_e.func_72867_j(p_78474_1_); if (f > 0.0F) -@@ -1830,6 +1852,13 @@ +@@ -1820,6 +1843,13 @@ this.field_175081_S = f7; } -+ net.minecraftforge.client.event.EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(this, entity, block, p_78466_1_, this.field_175080_Q, this.field_175082_R, this.field_175081_S); ++ net.minecraftforge.client.event.EntityViewRenderEvent.FogColors event = new net.minecraftforge.client.event.EntityViewRenderEvent.FogColors(this, entity, iblockstate, p_78466_1_, this.field_175080_Q, this.field_175082_R, this.field_175081_S); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + -+ this.field_175080_Q = event.red; -+ this.field_175082_R = event.green; -+ this.field_175081_S = event.blue; ++ this.field_175080_Q = event.getRed(); ++ this.field_175082_R = event.getGreen(); ++ this.field_175081_S = event.getBlue(); + GlStateManager.func_179082_a(this.field_175080_Q, this.field_175082_R, this.field_175081_S, 0.0F); } -@@ -1848,6 +1877,10 @@ +@@ -1830,7 +1860,9 @@ + GlStateManager.func_187432_a(0.0F, -1.0F, 0.0F); GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); - Block block = ActiveRenderInfo.func_180786_a(this.field_78531_r.field_71441_e, entity, p_78468_2_); - -+ float hook = net.minecraftforge.client.ForgeHooksClient.getFogDensity(this, entity, block, p_78468_2_, 0.1F); -+ if (hook >= 0) -+ GlStateManager.func_179095_a(hook); + IBlockState iblockstate = ActiveRenderInfo.func_186703_a(this.field_78531_r.field_71441_e, entity, p_78468_2_); +- ++ float hook = net.minecraftforge.client.ForgeHooksClient.getFogDensity(this, entity, iblockstate, p_78468_2_, 0.1F); ++ if (hook >= 0) GlStateManager.func_179095_a(hook); + else - if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).func_70644_a(Potion.field_76440_q)) + if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).func_70644_a(MobEffects.field_76440_q)) { float f1 = 5.0F; -@@ -1925,6 +1958,7 @@ +@@ -1915,6 +1947,7 @@ GlStateManager.func_179102_b(f * 0.05F); GlStateManager.func_179153_c(Math.min(f, 192.0F) * 0.5F); } -+ net.minecraftforge.client.ForgeHooksClient.onFogRender(this, entity, block, p_78468_2_, p_78468_1_, f); ++ net.minecraftforge.client.ForgeHooksClient.onFogRender(this, entity, iblockstate, p_78468_2_, p_78468_1_, f); } GlStateManager.func_179142_g(); diff --git a/patches/minecraft/net/minecraft/client/renderer/InventoryEffectRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/InventoryEffectRenderer.java.patch index 8bdca504f1..81041e73d5 100644 --- a/patches/minecraft/net/minecraft/client/renderer/InventoryEffectRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/InventoryEffectRenderer.java.patch @@ -1,28 +1,30 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/InventoryEffectRenderer.java +++ ../src-work/minecraft/net/minecraft/client/renderer/InventoryEffectRenderer.java -@@ -27,7 +27,12 @@ +@@ -28,8 +28,14 @@ protected void func_175378_g() { - if (!this.field_146297_k.field_71439_g.func_70651_bq().isEmpty()) + boolean hasVisibleEffect = false; + for(PotionEffect potioneffect : this.field_146297_k.field_71439_g.func_70651_bq()) { -+ Potion potion = Potion.field_76425_a[potioneffect.func_76456_a()]; ++ Potion potion = potioneffect.func_188419_a(); + if(potion.shouldRender(potioneffect)) { hasVisibleEffect = true; break; } + } + if (!this.field_146297_k.field_71439_g.func_70651_bq().isEmpty() && hasVisibleEffect) { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.PotionShiftEvent(this))) this.field_147003_i = (this.field_146294_l - this.field_146999_f) / 2; else this.field_147003_i = 160 + (this.field_146294_l - this.field_146999_f - 200) / 2; this.field_147045_u = true; -@@ -70,6 +75,7 @@ - for (PotionEffect potioneffect : this.field_146297_k.field_71439_g.func_70651_bq()) + } +@@ -71,6 +77,7 @@ + for (PotionEffect potioneffect : Ordering.natural().sortedCopy(collection)) { - Potion potion = Potion.field_76425_a[potioneffect.func_76456_a()]; + Potion potion = potioneffect.func_188419_a(); + if(!potion.shouldRender(potioneffect)) continue; GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); this.field_146297_k.func_110434_K().func_110577_a(field_147001_a); this.func_73729_b(i, j, 0, 166, 140, 32); -@@ -80,6 +86,8 @@ +@@ -81,6 +88,8 @@ this.func_73729_b(i + 6, j + 7, 0 + i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18); } diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemModelMesher.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemModelMesher.java.patch index 09c4a98789..1b7646b17e 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemModelMesher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemModelMesher.java.patch @@ -1,14 +1,13 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/ItemModelMesher.java +++ ../src-work/minecraft/net/minecraft/client/renderer/ItemModelMesher.java -@@ -50,6 +50,11 @@ - } - } +@@ -32,7 +32,9 @@ -+ if(ibakedmodel instanceof net.minecraftforge.client.model.ISmartItemModel) -+ { -+ ibakedmodel = ((net.minecraftforge.client.model.ISmartItemModel)ibakedmodel).handleItemState(p_178089_1_); -+ } -+ - if (ibakedmodel == null) - { - ibakedmodel = this.field_178090_d.func_174951_a(); + public TextureAtlasSprite func_178087_a(Item p_178087_1_, int p_178087_2_) + { +- return this.func_178089_a(new ItemStack(p_178087_1_, 1, p_178087_2_)).func_177554_e(); ++ ItemStack stack = new ItemStack(p_178087_1_, 1, p_178087_2_); ++ IBakedModel model = this.func_178089_a(stack); ++ return model.func_188617_f().handleItemState(model, stack, null, null).func_177554_e(); + } + + public IBakedModel func_178089_a(ItemStack p_178089_1_) diff --git a/patches/minecraft/net/minecraft/client/renderer/ItemRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/ItemRenderer.java.patch index 9e4e3ebcd7..d0f3d8a146 100644 --- a/patches/minecraft/net/minecraft/client/renderer/ItemRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/ItemRenderer.java.patch @@ -1,15 +1,15 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/ItemRenderer.java +++ ../src-work/minecraft/net/minecraft/client/renderer/ItemRenderer.java -@@ -313,7 +313,7 @@ - - if (this.field_78453_b != null) - { -- if (this.field_78453_b.func_77973_b() == Items.field_151098_aY) -+ if (this.field_78453_b.func_77973_b() instanceof net.minecraft.item.ItemMap) - { - this.func_178097_a(abstractclientplayer, f2, f, f1); +@@ -360,7 +360,7 @@ + this.func_187456_a(p_187457_7_, p_187457_5_, enumhandside); } -@@ -365,6 +365,7 @@ + } +- else if (p_187457_6_.func_77973_b() == Items.field_151098_aY) ++ else if (p_187457_6_.func_77973_b() instanceof net.minecraft.item.ItemMap) + { + if (flag && this.field_187468_e == null) + { +@@ -444,6 +444,7 @@ if (this.field_78455_a.field_71439_g.func_70094_T()) { IBlockState iblockstate = this.field_78455_a.field_71441_e.func_180495_p(new BlockPos(this.field_78455_a.field_71439_g)); @@ -17,7 +17,7 @@ EntityPlayer entityplayer = this.field_78455_a.field_71439_g; for (int i = 0; i < 8; ++i) -@@ -378,11 +379,13 @@ +@@ -457,11 +458,13 @@ if (iblockstate1.func_177230_c().func_176214_u()) { iblockstate = iblockstate1; @@ -25,13 +25,13 @@ } } - if (iblockstate.func_177230_c().func_149645_b() != -1) + if (iblockstate.func_185901_i() != EnumBlockRenderType.INVISIBLE) { + if (!net.minecraftforge.event.ForgeEventFactory.renderBlockOverlay(field_78455_a.field_71439_g, p_78447_1_, net.minecraftforge.client.event.RenderBlockOverlayEvent.OverlayType.BLOCK, iblockstate, overlayPos)) this.func_178108_a(p_78447_1_, this.field_78455_a.func_175602_ab().func_175023_a().func_178122_a(iblockstate)); } } -@@ -391,11 +394,13 @@ +@@ -470,11 +473,13 @@ { if (this.field_78455_a.field_71439_g.func_70055_a(Material.field_151586_h)) { @@ -45,16 +45,14 @@ this.func_78442_d(p_78447_1_); } } -@@ -512,6 +517,12 @@ +@@ -596,8 +601,8 @@ + else { - if (!this.field_78453_b.func_179549_c(itemstack)) - { -+ if (!this.field_78453_b.func_77973_b().shouldCauseReequipAnimation(this.field_78453_b, itemstack, field_78450_g != entityplayer.field_71071_by.field_70461_c)) -+ { -+ this.field_78453_b = itemstack; -+ this.field_78450_g = entityplayer.field_71071_by.field_70461_c; -+ return; -+ } - flag = true; - } + float f = entityplayersp.func_184825_o(1.0F); +- this.field_187469_f += MathHelper.func_76131_a((Objects.equal(this.field_187467_d, itemstack) ? f * f * f : 0.0F) - this.field_187469_f, -0.4F, 0.4F); +- this.field_187471_h += MathHelper.func_76131_a((float)(Objects.equal(this.field_187468_e, itemstack1) ? 1 : 0) - this.field_187471_h, -0.4F, 0.4F); ++ this.field_187469_f += MathHelper.func_76131_a((!net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.field_187467_d, itemstack, entityplayersp.field_71071_by.field_70461_c) ? f * f * f : 0.0F) - this.field_187469_f, -0.4F, 0.4F); ++ this.field_187471_h += MathHelper.func_76131_a((float)(!net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.field_187468_e, itemstack1, -1) ? 1 : 0) - this.field_187471_h, -0.4F, 0.4F); } + + if (this.field_187469_f < 0.1F) diff --git a/patches/minecraft/net/minecraft/client/renderer/OpenGlHelper.java.patch b/patches/minecraft/net/minecraft/client/renderer/OpenGlHelper.java.patch index 98273ca48e..41709861e3 100644 --- a/patches/minecraft/net/minecraft/client/renderer/OpenGlHelper.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/OpenGlHelper.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/OpenGlHelper.java +++ ../src-work/minecraft/net/minecraft/client/renderer/OpenGlHelper.java -@@ -83,6 +83,10 @@ +@@ -92,6 +92,10 @@ public static int field_176089_P; public static int field_148826_e; @@ -11,7 +11,7 @@ public static void func_77474_a() { ContextCapabilities contextcapabilities = GLContext.getCapabilities(); -@@ -843,6 +847,12 @@ +@@ -852,6 +856,12 @@ { GL13.glMultiTexCoord2f(p_77475_0_, p_77475_1_, p_77475_2_); } diff --git a/patches/minecraft/net/minecraft/client/renderer/RenderGlobal.java.patch b/patches/minecraft/net/minecraft/client/renderer/RenderGlobal.java.patch index cee9639e68..cb766654a5 100644 --- a/patches/minecraft/net/minecraft/client/renderer/RenderGlobal.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/RenderGlobal.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/RenderGlobal.java +++ ../src-work/minecraft/net/minecraft/client/renderer/RenderGlobal.java -@@ -525,8 +525,10 @@ +@@ -547,8 +547,10 @@ public void func_180446_a(Entity p_180446_1_, ICamera p_180446_2_, float p_180446_3_) { @@ -11,7 +11,7 @@ --this.field_72740_G; } else -@@ -537,9 +539,12 @@ +@@ -559,9 +561,12 @@ this.field_72769_h.field_72984_F.func_76320_a("prepare"); TileEntityRendererDispatcher.field_147556_a.func_178470_a(this.field_72769_h, this.field_72777_q.func_110434_K(), this.field_72777_q.field_71466_p, this.field_72777_q.func_175606_aa(), p_180446_3_); this.field_175010_j.func_180597_a(this.field_72769_h, this.field_72777_q.field_71466_p, this.field_72777_q.func_175606_aa(), this.field_72777_q.field_147125_j, this.field_72777_q.field_71474_y, p_180446_3_); @@ -24,7 +24,7 @@ Entity entity = this.field_72777_q.func_175606_aa(); double d3 = entity.field_70142_S + (entity.field_70165_t - entity.field_70142_S) * (double)p_180446_3_; double d4 = entity.field_70137_T + (entity.field_70163_u - entity.field_70137_T) * (double)p_180446_3_; -@@ -551,11 +556,15 @@ +@@ -573,11 +578,15 @@ this.field_72777_q.field_71460_t.func_180436_i(); this.field_72769_h.field_72984_F.func_76318_c("global"); List list = this.field_72769_h.func_72910_y(); @@ -40,39 +40,39 @@ ++this.field_72749_I; if (entity1.func_145770_h(d0, d1, d2)) -@@ -577,6 +586,7 @@ - for (int j = 0; j < list.size(); ++j) +@@ -599,6 +608,7 @@ { - Entity entity3 = (Entity)list.get(j); -+ if (!entity3.shouldRenderInPass(pass)) continue; - boolean flag = this.field_72777_q.func_175606_aa() instanceof EntityLivingBase && ((EntityLivingBase)this.field_72777_q.func_175606_aa()).func_70608_bn(); - boolean flag1 = entity3.func_145770_h(d0, d1, d2) && (entity3.field_70158_ak || p_180446_2_.func_78546_a(entity3.func_174813_aQ()) || entity3.field_70153_n == this.field_72777_q.field_71439_g) && entity3 instanceof EntityPlayer; + for (Entity entity2 : classinheritancemultimap) + { ++ if(!entity2.shouldRenderInPass(pass)) continue; + boolean flag = this.field_175010_j.func_178635_a(entity2, p_180446_2_, d0, d1, d2) || entity2.func_184215_y(this.field_72777_q.field_71439_g); -@@ -626,6 +636,7 @@ - } + if (flag) +@@ -633,6 +643,7 @@ + } + } - entity2 = (Entity)iterator.next(); -+ if (!entity2.shouldRenderInPass(pass)) continue; - flag2 = this.field_175010_j.func_178635_a(entity2, p_180446_2_, d0, d1, d2) || entity2.field_70153_n == this.field_72777_q.field_71439_g; - - if (!flag2) -@@ -654,6 +665,7 @@ ++ if(pass == 0) + if (this.func_174985_d() && (!list1.isEmpty() || this.field_184386_ad)) + { + this.field_72769_h.field_72984_F.func_76318_c("entityOutlines"); +@@ -672,6 +683,7 @@ this.field_72769_h.field_72984_F.func_76318_c("blockentities"); RenderHelper.func_74519_b(); + TileEntityRendererDispatcher.field_147556_a.preDrawBatch(); for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation1 : this.field_72755_R) { - List list1 = renderglobal$containerlocalrenderinformation1.field_178036_a.func_178571_g().func_178485_b(); -@@ -662,6 +674,7 @@ + List list3 = renderglobal$containerlocalrenderinformation1.field_178036_a.func_178571_g().func_178485_b(); +@@ -680,6 +692,7 @@ { - for (TileEntity tileentity2 : list1) + for (TileEntity tileentity2 : list3) { + if (!tileentity2.shouldRenderInPass(pass) || !p_180446_2_.func_78546_a(tileentity2.getRenderBoundingBox())) continue; TileEntityRendererDispatcher.field_147556_a.func_180546_a(tileentity2, p_180446_3_, -1); } } -@@ -671,9 +684,11 @@ +@@ -689,9 +702,11 @@ { for (TileEntity tileentity : this.field_181024_n) { @@ -84,7 +84,7 @@ this.func_180443_s(); -@@ -700,7 +715,7 @@ +@@ -718,7 +733,7 @@ Block block = this.field_72769_h.func_180495_p(blockpos).func_177230_c(); @@ -93,7 +93,7 @@ { TileEntityRendererDispatcher.field_147556_a.func_180546_a(tileentity1, p_180446_3_, destroyblockprogress.func_73106_e()); } -@@ -1161,6 +1176,12 @@ +@@ -1210,6 +1225,13 @@ public void func_174976_a(float p_174976_1_, int p_174976_2_) { @@ -103,10 +103,11 @@ + renderer.render(p_174976_1_, field_72769_h, field_72777_q); + return; + } - if (this.field_72777_q.field_71441_e.field_73011_w.func_177502_q() == 1) ++ + if (this.field_72777_q.field_71441_e.field_73011_w.func_186058_p().func_186068_a() == 1) { this.func_180448_r(); -@@ -1378,6 +1399,12 @@ +@@ -1427,6 +1449,12 @@ public void func_180447_b(float p_180447_1_, int p_180447_2_) { @@ -119,7 +120,7 @@ if (this.field_72777_q.field_71441_e.field_73011_w.func_76569_d()) { if (this.field_72777_q.field_71474_y.func_181147_e() == 2) -@@ -1793,8 +1820,11 @@ +@@ -1854,8 +1882,11 @@ double d4 = (double)blockpos.func_177956_o() - d1; double d5 = (double)blockpos.func_177952_p() - d2; Block block = this.field_72769_h.func_180495_p(blockpos).func_177230_c(); @@ -132,21 +133,3 @@ { if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D) { -@@ -1949,13 +1979,16 @@ - if (p_174961_1_ != null) - { - ItemRecord itemrecord = ItemRecord.func_150926_b(p_174961_1_); -+ ResourceLocation resource = null; - - if (itemrecord != null) - { - this.field_72777_q.field_71456_v.func_73833_a(itemrecord.func_150927_i()); -+ resource = itemrecord.getRecordResource(p_174961_1_); - } - -- PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.func_147675_a(new ResourceLocation(p_174961_1_), (float)p_174961_2_.func_177958_n(), (float)p_174961_2_.func_177956_o(), (float)p_174961_2_.func_177952_p()); -+ if (resource == null) resource = new ResourceLocation(p_174961_1_); -+ PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.func_147675_a(resource, (float)p_174961_2_.func_177958_n(), (float)p_174961_2_.func_177956_o(), (float)p_174961_2_.func_177952_p()); - this.field_147593_P.put(p_174961_2_, positionedsoundrecord); - this.field_72777_q.func_147118_V().func_147682_a(positionedsoundrecord); - } diff --git a/patches/minecraft/net/minecraft/client/renderer/RenderItem.java.patch b/patches/minecraft/net/minecraft/client/renderer/RenderItem.java.patch new file mode 100644 index 0000000000..e4a020fc9f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/RenderItem.java.patch @@ -0,0 +1,93 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/RenderItem.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/RenderItem.java +@@ -71,7 +71,7 @@ + public RenderItem(TextureManager p_i46552_1_, ModelManager p_i46552_2_, ItemColors p_i46552_3_) + { + this.field_175057_n = p_i46552_1_; +- this.field_175059_m = new ItemModelMesher(p_i46552_2_); ++ this.field_175059_m = new net.minecraftforge.client.ItemModelMesherForge(p_i46552_2_); + this.func_175041_b(); + this.field_184395_f = p_i46552_3_; + } +@@ -223,7 +223,7 @@ + k = k | -16777216; + } + +- this.func_175033_a(p_175032_1_, bakedquad, k); ++ net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(p_175032_1_, bakedquad, k); + } + } + +@@ -245,17 +245,7 @@ + public IBakedModel func_184393_a(ItemStack p_184393_1_, World p_184393_2_, EntityLivingBase p_184393_3_) + { + IBakedModel ibakedmodel = this.field_175059_m.func_178089_a(p_184393_1_); +- Item item = p_184393_1_.func_77973_b(); +- +- if (item != null && item.func_185040_i()) +- { +- ResourceLocation resourcelocation = ibakedmodel.func_188617_f().func_188021_a(p_184393_1_, p_184393_2_, p_184393_3_); +- return resourcelocation == null ? ibakedmodel : this.field_175059_m.func_178083_a().func_174953_a(new ModelResourceLocation(resourcelocation, "inventory")); +- } +- else +- { +- return ibakedmodel; +- } ++ return ibakedmodel.func_188617_f().handleItemState(ibakedmodel, p_184393_1_, p_184393_2_, p_184393_3_); + } + + public void func_184392_a(ItemStack p_184392_1_, EntityLivingBase p_184392_2_, ItemCameraTransforms.TransformType p_184392_3_, boolean p_184392_4_) +@@ -279,14 +269,9 @@ + GlStateManager.func_179147_l(); + GlStateManager.func_187428_a(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); + GlStateManager.func_179094_E(); +- ItemCameraTransforms itemcameratransforms = p_184394_2_.func_177552_f(); +- ItemCameraTransforms.func_188034_a(itemcameratransforms.func_181688_b(p_184394_3_), p_184394_4_); ++ // TODO: check if negative scale is a thing ++ p_184394_2_ = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(p_184394_2_, p_184394_3_, p_184394_4_); + +- if (this.func_183005_a(itemcameratransforms.func_181688_b(p_184394_3_))) +- { +- GlStateManager.func_187407_a(GlStateManager.CullFace.FRONT); +- } +- + this.func_180454_a(p_184394_1_, p_184394_2_); + GlStateManager.func_187407_a(GlStateManager.CullFace.BACK); + GlStateManager.func_179121_F(); +@@ -319,7 +304,7 @@ + GlStateManager.func_187401_a(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); + GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); + this.func_180452_a(p_184390_2_, p_184390_3_, p_184390_4_.func_177556_c()); +- p_184390_4_.func_177552_f().func_181689_a(ItemCameraTransforms.TransformType.GUI); ++ p_184390_4_ = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(p_184390_4_, ItemCameraTransforms.TransformType.GUI, false); + this.func_180454_a(p_184390_1_, p_184390_4_); + GlStateManager.func_179118_c(); + GlStateManager.func_179101_C(); +@@ -424,12 +409,16 @@ + p_180453_1_.func_175063_a(s, (float)(p_180453_3_ + 19 - 2 - p_180453_1_.func_78256_a(s)), (float)(p_180453_4_ + 6 + 3), 16777215); + GlStateManager.func_179145_e(); + GlStateManager.func_179126_j(); ++ // Fixes opaque cooldown overlay a bit lower ++ // TODO: check if enabled blending still screws things up down the line. ++ GlStateManager.func_179147_l(); + } + +- if (p_180453_2_.func_77951_h()) ++ if (p_180453_2_.func_77973_b().showDurabilityBar(p_180453_2_)) + { +- int j = (int)Math.round(13.0D - (double)p_180453_2_.func_77952_i() * 13.0D / (double)p_180453_2_.func_77958_k()); +- int i = (int)Math.round(255.0D - (double)p_180453_2_.func_77952_i() * 255.0D / (double)p_180453_2_.func_77958_k()); ++ double health = p_180453_2_.func_77973_b().getDurabilityForDisplay(p_180453_2_); ++ int j = (int)Math.round(13.0D - health * 13.0D); ++ int i = (int)Math.round(255.0D - health * 255.0D); + GlStateManager.func_179140_f(); + GlStateManager.func_179097_i(); + GlStateManager.func_179090_x(); +@@ -1053,6 +1042,7 @@ + this.func_175029_a(Blocks.field_185779_df, TileEntityStructure.Mode.LOAD.func_185110_a(), "structure_block"); + this.func_175029_a(Blocks.field_185779_df, TileEntityStructure.Mode.CORNER.func_185110_a(), "structure_block"); + this.func_175029_a(Blocks.field_185779_df, TileEntityStructure.Mode.DATA.func_185110_a(), "structure_block"); ++ net.minecraftforge.client.model.ModelLoader.onRegisterItems(this.field_175059_m); + } + + public void func_110549_a(IResourceManager p_110549_1_) diff --git a/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/VertexBuffer.java.patch similarity index 74% rename from patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch rename to patches/minecraft/net/minecraft/client/renderer/VertexBuffer.java.patch index bd74c5c478..fbf7ce9417 100644 --- a/patches/minecraft/net/minecraft/client/renderer/WorldRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/VertexBuffer.java.patch @@ -1,6 +1,15 @@ ---- ../src-base/minecraft/net/minecraft/client/renderer/WorldRenderer.java -+++ ../src-work/minecraft/net/minecraft/client/renderer/WorldRenderer.java -@@ -506,15 +506,15 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/VertexBuffer.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/VertexBuffer.java +@@ -126,6 +126,8 @@ + + bitset.set(l1); + } ++ this.field_178999_b.limit(this.field_178999_b.capacity()); ++ this.field_178999_b.position(this.func_181664_j()); + } + + public VertexBuffer.State func_181672_a() +@@ -510,15 +512,15 @@ break; case USHORT: case SHORT: @@ -22,20 +31,13 @@ } this.func_181667_k(); -@@ -578,6 +578,16 @@ +@@ -609,4 +611,9 @@ + return this.field_179018_e; } } - -+ public void checkAndGrow() -+ { -+ this.func_181670_b(field_179011_q.func_177338_f()/* / 4 * 4 */); -+ } + + public boolean isColorDisabled() + { + return field_78939_q; + } -+ - @SideOnly(Side.CLIENT) - public class State - { + } diff --git a/patches/minecraft/net/minecraft/client/renderer/WorldVertexBufferUploader.java.patch b/patches/minecraft/net/minecraft/client/renderer/WorldVertexBufferUploader.java.patch index 3102b6d98f..8b9356ee98 100644 --- a/patches/minecraft/net/minecraft/client/renderer/WorldVertexBufferUploader.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/WorldVertexBufferUploader.java.patch @@ -1,63 +1,54 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/WorldVertexBufferUploader.java +++ ../src-work/minecraft/net/minecraft/client/renderer/WorldVertexBufferUploader.java -@@ -23,32 +23,9 @@ +@@ -28,26 +28,8 @@ + int l = vertexformatelement.func_177369_e(); + bytebuffer.position(vertexformat.func_181720_d(j)); - for (int j = 0; j < list.size(); ++j) - { -+ // moved to VertexFormatElement.preDraw - VertexFormatElement vertexformatelement = (VertexFormatElement)list.get(j); -- VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.func_177375_c(); -- int k = vertexformatelement.func_177367_b().func_177397_c(); -- int l = vertexformatelement.func_177369_e(); -- bytebuffer.position(vertexformat.func_181720_d(j)); -- - switch (vertexformatelement$enumusage) - { - case POSITION: -- GL11.glVertexPointer(vertexformatelement.func_177370_d(), k, i, bytebuffer); -- GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); +- GlStateManager.func_187427_b(vertexformatelement.func_177370_d(), k, i, bytebuffer); +- GlStateManager.func_187410_q(32884); - break; - case UV: - OpenGlHelper.func_77472_b(OpenGlHelper.field_77478_a + l); -- GL11.glTexCoordPointer(vertexformatelement.func_177370_d(), k, i, bytebuffer); -- GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); +- GlStateManager.func_187404_a(vertexformatelement.func_177370_d(), k, i, bytebuffer); +- GlStateManager.func_187410_q(32888); - OpenGlHelper.func_77472_b(OpenGlHelper.field_77478_a); - break; - case COLOR: -- GL11.glColorPointer(vertexformatelement.func_177370_d(), k, i, bytebuffer); -- GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); +- GlStateManager.func_187400_c(vertexformatelement.func_177370_d(), k, i, bytebuffer); +- GlStateManager.func_187410_q(32886); - break; - case NORMAL: -- GL11.glNormalPointer(k, i, bytebuffer); -- GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY); +- GlStateManager.func_187446_a(k, i, bytebuffer); +- GlStateManager.func_187410_q(32885); - } ++ // moved to VertexFormatElement.preDraw + vertexformatelement.func_177375_c().preDraw(vertexformat, j, i, bytebuffer); } - GL11.glDrawArrays(p_181679_1_.func_178979_i(), 0, p_181679_1_.func_178989_h()); -@@ -57,26 +34,8 @@ - for (int j1 = list.size(); i1 < j1; ++i1) - { - VertexFormatElement vertexformatelement1 = (VertexFormatElement)list.get(i1); -- VertexFormatElement.EnumUsage vertexformatelement$enumusage1 = vertexformatelement1.func_177375_c(); -- int k1 = vertexformatelement1.func_177369_e(); -- + GlStateManager.func_187439_f(p_181679_1_.func_178979_i(), 0, p_181679_1_.func_178989_h()); +@@ -59,23 +41,8 @@ + VertexFormatElement.EnumUsage vertexformatelement$enumusage1 = vertexformatelement1.func_177375_c(); + int k1 = vertexformatelement1.func_177369_e(); + - switch (vertexformatelement$enumusage1) - { - case POSITION: -- GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); +- GlStateManager.func_187429_p(32884); - break; - case UV: - OpenGlHelper.func_77472_b(OpenGlHelper.field_77478_a + k1); -- GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY); +- GlStateManager.func_187429_p(32888); - OpenGlHelper.func_77472_b(OpenGlHelper.field_77478_a); - break; - case COLOR: -- GL11.glDisableClientState(GL11.GL_COLOR_ARRAY); +- GlStateManager.func_187429_p(32886); - GlStateManager.func_179117_G(); - break; - case NORMAL: -- GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY); +- GlStateManager.func_187429_p(32885); - } + // moved to VertexFormatElement.postDraw + vertexformatelement1.func_177375_c().postDraw(vertexformat, i1, i, bytebuffer); diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch index 656fce0dfc..2348edf932 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java.patch @@ -1,13 +1,54 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java +++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/BakedQuad.java -@@ -5,8 +5,9 @@ +@@ -6,15 +6,26 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class BakedQuad +public class BakedQuad implements net.minecraftforge.client.model.pipeline.IVertexProducer { -+ @Override public void pipe(net.minecraftforge.client.model.pipeline.IVertexConsumer consumer) { net.minecraftforge.client.model.pipeline.LightUtil.putBakedQuad(consumer, this); } protected final int[] field_178215_a; protected final int field_178213_b; protected final EnumFacing field_178214_c; + protected final TextureAtlasSprite field_187509_d; + ++ /** ++ * @deprecated Use constructor with the format argument. ++ */ ++ @Deprecated + public BakedQuad(int[] p_i46574_1_, int p_i46574_2_, EnumFacing p_i46574_3_, TextureAtlasSprite p_i46574_4_) + { ++ this(p_i46574_1_, p_i46574_2_, p_i46574_3_, p_i46574_4_, true, net.minecraft.client.renderer.vertex.DefaultVertexFormats.field_176599_b); ++ } ++ ++ public BakedQuad(int[] p_i46574_1_, int p_i46574_2_, EnumFacing p_i46574_3_, TextureAtlasSprite p_i46574_4_, boolean applyDiffuseLighting, net.minecraft.client.renderer.vertex.VertexFormat format) ++ { ++ this.format = format; ++ this.applyDiffuseLighting = applyDiffuseLighting; + this.field_178215_a = p_i46574_1_; + this.field_178213_b = p_i46574_2_; + this.field_178214_c = p_i46574_3_; +@@ -45,4 +56,23 @@ + { + return this.field_178214_c; + } ++ ++ protected final net.minecraft.client.renderer.vertex.VertexFormat format; ++ protected final boolean applyDiffuseLighting; ++ ++ @Override ++ public void pipe(net.minecraftforge.client.model.pipeline.IVertexConsumer consumer) ++ { ++ net.minecraftforge.client.model.pipeline.LightUtil.putBakedQuad(consumer, this); ++ } ++ ++ public net.minecraft.client.renderer.vertex.VertexFormat getFormat() ++ { ++ return format; ++ } ++ ++ public boolean shouldApplyDiffuseLighting() ++ { ++ return applyDiffuseLighting; ++ } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuadRetextured.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuadRetextured.java.patch new file mode 100644 index 0000000000..10b56f5345 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/BakedQuadRetextured.java.patch @@ -0,0 +1,25 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/BakedQuadRetextured.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/BakedQuadRetextured.java +@@ -12,7 +12,7 @@ + + public BakedQuadRetextured(BakedQuad p_i46217_1_, TextureAtlasSprite p_i46217_2_) + { +- super(Arrays.copyOf(p_i46217_1_.func_178209_a(), p_i46217_1_.func_178209_a().length), p_i46217_1_.field_178213_b, FaceBakery.func_178410_a(p_i46217_1_.func_178209_a()), p_i46217_1_.func_187508_a()); ++ super(Arrays.copyOf(p_i46217_1_.func_178209_a(), p_i46217_1_.func_178209_a().length), p_i46217_1_.field_178213_b, FaceBakery.func_178410_a(p_i46217_1_.func_178209_a()), p_i46217_1_.func_187508_a(), p_i46217_1_.applyDiffuseLighting, p_i46217_1_.format); + this.field_178218_d = p_i46217_2_; + this.func_178217_e(); + } +@@ -21,9 +21,10 @@ + { + for (int i = 0; i < 4; ++i) + { +- int j = 7 * i; +- this.field_178215_a[j + 4] = Float.floatToRawIntBits(this.field_178218_d.func_94214_a((double)this.field_187509_d.func_188537_a(Float.intBitsToFloat(this.field_178215_a[j + 4])))); +- this.field_178215_a[j + 4 + 1] = Float.floatToRawIntBits(this.field_178218_d.func_94207_b((double)this.field_187509_d.func_188536_b(Float.intBitsToFloat(this.field_178215_a[j + 4 + 1])))); ++ int j = format.func_181719_f() * i; ++ int uvIndex = format.func_177344_b(0) / 4; ++ this.field_178215_a[j + uvIndex] = Float.floatToRawIntBits(this.field_178218_d.func_94214_a((double)this.field_187509_d.func_188537_a(Float.intBitsToFloat(this.field_178215_a[j + uvIndex])))); ++ this.field_178215_a[j + uvIndex + 1] = Float.floatToRawIntBits(this.field_178218_d.func_94207_b((double)this.field_187509_d.func_188536_b(Float.intBitsToFloat(this.field_178215_a[j + uvIndex + 1])))); + } + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch index fb28a524da..f27905bd1c 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java.patch @@ -1,82 +1,105 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java +++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/FaceBakery.java -@@ -20,7 +20,12 @@ +@@ -48,14 +48,19 @@ public BakedQuad func_178414_a(Vector3f p_178414_1_, Vector3f p_178414_2_, BlockPartFace p_178414_3_, TextureAtlasSprite p_178414_4_, EnumFacing p_178414_5_, ModelRotation p_178414_6_, BlockPartRotation p_178414_7_, boolean p_178414_8_, boolean p_178414_9_) { -- int[] aint = this.func_178405_a(p_178414_3_, p_178414_4_, p_178414_5_, this.func_178403_a(p_178414_1_, p_178414_2_), p_178414_6_, p_178414_7_, p_178414_8_, p_178414_9_); -+ return makeBakedQuad(p_178414_1_, p_178414_2_, p_178414_3_, p_178414_4_, p_178414_5_, (net.minecraftforge.client.model.ITransformation)p_178414_6_, p_178414_7_, p_178414_8_, p_178414_9_); ++ return makeBakedQuad(p_178414_1_, p_178414_2_, p_178414_3_, p_178414_4_, p_178414_5_, (net.minecraftforge.common.model.ITransformation)p_178414_6_, p_178414_7_, p_178414_8_, p_178414_9_); + } + -+ public BakedQuad makeBakedQuad(Vector3f p_178414_1_, Vector3f p_178414_2_, BlockPartFace p_178414_3_, TextureAtlasSprite p_178414_4_, EnumFacing p_178414_5_, net.minecraftforge.client.model.ITransformation p_178414_6_, BlockPartRotation p_178414_7_, boolean p_178414_8_, boolean p_178414_9_) ++ public BakedQuad makeBakedQuad(Vector3f p_178414_1_, Vector3f p_178414_2_, BlockPartFace p_178414_3_, TextureAtlasSprite p_178414_4_, EnumFacing p_178414_5_, net.minecraftforge.common.model.ITransformation p_178414_6_, BlockPartRotation p_178414_7_, boolean p_178414_8_, boolean p_178414_9_) + { -+ int[] aint = this.makeQuadVertexData(p_178414_3_, p_178414_4_, p_178414_5_, this.func_178403_a(p_178414_1_, p_178414_2_), p_178414_6_, p_178414_7_, p_178414_8_, p_178414_9_); - EnumFacing enumfacing = func_178410_a(aint); + BlockFaceUV blockfaceuv = p_178414_3_.field_178243_e; if (p_178414_8_) -@@ -33,16 +38,22 @@ + { +- blockfaceuv = this.func_188010_a(p_178414_3_.field_178243_e, p_178414_5_, p_178414_6_); ++ blockfaceuv = net.minecraftforge.client.ForgeHooksClient.applyUVLock(p_178414_3_.field_178243_e, p_178414_5_, p_178414_6_); + } + +- int[] aint = this.func_188012_a(blockfaceuv, p_178414_4_, p_178414_5_, this.func_178403_a(p_178414_1_, p_178414_2_), p_178414_6_, p_178414_7_, p_178414_9_); ++ int[] aint = this.makeQuadVertexData(blockfaceuv, p_178414_4_, p_178414_5_, this.func_178403_a(p_178414_1_, p_178414_2_), p_178414_6_, p_178414_7_, false); + EnumFacing enumfacing = func_178410_a(aint); + + if (p_178414_7_ == null) +@@ -63,7 +68,8 @@ this.func_178408_a(aint, enumfacing); } +- return new BakedQuad(aint, p_178414_3_.field_178245_c, enumfacing, p_178414_4_); + net.minecraftforge.client.ForgeHooksClient.fillNormal(aint, enumfacing); - return new BakedQuad(aint, p_178414_3_.field_178245_c, enumfacing); ++ return new BakedQuad(aint, p_178414_3_.field_178245_c, enumfacing, p_178414_4_, p_178414_9_, net.minecraft.client.renderer.vertex.DefaultVertexFormats.field_176599_b); } - private int[] func_178405_a(BlockPartFace p_178405_1_, TextureAtlasSprite p_178405_2_, EnumFacing p_178405_3_, float[] p_178405_4_, ModelRotation p_178405_5_, BlockPartRotation p_178405_6_, boolean p_178405_7_, boolean p_178405_8_) + private BlockFaceUV func_188010_a(BlockFaceUV p_188010_1_, EnumFacing p_188010_2_, ModelRotation p_188010_3_) +@@ -73,11 +79,16 @@ + + private int[] func_188012_a(BlockFaceUV p_188012_1_, TextureAtlasSprite p_188012_2_, EnumFacing p_188012_3_, float[] p_188012_4_, ModelRotation p_188012_5_, BlockPartRotation p_188012_6_, boolean p_188012_7_) { -+ return func_178405_a(p_178405_1_, p_178405_2_, p_178405_3_, p_178405_4_, p_178405_5_, p_178405_6_, p_178405_7_, p_178405_8_); ++ return makeQuadVertexData(p_188012_1_, p_188012_2_, p_188012_3_, p_188012_4_, (net.minecraftforge.common.model.ITransformation)p_188012_5_, p_188012_6_, p_188012_7_); + } + -+ private int[] makeQuadVertexData(BlockPartFace p_178405_1_, TextureAtlasSprite p_178405_2_, EnumFacing p_178405_3_, float[] p_178405_4_, net.minecraftforge.client.model.ITransformation p_178405_5_, BlockPartRotation p_178405_6_, boolean p_178405_7_, boolean p_178405_8_) ++ private int[] makeQuadVertexData(BlockFaceUV uvs, TextureAtlasSprite sprite, EnumFacing orientation, float[] p_188012_4_, net.minecraftforge.common.model.ITransformation rotationIn, BlockPartRotation partRotation, boolean shade) + { int[] aint = new int[28]; for (int i = 0; i < 4; ++i) { -- this.func_178402_a(aint, i, p_178405_3_, p_178405_1_, p_178405_4_, p_178405_2_, p_178405_5_, p_178405_6_, p_178405_7_, p_178405_8_); -+ this.fillVertexData(aint, i, p_178405_3_, p_178405_1_, p_178405_4_, p_178405_2_, p_178405_5_, p_178405_6_, p_178405_7_, p_178405_8_); +- this.func_188015_a(aint, i, p_188012_3_, p_188012_1_, p_188012_4_, p_188012_2_, p_188012_5_, p_188012_6_, p_188012_7_); ++ this.fillVertexData(aint, i, orientation, uvs, p_188012_4_, sprite, rotationIn, partRotation, shade); } return aint; -@@ -88,12 +99,17 @@ +@@ -123,12 +134,17 @@ - private void func_178402_a(int[] p_178402_1_, int p_178402_2_, EnumFacing p_178402_3_, BlockPartFace p_178402_4_, float[] p_178402_5_, TextureAtlasSprite p_178402_6_, ModelRotation p_178402_7_, BlockPartRotation p_178402_8_, boolean p_178402_9_, boolean p_178402_10_) + private void func_188015_a(int[] p_188015_1_, int p_188015_2_, EnumFacing p_188015_3_, BlockFaceUV p_188015_4_, float[] p_188015_5_, TextureAtlasSprite p_188015_6_, ModelRotation p_188015_7_, BlockPartRotation p_188015_8_, boolean p_188015_9_) { -- EnumFacing enumfacing = p_178402_7_.func_177523_a(p_178402_3_); -+ func_178402_a(p_178402_1_, p_178402_2_, p_178402_3_, p_178402_4_, p_178402_5_, p_178402_6_, p_178402_7_, p_178402_8_, p_178402_9_, p_178402_10_); +- EnumFacing enumfacing = p_188015_7_.func_177523_a(p_188015_3_); ++ fillVertexData(p_188015_1_, p_188015_2_, p_188015_3_, p_188015_4_, p_188015_5_, p_188015_6_, (net.minecraftforge.common.model.ITransformation)p_188015_7_, p_188015_8_, p_188015_9_); + } + -+ private void fillVertexData(int[] p_178402_1_, int p_178402_2_, EnumFacing p_178402_3_, BlockPartFace p_178402_4_, float[] p_178402_5_, TextureAtlasSprite p_178402_6_, net.minecraftforge.client.model.ITransformation p_178402_7_, BlockPartRotation p_178402_8_, boolean p_178402_9_, boolean p_178402_10_) ++ private void fillVertexData(int[] p_188015_1_, int p_188015_2_, EnumFacing p_188015_3_, BlockFaceUV p_188015_4_, float[] p_188015_5_, TextureAtlasSprite p_188015_6_, net.minecraftforge.common.model.ITransformation p_188015_7_, BlockPartRotation p_188015_8_, boolean p_188015_9_) + { -+ EnumFacing enumfacing = p_178402_7_.rotate(p_178402_3_); - int i = p_178402_10_ ? this.func_178413_a(enumfacing) : -1; - EnumFaceDirection.VertexInformation enumfacedirection$vertexinformation = EnumFaceDirection.func_179027_a(p_178402_3_).func_179025_a(p_178402_2_); - Vector3f vector3f = new Vector3f(p_178402_5_[enumfacedirection$vertexinformation.field_179184_a], p_178402_5_[enumfacedirection$vertexinformation.field_179182_b], p_178402_5_[enumfacedirection$vertexinformation.field_179183_c]); - this.func_178407_a(vector3f, p_178402_8_); -- int j = this.func_178415_a(vector3f, p_178402_3_, p_178402_2_, p_178402_7_, p_178402_9_); -+ int j = this.rotateVertex(vector3f, p_178402_3_, p_178402_2_, p_178402_7_, p_178402_9_); - this.func_178404_a(p_178402_1_, j, p_178402_2_, vector3f, i, p_178402_6_, p_178402_4_.field_178243_e); ++ EnumFacing enumfacing = p_188015_7_.rotate(p_188015_3_); + int i = p_188015_9_ ? this.func_178413_a(enumfacing) : -1; + EnumFaceDirection.VertexInformation enumfacedirection$vertexinformation = EnumFaceDirection.func_179027_a(p_188015_3_).func_179025_a(p_188015_2_); + Vector3f vector3f = new Vector3f(p_188015_5_[enumfacedirection$vertexinformation.field_179184_a], p_188015_5_[enumfacedirection$vertexinformation.field_179182_b], p_188015_5_[enumfacedirection$vertexinformation.field_179183_c]); + this.func_178407_a(vector3f, p_188015_8_); +- int j = this.func_188011_a(vector3f, p_188015_3_, p_188015_2_, p_188015_7_); ++ int j = this.rotateVertex(vector3f, p_188015_3_, p_188015_2_, p_188015_7_); + this.func_178404_a(p_188015_1_, j, p_188015_2_, vector3f, i, p_188015_6_, p_188015_4_); } -@@ -154,14 +170,19 @@ +@@ -139,8 +155,8 @@ + p_178404_1_[i + 1] = Float.floatToRawIntBits(p_178404_4_.y); + p_178404_1_[i + 2] = Float.floatToRawIntBits(p_178404_4_.z); + p_178404_1_[i + 3] = p_178404_5_; +- p_178404_1_[i + 4] = Float.floatToRawIntBits(p_178404_6_.func_94214_a((double)p_178404_7_.func_178348_a(p_178404_3_))); +- p_178404_1_[i + 4 + 1] = Float.floatToRawIntBits(p_178404_6_.func_94207_b((double)p_178404_7_.func_178346_b(p_178404_3_))); ++ p_178404_1_[i + 4] = Float.floatToRawIntBits(p_178404_6_.func_94214_a((double)p_178404_7_.func_178348_a(p_178404_3_) * .999 + p_178404_7_.func_178348_a((p_178404_3_ + 2) % 4) * .001)); ++ p_178404_1_[i + 4 + 1] = Float.floatToRawIntBits(p_178404_6_.func_94207_b((double)p_178404_7_.func_178346_b(p_178404_3_) * .999 + p_178404_7_.func_178346_b((p_178404_3_ + 2) % 4) * .001)); + } - public int func_178415_a(Vector3f p_178415_1_, EnumFacing p_178415_2_, int p_178415_3_, ModelRotation p_178415_4_, boolean p_178415_5_) + private void func_178407_a(Vector3f p_178407_1_, BlockPartRotation p_178407_2_) +@@ -189,14 +205,19 @@ + + public int func_188011_a(Vector3f p_188011_1_, EnumFacing p_188011_2_, int p_188011_3_, ModelRotation p_188011_4_) { -+ return func_178415_a(p_178415_1_, p_178415_2_, p_178415_3_, p_178415_4_, p_178415_5_); ++ return rotateVertex(p_188011_1_, p_188011_2_, p_188011_3_, (net.minecraftforge.common.model.ITransformation)p_188011_4_); + } + -+ public int rotateVertex(Vector3f p_178415_1_, EnumFacing p_178415_2_, int p_178415_3_, net.minecraftforge.client.model.ITransformation p_178415_4_, boolean p_178415_5_) ++ public int rotateVertex(Vector3f p_188011_1_, EnumFacing p_188011_2_, int p_188011_3_, net.minecraftforge.common.model.ITransformation p_188011_4_) + { - if (p_178415_4_ == ModelRotation.X0_Y0) + if (p_188011_4_ == ModelRotation.X0_Y0) { - return p_178415_3_; + return p_188011_3_; } else { -- this.func_178406_a(p_178415_1_, new Vector3f(0.5F, 0.5F, 0.5F), p_178415_4_.func_177525_a(), new Vector3f(1.0F, 1.0F, 1.0F)); -- return p_178415_4_.func_177520_a(p_178415_2_, p_178415_3_); -+ net.minecraftforge.client.ForgeHooksClient.transform(p_178415_1_, p_178415_4_.getMatrix()); -+ return p_178415_4_.rotate(p_178415_2_, p_178415_3_); +- this.func_178406_a(p_188011_1_, new Vector3f(0.5F, 0.5F, 0.5F), p_188011_4_.func_177525_a(), new Vector3f(1.0F, 1.0F, 1.0F)); +- return p_188011_4_.func_177520_a(p_188011_2_, p_188011_3_); ++ net.minecraftforge.client.ForgeHooksClient.transform(p_188011_1_, p_188011_4_.getMatrix()); ++ return p_188011_4_.rotate(p_188011_2_, p_188011_3_); } } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/IBakedModel.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/IBakedModel.java.patch new file mode 100644 index 0000000000..af5da1d944 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/IBakedModel.java.patch @@ -0,0 +1,10 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/IBakedModel.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/IBakedModel.java +@@ -20,6 +20,7 @@ + + TextureAtlasSprite func_177554_e(); + ++ @Deprecated + ItemCameraTransforms func_177552_f(); + + ItemOverrideList func_188617_f(); diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemCameraTransforms.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemCameraTransforms.java.patch index 7d8ba1837b..74a4f9c042 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemCameraTransforms.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemCameraTransforms.java.patch @@ -1,23 +1,45 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/block/model/ItemCameraTransforms.java +++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/ItemCameraTransforms.java -@@ -10,7 +10,11 @@ - import net.minecraftforge.fml.relauncher.Side; +@@ -12,6 +12,9 @@ import net.minecraftforge.fml.relauncher.SideOnly; + import org.lwjgl.util.vector.Quaternion; +/* + * @deprecated use {@link net.minecraftforge.client.model.IPerspectiveAwareModel} instead + */ @SideOnly(Side.CLIENT) -+@Deprecated public class ItemCameraTransforms { - public static final ItemCameraTransforms field_178357_a = new ItemCameraTransforms(); -@@ -117,7 +121,7 @@ +@@ -39,6 +42,7 @@ + this(ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a, ItemTransformVec3f.field_178366_a); + } + ++ @Deprecated + public ItemCameraTransforms(ItemCameraTransforms p_i46443_1_) + { + this.field_188036_k = p_i46443_1_.field_188036_k; +@@ -51,6 +55,7 @@ + this.field_181700_p = p_i46443_1_.field_181700_p; + } + ++ @Deprecated + public ItemCameraTransforms(ItemTransformVec3f p_i46569_1_, ItemTransformVec3f p_i46569_2_, ItemTransformVec3f p_i46569_3_, ItemTransformVec3f p_i46569_4_, ItemTransformVec3f p_i46569_5_, ItemTransformVec3f p_i46569_6_, ItemTransformVec3f p_i46569_7_, ItemTransformVec3f p_i46569_8_) + { + this.field_188036_k = p_i46569_1_; +@@ -103,6 +108,7 @@ + return new Quaternion(f3 * f6 * f8 + f4 * f5 * f7, f4 * f5 * f8 - f3 * f6 * f7, f3 * f5 * f8 + f4 * f6 * f7, f4 * f6 * f8 - f3 * f5 * f7); + } + ++ @Deprecated + public ItemTransformVec3f func_181688_b(ItemCameraTransforms.TransformType p_181688_1_) + { + switch (p_181688_1_) +@@ -169,7 +175,7 @@ } @SideOnly(Side.CLIENT) - public static enum TransformType -+ public static enum TransformType implements net.minecraftforge.client.model.IModelPart ++ public static enum TransformType implements net.minecraftforge.common.model.IModelPart { NONE, - THIRD_PERSON, + THIRD_PERSON_LEFT_HAND, diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrideList.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrideList.java.patch new file mode 100644 index 0000000000..a000941766 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemOverrideList.java.patch @@ -0,0 +1,34 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/ItemOverrideList.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/ItemOverrideList.java +@@ -27,6 +27,7 @@ + } + } + ++ @Deprecated + public ResourceLocation func_188021_a(ItemStack p_188021_1_, World p_188021_2_, EntityLivingBase p_188021_3_) + { + if (!this.field_188023_b.isEmpty()) +@@ -42,4 +43,23 @@ + + return null; + } ++ ++ public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) ++ { ++ net.minecraft.item.Item item = stack.func_77973_b(); ++ if (item != null && item.func_185040_i()) ++ { ++ ResourceLocation location = func_188021_a(stack, world, entity); ++ if (location != null) ++ { ++ return net.minecraft.client.Minecraft.func_71410_x().func_175599_af().func_175037_a().func_178083_a().func_174953_a(net.minecraftforge.client.model.ModelLoader.getInventoryVariant(location.toString())); ++ } ++ } ++ return originalModel; ++ } ++ ++ public com.google.common.collect.ImmutableList getOverrides() ++ { ++ return com.google.common.collect.ImmutableList.copyOf(field_188023_b); ++ } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java.patch index 22f1377820..9dde502f97 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ItemTransformVec3f.java.patch @@ -10,9 +10,9 @@ @SideOnly(Side.CLIENT) -public class ItemTransformVec3f +@Deprecated -+public class ItemTransformVec3f implements net.minecraftforge.client.model.IModelState ++public class ItemTransformVec3f implements net.minecraftforge.common.model.IModelState { -+ public com.google.common.base.Optional apply(com.google.common.base.Optional part) { return net.minecraftforge.client.ForgeHooksClient.applyTransform(this, part); } ++ public com.google.common.base.Optional apply(com.google.common.base.Optional part) { return net.minecraftforge.client.ForgeHooksClient.applyTransform(this, part); } public static final ItemTransformVec3f field_178366_a = new ItemTransformVec3f(new Vector3f(), new Vector3f(), new Vector3f(1.0F, 1.0F, 1.0F)); public final Vector3f field_178364_b; public final Vector3f field_178365_c; diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ModelBakery.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelBakery.java.patch new file mode 100644 index 0000000000..b7ac03ea1f --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelBakery.java.patch @@ -0,0 +1,164 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/ModelBakery.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/ModelBakery.java +@@ -102,6 +102,21 @@ + { + try + { ++ loadBlock(blockstatemapper, block, resourcelocation); ++ } ++ catch (Exception exception) ++ { ++ field_177603_c.warn((String)("Unable to load definition " + resourcelocation), (Throwable)exception); ++ } ++ } ++ } ++ } ++ ++ protected void loadBlock(BlockStateMapper blockstatemapper, Block block, final ResourceLocation resourcelocation) ++ { ++ { ++ { ++ { + ModelBlockDefinition modelblockdefinition = this.func_177586_a(resourcelocation); + Map map = blockstatemapper.func_188181_b(block); + +@@ -109,7 +124,7 @@ + { + Collection collection = Sets.newHashSet(map.values()); + modelblockdefinition.func_188001_c().func_188138_a(block.func_176194_O()); +- this.field_188642_k.put(modelblockdefinition, Lists.newArrayList(Iterables.filter(collection, new Predicate() ++ registerMultipartVariant(modelblockdefinition, Lists.newArrayList(Iterables.filter(collection, new Predicate() + { + public boolean apply(ModelResourceLocation p_apply_1_) + { +@@ -126,22 +141,18 @@ + { + try + { +- this.field_177612_i.put(modelresourcelocation, modelblockdefinition.func_188004_c(modelresourcelocation.func_177518_c())); ++ this.func_177569_a(modelblockdefinition, modelresourcelocation); + } + catch (RuntimeException var12) + { + if (!modelblockdefinition.func_188002_b()) + { +- field_177603_c.warn("Unable to load variant: " + modelresourcelocation.func_177518_c() + " from " + modelresourcelocation); ++ field_177603_c.warn("Unable to load variant: " + modelresourcelocation.func_177518_c() + " from " + modelresourcelocation, var12); + } + } + } + } + } +- catch (Exception exception) +- { +- field_177603_c.warn((String)("Unable to load definition " + resourcelocation), (Throwable)exception); +- } + } + } + } +@@ -370,6 +381,7 @@ + + protected void func_177592_e() + { ++ this.field_177613_u.clear(); //FML clear this to prevent double ups. + this.field_177613_u.put(Item.func_150898_a(Blocks.field_150348_b), Lists.newArrayList(new String[] {"stone", "granite", "granite_smooth", "diorite", "diorite_smooth", "andesite", "andesite_smooth"})); + this.field_177613_u.put(Item.func_150898_a(Blocks.field_150346_d), Lists.newArrayList(new String[] {"dirt", "coarse_dirt", "podzol"})); + this.field_177613_u.put(Item.func_150898_a(Blocks.field_150344_f), Lists.newArrayList(new String[] {"oak_planks", "spruce_planks", "birch_planks", "jungle_planks", "acacia_planks", "dark_oak_planks"})); +@@ -413,6 +425,10 @@ + this.field_177613_u.put(Item.func_150898_a(Blocks.field_180407_aO), Lists.newArrayList(new String[] {"oak_fence"})); + this.field_177613_u.put(Items.field_179570_aq, Lists.newArrayList(new String[] {"oak_door"})); + this.field_177613_u.put(Items.field_151124_az, Lists.newArrayList(new String[] {"oak_boat"})); ++ for (Entry, Set> e : customVariantNames.entrySet()) ++ { ++ this.field_177613_u.put(e.getKey().get(), Lists.newArrayList(e.getValue().iterator())); ++ } + } + + protected List func_177596_a(Item p_177596_1_) +@@ -429,7 +445,7 @@ + + protected ResourceLocation func_177583_a(String p_177583_1_) + { +- ResourceLocation resourcelocation = new ResourceLocation(p_177583_1_); ++ ResourceLocation resourcelocation = new ResourceLocation(p_177583_1_.replaceAll("#.*", "")); + return new ResourceLocation(resourcelocation.func_110624_b(), "item/" + resourcelocation.func_110623_a()); + } + +@@ -536,7 +552,7 @@ + for (Entry entry : this.field_177615_s.entrySet()) + { + ResourceLocation resourcelocation = (ResourceLocation)entry.getValue(); +- ModelResourceLocation modelresourcelocation = new ModelResourceLocation((String)entry.getKey(), "inventory"); ++ ModelResourceLocation modelresourcelocation = net.minecraftforge.client.model.ModelLoader.getInventoryVariant(entry.getKey()); + ModelBlock modelblock = (ModelBlock)this.field_177611_h.get(resourcelocation); + + if (modelblock != null && modelblock.func_178303_d()) +@@ -623,6 +639,11 @@ + + private IBakedModel func_177578_a(ModelBlock p_177578_1_, ModelRotation p_177578_2_, boolean p_177578_3_) + { ++ return bakeModel(p_177578_1_, (net.minecraftforge.common.model.ITransformation)p_177578_2_, p_177578_3_); ++ } ++ ++ protected IBakedModel bakeModel(ModelBlock p_177578_1_, net.minecraftforge.common.model.ITransformation p_177578_2_, boolean p_177578_3_) ++ { + TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.field_177599_g.get(new ResourceLocation(p_177578_1_.func_178308_c("particle"))); + SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(p_177578_1_, p_177578_1_.func_187967_g())).func_177646_a(textureatlassprite); + +@@ -639,13 +660,13 @@ + BlockPartFace blockpartface = (BlockPartFace)blockpart.field_178240_c.get(enumfacing); + TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)this.field_177599_g.get(new ResourceLocation(p_177578_1_.func_178308_c(blockpartface.field_178242_d))); + +- if (blockpartface.field_178244_b == null) ++ if (blockpartface.field_178244_b == null || !net.minecraftforge.common.model.TRSRTransformation.isInteger(p_177578_2_.getMatrix())) + { +- simplebakedmodel$builder.func_177648_a(this.func_177589_a(blockpart, blockpartface, textureatlassprite1, enumfacing, p_177578_2_, p_177578_3_)); ++ simplebakedmodel$builder.func_177648_a(this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, p_177578_2_, p_177578_3_)); + } + else + { +- simplebakedmodel$builder.func_177650_a(p_177578_2_.func_177523_a(blockpartface.field_178244_b), this.func_177589_a(blockpart, blockpartface, textureatlassprite1, enumfacing, p_177578_2_, p_177578_3_)); ++ simplebakedmodel$builder.func_177650_a(p_177578_2_.rotate(blockpartface.field_178244_b), this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, p_177578_2_, p_177578_3_)); + } + } + } +@@ -656,9 +677,14 @@ + + private BakedQuad func_177589_a(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, ModelRotation p_177589_5_, boolean p_177589_6_) + { +- return this.field_177607_l.func_178414_a(p_177589_1_.field_178241_a, p_177589_1_.field_178239_b, p_177589_2_, p_177589_3_, p_177589_4_, p_177589_5_, p_177589_1_.field_178237_d, p_177589_6_, p_177589_1_.field_178238_e); ++ return makeBakedQuad(p_177589_1_, p_177589_2_, p_177589_3_, p_177589_4_, (net.minecraftforge.common.model.ITransformation)p_177589_5_, p_177589_6_); + } + ++ protected BakedQuad makeBakedQuad(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, net.minecraftforge.common.model.ITransformation p_177589_5_, boolean p_177589_6_) ++ { ++ return this.field_177607_l.makeBakedQuad(p_177589_1_.field_178241_a, p_177589_1_.field_178239_b, p_177589_2_, p_177589_3_, p_177589_4_, p_177589_5_, p_177589_1_.field_178237_d, p_177589_6_, p_177589_1_.field_178238_e); ++ } ++ + private void func_177597_h() + { + this.func_177574_i(); +@@ -878,4 +904,23 @@ + field_177606_o.field_178317_b = "generation marker"; + field_177616_r.field_178317_b = "block entity marker"; + } ++ ++ protected void registerMultipartVariant(ModelBlockDefinition definition, Collection locations) ++ { ++ this.field_188642_k.put(definition, locations); ++ } ++ ++ private static Map, Set> customVariantNames = Maps.newHashMap(); ++ ++ public static void registerItemVariants(Item item, ResourceLocation... names) ++ { ++ if (!customVariantNames.containsKey(item.delegate)) ++ { ++ customVariantNames.put(item.delegate, Sets.newHashSet()); ++ } ++ for(ResourceLocation name : names) ++ { ++ customVariantNames.get(item.delegate).add(name.toString()); ++ } ++ } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ModelBlockDefinition.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelBlockDefinition.java.patch index 30299b2902..aef97997d9 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/model/ModelBlockDefinition.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelBlockDefinition.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/block/model/ModelBlockDefinition.java +++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/ModelBlockDefinition.java -@@ -29,7 +29,7 @@ +@@ -31,7 +31,7 @@ public static ModelBlockDefinition func_178331_a(Reader p_178331_0_) { @@ -8,22 +8,4 @@ + return net.minecraftforge.client.model.BlockStateLoader.load(p_178331_0_, field_178333_a); } - public ModelBlockDefinition(Collection p_i46221_1_) -@@ -155,11 +155,17 @@ - return this.field_178437_a; - } - -+ @Deprecated - public ModelRotation func_178432_b() - { - return this.field_178435_b; - } - -+ public net.minecraftforge.client.model.IModelState getState() -+ { -+ return this.field_178435_b; -+ } -+ - public boolean func_178433_c() - { - return this.field_178436_c; + public ModelBlockDefinition(Map p_i46572_1_, Multipart p_i46572_2_) diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelManager.java.patch similarity index 60% rename from patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch rename to patches/minecraft/net/minecraft/client/renderer/block/model/ModelManager.java.patch index 9b92db76e4..b05f5c139c 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelManager.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelManager.java.patch @@ -1,11 +1,11 @@ ---- ../src-base/minecraft/net/minecraft/client/resources/model/ModelManager.java -+++ ../src-work/minecraft/net/minecraft/client/resources/model/ModelManager.java +--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/ModelManager.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/ModelManager.java @@ -24,9 +24,10 @@ public void func_110549_a(IResourceManager p_110549_1_) { - ModelBakery modelbakery = new ModelBakery(p_110549_1_, this.field_174956_b, this.field_174957_c); -+ ModelBakery modelbakery = new net.minecraftforge.client.model.ModelLoader(p_110549_1_, this.field_174956_b, this.field_174957_c); ++ net.minecraftforge.client.model.ModelLoader modelbakery = new net.minecraftforge.client.model.ModelLoader(p_110549_1_, this.field_174956_b, this.field_174957_c); this.field_174958_a = modelbakery.func_177570_a(); this.field_174955_d = (IBakedModel)this.field_174958_a.func_82594_a(ModelBakery.field_177604_a); + net.minecraftforge.client.ForgeHooksClient.onModelBake(this, this.field_174958_a, modelbakery); diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/ModelResourceLocation.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelResourceLocation.java.patch new file mode 100644 index 0000000000..b9461784b3 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelResourceLocation.java.patch @@ -0,0 +1,14 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/ModelResourceLocation.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/ModelResourceLocation.java +@@ -1,11 +1,8 @@ + package net.minecraft.client.renderer.block.model; + + import net.minecraft.util.ResourceLocation; +-import net.minecraftforge.fml.relauncher.Side; +-import net.minecraftforge.fml.relauncher.SideOnly; + import org.apache.commons.lang3.StringUtils; + +-@SideOnly(Side.CLIENT) + public class ModelResourceLocation extends ResourceLocation + { + private final String field_177519_c; diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelRotation.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelRotation.java.patch similarity index 63% rename from patches/minecraft/net/minecraft/client/resources/model/ModelRotation.java.patch rename to patches/minecraft/net/minecraft/client/renderer/block/model/ModelRotation.java.patch index 893292696c..af4bc66637 100644 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelRotation.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/ModelRotation.java.patch @@ -1,11 +1,11 @@ ---- ../src-base/minecraft/net/minecraft/client/resources/model/ModelRotation.java -+++ ../src-work/minecraft/net/minecraft/client/resources/model/ModelRotation.java +--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/ModelRotation.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/ModelRotation.java @@ -10,7 +10,7 @@ import org.lwjgl.util.vector.Vector3f; @SideOnly(Side.CLIENT) -public enum ModelRotation -+public enum ModelRotation implements net.minecraftforge.client.model.IModelState, net.minecraftforge.client.model.ITransformation ++public enum ModelRotation implements net.minecraftforge.common.model.IModelState, net.minecraftforge.common.model.ITransformation { X0_Y0(0, 0), X0_Y90(0, 90), @@ -14,7 +14,7 @@ } } + -+ public com.google.common.base.Optional apply(com.google.common.base.Optional part) { return net.minecraftforge.client.ForgeHooksClient.applyTransform(getMatrix(), part); } ++ public com.google.common.base.Optional apply(com.google.common.base.Optional part) { return net.minecraftforge.client.ForgeHooksClient.applyTransform(getMatrix(), part); } + public javax.vecmath.Matrix4f getMatrix() { return net.minecraftforge.client.ForgeHooksClient.getMatrix(this); } + public EnumFacing rotate(EnumFacing facing) { return func_177523_a(facing); } + public int rotate(EnumFacing facing, int vertexIndex) { return func_177520_a(facing, vertexIndex); } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/model/Variant.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/model/Variant.java.patch new file mode 100644 index 0000000000..d176aa5f9d --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/block/model/Variant.java.patch @@ -0,0 +1,39 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/block/model/Variant.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/block/model/Variant.java +@@ -12,7 +12,7 @@ + import net.minecraftforge.fml.relauncher.SideOnly; + + @SideOnly(Side.CLIENT) +-public class Variant ++public class Variant implements net.minecraftforge.client.model.ISmartVariant + { + private final ResourceLocation field_188050_a; + private final ModelRotation field_188051_b; +@@ -32,11 +32,17 @@ + return this.field_188050_a; + } + ++ @Deprecated + public ModelRotation func_188048_b() + { + return this.field_188051_b; + } + ++ public net.minecraftforge.common.model.IModelState getState() ++ { ++ return this.field_188051_b; ++ } ++ + public boolean func_188049_c() + { + return this.field_188052_c; +@@ -138,4 +144,9 @@ + } + } + } ++ ++ public net.minecraftforge.client.model.IModel process(net.minecraftforge.client.model.IModel base) ++ { ++ return net.minecraftforge.client.model.ModelProcessingHelper.uvlock(base, func_188049_c()); ++ } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/block/statemap/StateMap.java.patch b/patches/minecraft/net/minecraft/client/renderer/block/statemap/StateMap.java.patch index 0358100332..c0c6918373 100644 --- a/patches/minecraft/net/minecraft/client/renderer/block/statemap/StateMap.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/block/statemap/StateMap.java.patch @@ -4,8 +4,8 @@ } else { -- s = ((IProperty)this.field_178142_a).func_177702_a((Comparable)map.remove(this.field_178142_a)); -+ s = String.format("%s:%s", ((ResourceLocation)Block.field_149771_c.func_177774_c(p_178132_1_.func_177230_c())).func_110624_b(), ((IProperty)this.field_178142_a).func_177702_a((Comparable)map.remove(this.field_178142_a))); +- s = this.func_187490_a(this.field_178142_a, map); ++ s = String.format("%s:%s", Block.field_149771_c.func_177774_c(p_178132_1_.func_177230_c()).func_110624_b(), this.func_187490_a(this.field_178142_a, map)); } if (this.field_178141_c != null) diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch new file mode 100644 index 0000000000..4881014860 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java.patch @@ -0,0 +1,19 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/chunk/ChunkRenderDispatcher.java +@@ -43,9 +43,15 @@ + + public ChunkRenderDispatcher() + { ++ this(-1); ++ } ++ ++ public ChunkRenderDispatcher(int countRenderBuilders) ++ { + int i = Math.max(1, (int)((double)Runtime.getRuntime().maxMemory() * 0.3D) / 10485760); + int j = Math.max(1, MathHelper.func_76125_a(Runtime.getRuntime().availableProcessors(), 1, i / 5)); +- this.field_188249_c = MathHelper.func_76125_a(j * 10, 1, i); ++ if(countRenderBuilders < 0) countRenderBuilders = MathHelper.func_76125_a(j * 10, 1, i); ++ this.field_188249_c = countRenderBuilders; + + if (j > 1) + { diff --git a/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunk.java.patch b/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunk.java.patch index c7abba8326..bb29f62d10 100644 --- a/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunk.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/chunk/RenderChunk.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/chunk/RenderChunk.java +++ ../src-work/minecraft/net/minecraft/client/renderer/chunk/RenderChunk.java -@@ -131,7 +131,9 @@ +@@ -133,7 +133,9 @@ return; } @@ -11,7 +11,7 @@ p_178581_4_.func_178543_a(compiledchunk); } finally -@@ -158,7 +160,7 @@ +@@ -160,7 +162,7 @@ lvt_10_1_.func_178606_a(blockpos$mutableblockpos); } @@ -20,27 +20,28 @@ { TileEntity tileentity = iblockaccess.func_175625_s(new BlockPos(blockpos$mutableblockpos)); TileEntitySpecialRenderer tileentityspecialrenderer = TileEntityRendererDispatcher.field_147556_a.func_147547_b(tileentity); -@@ -174,7 +176,9 @@ +@@ -176,7 +178,9 @@ } } -- EnumWorldBlockLayer enumworldblocklayer1 = block.func_180664_k(); -+ for(EnumWorldBlockLayer enumworldblocklayer1 : EnumWorldBlockLayer.values()) { -+ if(!block.canRenderInLayer(enumworldblocklayer1)) continue; -+ net.minecraftforge.client.ForgeHooksClient.setRenderLayer(enumworldblocklayer1); - int j = enumworldblocklayer1.ordinal(); +- BlockRenderLayer blockrenderlayer1 = block.func_180664_k(); ++ for(BlockRenderLayer blockrenderlayer1 : BlockRenderLayer.values()) { ++ if(!block.canRenderInLayer(iblockstate, blockrenderlayer1)) continue; ++ net.minecraftforge.client.ForgeHooksClient.setRenderLayer(blockrenderlayer1); + int j = blockrenderlayer1.ordinal(); - if (block.func_149645_b() != -1) -@@ -189,6 +193,7 @@ + if (block.func_176223_P().func_185901_i() != EnumBlockRenderType.INVISIBLE) +@@ -191,6 +195,8 @@ - aboolean[j] |= blockrendererdispatcher.func_175018_a(iblockstate, blockpos$mutableblockpos, iblockaccess, worldrenderer); + aboolean[j] |= blockrendererdispatcher.func_175018_a(iblockstate, blockpos$mutableblockpos, iblockaccess, vertexbuffer); } + } ++ net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null); } - for (EnumWorldBlockLayer enumworldblocklayer : EnumWorldBlockLayer.values()) -@@ -385,6 +390,26 @@ - return this.field_178593_n; + for (BlockRenderLayer blockrenderlayer : BlockRenderLayer.values()) +@@ -413,6 +419,26 @@ + return this.field_178593_n && this.field_188284_q; } + /* ======================================== FORGE START =====================================*/ diff --git a/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch b/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch new file mode 100644 index 0000000000..93ce7f14e3 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch @@ -0,0 +1,32 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/color/BlockColors.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/color/BlockColors.java +@@ -25,7 +25,8 @@ + @SideOnly(Side.CLIENT) + public class BlockColors + { +- private final ObjectIntIdentityMap field_186725_a = new ObjectIntIdentityMap(32); ++ // FORGE: Use RegistryDelegates as non-Vanilla block ids are not constant ++ private final java.util.Map, IBlockColor> blockColorMap = com.google.common.collect.Maps.newHashMap(); + + public static BlockColors func_186723_a() + { +@@ -145,7 +146,7 @@ + + public int func_186724_a(IBlockState p_186724_1_, IBlockAccess p_186724_2_, BlockPos p_186724_3_, int p_186724_4_) + { +- IBlockColor iblockcolor = (IBlockColor)this.field_186725_a.func_148745_a(Block.func_149682_b(p_186724_1_.func_177230_c())); ++ IBlockColor iblockcolor = (IBlockColor)this.blockColorMap.get(p_186724_1_.func_177230_c().delegate); + return iblockcolor == null ? -1 : iblockcolor.func_186720_a(p_186724_1_, p_186724_2_, p_186724_3_, p_186724_4_); + } + +@@ -155,7 +156,9 @@ + + for (int j = p_186722_2_.length; i < j; ++i) + { +- this.field_186725_a.func_148746_a(p_186722_1_, Block.func_149682_b(p_186722_2_[i])); ++ if (p_186722_2_[i] == null) throw new IllegalArgumentException("Block registered to block color handler cannot be null!"); ++ if (p_186722_2_[i].getRegistryName() == null) throw new IllegalArgumentException("Block must be registered before assigning color handler."); ++ this.blockColorMap.put(p_186722_2_[i].delegate, p_186722_1_); + } + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch b/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch new file mode 100644 index 0000000000..c9764c9846 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch @@ -0,0 +1,43 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/color/ItemColors.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/color/ItemColors.java +@@ -26,7 +26,8 @@ + @SideOnly(Side.CLIENT) + public class ItemColors + { +- private final ObjectIntIdentityMap field_186732_a = new ObjectIntIdentityMap(32); ++ // FORGE: Use RegistryDelegates as non-Vanilla item ids are not constant ++ private final java.util.Map, IItemColor> itemColorMap = com.google.common.collect.Maps.newHashMap(); + + public static ItemColors func_186729_a(final BlockColors p_186729_0_) + { +@@ -136,7 +137,7 @@ + + public int func_186728_a(ItemStack p_186728_1_, int p_186728_2_) + { +- IItemColor iitemcolor = (IItemColor)this.field_186732_a.func_148745_a(Item.field_150901_e.func_148757_b(p_186728_1_.func_77973_b())); ++ IItemColor iitemcolor = (IItemColor)this.itemColorMap.get(p_186728_1_.func_77973_b().delegate); + return iitemcolor == null ? -1 : iitemcolor.func_186726_a(p_186728_1_, p_186728_2_); + } + +@@ -146,7 +147,9 @@ + + for (int j = p_186731_2_.length; i < j; ++i) + { +- this.field_186732_a.func_148746_a(p_186731_1_, Item.func_150891_b(Item.func_150898_a(p_186731_2_[i]))); ++ if (p_186731_2_[i] == null) throw new IllegalArgumentException("Block registered to item color handler cannot be null!"); ++ if (p_186731_2_[i].getRegistryName() == null) throw new IllegalArgumentException("Block must be registered before assigning color handler."); ++ this.itemColorMap.put(Item.func_150898_a(p_186731_2_[i]).delegate, p_186731_1_); + } + } + +@@ -156,7 +159,9 @@ + + for (int j = p_186730_2_.length; i < j; ++i) + { +- this.field_186732_a.func_148746_a(p_186730_1_, Item.func_150891_b(p_186730_2_[i])); ++ if (p_186730_2_[i] == null) throw new IllegalArgumentException("Item registered to item color handler cannot be null!"); ++ if (p_186730_2_[i].getRegistryName() == null) throw new IllegalArgumentException("Item must be registered before assigning color handler."); ++ this.itemColorMap.put(p_186730_2_[i].delegate, p_186730_1_); + } + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderEntityItem.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderEntityItem.java.patch index 155cd7b44c..93c9d6fd06 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RenderEntityItem.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderEntityItem.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderEntityItem.java +++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderEntityItem.java -@@ -41,7 +41,7 @@ +@@ -44,7 +44,7 @@ boolean flag = p_177077_9_.func_177556_c(); int i = this.func_177078_a(itemstack); float f = 0.25F; @@ -9,44 +9,53 @@ float f2 = p_177077_9_.func_177552_f().func_181688_b(ItemCameraTransforms.TransformType.GROUND).field_178363_d.y; GlStateManager.func_179109_b((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_); -@@ -110,7 +110,6 @@ +@@ -114,16 +114,13 @@ + GlStateManager.func_179094_E(); + IBakedModel ibakedmodel = this.field_177080_a.func_184393_a(itemstack, p_76986_1_.field_70170_p, (EntityLivingBase)null); + int j = this.func_177077_a(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_9_, ibakedmodel); +- float f = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.x; +- float f1 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.y; +- float f2 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.z; + boolean flag1 = ibakedmodel.func_177556_c(); - for (int j = 0; j < i; ++j) + if (!flag1) { -- if (ibakedmodel.func_177556_c()) - { - GlStateManager.func_179094_E(); +- float f3 = -0.0F * (float)(j - 1) * 0.5F * f; +- float f4 = -0.0F * (float)(j - 1) * 0.5F * f1; +- float f5 = -0.09375F * (float)(j - 1) * 0.5F * f2; ++ float f3 = -0.0F * (float)(j - 1) * 0.5F; ++ float f4 = -0.0F * (float)(j - 1) * 0.5F; ++ float f5 = -0.09375F * (float)(j - 1) * 0.5F; + GlStateManager.func_179109_b(f3, f4, f5); + } -@@ -119,25 +118,15 @@ - float f = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F; - float f1 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F; - float f2 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F; -- GlStateManager.func_179109_b(f, f1, f2); -+ GlStateManager.func_179109_b(shouldSpreadItems() ? f : 0.0F, shouldSpreadItems() ? f1 : 0.0F, f2); +@@ -144,10 +141,10 @@ + float f7 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F; + float f9 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F; + float f6 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F; +- GlStateManager.func_179109_b(f7, f9, f6); ++ GlStateManager.func_179109_b(shouldSpreadItems() ? f7 : 0, shouldSpreadItems() ? f9 : 0, f6); } -+ if (ibakedmodel.func_177556_c()) - GlStateManager.func_179152_a(0.5F, 0.5F, 0.5F); - ibakedmodel.func_177552_f().func_181689_a(ItemCameraTransforms.TransformType.GROUND); -+ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GROUND); ++ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GROUND, false); this.field_177080_a.func_180454_a(itemstack, ibakedmodel); GlStateManager.func_179121_F(); } -- else -- { -- GlStateManager.func_179094_E(); +@@ -162,10 +159,10 @@ + GlStateManager.func_179109_b(f8, f10, 0.0F); + } + - ibakedmodel.func_177552_f().func_181689_a(ItemCameraTransforms.TransformType.GROUND); -- this.field_177080_a.func_180454_a(itemstack, ibakedmodel); -- GlStateManager.func_179121_F(); -- float f3 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.x; -- float f4 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.y; -- float f5 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.z; -- GlStateManager.func_179109_b(0.0F * f3, 0.0F * f4, 0.046875F * f5); -- } ++ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GROUND, false); + this.field_177080_a.func_180454_a(itemstack, ibakedmodel); + GlStateManager.func_179121_F(); +- GlStateManager.func_179109_b(0.0F * f, 0.0F * f1, 0.09375F * f2); ++ GlStateManager.func_179109_b(0.0F, 0.0F, 0.09375F); + } } - GlStateManager.func_179121_F(); -@@ -157,4 +146,25 @@ +@@ -192,4 +189,25 @@ { return TextureMap.field_110575_b; } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderItem.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderItem.java.patch deleted file mode 100644 index 253b492fc9..0000000000 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RenderItem.java.patch +++ /dev/null @@ -1,90 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderItem.java -+++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderItem.java -@@ -72,7 +72,7 @@ - public RenderItem(TextureManager p_i46165_1_, ModelManager p_i46165_2_) - { - this.field_175057_n = p_i46165_1_; -- this.field_175059_m = new ItemModelMesher(p_i46165_2_); -+ this.field_175059_m = new net.minecraftforge.client.ItemModelMesherForge(p_i46165_2_); - this.func_175041_b(); - } - -@@ -226,7 +226,7 @@ - k = k | -16777216; - } - -- this.func_175033_a(p_175032_1_, bakedquad, k); -+ net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(p_175032_1_, bakedquad, k); - } - } - -@@ -296,6 +296,11 @@ - modelresourcelocation = new ModelResourceLocation("bow_pulling_0", "inventory"); - } - } -+ else -+ { -+ // TODO: maybe switch to the smart player model / normal smart item model? -+ modelresourcelocation = item.getModel(p_175049_1_, entityplayer, entityplayer.func_71052_bv()); -+ } - - if (modelresourcelocation != null) - { -@@ -317,14 +322,9 @@ - GlStateManager.func_179147_l(); - GlStateManager.func_179120_a(770, 771, 1, 0); - GlStateManager.func_179094_E(); -- ItemCameraTransforms itemcameratransforms = p_175040_2_.func_177552_f(); -- itemcameratransforms.func_181689_a(p_175040_3_); -+ // TODO: check if negative scale is a thing -+ p_175040_2_ = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(p_175040_2_, p_175040_3_); - -- if (this.func_183005_a(itemcameratransforms.func_181688_b(p_175040_3_))) -- { -- GlStateManager.func_179107_e(1028); -- } -- - this.func_180454_a(p_175040_1_, p_175040_2_); - GlStateManager.func_179107_e(1029); - GlStateManager.func_179121_F(); -@@ -352,7 +352,7 @@ - GlStateManager.func_179112_b(770, 771); - GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); - this.func_180452_a(p_175042_2_, p_175042_3_, ibakedmodel.func_177556_c()); -- ibakedmodel.func_177552_f().func_181689_a(ItemCameraTransforms.TransformType.GUI); -+ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GUI); - this.func_180454_a(p_175042_1_, ibakedmodel); - GlStateManager.func_179118_c(); - GlStateManager.func_179101_C(); -@@ -459,10 +459,11 @@ - GlStateManager.func_179126_j(); - } - -- if (p_180453_2_.func_77951_h()) -+ if (p_180453_2_.func_77973_b().showDurabilityBar(p_180453_2_)) - { -- int j = (int)Math.round(13.0D - (double)p_180453_2_.func_77952_i() * 13.0D / (double)p_180453_2_.func_77958_k()); -- int i = (int)Math.round(255.0D - (double)p_180453_2_.func_77952_i() * 255.0D / (double)p_180453_2_.func_77958_k()); -+ double health = p_180453_2_.func_77973_b().getDurabilityForDisplay(p_180453_2_); -+ int j = (int)Math.round(13.0D - health * 13.0D); -+ int i = (int)Math.round(255.0D - health * 255.0D); - GlStateManager.func_179140_f(); - GlStateManager.func_179097_i(); - GlStateManager.func_179090_x(); -@@ -473,7 +474,7 @@ - this.func_181565_a(worldrenderer, p_180453_3_ + 2, p_180453_4_ + 13, 13, 2, 0, 0, 0, 255); - this.func_181565_a(worldrenderer, p_180453_3_ + 2, p_180453_4_ + 13, 12, 1, (255 - i) / 4, 64, 0, 255); - this.func_181565_a(worldrenderer, p_180453_3_ + 2, p_180453_4_ + 13, j, 1, 255 - i, i, 0, 255); -- GlStateManager.func_179147_l(); -+ //GlStateManager.enableBlend(); // Forge: Disable Blend because it screws with a lot of things down the line. - GlStateManager.func_179141_d(); - GlStateManager.func_179098_w(); - GlStateManager.func_179145_e(); -@@ -1038,6 +1039,7 @@ - this.func_175029_a(Blocks.field_150420_aW, BlockHugeMushroom.EnumType.ALL_INSIDE.func_176896_a(), "brown_mushroom_block"); - this.func_175029_a(Blocks.field_150419_aX, BlockHugeMushroom.EnumType.ALL_INSIDE.func_176896_a(), "red_mushroom_block"); - this.func_175031_a(Blocks.field_150380_bt, "dragon_egg"); -+ net.minecraftforge.client.model.ModelLoader.onRegisterItems(this.field_175059_m); - } - - public void func_110549_a(IResourceManager p_110549_1_) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderLivingBase.java.patch similarity index 58% rename from patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch rename to patches/minecraft/net/minecraft/client/renderer/entity/RenderLivingBase.java.patch index 04e75b48e1..8d2a950867 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderLivingBase.java.patch @@ -1,51 +1,51 @@ ---- ../src-base/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java -+++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RendererLivingEntity.java -@@ -38,6 +38,9 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderLivingBase.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderLivingBase.java +@@ -32,6 +32,9 @@ protected List> field_177097_h = Lists.>newArrayList(); - protected boolean field_177098_i = false; + protected boolean field_188323_j = false; + public static float NAME_TAG_RANGE = 64.0f; + public static float NAME_TAG_RANGE_SNEAK = 32.0f; + - public RendererLivingEntity(RenderManager p_i46156_1_, ModelBase p_i46156_2_, float p_i46156_3_) + public RenderLivingBase(RenderManager p_i46156_1_, ModelBase p_i46156_2_, float p_i46156_3_) { super(p_i46156_1_); -@@ -83,10 +86,12 @@ +@@ -77,10 +80,12 @@ public void func_76986_a(T p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_))) return; ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Pre(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_))) return; GlStateManager.func_179094_E(); GlStateManager.func_179129_p(); this.field_77045_g.field_78095_p = this.func_77040_d(p_76986_1_, p_76986_9_); -- this.field_77045_g.field_78093_q = p_76986_1_.func_70115_ae(); -+ boolean shouldSit = p_76986_1_.func_70115_ae() && (p_76986_1_.field_70154_o != null && p_76986_1_.field_70154_o.shouldRiderSit()); +- this.field_77045_g.field_78093_q = p_76986_1_.func_184218_aH(); ++ boolean shouldSit = p_76986_1_.func_184218_aH() && (p_76986_1_.func_184187_bx() != null && p_76986_1_.func_184187_bx().shouldRiderSit()); + this.field_77045_g.field_78093_q = shouldSit; this.field_77045_g.field_78091_s = p_76986_1_.func_70631_g_(); try -@@ -95,7 +100,7 @@ +@@ -89,7 +94,7 @@ float f1 = this.func_77034_a(p_76986_1_.field_70758_at, p_76986_1_.field_70759_as, p_76986_9_); float f2 = f1 - f; -- if (p_76986_1_.func_70115_ae() && p_76986_1_.field_70154_o instanceof EntityLivingBase) -+ if (shouldSit && p_76986_1_.field_70154_o instanceof EntityLivingBase) +- if (p_76986_1_.func_184218_aH() && p_76986_1_.func_184187_bx() instanceof EntityLivingBase) ++ if (shouldSit && p_76986_1_.func_184187_bx() instanceof EntityLivingBase) { - EntityLivingBase entitylivingbase = (EntityLivingBase)p_76986_1_.field_70154_o; + EntityLivingBase entitylivingbase = (EntityLivingBase)p_76986_1_.func_184187_bx(); f = this.func_77034_a(entitylivingbase.field_70760_ar, entitylivingbase.field_70761_aq, p_76986_9_); -@@ -191,6 +196,7 @@ - { - super.func_76986_a(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); - } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Post(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_)); +@@ -197,6 +202,7 @@ + GlStateManager.func_179089_o(); + GlStateManager.func_179121_F(); + super.func_76986_a(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Post(p_76986_1_, this, p_76986_2_, p_76986_4_, p_76986_6_)); } - protected boolean func_177088_c(T p_177088_1_) -@@ -469,10 +475,11 @@ + public float func_188322_c(T p_188322_1_, float p_188322_2_) +@@ -452,10 +458,11 @@ public void func_177067_a(T p_177067_1_, double p_177067_2_, double p_177067_4_, double p_177067_6_) { -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Specials.Pre(p_177067_1_, this, p_177067_2_, p_177067_4_, p_177067_6_))) return; ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Specials.Pre(p_177067_1_, this, p_177067_2_, p_177067_4_, p_177067_6_))) return; if (this.func_177070_b(p_177067_1_)) { double d0 = p_177067_1_.func_70068_e(this.field_76990_c.field_78734_h); @@ -54,11 +54,11 @@ if (d0 < (double)(f * f)) { -@@ -518,6 +525,7 @@ - } +@@ -464,6 +471,7 @@ + this.func_188296_a(p_177067_1_, p_177067_2_, p_177067_4_, p_177067_6_, s, d0); } } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Specials.Post(p_177067_1_, this, p_177067_2_, p_177067_4_, p_177067_6_)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderLivingEvent.Specials.Post(p_177067_1_, this, p_177067_2_, p_177067_4_, p_177067_6_)); } protected boolean func_177070_b(T p_177070_1_) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderManager.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderManager.java.patch index 267976b536..9292829e3d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RenderManager.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderManager.java.patch @@ -1,27 +1,28 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderManager.java +++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderManager.java -@@ -192,7 +192,12 @@ +@@ -204,8 +204,13 @@ this.field_178637_m = new RenderPlayer(this); this.field_178636_l.put("default", this.field_178637_m); this.field_178636_l.put("slim", new RenderPlayer(this, true)); + net.minecraftforge.fml.client.registry.RenderingRegistry.loadEntityRenderers(this, this.field_78729_o); } -+ + + public Map getSkinMap() { + return (Map) java.util.Collections.unmodifiableMap(field_178636_l); + } - ++ public void func_178628_a(double p_178628_1_, double p_178628_3_, double p_178628_5_) { -@@ -241,9 +246,9 @@ + this.field_78725_b = p_178628_1_; +@@ -253,9 +258,9 @@ IBlockState iblockstate = p_180597_1_.func_180495_p(new BlockPos(p_180597_3_)); Block block = iblockstate.func_177230_c(); - if (block == Blocks.field_150324_C) -+ if (block.isBed(p_180597_1_, new BlockPos(p_180597_3_), (EntityLivingBase)p_180597_3_)) ++ if (block.isBed(iblockstate, p_180597_1_, new BlockPos(p_180597_3_), (EntityLivingBase)p_180597_3_)) { -- int i = ((EnumFacing)iblockstate.func_177229_b(BlockBed.field_176387_N)).func_176736_b(); -+ int i = block.getBedDirection(p_180597_1_, new BlockPos(p_180597_3_)).func_176736_b(); +- int i = ((EnumFacing)iblockstate.func_177229_b(BlockBed.field_185512_D)).func_176736_b(); ++ int i = block.getBedDirection(iblockstate, p_180597_1_, new BlockPos(p_180597_3_)).func_176736_b(); this.field_78735_i = (float)(i * 90 + 180); this.field_78732_j = 0.0F; } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java.patch index 9843655945..f54ab04379 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java +++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderPlayer.java -@@ -49,6 +49,7 @@ +@@ -55,6 +55,7 @@ public void func_76986_a(AbstractClientPlayer p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { @@ -8,9 +8,9 @@ if (!p_76986_1_.func_175144_cb() || this.field_76990_c.field_78734_h == p_76986_1_) { double d0 = p_76986_4_; -@@ -61,6 +62,7 @@ - this.func_177137_d(p_76986_1_); +@@ -69,6 +70,7 @@ super.func_76986_a(p_76986_1_, p_76986_2_, d0, p_76986_6_, p_76986_8_, p_76986_9_); + GlStateManager.func_187440_b(GlStateManager.Profile.PLAYER_SKIN); } + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Post(p_76986_1_, this, p_76986_9_, p_76986_2_, p_76986_4_, p_76986_6_)); } diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/RenderVillager.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/RenderVillager.java.patch index 75cae2f1b4..4b0720edfa 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/RenderVillager.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/RenderVillager.java.patch @@ -1,11 +1,25 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderVillager.java +++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderVillager.java -@@ -44,7 +44,7 @@ - case 4: - return field_110906_m; - default: +@@ -31,21 +31,7 @@ + + protected ResourceLocation func_110775_a(EntityVillager p_110775_1_) + { +- switch (p_110775_1_.func_70946_n()) +- { +- case 0: +- return field_110904_g; +- case 1: +- return field_110908_h; +- case 2: +- return field_110907_k; +- case 3: +- return field_110905_l; +- case 4: +- return field_110906_m; +- default: - return field_110903_f; -+ return net.minecraftforge.fml.common.registry.VillagerRegistry.getVillagerSkin(p_110775_1_.func_70946_n(), field_110903_f); - } +- } ++ return p_110775_1_.getProfessionForge().getSkin(); } + protected void func_77041_b(EntityVillager p_77041_1_, float p_77041_2_) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java.patch index 2bbf64ef4a..7d33508e94 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java.patch @@ -1,47 +1,46 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java +++ ../src-work/minecraft/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java -@@ -55,29 +55,28 @@ - T t = this.func_177175_a(p_177182_9_); - t.func_178686_a(this.field_177190_a.func_177087_b()); - t.func_78086_a(p_177182_1_, p_177182_2_, p_177182_3_, p_177182_4_); -+ t = getArmorModelHook(p_177182_1_, itemstack, p_177182_9_, t); - this.func_177179_a(t, p_177182_9_); - boolean flag = this.func_177180_b(p_177182_9_); -- this.field_177190_a.func_110776_a(this.func_177181_a(itemarmor, flag)); -+ this.field_177190_a.func_110776_a(this.getArmorResource(p_177182_1_, itemstack, flag ? 2 : 1, null)); +@@ -59,29 +59,27 @@ + T t = this.func_188360_a(p_188361_9_); + t.func_178686_a(this.field_177190_a.func_177087_b()); + t.func_78086_a(p_188361_1_, p_188361_2_, p_188361_3_, p_188361_4_); ++ t = getArmorModelHook(p_188361_1_, itemstack, p_188361_9_, t); + this.func_188359_a(t, p_188361_9_); + boolean flag = this.func_188363_b(p_188361_9_); +- this.field_177190_a.func_110776_a(this.func_177181_a(itemarmor, flag)); ++ this.field_177190_a.func_110776_a(this.getArmorResource(p_188361_1_, itemstack, p_188361_9_, null)); -- switch (itemarmor.func_82812_d()) -- { -- case LEATHER: - int i = itemarmor.func_82814_b(itemstack); -+ { -+ if (i != -1) // Allow this for anything, not only cloth. +- switch (itemarmor.func_82812_d()) +- { +- case LEATHER: + int i = itemarmor.func_82814_b(itemstack); + { - float f = (float)(i >> 16 & 255) / 255.0F; - float f1 = (float)(i >> 8 & 255) / 255.0F; - float f2 = (float)(i & 255) / 255.0F; - GlStateManager.func_179131_c(this.field_177184_f * f, this.field_177185_g * f1, this.field_177192_h * f2, this.field_177187_e); - t.func_78088_a(p_177182_1_, p_177182_2_, p_177182_3_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_); -- this.field_177190_a.func_110776_a(this.func_177178_a(itemarmor, flag, "overlay")); -- case CHAIN: -- case IRON: -- case GOLD: -- case DIAMOND: -+ this.field_177190_a.func_110776_a(this.getArmorResource(p_177182_1_, itemstack, flag ? 2 : 1, "overlay")); -+ } -+ { // Non-colored - GlStateManager.func_179131_c(this.field_177184_f, this.field_177185_g, this.field_177192_h, this.field_177187_e); - t.func_78088_a(p_177182_1_, p_177182_2_, p_177182_3_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_); -- default: ++ if (i != 0xFFFFFF) // Allow this for anything, not only cloth ++ { + float f = (float)(i >> 16 & 255) / 255.0F; + float f1 = (float)(i >> 8 & 255) / 255.0F; + float f2 = (float)(i & 255) / 255.0F; + GlStateManager.func_179131_c(this.field_177184_f * f, this.field_177185_g * f1, this.field_177192_h * f2, this.field_177187_e); + t.func_78088_a(p_188361_1_, p_188361_2_, p_188361_3_, p_188361_5_, p_188361_6_, p_188361_7_, p_188361_8_); +- this.field_177190_a.func_110776_a(this.func_177178_a(itemarmor, flag, "overlay")); +- case CHAIN: +- case IRON: +- case GOLD: +- case DIAMOND: ++ this.field_177190_a.func_110776_a(this.getArmorResource(p_188361_1_, itemstack, p_188361_9_, "overlay")); ++ } ++ { // Non-colored + GlStateManager.func_179131_c(this.field_177184_f, this.field_177185_g, this.field_177192_h, this.field_177187_e); + t.func_78088_a(p_188361_1_, p_188361_2_, p_188361_3_, p_188361_5_, p_188361_6_, p_188361_7_, p_188361_8_); +- default: - -- if (!this.field_177193_i && itemstack.func_77948_v()) -+ } -+ // Default -+ if (!this.field_177193_i && itemstack.func_77962_s()) - { - this.func_177183_a(p_177182_1_, t, p_177182_2_, p_177182_3_, p_177182_4_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_); - } -@@ -135,11 +134,13 @@ +- if (!this.field_177193_i && itemstack.func_77948_v()) ++ } // Default ++ if (!this.field_177193_i && itemstack.func_77962_s()) + { + func_188364_a(this.field_177190_a, p_188361_1_, t, p_188361_2_, p_188361_3_, p_188361_4_, p_188361_5_, p_188361_6_, p_188361_7_, p_188361_8_); + } +@@ -140,11 +138,13 @@ GlStateManager.func_179084_k(); } @@ -55,21 +54,21 @@ private ResourceLocation func_177178_a(ItemArmor p_177178_1_, boolean p_177178_2_, String p_177178_3_) { String s = String.format("textures/models/armor/%s_layer_%d%s.png", new Object[] {p_177178_1_.func_82812_d().func_179242_c(), Integer.valueOf(p_177178_2_ ? 2 : 1), p_177178_3_ == null ? "" : String.format("_%s", new Object[]{p_177178_3_})}); -@@ -157,4 +158,49 @@ +@@ -162,4 +162,49 @@ protected abstract void func_177177_a(); - protected abstract void func_177179_a(T p_177179_1_, int p_177179_2_); + protected abstract void func_188359_a(T p_188359_1_, EntityEquipmentSlot p_188359_2_); + + /*=================================== FORGE START =========================================*/ + + /** + * Hook to allow item-sensitive armor model. for LayerBipedArmor. + */ -+ protected T getArmorModelHook(EntityLivingBase entity, ItemStack itemStack, int slot, T model) ++ protected T getArmorModelHook(EntityLivingBase entity, ItemStack itemStack, EntityEquipmentSlot slot, T model) + { + return model; + } -+ ++ + /** + * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide. + * @@ -79,7 +78,7 @@ + * @param type Subtype, can be null or "overlay" + * @return ResourceLocation pointing at the armor's texture + */ -+ public ResourceLocation getArmorResource(net.minecraft.entity.Entity entity, ItemStack stack, int slot, String type) ++ public ResourceLocation getArmorResource(net.minecraft.entity.Entity entity, ItemStack stack, EntityEquipmentSlot slot, String type) + { + ItemArmor item = (ItemArmor)stack.func_77973_b(); + String texture = item.func_82812_d().func_179242_c(); @@ -90,7 +89,7 @@ + domain = texture.substring(0, idx); + texture = texture.substring(idx + 1); + } -+ String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (slot == 2 ? 2 : 1), type == null ? "" : String.format("_%s", type)); ++ String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (func_188363_b(slot) ? 2 : 1), type == null ? "" : String.format("_%s", type)); + + s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type); + ResourceLocation resourcelocation = (ResourceLocation)field_177191_j.get(s1); diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/layers/LayerBipedArmor.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/layers/LayerBipedArmor.java.patch index e391d61ac7..b5b72c1951 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/layers/LayerBipedArmor.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/layers/LayerBipedArmor.java.patch @@ -1,12 +1,12 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/entity/layers/LayerBipedArmor.java +++ ../src-work/minecraft/net/minecraft/client/renderer/entity/layers/LayerBipedArmor.java -@@ -49,4 +49,10 @@ +@@ -51,4 +51,10 @@ { p_177194_1_.func_178719_a(false); } + + @Override -+ protected ModelBiped getArmorModelHook(net.minecraft.entity.EntityLivingBase entity, net.minecraft.item.ItemStack itemStack, int slot, ModelBiped model) ++ protected ModelBiped getArmorModelHook(net.minecraft.entity.EntityLivingBase entity, net.minecraft.item.ItemStack itemStack, EntityEquipmentSlot slot, ModelBiped model) + { + return net.minecraftforge.client.ForgeHooksClient.getArmorModel(entity, itemStack, slot, model); + } diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch index 1dbb9630a2..9f4d33cb8d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/Stitcher.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/texture/Stitcher.java +++ ../src-work/minecraft/net/minecraft/client/renderer/texture/Stitcher.java -@@ -58,12 +58,17 @@ +@@ -56,18 +56,24 @@ { Stitcher.Holder[] astitcher$holder = (Stitcher.Holder[])this.field_94319_a.toArray(new Stitcher.Holder[this.field_94319_a.size()]); Arrays.sort((Object[])astitcher$holder); @@ -18,15 +18,14 @@ throw new StitcherException(stitcher$holder, s); } } -@@ -73,6 +78,7 @@ - this.field_94318_c = MathHelper.func_151236_b(this.field_94318_c); - this.field_94315_d = MathHelper.func_151236_b(this.field_94315_d); - } + + this.field_94318_c = MathHelper.func_151236_b(this.field_94318_c); + this.field_94315_d = MathHelper.func_151236_b(this.field_94315_d); + net.minecraftforge.fml.common.ProgressManager.pop(bar); } public List func_94309_g() -@@ -260,7 +266,7 @@ +@@ -238,7 +244,7 @@ public String toString() { diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch index 7d88952483..b7a16e4ae0 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java.patch @@ -1,6 +1,23 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java +++ ../src-work/minecraft/net/minecraft/client/renderer/texture/TextureAtlasSprite.java -@@ -402,4 +402,30 @@ +@@ -50,12 +50,10 @@ + this.field_110975_c = p_110971_3_; + this.field_110974_d = p_110971_4_; + this.field_130222_e = p_110971_5_; +- float f = (float)(0.009999999776482582D / (double)p_110971_1_); +- float f1 = (float)(0.009999999776482582D / (double)p_110971_2_); +- this.field_110979_l = (float)p_110971_3_ / (float)((double)p_110971_1_) + f; +- this.field_110980_m = (float)(p_110971_3_ + this.field_130223_c) / (float)((double)p_110971_1_) - f; +- this.field_110977_n = (float)p_110971_4_ / (float)p_110971_2_ + f1; +- this.field_110978_o = (float)(p_110971_4_ + this.field_130224_d) / (float)p_110971_2_ - f1; ++ this.field_110979_l = (float)p_110971_3_ / (float)p_110971_1_; ++ this.field_110980_m = (float)(p_110971_3_ + this.field_130223_c) / (float)p_110971_1_; ++ this.field_110977_n = (float)p_110971_4_ / (float)p_110971_2_; ++ this.field_110978_o = (float)(p_110971_4_ + this.field_130224_d) / (float)p_110971_2_; + } + + public void func_94217_a(TextureAtlasSprite p_94217_1_) +@@ -398,4 +396,30 @@ { return "TextureAtlasSprite{name=\'" + this.field_110984_i + '\'' + ", frameCount=" + this.field_110976_a.size() + ", rotated=" + this.field_130222_e + ", x=" + this.field_110975_c + ", y=" + this.field_110974_d + ", height=" + this.field_130224_d + ", width=" + this.field_130223_c + ", u0=" + this.field_110979_l + ", u1=" + this.field_110980_m + ", v0=" + this.field_110977_n + ", v1=" + this.field_110978_o + '}'; } diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch index 133b68b97c..4622bff373 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureMap.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/texture/TextureMap.java +++ ../src-work/minecraft/net/minecraft/client/renderer/texture/TextureMap.java -@@ -28,6 +28,7 @@ +@@ -26,6 +26,7 @@ @SideOnly(Side.CLIENT) public class TextureMap extends AbstractTexture implements ITickableTextureObject { @@ -8,7 +8,7 @@ private static final Logger field_147635_d = LogManager.getLogger(); public static final ResourceLocation field_174945_f = new ResourceLocation("missingno"); public static final ResourceLocation field_110575_b = new ResourceLocation("textures/atlas/blocks.png"); -@@ -38,6 +39,7 @@ +@@ -36,6 +37,7 @@ private final IIconCreator field_174946_m; private int field_147636_j; private final TextureAtlasSprite field_94249_f; @@ -16,32 +16,31 @@ public TextureMap(String p_i46099_1_) { -@@ -46,12 +48,23 @@ +@@ -44,12 +46,23 @@ public TextureMap(String p_i46100_1_, IIconCreator p_i46100_2_) { + this(p_i46100_1_, p_i46100_2_, false); + } + -+ public TextureMap(String p_i46100_1_, boolean skipFirst) ++ public TextureMap(String basePathIn, boolean skipFirst) + { -+ this(p_i46100_1_, null, skipFirst); ++ this(basePathIn, null, skipFirst); + } + -+ public TextureMap(String p_i46100_1_, IIconCreator iconCreatorIn, boolean skipFirst) ++ public TextureMap(String p_i46100_1_, IIconCreator p_i46100_2_, boolean skipFirst) + { this.field_94258_i = Lists.newArrayList(); this.field_110574_e = Maps.newHashMap(); this.field_94252_e = Maps.newHashMap(); this.field_94249_f = new TextureAtlasSprite("missingno"); this.field_94254_c = p_i46100_1_; -- this.field_174946_m = p_i46100_2_; -+ this.field_174946_m = iconCreatorIn; + this.field_174946_m = p_i46100_2_; + this.skipFirst = skipFirst && ENABLE_SKIP; } private void func_110569_e() -@@ -90,12 +103,28 @@ +@@ -88,12 +101,26 @@ int j = Integer.MAX_VALUE; int k = 1 << this.field_147636_j; @@ -53,67 +52,52 @@ for (Entry entry : this.field_110574_e.entrySet()) { TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)entry.getValue(); - ResourceLocation resourcelocation = new ResourceLocation(textureatlassprite.func_94215_i()); - ResourceLocation resourcelocation1 = this.func_147634_a(resourcelocation, 0); -+ bar.step(resourcelocation1.func_110623_a()); + ResourceLocation resourcelocation = this.func_184396_a(textureatlassprite); ++ bar.step(resourcelocation.func_110623_a()); + IResource iresource = null; + if (textureatlassprite.hasCustomLoader(p_110571_1_, resourcelocation)) + { -+ if (!textureatlassprite.load(p_110571_1_, resourcelocation)) ++ if (textureatlassprite.load(p_110571_1_, resourcelocation)) + { -+ j = Math.min(j, Math.min(textureatlassprite.func_94211_a(), textureatlassprite.func_94216_b())); -+ stitcher.func_110934_a(textureatlassprite); ++ continue; + } -+ continue; + } -+ ++ else try { - IResource iresource = p_110571_1_.func_110536_a(resourcelocation1); -@@ -145,12 +174,14 @@ + PngSizeInfo pngsizeinfo = PngSizeInfo.func_188532_a(p_110571_1_.func_110536_a(resourcelocation)); +@@ -103,12 +130,14 @@ } catch (RuntimeException runtimeexception) { -- field_147635_d.error((String)("Unable to parse metadata from " + resourcelocation1), (Throwable)runtimeexception); -+ //logger.error((String)("Unable to parse metadata from " + resourcelocation1), (Throwable)runtimeexception); -+ net.minecraftforge.fml.client.FMLClientHandler.instance().trackBrokenTexture(resourcelocation1, runtimeexception.getMessage()); +- field_147635_d.error((String)("Unable to parse metadata from " + resourcelocation), (Throwable)runtimeexception); ++ //logger.error((String)("Unable to parse metadata from " + resourcelocation), (Throwable)runtimeexception); ++ net.minecraftforge.fml.client.FMLClientHandler.instance().trackBrokenTexture(resourcelocation, runtimeexception.getMessage()); continue; } - catch (IOException ioexception1) + catch (IOException ioexception) { -- field_147635_d.error((String)("Using missing texture, unable to load " + resourcelocation1), (Throwable)ioexception1); -+ //logger.error((String)("Using missing texture, unable to load " + resourcelocation1), (Throwable)ioexception1); -+ net.minecraftforge.fml.client.FMLClientHandler.instance().trackMissingTexture(resourcelocation1); +- field_147635_d.error((String)("Using missing texture, unable to load " + resourcelocation), (Throwable)ioexception); ++ //logger.error((String)("Using missing texture, unable to load " + resourcelocation), (Throwable)ioexception); ++ net.minecraftforge.fml.client.FMLClientHandler.instance().trackMissingTexture(resourcelocation); continue; } - -@@ -166,6 +197,7 @@ + finally +@@ -128,6 +157,7 @@ stitcher.func_110934_a(textureatlassprite); } + net.minecraftforge.fml.common.ProgressManager.pop(bar); - int j1 = Math.min(j, k); - int k1 = MathHelper.func_151239_c(j1); + int l = Math.min(j, k); + int i1 = MathHelper.func_151239_c(l); -@@ -175,8 +207,11 @@ - this.field_147636_j = k1; - } - -+ bar = net.minecraftforge.fml.common.ProgressManager.push("Mipmap generation", skipFirst ? 0 : this.field_110574_e.size()); - for (final TextureAtlasSprite textureatlassprite1 : this.field_110574_e.values()) - { -+ if (skipFirst) break; -+ bar.step(textureatlassprite1.func_94215_i()); - try - { - textureatlassprite1.func_147963_d(this.field_147636_j); -@@ -213,9 +248,13 @@ +@@ -139,9 +169,12 @@ this.field_94249_f.func_147963_d(this.field_147636_j); stitcher.func_110934_a(this.field_94249_f); -+ net.minecraftforge.fml.common.ProgressManager.pop(bar); + skipFirst = false; -+ bar = net.minecraftforge.fml.common.ProgressManager.push("Texture creation", 3); ++ bar = net.minecraftforge.fml.common.ProgressManager.push("Texture creation", 2); try { @@ -121,7 +105,7 @@ stitcher.func_94305_f(); } catch (StitcherException stitcherexception) -@@ -224,9 +263,11 @@ +@@ -150,11 +183,16 @@ } field_147635_d.info("Created: {}x{} {}-atlas", new Object[] {Integer.valueOf(stitcher.func_110935_a()), Integer.valueOf(stitcher.func_110936_b()), this.field_94254_c}); @@ -129,13 +113,18 @@ TextureUtil.func_180600_a(this.func_110552_b(), this.field_147636_j, stitcher.func_110935_a(), stitcher.func_110936_b()); Map map = Maps.newHashMap(this.field_110574_e); -+ bar.step("Uploading GL texture"); - for (TextureAtlasSprite textureatlassprite2 : stitcher.func_94309_g()) ++ net.minecraftforge.fml.common.ProgressManager.pop(bar); ++ bar = net.minecraftforge.fml.common.ProgressManager.push("Texture mipmap and upload", stitcher.func_94309_g().size()); ++ + for (TextureAtlasSprite textureatlassprite1 : stitcher.func_94309_g()) { - String s = textureatlassprite2.func_94215_i(); -@@ -256,6 +297,13 @@ ++ bar.step(textureatlassprite1.func_94215_i()); + if (textureatlassprite1 == this.field_94249_f || this.func_184397_a(p_110571_1_, textureatlassprite1)) + { + String s = textureatlassprite1.func_94215_i(); +@@ -185,6 +223,13 @@ { - textureatlassprite3.func_94217_a(this.field_94249_f); + textureatlassprite2.func_94217_a(this.field_94249_f); } + + net.minecraftforge.client.ForgeHooksClient.onTextureStitchedPost(this); @@ -146,8 +135,26 @@ + net.minecraftforge.fml.common.ProgressManager.pop(bar); } - private ResourceLocation func_147634_a(ResourceLocation p_147634_1_, int p_147634_2_) -@@ -319,4 +367,37 @@ + private boolean func_184397_a(IResourceManager p_184397_1_, final TextureAtlasSprite p_184397_2_) +@@ -194,7 +239,7 @@ + label9: + { + boolean flag; +- ++ if (p_184397_2_.hasCustomLoader(p_184397_1_, resourcelocation)) break label9; + try + { + iresource = p_184397_1_.func_110536_a(resourcelocation); +@@ -291,7 +336,7 @@ + } + else + { +- TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.field_110574_e.get(p_174942_1_); ++ TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.field_110574_e.get(p_174942_1_.toString()); + + if (textureatlassprite == null) + { +@@ -317,4 +362,37 @@ { return this.field_94249_f; } diff --git a/patches/minecraft/net/minecraft/client/renderer/texture/TextureUtil.java.patch b/patches/minecraft/net/minecraft/client/renderer/texture/TextureUtil.java.patch index a9d758ece2..cb9c3dc8e8 100644 --- a/patches/minecraft/net/minecraft/client/renderer/texture/TextureUtil.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/texture/TextureUtil.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/texture/TextureUtil.java +++ ../src-work/minecraft/net/minecraft/client/renderer/texture/TextureUtil.java -@@ -197,9 +197,11 @@ +@@ -202,9 +202,11 @@ public static void func_180600_a(int p_180600_0_, int p_180600_1_, int p_180600_2_, int p_180600_3_) { @@ -12,4 +12,4 @@ + } if (p_180600_1_ >= 0) { - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, p_180600_1_); + GlStateManager.func_187421_b(3553, 33085, p_180600_1_); diff --git a/patches/minecraft/net/minecraft/client/renderer/tileentity/RenderItemFrame.java.patch b/patches/minecraft/net/minecraft/client/renderer/tileentity/RenderItemFrame.java.patch index d0ec3a7d9f..1cd896209d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/tileentity/RenderItemFrame.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/tileentity/RenderItemFrame.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/tileentity/RenderItemFrame.java +++ ../src-work/minecraft/net/minecraft/client/renderer/tileentity/RenderItemFrame.java -@@ -99,15 +99,18 @@ +@@ -105,15 +105,18 @@ GlStateManager.func_179140_f(); int i = p_82402_1_.func_82333_j(); @@ -21,9 +21,9 @@ this.field_76990_c.field_78724_e.func_110577_a(field_110789_a); GlStateManager.func_179114_b(180.0F, 0.0F, 0.0F, 1.0F); float f = 0.0078125F; -@@ -165,6 +168,7 @@ - textureatlassprite.func_94219_l(); - } +@@ -142,6 +145,7 @@ + RenderHelper.func_74518_a(); + GlStateManager.func_179099_b(); } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java.patch index 22634cf060..3977f21e22 100644 --- a/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java +++ ../src-work/minecraft/net/minecraft/client/renderer/tileentity/TileEntityItemStackRenderer.java -@@ -78,6 +78,7 @@ +@@ -98,6 +98,7 @@ { TileEntityRendererDispatcher.field_147556_a.func_147549_a(this.field_147718_c, 0.0D, 0.0D, 0.0D, 0.0F); } diff --git a/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java.patch b/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java.patch index 92a84ea6bf..f5f95ca273 100644 --- a/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java.patch @@ -1,25 +1,25 @@ --- ../src-base/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java +++ ../src-work/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java -@@ -102,11 +102,14 @@ +@@ -106,11 +106,14 @@ { if (p_180546_1_.func_145835_a(this.field_147560_j, this.field_147561_k, this.field_147558_l) < p_180546_1_.func_145833_n()) { -+ if(!p_180546_1_.hasFastRenderer()) ++ if(!drawingBatch || !p_180546_1_.hasFastRenderer()) + { int i = this.field_147550_f.func_175626_b(p_180546_1_.func_174877_v(), 0); int j = i % 65536; int k = i / 65536; - OpenGlHelper.func_77475_a(OpenGlHelper.field_77476_b, (float)j / 1.0F, (float)k / 1.0F); + OpenGlHelper.func_77475_a(OpenGlHelper.field_77476_b, (float)j, (float)k); GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); + } BlockPos blockpos = p_180546_1_.func_174877_v(); this.func_178469_a(p_180546_1_, (double)blockpos.func_177958_n() - field_147554_b, (double)blockpos.func_177956_o() - field_147555_c, (double)blockpos.func_177952_p() - field_147552_d, p_180546_2_, p_180546_3_); } -@@ -125,6 +128,11 @@ +@@ -129,6 +132,11 @@ { try { -+ if(p_178469_1_.hasFastRenderer()) ++ if(drawingBatch && p_178469_1_.hasFastRenderer()) + { + tileentityspecialrenderer.renderTileEntityFast(p_178469_1_, p_178469_2_, p_178469_4_, p_178469_6_, p_178469_8_, p_178469_9_, batchBuffer.func_178180_c()); + } @@ -27,7 +27,7 @@ tileentityspecialrenderer.func_180535_a(p_178469_1_, p_178469_2_, p_178469_4_, p_178469_6_, p_178469_8_, p_178469_9_); } catch (Throwable throwable) -@@ -146,4 +154,49 @@ +@@ -155,4 +163,52 @@ { return this.field_147557_n; } @@ -37,6 +37,7 @@ + * Buffer used for batched TESRs + */ + private net.minecraft.client.renderer.Tessellator batchBuffer = new net.minecraft.client.renderer.Tessellator(0x200000); ++ private boolean drawingBatch = false; + + /** + * Prepare for a batched TESR rendering. @@ -45,6 +46,7 @@ + public void preDrawBatch() + { + batchBuffer.func_178180_c().func_181668_a(org.lwjgl.opengl.GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.field_176600_a); ++ drawingBatch = true; + } + + /** @@ -75,5 +77,6 @@ + batchBuffer.func_78381_a(); + + net.minecraft.client.renderer.RenderHelper.func_74519_b(); ++ drawingBatch = false; + } } diff --git a/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer.java.patch index 2dcbbec257..adf45bb4c5 100644 --- a/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer.java.patch @@ -5,5 +5,5 @@ return false; } + -+ public void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, net.minecraft.client.renderer.WorldRenderer worldRenderer) {} ++ public void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, net.minecraft.client.renderer.VertexBuffer buffer) {} } diff --git a/patches/minecraft/net/minecraft/client/resources/FallbackResourceManager.java.patch b/patches/minecraft/net/minecraft/client/resources/FallbackResourceManager.java.patch index fa5296e396..4d42cf3118 100644 --- a/patches/minecraft/net/minecraft/client/resources/FallbackResourceManager.java.patch +++ b/patches/minecraft/net/minecraft/client/resources/FallbackResourceManager.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/resources/FallbackResourceManager.java +++ ../src-work/minecraft/net/minecraft/client/resources/FallbackResourceManager.java -@@ -67,6 +67,7 @@ +@@ -68,6 +68,7 @@ throw new FileNotFoundException(p_110536_1_.toString()); } diff --git a/patches/minecraft/net/minecraft/client/resources/LanguageManager.java.patch b/patches/minecraft/net/minecraft/client/resources/LanguageManager.java.patch deleted file mode 100644 index 4bc3d483c2..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/LanguageManager.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/client/resources/LanguageManager.java -+++ ../src-work/minecraft/net/minecraft/client/resources/LanguageManager.java -@@ -73,6 +73,7 @@ - } - - field_135049_a.func_135022_a(p_110549_1_, list); -+ net.minecraftforge.fml.common.registry.LanguageRegistry.instance().mergeLanguageTable(field_135049_a.field_135032_a, this.field_135048_c); - StringTranslate.func_135063_a(field_135049_a.field_135032_a); - } - diff --git a/patches/minecraft/net/minecraft/client/resources/model/IBakedModel.java.patch b/patches/minecraft/net/minecraft/client/resources/model/IBakedModel.java.patch deleted file mode 100644 index d792aea1bb..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/model/IBakedModel.java.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/client/resources/model/IBakedModel.java -+++ ../src-work/minecraft/net/minecraft/client/resources/model/IBakedModel.java -@@ -23,5 +23,6 @@ - - TextureAtlasSprite func_177554_e(); - -+ @Deprecated - ItemCameraTransforms func_177552_f(); - } diff --git a/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch b/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch deleted file mode 100644 index 3382ee553b..0000000000 --- a/patches/minecraft/net/minecraft/client/resources/model/ModelBakery.java.patch +++ /dev/null @@ -1,129 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/client/resources/model/ModelBakery.java -+++ ../src-work/minecraft/net/minecraft/client/resources/model/ModelBakery.java -@@ -114,7 +114,7 @@ - } - catch (Exception var6) - { -- field_177603_c.warn("Unable to load variant: " + modelresourcelocation.func_177518_c() + " from " + modelresourcelocation); -+ field_177603_c.warn("Unable to load variant: " + modelresourcelocation.func_177518_c() + " from " + modelresourcelocation, var6); - } - } - catch (Exception exception) -@@ -294,6 +294,7 @@ - - protected void func_177592_e() - { -+ this.field_177613_u.clear(); //FML clear this to prevent double ups. - this.field_177613_u.put(Item.func_150898_a(Blocks.field_150348_b), Lists.newArrayList(new String[] {"stone", "granite", "granite_smooth", "diorite", "diorite_smooth", "andesite", "andesite_smooth"})); - this.field_177613_u.put(Item.func_150898_a(Blocks.field_150346_d), Lists.newArrayList(new String[] {"dirt", "coarse_dirt", "podzol"})); - this.field_177613_u.put(Item.func_150898_a(Blocks.field_150344_f), Lists.newArrayList(new String[] {"oak_planks", "spruce_planks", "birch_planks", "jungle_planks", "acacia_planks", "dark_oak_planks"})); -@@ -336,6 +337,10 @@ - this.field_177613_u.put(Item.func_150898_a(Blocks.field_180390_bo), Lists.newArrayList(new String[] {"oak_fence_gate"})); - this.field_177613_u.put(Item.func_150898_a(Blocks.field_180407_aO), Lists.newArrayList(new String[] {"oak_fence"})); - this.field_177613_u.put(Items.field_179570_aq, Lists.newArrayList(new String[] {"oak_door"})); -+ for (Entry, Set> e : customVariantNames.entrySet()) -+ { -+ this.field_177613_u.put(e.getKey().get(), Lists.newArrayList(e.getValue().iterator())); -+ } - } - - protected List func_177596_a(Item p_177596_1_) -@@ -352,7 +357,7 @@ - - protected ResourceLocation func_177583_a(String p_177583_1_) - { -- ResourceLocation resourcelocation = new ResourceLocation(p_177583_1_); -+ ResourceLocation resourcelocation = new ResourceLocation(p_177583_1_.replaceAll("#.*", "")); - return new ResourceLocation(resourcelocation.func_110624_b(), "item/" + resourcelocation.func_110623_a()); - } - -@@ -395,7 +400,7 @@ - for (Entry entry : this.field_177615_s.entrySet()) - { - ResourceLocation resourcelocation = (ResourceLocation)entry.getValue(); -- ModelResourceLocation modelresourcelocation1 = new ModelResourceLocation((String)entry.getKey(), "inventory"); -+ ModelResourceLocation modelresourcelocation1 = net.minecraftforge.client.model.ModelLoader.getInventoryVariant(entry.getKey()); - ModelBlock modelblock1 = (ModelBlock)this.field_177611_h.get(resourcelocation); - - if (modelblock1 != null && modelblock1.func_178303_d()) -@@ -453,6 +458,11 @@ - - private IBakedModel func_177578_a(ModelBlock p_177578_1_, ModelRotation p_177578_2_, boolean p_177578_3_) - { -+ return bakeModel(p_177578_1_, (net.minecraftforge.client.model.ITransformation)p_177578_2_, p_177578_3_); -+ } -+ -+ protected IBakedModel bakeModel(ModelBlock p_177578_1_, net.minecraftforge.client.model.ITransformation p_177578_2_, boolean p_177578_3_) -+ { - TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.field_177599_g.get(new ResourceLocation(p_177578_1_.func_178308_c("particle"))); - SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(p_177578_1_)).func_177646_a(textureatlassprite); - -@@ -463,13 +473,13 @@ - BlockPartFace blockpartface = (BlockPartFace)blockpart.field_178240_c.get(enumfacing); - TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)this.field_177599_g.get(new ResourceLocation(p_177578_1_.func_178308_c(blockpartface.field_178242_d))); - -- if (blockpartface.field_178244_b == null) -+ if (blockpartface.field_178244_b == null || !net.minecraftforge.client.model.TRSRTransformation.isInteger(p_177578_2_.getMatrix())) - { -- simplebakedmodel$builder.func_177648_a(this.func_177589_a(blockpart, blockpartface, textureatlassprite1, enumfacing, p_177578_2_, p_177578_3_)); -+ simplebakedmodel$builder.func_177648_a(this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, p_177578_2_, p_177578_3_)); - } - else - { -- simplebakedmodel$builder.func_177650_a(p_177578_2_.func_177523_a(blockpartface.field_178244_b), this.func_177589_a(blockpart, blockpartface, textureatlassprite1, enumfacing, p_177578_2_, p_177578_3_)); -+ simplebakedmodel$builder.func_177650_a(p_177578_2_.rotate(blockpartface.field_178244_b), this.makeBakedQuad(blockpart, blockpartface, textureatlassprite1, enumfacing, p_177578_2_, p_177578_3_)); - } - } - } -@@ -479,9 +489,14 @@ - - private BakedQuad func_177589_a(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, ModelRotation p_177589_5_, boolean p_177589_6_) - { -- return this.field_177607_l.func_178414_a(p_177589_1_.field_178241_a, p_177589_1_.field_178239_b, p_177589_2_, p_177589_3_, p_177589_4_, p_177589_5_, p_177589_1_.field_178237_d, p_177589_6_, p_177589_1_.field_178238_e); -+ return makeBakedQuad(p_177589_1_, p_177589_2_, p_177589_3_, p_177589_4_, (net.minecraftforge.client.model.ITransformation)p_177589_5_, p_177589_6_); - } - -+ protected BakedQuad makeBakedQuad(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, net.minecraftforge.client.model.ITransformation p_177589_5_, boolean p_177589_6_) -+ { -+ return this.field_177607_l.makeBakedQuad(p_177589_1_.field_178241_a, p_177589_1_.field_178239_b, p_177589_2_, p_177589_3_, p_177589_4_, p_177589_5_, p_177589_1_.field_178237_d, p_177589_6_, p_177589_1_.field_178238_e); -+ } -+ - private void func_177597_h() - { - this.func_177574_i(); -@@ -722,4 +737,35 @@ - field_177617_q.field_178317_b = "class generation marker"; - field_177616_r.field_178317_b = "block entity marker"; - } -+ -+ /*********************************************************** -+ * FML Start -+ ***********************************************************/ -+ private static Map, Set> customVariantNames = Maps.newHashMap(); -+ /** -+ * @deprecated use registerItemVariants -+ */ -+ @Deprecated -+ public static void addVariantName(Item item, String... names) -+ { -+ if (customVariantNames.containsKey(item.delegate)) -+ customVariantNames.get(item.delegate).addAll(Lists.newArrayList(names)); -+ else -+ customVariantNames.put(item.delegate, Sets.newHashSet(names)); -+ } -+ -+ public static void registerItemVariants(Item item, T... names) -+ { -+ if (!customVariantNames.containsKey(item.delegate)) -+ { -+ customVariantNames.put(item.delegate, Sets.newHashSet()); -+ } -+ for(ResourceLocation name : names) -+ { -+ customVariantNames.get(item.delegate).add(name.toString()); -+ } -+ } -+ /*********************************************************** -+ * FML End -+ ***********************************************************/ - } diff --git a/patches/minecraft/net/minecraft/client/settings/GameSettings.java.patch b/patches/minecraft/net/minecraft/client/settings/GameSettings.java.patch index 7d50686a06..affbeca4f3 100644 --- a/patches/minecraft/net/minecraft/client/settings/GameSettings.java.patch +++ b/patches/minecraft/net/minecraft/client/settings/GameSettings.java.patch @@ -1,6 +1,30 @@ --- ../src-base/minecraft/net/minecraft/client/settings/GameSettings.java +++ ../src-work/minecraft/net/minecraft/client/settings/GameSettings.java -@@ -994,6 +994,7 @@ +@@ -147,6 +147,7 @@ + + public GameSettings(Minecraft p_i46326_1_, File p_i46326_2_) + { ++ setForgeKeybindProperties(); + this.field_74324_K = (KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.field_74312_F, this.field_74313_G, this.field_74351_w, this.field_74370_x, this.field_74368_y, this.field_74366_z, this.field_74314_A, this.field_74311_E, this.field_151444_V, this.field_74316_C, this.field_151445_Q, this.field_74310_D, this.field_74321_H, this.field_74322_I, this.field_74323_J, this.field_151447_Z, this.field_151457_aa, this.field_151458_ab, this.field_152395_am, this.field_178883_an, this.field_186718_X}, this.field_151456_ac); + this.field_74318_M = EnumDifficulty.NORMAL; + this.field_74332_R = ""; +@@ -171,6 +172,7 @@ + + public GameSettings() + { ++ setForgeKeybindProperties(); + this.field_74324_K = (KeyBinding[])ArrayUtils.addAll(new KeyBinding[] {this.field_74312_F, this.field_74313_G, this.field_74351_w, this.field_74370_x, this.field_74368_y, this.field_74366_z, this.field_74314_A, this.field_74311_E, this.field_151444_V, this.field_74316_C, this.field_151445_Q, this.field_74310_D, this.field_74321_H, this.field_74322_I, this.field_74323_J, this.field_151447_Z, this.field_151457_aa, this.field_151458_ab, this.field_152395_am, this.field_178883_an, this.field_186718_X}, this.field_151456_ac); + this.field_74318_M = EnumDifficulty.NORMAL; + this.field_74332_R = ""; +@@ -846,6 +848,7 @@ + if (astring[0].equals("key_" + keybinding.func_151464_g())) + { + keybinding.func_151462_b(Integer.parseInt(astring[1])); ++ if (astring.length == 3) keybinding.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.valueFromString(astring[2]), Integer.parseInt(astring[1])); + } + } + +@@ -887,6 +890,7 @@ public void func_74303_b() { @@ -8,3 +32,38 @@ try { PrintWriter printwriter = new PrintWriter(new FileWriter(this.field_74354_ai)); +@@ -955,7 +959,8 @@ + + for (KeyBinding keybinding : this.field_74324_K) + { +- printwriter.println("key_" + keybinding.func_151464_g() + ":" + keybinding.func_151463_i()); ++ String keyString = "key_" + keybinding.func_151464_g() + ":" + keybinding.func_151463_i(); ++ printwriter.println(keybinding.getKeyModifier() != net.minecraftforge.client.settings.KeyModifier.NONE ? keyString + ":" + keybinding.getKeyModifier() : keyString); + } + + for (SoundCategory soundcategory : SoundCategory.values()) +@@ -1184,4 +1189,24 @@ + return p_148264_1_; + } + } ++ ++ /******* Forge Start ***********/ ++ private void setForgeKeybindProperties() { ++ net.minecraftforge.client.settings.KeyConflictContext inGame = net.minecraftforge.client.settings.KeyConflictContext.IN_GAME; ++ field_74351_w.setKeyConflictContext(inGame); ++ field_74370_x.setKeyConflictContext(inGame); ++ field_74368_y.setKeyConflictContext(inGame); ++ field_74366_z.setKeyConflictContext(inGame); ++ field_74314_A.setKeyConflictContext(inGame); ++ field_74311_E.setKeyConflictContext(inGame); ++ field_151444_V.setKeyConflictContext(inGame); ++ field_74312_F.setKeyConflictContext(inGame); ++ field_74310_D.setKeyConflictContext(inGame); ++ field_74321_H.setKeyConflictContext(inGame); ++ field_74323_J.setKeyConflictContext(inGame); ++ field_151457_aa.setKeyConflictContext(inGame); ++ field_151458_ab.setKeyConflictContext(inGame); ++ field_186718_X.setKeyConflictContext(inGame); ++ } ++ /******* Forge End ***********/ + } diff --git a/patches/minecraft/net/minecraft/client/settings/KeyBinding.java.patch b/patches/minecraft/net/minecraft/client/settings/KeyBinding.java.patch new file mode 100644 index 0000000000..d238490901 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/settings/KeyBinding.java.patch @@ -0,0 +1,190 @@ +--- ../src-base/minecraft/net/minecraft/client/settings/KeyBinding.java ++++ ../src-work/minecraft/net/minecraft/client/settings/KeyBinding.java +@@ -14,7 +14,7 @@ + public class KeyBinding implements Comparable + { + private static final List field_74516_a = Lists.newArrayList(); +- private static final IntHashMap field_74514_b = new IntHashMap(); ++ private static final net.minecraftforge.client.settings.KeyBindingMap field_74514_b = new net.minecraftforge.client.settings.KeyBindingMap(); + private static final Set field_151473_c = Sets.newHashSet(); + private final String field_74515_c; + private final int field_151472_e; +@@ -27,7 +27,7 @@ + { + if (p_74507_0_ != 0) + { +- KeyBinding keybinding = (KeyBinding)field_74514_b.func_76041_a(p_74507_0_); ++ KeyBinding keybinding = field_74514_b.lookupActive(p_74507_0_); + + if (keybinding != null) + { +@@ -40,7 +40,7 @@ + { + if (p_74510_0_ != 0) + { +- KeyBinding keybinding = (KeyBinding)field_74514_b.func_76041_a(p_74510_0_); ++ for (KeyBinding keybinding : field_74514_b.lookupAll(p_74510_0_)) + + if (keybinding != null) + { +@@ -74,11 +74,11 @@ + + public static void func_74508_b() + { +- field_74514_b.func_76046_c(); ++ field_74514_b.clearMap(); + + for (KeyBinding keybinding : field_74516_a) + { +- field_74514_b.func_76038_a(keybinding.field_74512_d, keybinding); ++ field_74514_b.addKey(keybinding.field_74512_d, keybinding); + } + } + +@@ -94,13 +94,13 @@ + this.field_151472_e = p_i45001_2_; + this.field_151471_f = p_i45001_3_; + field_74516_a.add(this); +- field_74514_b.func_76038_a(p_i45001_2_, this); ++ field_74514_b.addKey(p_i45001_2_, this); + field_151473_c.add(p_i45001_3_); + } + + public boolean func_151470_d() + { +- return this.field_74513_e; ++ return this.field_74513_e && getKeyConflictContext().isActive() && getKeyModifier().isActive(); + } + + public String func_151466_e() +@@ -158,4 +158,130 @@ + + return i; + } ++ ++ /****************** Forge Start *****************************/ ++ private net.minecraftforge.client.settings.KeyModifier keyModifierDefault = net.minecraftforge.client.settings.KeyModifier.NONE; ++ private net.minecraftforge.client.settings.KeyModifier keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; ++ private net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext = net.minecraftforge.client.settings.KeyConflictContext.UNIVERSAL; ++ ++ /** ++ * Convenience constructor for creating KeyBindings with keyConflictContext set. ++ */ ++ public KeyBinding(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, int keyCode, String category) ++ { ++ this(description, keyConflictContext, net.minecraftforge.client.settings.KeyModifier.NONE, keyCode, category); ++ } ++ ++ /** ++ * Convenience constructor for creating KeyBindings with keyConflictContext and keyModifier set. ++ */ ++ public KeyBinding(String description, net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext, net.minecraftforge.client.settings.KeyModifier keyModifier, int keyCode, String category) ++ { ++ this.field_74515_c = description; ++ this.field_74512_d = keyCode; ++ this.field_151472_e = keyCode; ++ this.field_151471_f = category; ++ this.keyConflictContext = keyConflictContext; ++ this.keyModifier = keyModifier; ++ this.keyModifierDefault = keyModifier; ++ if (this.keyModifier.matches(keyCode)) ++ { ++ this.keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; ++ } ++ field_74516_a.add(this); ++ field_74514_b.addKey(keyCode, this); ++ field_151473_c.add(category); ++ } ++ ++ /** ++ * Checks that the key conflict context and modifier are active, and that the keyCode matches this binding. ++ */ ++ public boolean isActiveAndMatches(int keyCode) ++ { ++ return keyCode == this.func_151463_i() && getKeyConflictContext().isActive() && getKeyModifier().isActive(); ++ } ++ ++ public void setKeyConflictContext(net.minecraftforge.client.settings.IKeyConflictContext keyConflictContext) ++ { ++ this.keyConflictContext = keyConflictContext; ++ } ++ ++ public net.minecraftforge.client.settings.IKeyConflictContext getKeyConflictContext() ++ { ++ return keyConflictContext; ++ } ++ ++ public net.minecraftforge.client.settings.KeyModifier getKeyModifierDefault() ++ { ++ return keyModifierDefault; ++ } ++ ++ public net.minecraftforge.client.settings.KeyModifier getKeyModifier() ++ { ++ return keyModifier; ++ } ++ ++ public void setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier keyModifier, int keyCode) ++ { ++ this.field_74512_d = keyCode; ++ if (keyModifier.matches(keyCode)) ++ { ++ keyModifier = net.minecraftforge.client.settings.KeyModifier.NONE; ++ } ++ field_74514_b.removeKey(this); ++ this.keyModifier = keyModifier; ++ field_74514_b.addKey(keyCode, this); ++ } ++ ++ public void setToDefault() ++ { ++ setKeyModifierAndCode(getKeyModifierDefault(), func_151469_h()); ++ } ++ ++ public boolean isSetToDefaultValue() ++ { ++ return func_151463_i() == func_151469_h() && getKeyModifier() == getKeyModifierDefault(); ++ } ++ ++ /** ++ * Returns true when the other keyBinding conflicts with this one ++ */ ++ public boolean conflicts(KeyBinding other) ++ { ++ if (getKeyConflictContext().conflicts(other.getKeyConflictContext()) || other.getKeyConflictContext().conflicts(getKeyConflictContext())) ++ { ++ net.minecraftforge.client.settings.KeyModifier keyModifier = getKeyModifier(); ++ net.minecraftforge.client.settings.KeyModifier otherKeyModifier = other.getKeyModifier(); ++ if (keyModifier.matches(other.func_151463_i()) || otherKeyModifier.matches(func_151463_i())) ++ { ++ return true; ++ } ++ else if (keyModifier == otherKeyModifier || keyModifier == net.minecraftforge.client.settings.KeyModifier.NONE || otherKeyModifier == net.minecraftforge.client.settings.KeyModifier.NONE) ++ { ++ return func_151463_i() == other.func_151463_i(); ++ } ++ } ++ return false; ++ } ++ ++ /** ++ * Returns true when one of the bindings' key codes conflicts with the other's modifier. ++ */ ++ public boolean hasKeyCodeModifierConflict(KeyBinding other) ++ { ++ if (getKeyConflictContext().conflicts(other.getKeyConflictContext()) || other.getKeyConflictContext().conflicts(getKeyConflictContext())) ++ { ++ if (getKeyModifier().matches(other.func_151463_i()) || other.getKeyModifier().matches(func_151463_i())) ++ { ++ return true; ++ } ++ } ++ return false; ++ } ++ ++ public String getDisplayName() ++ { ++ return getKeyModifier().getLocalizedComboName(func_151463_i()); ++ } ++ /****************** Forge End *****************************/ + } diff --git a/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch b/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch index 5c9c777d25..8bcdddcc2b 100644 --- a/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch +++ b/patches/minecraft/net/minecraft/client/shader/Framebuffer.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/client/shader/Framebuffer.java +++ ../src-work/minecraft/net/minecraft/client/shader/Framebuffer.java -@@ -119,8 +119,17 @@ +@@ -118,8 +118,17 @@ if (this.field_147619_e) { OpenGlHelper.func_153176_h(OpenGlHelper.field_153199_f, this.field_147624_h); @@ -18,7 +18,7 @@ } this.func_147614_f(); -@@ -280,4 +289,36 @@ +@@ -279,4 +288,36 @@ GlStateManager.func_179086_m(i); this.func_147609_e(); } diff --git a/patches/minecraft/net/minecraft/command/CommandBase.java.patch b/patches/minecraft/net/minecraft/command/CommandBase.java.patch index 1cfdfa4067..49c1eaedf8 100644 --- a/patches/minecraft/net/minecraft/command/CommandBase.java.patch +++ b/patches/minecraft/net/minecraft/command/CommandBase.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/command/CommandBase.java +++ ../src-work/minecraft/net/minecraft/command/CommandBase.java -@@ -329,7 +329,7 @@ - ichatcomponent.func_150258_a(" "); +@@ -369,7 +369,7 @@ + itextcomponent.func_150258_a(" "); } -- IChatComponent ichatcomponent1 = new ChatComponentText(p_147176_1_[i]); -+ IChatComponent ichatcomponent1 = net.minecraftforge.common.ForgeHooks.newChatWithLinks(p_147176_1_[i]); // Forge: links for messages +- ITextComponent itextcomponent1 = new TextComponentString(p_147176_1_[i]); ++ ITextComponent itextcomponent1 = net.minecraftforge.common.ForgeHooks.newChatWithLinks(p_147176_1_[i]); // Forge: links for messages if (p_147176_3_) { diff --git a/patches/minecraft/net/minecraft/command/CommandEnchant.java.patch b/patches/minecraft/net/minecraft/command/CommandEnchant.java.patch index 361b3dc030..f3ca18c30e 100644 --- a/patches/minecraft/net/minecraft/command/CommandEnchant.java.patch +++ b/patches/minecraft/net/minecraft/command/CommandEnchant.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/command/CommandEnchant.java +++ ../src-work/minecraft/net/minecraft/command/CommandEnchant.java -@@ -93,7 +93,7 @@ +@@ -85,7 +85,7 @@ { - Enchantment enchantment2 = Enchantment.func_180306_c(l); + Enchantment enchantment1 = Enchantment.func_185262_c(k); -- if (!enchantment2.func_77326_a(enchantment1)) -+ if (!enchantment2.func_77326_a(enchantment1) || !enchantment1.func_77326_a(enchantment2)) //Forge BugFix: Let Both enchantments veto being together +- if (!enchantment.func_77326_a(enchantment1)) ++ if (!enchantment.func_77326_a(enchantment1) || !enchantment1.func_77326_a(enchantment)) //Forge BugFix: Let Both enchantments veto being together { - throw new CommandException("commands.enchant.cantCombine", new Object[] {enchantment1.func_77316_c(j), enchantment2.func_77316_c(nbttaglist.func_150305_b(k).func_74765_d("lvl"))}); + throw new CommandException("commands.enchant.cantCombine", new Object[] {enchantment.func_77316_c(i), enchantment1.func_77316_c(nbttaglist.func_150305_b(j).func_74765_d("lvl"))}); } diff --git a/patches/minecraft/net/minecraft/command/CommandFill.java.patch b/patches/minecraft/net/minecraft/command/CommandFill.java.patch index c9950fe719..38da66d370 100644 --- a/patches/minecraft/net/minecraft/command/CommandFill.java.patch +++ b/patches/minecraft/net/minecraft/command/CommandFill.java.patch @@ -1,28 +1,28 @@ --- ../src-base/minecraft/net/minecraft/command/CommandFill.java +++ ../src-work/minecraft/net/minecraft/command/CommandFill.java -@@ -48,6 +48,7 @@ +@@ -50,6 +50,7 @@ { - i = func_175764_a(p_71515_2_[7], 0, 15); + i = func_175764_a(p_184881_3_[7], 0, 15); } + IBlockState state = block.func_176203_a(i); BlockPos blockpos2 = new BlockPos(Math.min(blockpos.func_177958_n(), blockpos1.func_177958_n()), Math.min(blockpos.func_177956_o(), blockpos1.func_177956_o()), Math.min(blockpos.func_177952_p(), blockpos1.func_177952_p())); BlockPos blockpos3 = new BlockPos(Math.max(blockpos.func_177958_n(), blockpos1.func_177958_n()), Math.max(blockpos.func_177956_o(), blockpos1.func_177956_o()), Math.max(blockpos.func_177952_p(), blockpos1.func_177952_p())); -@@ -75,7 +76,7 @@ +@@ -77,7 +78,7 @@ NBTTagCompound nbttagcompound = new NBTTagCompound(); boolean flag = false; -- if (p_71515_2_.length >= 10 && block.func_149716_u()) -+ if (p_71515_2_.length >= 10 && block.hasTileEntity(state)) +- if (p_184881_3_.length >= 10 && block.func_149716_u()) ++ if (p_184881_3_.length >= 10 && block.hasTileEntity(state)) { - String s = func_147178_a(p_71515_1_, p_71515_2_, 9).func_150260_c(); + String s = func_147178_a(p_184881_2_, p_184881_3_, 9).func_150260_c(); -@@ -116,7 +117,7 @@ +@@ -118,7 +119,7 @@ continue; } } -- else if (p_71515_2_[8].equals("replace") && !block.func_149716_u()) -+ else if (p_71515_2_[8].equals("replace") && !block.hasTileEntity(state)) +- else if (p_184881_3_[8].equals("replace") && !block.func_149716_u()) ++ else if (p_184881_3_[8].equals("replace") && !block.hasTileEntity(state)) { - if (p_71515_2_.length > 9) + if (p_184881_3_.length > 9) { diff --git a/patches/minecraft/net/minecraft/command/CommandHandler.java.patch b/patches/minecraft/net/minecraft/command/CommandHandler.java.patch index ab5182a944..0b22b88a0d 100644 --- a/patches/minecraft/net/minecraft/command/CommandHandler.java.patch +++ b/patches/minecraft/net/minecraft/command/CommandHandler.java.patch @@ -1,28 +1,28 @@ --- ../src-base/minecraft/net/minecraft/command/CommandHandler.java +++ ../src-work/minecraft/net/minecraft/command/CommandHandler.java -@@ -44,6 +44,16 @@ +@@ -46,6 +46,16 @@ } - else if (icommand.func_71519_b(p_71556_1_)) + else if (icommand.func_184882_a(this.func_184879_a(), p_71556_1_)) { + net.minecraftforge.event.CommandEvent event = new net.minecraftforge.event.CommandEvent(icommand, p_71556_1_, astring); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) + { -+ if (event.exception != null) ++ if (event.getException() != null) + { -+ com.google.common.base.Throwables.propagateIfPossible(event.exception); ++ com.google.common.base.Throwables.propagateIfPossible(event.getException()); + } + return 1; + } + if (i > -1) { - List list = PlayerSelector.func_179656_b(p_71556_1_, astring[i], Entity.class); -@@ -107,7 +117,7 @@ - ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.generic.exception", new Object[0]); - chatcomponenttranslation.func_150256_b().func_150238_a(EnumChatFormatting.RED); - p_175786_1_.func_145747_a(chatcomponenttranslation); + List list = EntitySelector.func_179656_b(p_71556_1_, astring[i], Entity.class); +@@ -109,7 +119,7 @@ + TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.generic.exception", new Object[0]); + textcomponenttranslation.func_150256_b().func_150238_a(TextFormatting.RED); + p_175786_1_.func_145747_a(textcomponenttranslation); - field_147175_a.warn("Couldn\'t process command: \'" + p_175786_4_ + "\'"); -+ field_147175_a.warn("Couldn\'t process command: \'" + p_175786_4_ + "\'", var9); // Forge: Log stacktrace of unknown exceptions ++ field_147175_a.warn("Couldn\'t process command: \'" + p_175786_4_ + "\'", var9); } return false; diff --git a/patches/minecraft/net/minecraft/command/PlayerSelector.java.patch b/patches/minecraft/net/minecraft/command/EntitySelector.java.patch similarity index 84% rename from patches/minecraft/net/minecraft/command/PlayerSelector.java.patch rename to patches/minecraft/net/minecraft/command/EntitySelector.java.patch index 1aacfa2551..b93a59d9e9 100644 --- a/patches/minecraft/net/minecraft/command/PlayerSelector.java.patch +++ b/patches/minecraft/net/minecraft/command/EntitySelector.java.patch @@ -1,8 +1,8 @@ ---- ../src-base/minecraft/net/minecraft/command/PlayerSelector.java -+++ ../src-work/minecraft/net/minecraft/command/PlayerSelector.java +--- ../src-base/minecraft/net/minecraft/command/EntitySelector.java ++++ ../src-work/minecraft/net/minecraft/command/EntitySelector.java @@ -36,9 +36,9 @@ - public class PlayerSelector + public class EntitySelector { - private static final Pattern field_82389_a = Pattern.compile("^@([pare])(?:\\[([\\w=,!-]*)\\])?$"); + private static final Pattern field_82389_a = Pattern.compile("^@([pare])(?:\\[([\\w\\.=,!-]*)\\])?$"); // FORGE: allow . in entity selectors diff --git a/patches/minecraft/net/minecraft/command/server/CommandSetBlock.java.patch b/patches/minecraft/net/minecraft/command/server/CommandSetBlock.java.patch index e5ef73f0b5..fcb4ea652b 100644 --- a/patches/minecraft/net/minecraft/command/server/CommandSetBlock.java.patch +++ b/patches/minecraft/net/minecraft/command/server/CommandSetBlock.java.patch @@ -1,20 +1,20 @@ --- ../src-base/minecraft/net/minecraft/command/server/CommandSetBlock.java +++ ../src-work/minecraft/net/minecraft/command/server/CommandSetBlock.java -@@ -52,6 +52,8 @@ - i = func_175764_a(p_71515_2_[4], 0, 15); +@@ -54,6 +54,8 @@ + i = func_175764_a(p_184881_3_[4], 0, 15); } + IBlockState state = block.func_176203_a(i); + - World world = p_71515_1_.func_130014_f_(); + World world = p_184881_2_.func_130014_f_(); if (!world.func_175667_e(blockpos)) -@@ -63,7 +65,7 @@ +@@ -65,7 +67,7 @@ NBTTagCompound nbttagcompound = new NBTTagCompound(); boolean flag = false; -- if (p_71515_2_.length >= 7 && block.func_149716_u()) -+ if (p_71515_2_.length >= 7 && block.hasTileEntity(state)) +- if (p_184881_3_.length >= 7 && block.func_149716_u()) ++ if (p_184881_3_.length >= 7 && block.hasTileEntity(state)) { - String s = func_147178_a(p_71515_1_, p_71515_2_, 6).func_150260_c(); + String s = func_147178_a(p_184881_2_, p_184881_3_, 6).func_150260_c(); diff --git a/patches/minecraft/net/minecraft/command/server/CommandTestForBlock.java.patch b/patches/minecraft/net/minecraft/command/server/CommandTestForBlock.java.patch index a9dae5314d..4a1533789a 100644 --- a/patches/minecraft/net/minecraft/command/server/CommandTestForBlock.java.patch +++ b/patches/minecraft/net/minecraft/command/server/CommandTestForBlock.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/command/server/CommandTestForBlock.java +++ ../src-work/minecraft/net/minecraft/command/server/CommandTestForBlock.java -@@ -70,7 +70,7 @@ +@@ -72,7 +72,7 @@ NBTTagCompound nbttagcompound = new NBTTagCompound(); boolean flag = false; -- if (p_71515_2_.length >= 6 && block.func_149716_u()) -+ if (p_71515_2_.length >= 6 && block.hasTileEntity(block.func_176203_a(i))) +- if (p_184881_3_.length >= 6 && block.func_149716_u()) ++ if (p_184881_3_.length >= 6 && block.hasTileEntity(block.func_176203_a(i))) { - String s = func_147178_a(p_71515_1_, p_71515_2_, 5).func_150260_c(); + String s = func_147178_a(p_184881_2_, p_184881_3_, 5).func_150260_c(); diff --git a/patches/minecraft/net/minecraft/crash/CrashReportCategory.java.patch b/patches/minecraft/net/minecraft/crash/CrashReportCategory.java.patch index 6af34573dd..ab4e3edde9 100644 --- a/patches/minecraft/net/minecraft/crash/CrashReportCategory.java.patch +++ b/patches/minecraft/net/minecraft/crash/CrashReportCategory.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/crash/CrashReportCategory.java +++ ../src-work/minecraft/net/minecraft/crash/CrashReportCategory.java -@@ -117,8 +117,11 @@ +@@ -122,8 +122,11 @@ } else { diff --git a/patches/minecraft/net/minecraft/enchantment/Enchantment.java.patch b/patches/minecraft/net/minecraft/enchantment/Enchantment.java.patch index 92f2bc57b1..682828fbba 100644 --- a/patches/minecraft/net/minecraft/enchantment/Enchantment.java.patch +++ b/patches/minecraft/net/minecraft/enchantment/Enchantment.java.patch @@ -1,15 +1,18 @@ --- ../src-base/minecraft/net/minecraft/enchantment/Enchantment.java +++ ../src-work/minecraft/net/minecraft/enchantment/Enchantment.java -@@ -61,7 +61,7 @@ +@@ -12,9 +12,9 @@ + import net.minecraft.util.registry.RegistryNamespaced; + import net.minecraft.util.text.translation.I18n; - if (field_180311_a[p_i45771_1_] != null) - { -- throw new IllegalArgumentException("Duplicate enchantment id!"); -+ throw new IllegalArgumentException("Duplicate enchantment id! " + this.getClass() + " and " + field_180311_a[p_i45771_1_].getClass() + " Enchantment ID:" + p_i45771_1_); - } - else - { -@@ -139,7 +139,7 @@ +-public abstract class Enchantment ++public abstract class Enchantment extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl + { +- public static final RegistryNamespaced field_185264_b = new RegistryNamespaced(); ++ public static final RegistryNamespaced field_185264_b = net.minecraftforge.fml.common.registry.GameData.getEnchantmentRegistry(); + private final EntityEquipmentSlot[] field_185263_a; + private final Enchantment.Rarity field_77333_a; + public EnumEnchantmentType field_77351_y; +@@ -118,7 +118,7 @@ public boolean func_92089_a(ItemStack p_92089_1_) { @@ -18,8 +21,8 @@ } public void func_151368_a(EntityLivingBase p_151368_1_, Entity p_151368_2_, int p_151368_3_) -@@ -150,6 +150,45 @@ - { +@@ -134,6 +134,26 @@ + return false; } + /** @@ -33,25 +36,6 @@ + return this.field_77351_y.func_77557_a(stack.func_77973_b()); + } + -+ private static final java.lang.reflect.Field bookSetter = Enchantment.class.getDeclaredFields()[1]; -+ /** -+ * Add to the list of enchantments applicable by the anvil from a book -+ * -+ * @param enchantment -+ */ -+ public static void addToBookList(Enchantment enchantment) -+ { -+ try -+ { -+ net.minecraftforge.common.util.EnumHelper.setFailsafeFieldValue(bookSetter, null, -+ com.google.common.collect.ObjectArrays.concat(field_77331_b, enchantment)); -+ } -+ catch (Exception e) -+ { -+ throw new RuntimeException(e); //Rethrow see what happens -+ } -+ } -+ + /** + * Is this enchantment allowed to be enchanted on books via Enchantment Table + * @return false to disable the vanilla feature @@ -61,6 +45,6 @@ + return true; + } + - static + public static void func_185257_f() { - List list = Lists.newArrayList(); + EntityEquipmentSlot[] aentityequipmentslot = new EntityEquipmentSlot[] {EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET}; diff --git a/patches/minecraft/net/minecraft/enchantment/EnchantmentHelper.java.patch b/patches/minecraft/net/minecraft/enchantment/EnchantmentHelper.java.patch index 6f607d4dd4..e874421c40 100644 --- a/patches/minecraft/net/minecraft/enchantment/EnchantmentHelper.java.patch +++ b/patches/minecraft/net/minecraft/enchantment/EnchantmentHelper.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/enchantment/EnchantmentHelper.java +++ ../src-work/minecraft/net/minecraft/enchantment/EnchantmentHelper.java -@@ -296,7 +296,7 @@ +@@ -292,7 +292,7 @@ public static int func_77514_a(Random p_77514_0_, int p_77514_1_, int p_77514_2_, ItemStack p_77514_3_) { Item item = p_77514_3_.func_77973_b(); @@ -9,33 +9,31 @@ if (i <= 0) { -@@ -345,7 +345,7 @@ - public static List func_77513_b(Random p_77513_0_, ItemStack p_77513_1_, int p_77513_2_) +@@ -339,7 +339,7 @@ { + List list = Lists.newArrayList(); Item item = p_77513_1_.func_77973_b(); - int i = item.func_77619_b(); + int i = item.getItemEnchantability(p_77513_1_); if (i <= 0) { -@@ -387,7 +387,9 @@ +@@ -380,7 +380,8 @@ - for (EnchantmentData enchantmentdata1 : list) - { -- if (!enchantmentdata1.field_76302_b.func_77326_a(Enchantment.func_180306_c(integer.intValue()))) -+ Enchantment e1 = enchantmentdata1.field_76302_b; -+ Enchantment e2 = Enchantment.func_180306_c(integer.intValue()); -+ if (!e1.func_77326_a(e2) || !e2.func_77326_a(e1)) //Forge BugFix: Let Both enchantments veto being together - { - flag = false; - break; -@@ -421,7 +423,8 @@ - - for (Enchantment enchantment : Enchantment.field_77331_b) + while (iterator.hasNext()) { -- if (enchantment != null && (enchantment.field_77351_y.func_77557_a(item) || flag)) -+ if (enchantment == null) continue; -+ if (enchantment.canApplyAtEnchantingTable(p_77505_1_) || (flag && enchantment.isAllowedOnBooks())) +- if (!p_185282_1_.field_76302_b.func_77326_a(((EnchantmentData)iterator.next()).field_76302_b)) ++ Enchantment e2 = iterator.next().field_76302_b; ++ if (!p_185282_1_.field_76302_b.func_77326_a(e2) || !e2.func_77326_a(p_185282_1_.field_76302_b)) //Forge BugFix: Let Both enchantments veto being together { - for (int i = enchantment.func_77319_d(); i <= enchantment.func_77325_b(); ++i) + iterator.remove(); + } +@@ -395,7 +396,7 @@ + + for (Enchantment enchantment : Enchantment.field_185264_b) + { +- if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.field_77351_y.func_77557_a(item) || flag)) ++ if ((!enchantment.func_185261_e() || p_185291_2_) && (enchantment.canApplyAtEnchantingTable(p_185291_1_) || (flag && enchantment.isAllowedOnBooks()))) + { + for (int i = enchantment.func_77325_b(); i > enchantment.func_77319_d() - 1; --i) { diff --git a/patches/minecraft/net/minecraft/entity/Entity.java.patch b/patches/minecraft/net/minecraft/entity/Entity.java.patch index 8d3e677c09..43f7adfdfe 100644 --- a/patches/minecraft/net/minecraft/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/entity/Entity.java.patch @@ -1,113 +1,69 @@ --- ../src-base/minecraft/net/minecraft/entity/Entity.java +++ ../src-work/minecraft/net/minecraft/entity/Entity.java -@@ -49,7 +49,7 @@ - import net.minecraftforge.fml.relauncher.Side; - import net.minecraftforge.fml.relauncher.SideOnly; +@@ -76,7 +76,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; -public abstract class Entity implements ICommandSender +public abstract class Entity implements ICommandSender, net.minecraftforge.common.capabilities.ICapabilitySerializable { + private static final Logger field_184243_a = LogManager.getLogger(); private static final AxisAlignedBB field_174836_a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); - private static int field_70152_a; -@@ -129,6 +129,15 @@ - protected UUID field_96093_i; - private final CommandResultStats field_174837_as; +@@ -195,8 +195,16 @@ + this.field_70180_af.func_187214_a(field_184242_az, ""); + this.field_70180_af.func_187214_a(field_184234_aB, Boolean.valueOf(false)); + this.func_70088_a(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this)); ++ capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this); + } + /** Forge: Used to store custom data for each entity. */ + private NBTTagCompound customEntityData; + public boolean captureDrops = false; + public java.util.ArrayList capturedDrops = new java.util.ArrayList(); -+ -+ @Deprecated //ToDo: Move to Capabilities? -+ protected java.util.HashMap extendedProperties = new java.util.HashMap(); + private net.minecraftforge.common.capabilities.CapabilityDispatcher capabilities; + public int func_145782_y() { return this.field_145783_c; -@@ -172,6 +181,9 @@ - this.field_70180_af.func_75682_a(2, ""); - this.field_70180_af.func_75682_a(4, Byte.valueOf((byte)0)); - this.func_70088_a(); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this)); -+ for (net.minecraftforge.common.IExtendedEntityProperties props : extendedProperties.values()) props.init(this, p_i1582_1_); -+ capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this); - } +@@ -1134,12 +1142,12 @@ + BlockPos blockpos = new BlockPos(this.field_70165_t, d0, this.field_70161_v); + IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); - protected abstract void func_70088_a(); -@@ -996,12 +1008,12 @@ - IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); - Block block = iblockstate.func_177230_c(); - -+ Boolean result = block.isEntityInsideMaterial(this.field_70170_p, blockpos, iblockstate, this, d0, p_70055_1_, true); -+ if (result != null) return result; ++ Boolean result = iblockstate.func_177230_c().isEntityInsideMaterial(this.field_70170_p, blockpos, iblockstate, this, d0, p_70055_1_, true); ++ if (result != null) return result; + - if (block.func_149688_o() == p_70055_1_) - { -- float f = BlockLiquid.func_149801_b(iblockstate.func_177230_c().func_176201_c(iblockstate)) - 0.11111111F; -- float f1 = (float)(blockpos.func_177956_o() + 1) - f; -- boolean flag = d0 < (double)f1; -- return !flag && this instanceof EntityPlayer ? false : flag; -+ return net.minecraftforge.common.ForgeHooks.isInsideOfMaterial(p_70055_1_, this, blockpos); - } - else - { -@@ -1356,6 +1368,23 @@ - p_70109_1_.func_74757_a("Silent", this.func_174814_R()); + if (iblockstate.func_185904_a() == p_70055_1_) + { +- float f = BlockLiquid.func_149801_b(iblockstate.func_177230_c().func_176201_c(iblockstate)) - 0.11111111F; +- float f1 = (float)(blockpos.func_177956_o() + 1) - f; +- boolean flag = d0 < (double)f1; +- return !flag && this instanceof EntityPlayer ? false : flag; ++ return net.minecraftforge.common.ForgeHooks.isInsideOfMaterial(p_70055_1_, this, blockpos); + } + else + { +@@ -1534,6 +1542,9 @@ + p_70109_1_.func_74782_a("Tags", nbttaglist); } + if (customEntityData != null) p_70109_1_.func_74782_a("ForgeData", customEntityData); -+ for (String identifier : this.extendedProperties.keySet()) -+ { -+ try -+ { -+ net.minecraftforge.common.IExtendedEntityProperties props = this.extendedProperties.get(identifier); -+ props.saveNBTData(p_70109_1_); -+ } -+ catch (Throwable t) -+ { -+ net.minecraftforge.fml.common.FMLLog.severe("Failed to save extended properties for %s. This is a mod issue.", identifier); -+ t.printStackTrace(); -+ } -+ } -+ + if (this.capabilities != null) p_70109_1_.func_74782_a("ForgeCaps", this.capabilities.serializeNBT()); + this.func_70014_b(p_70109_1_); - if (this.field_70154_o != null) -@@ -1438,6 +1467,30 @@ - this.func_174805_g(p_70020_1_.func_74767_n("CustomNameVisible")); - this.field_174837_as.func_179668_a(p_70020_1_); + if (this.func_184207_aI()) +@@ -1629,6 +1640,9 @@ this.func_174810_b(p_70020_1_.func_74767_n("Silent")); -+ + this.func_184195_f(p_70020_1_.func_74767_n("Glowing")); + + if (p_70020_1_.func_74764_b("ForgeData")) customEntityData = p_70020_1_.func_74775_l("ForgeData"); -+ for (String identifier : this.extendedProperties.keySet()) -+ { -+ try -+ { -+ net.minecraftforge.common.IExtendedEntityProperties props = this.extendedProperties.get(identifier); -+ props.loadNBTData(p_70020_1_); -+ } -+ catch (Throwable t) -+ { -+ net.minecraftforge.fml.common.FMLLog.severe("Failed to load extended properties for %s. This is a mod issue.", identifier); -+ t.printStackTrace(); -+ } -+ } -+ -+ //Rawr, legacy code, Vanilla added a UUID, keep this so older maps will convert properly TODO: Remove in 1.9 -+ if (p_70020_1_.func_74764_b("PersistentIDMSB") && p_70020_1_.func_74764_b("PersistentIDLSB")) -+ { -+ this.field_96093_i = new UUID(p_70020_1_.func_74763_f("PersistentIDMSB"), p_70020_1_.func_74763_f("PersistentIDLSB")); -+ } -+ + if (this.capabilities != null && p_70020_1_.func_74764_b("ForgeCaps")) this.capabilities.deserializeNBT(p_70020_1_.func_74775_l("ForgeCaps")); + - this.func_70037_a(p_70020_1_); - - if (this.func_142008_O()) -@@ -1512,7 +1565,10 @@ + if (p_70020_1_.func_150297_b("Tags", 9)) + { + this.field_184236_aF.clear(); +@@ -1715,7 +1729,10 @@ { EntityItem entityitem = new EntityItem(this.field_70170_p, this.field_70165_t, this.field_70163_u + (double)p_70099_2_, this.field_70161_v, p_70099_1_); entityitem.func_174869_p(); @@ -119,23 +75,23 @@ return entityitem; } else -@@ -1655,6 +1711,7 @@ +@@ -1824,6 +1841,7 @@ - public void func_70078_a(Entity p_70078_1_) + public boolean func_184205_a(Entity p_184205_1_, boolean p_184205_2_) { -+ if(!(this instanceof EntityLivingBase) && !net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_70078_1_, true)){ return; } - this.field_70149_e = 0.0D; - this.field_70147_f = 0.0D; - -@@ -2049,6 +2106,7 @@ ++ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_184205_1_, true)) return false; + if (p_184205_2_ || this.func_184228_n(p_184205_1_) && p_184205_1_.func_184219_q(this)) + { + if (this.func_184218_aH()) +@@ -2279,6 +2297,7 @@ { if (!this.field_70170_p.field_72995_K && !this.field_70128_L) { -+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_71027_1_)) return; ++ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_184204_1_)) return null; this.field_70170_p.field_72984_F.func_76320_a("changeDimension"); - MinecraftServer minecraftserver = MinecraftServer.func_71276_C(); + MinecraftServer minecraftserver = this.func_184102_h(); int i = this.field_71093_bK; -@@ -2092,7 +2150,7 @@ +@@ -2372,7 +2391,7 @@ public float func_180428_a(Explosion p_180428_1_, World p_180428_2_, BlockPos p_180428_3_, IBlockState p_180428_4_) { @@ -144,11 +100,10 @@ } public boolean func_174816_a(Explosion p_174816_1_, World p_174816_2_, BlockPos p_174816_3_, IBlockState p_174816_4_, float p_174816_5_) -@@ -2353,4 +2411,209 @@ - +@@ -2662,6 +2681,165 @@ EnchantmentHelper.func_151385_b(p_174815_1_, p_174815_2_); } -+ + + /* ================================== Forge Start =====================================*/ + /** + * Returns a NBTTagCompound that can be used to store custom data for this entity. @@ -179,7 +134,7 @@ + * @param target The full target the player is looking at + * @return A ItemStack to add to the player's inventory, Null if nothing should be added. + */ -+ public ItemStack getPickedResult(MovingObjectPosition target) ++ public ItemStack getPickedResult(RayTraceResult target) + { + if (this instanceof net.minecraft.entity.item.EntityPainting) + { @@ -207,24 +162,23 @@ + } + else if (this instanceof net.minecraft.entity.item.EntityBoat) + { -+ return new ItemStack(net.minecraft.init.Items.field_151124_az); ++ return new ItemStack(((EntityBoat)this).func_184455_j()); + } + else if (this instanceof net.minecraft.entity.item.EntityArmorStand) + { + return new ItemStack(net.minecraft.init.Items.field_179565_cj); + } ++ else if (this instanceof net.minecraft.entity.item.EntityEnderCrystal) ++ { ++ return new ItemStack(net.minecraft.init.Items.field_185158_cP); ++ } + else + { -+ int id = EntityList.func_75619_a(this); -+ if (id > 0 && EntityList.field_75627_a.containsKey(id)) -+ { -+ return new ItemStack(net.minecraft.init.Items.field_151063_bx, 1, id); -+ } + String name = EntityList.func_75621_b(this); -+ if (name != null && net.minecraftforge.fml.common.registry.EntityRegistry.getEggs().containsKey(name)) ++ if (EntityList.field_75627_a.containsKey(name)) + { + ItemStack stack = new ItemStack(net.minecraft.init.Items.field_151063_bx); -+ stack.func_77983_a("entity_name", new net.minecraft.nbt.NBTTagString(name)); ++ net.minecraft.item.ItemMonsterPlacer.func_185078_a(stack, name); + return stack; + } + } @@ -262,51 +216,6 @@ + } + + /** -+ * Register the instance of IExtendedProperties into the entity's collection. -+ * @param identifier The identifier which you can use to retrieve these properties for the entity. -+ * @param properties The instanceof IExtendedProperties to register -+ * @return The identifier that was used to register the extended properties. Empty String indicates an error. If your requested key already existed, this will return a modified one that is unique. -+ */ -+ public String registerExtendedProperties(String identifier, net.minecraftforge.common.IExtendedEntityProperties properties) -+ { -+ if (identifier == null) -+ { -+ net.minecraftforge.fml.common.FMLLog.warning("Someone is attempting to register extended properties using a null identifier. This is not allowed. Aborting. This may have caused instability."); -+ return ""; -+ } -+ if (properties == null) -+ { -+ net.minecraftforge.fml.common.FMLLog.warning("Someone is attempting to register null extended properties. This is not allowed. Aborting. This may have caused instability."); -+ return ""; -+ } -+ -+ String baseIdentifier = identifier; -+ int identifierModCount = 1; -+ while (this.extendedProperties.containsKey(identifier)) -+ { -+ identifier = String.format("%s%d", baseIdentifier, identifierModCount++); -+ } -+ -+ if (baseIdentifier != identifier) -+ { -+ net.minecraftforge.fml.common.FMLLog.info("An attempt was made to register exended properties using an existing key. The duplicate identifier (%s) has been remapped to %s.", baseIdentifier, identifier); -+ } -+ -+ this.extendedProperties.put(identifier, properties); -+ return identifier; -+ } -+ -+ /** -+ * Gets the extended properties identified by the passed in key -+ * @param identifier The key that identifies the extended properties. -+ * @return The instance of IExtendedProperties that was found, or null. -+ */ -+ public net.minecraftforge.common.IExtendedEntityProperties getExtendedProperties(String identifier) -+ { -+ return this.extendedProperties.get(identifier); -+ } -+ -+ /** + * If a rider of this entity can interact with this entity. Should return true on the + * ridden entity if so. + * @@ -353,4 +262,7 @@ + return ret; + } + /* ================================== Forge End =====================================*/ - } ++ + public void func_184178_b(EntityPlayerMP p_184178_1_) + { + } diff --git a/patches/minecraft/net/minecraft/entity/EntityAgeable.java.patch b/patches/minecraft/net/minecraft/entity/EntityAgeable.java.patch deleted file mode 100644 index 68c17bc54f..0000000000 --- a/patches/minecraft/net/minecraft/entity/EntityAgeable.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/entity/EntityAgeable.java -+++ ../src-work/minecraft/net/minecraft/entity/EntityAgeable.java -@@ -31,7 +31,7 @@ - { - if (!this.field_70170_p.field_72995_K) - { -- Class oclass = EntityList.func_90035_a(itemstack.func_77960_j()); -+ Class oclass = EntityList.field_75625_b.get(net.minecraft.item.ItemMonsterPlacer.getEntityName(itemstack)); - - if (oclass != null && this.getClass() == oclass) - { diff --git a/patches/minecraft/net/minecraft/entity/EntityHanging.java.patch b/patches/minecraft/net/minecraft/entity/EntityHanging.java.patch index 29d340d07f..e81fbae7b8 100644 --- a/patches/minecraft/net/minecraft/entity/EntityHanging.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityHanging.java.patch @@ -1,12 +1,12 @@ --- ../src-base/minecraft/net/minecraft/entity/EntityHanging.java +++ ../src-work/minecraft/net/minecraft/entity/EntityHanging.java -@@ -123,6 +123,9 @@ - { - BlockPos blockpos1 = blockpos.func_177967_a(enumfacing, k).func_177981_b(l); - Block block = this.field_70170_p.func_180495_p(blockpos1).func_177230_c(); -+ -+ if ( block.isSideSolid( this.field_70170_p, blockpos1, this.field_174860_b )) -+ continue; +@@ -139,6 +139,9 @@ + BlockPos blockpos1 = blockpos.func_177967_a(enumfacing, k + i1).func_177981_b(l + j1); + IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos1); - if (!block.func_149688_o().func_76220_a() && !BlockRedstoneDiode.func_149909_d(block)) ++ if (iblockstate.isSideSolid(this.field_70170_p, blockpos1, this.field_174860_b)) ++ continue; ++ + if (!iblockstate.func_185904_a().func_76220_a() && !BlockRedstoneDiode.func_185546_B(iblockstate)) { + return false; diff --git a/patches/minecraft/net/minecraft/entity/EntityList.java.patch b/patches/minecraft/net/minecraft/entity/EntityList.java.patch index 0a51ed53ee..968ebb6115 100644 --- a/patches/minecraft/net/minecraft/entity/EntityList.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityList.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/EntityList.java +++ ../src-work/minecraft/net/minecraft/entity/EntityList.java -@@ -88,6 +88,7 @@ +@@ -91,6 +91,7 @@ public static void func_75618_a(Class p_75618_0_, String p_75618_1_, int p_75618_2_) { @@ -8,9 +8,9 @@ if (field_75625_b.containsKey(p_75618_1_)) { throw new IllegalArgumentException("ID is already registered: " + p_75618_1_); -@@ -151,9 +152,10 @@ - p_75615_0_.func_82580_o("Type"); - } +@@ -148,9 +149,10 @@ + { + Entity entity = null; + Class oclass = null; try @@ -20,7 +20,7 @@ if (oclass != null) { -@@ -167,7 +169,17 @@ +@@ -164,7 +166,17 @@ if (entity != null) { @@ -38,31 +38,13 @@ } else { -@@ -343,7 +355,9 @@ +@@ -202,7 +214,8 @@ - public static class EntityEggInfo - { -+ @Deprecated // This is not always a valid number in the global ID list. - public final int field_75613_a; -+ public final String name; - public final int field_75611_b; - public final int field_75612_c; - public final StatBase field_151512_d; -@@ -356,6 +370,17 @@ - this.field_75612_c = p_i1583_3_; - this.field_151512_d = StatList.func_151182_a(this); - this.field_151513_e = StatList.func_151176_b(this); -+ this.name = EntityList.func_75617_a(p_i1583_1_); - } -+ -+ public EntityEggInfo(String name, int primaryColor, int secondaryColor) -+ { -+ this.field_75613_a = -1; -+ this.name = name; -+ this.field_75611_b = primaryColor; -+ this.field_75612_c = secondaryColor; -+ this.field_151512_d = (new StatBase("stat.killEntity." + name, new net.minecraft.util.ChatComponentTranslation("stat.entityKill", new net.minecraft.util.ChatComponentTranslation("entity." + name + ".name")))).func_75971_g(); -+ this.field_151513_e = (new StatBase("stat.entityKilledBy." + name, new net.minecraft.util.ChatComponentTranslation("stat.entityKilledBy", new net.minecraft.util.ChatComponentTranslation("entity." + name + ".name")))).func_75971_g(); -+ } - } - } + public static Entity func_188429_b(String p_188429_0_, World p_188429_1_) + { +- return func_75616_a(func_180122_a(p_188429_0_), p_188429_1_); ++ Entity e = func_75620_a(p_188429_0_, p_188429_1_); // Forge: Support entities without global ID ++ return e == null ? func_75620_a("Pig", p_188429_1_) : e; + } + + public static int func_75619_a(Entity p_75619_0_) diff --git a/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch b/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch index 915de5e84c..a65718d5ff 100644 --- a/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/EntityLiving.java +++ ../src-work/minecraft/net/minecraft/entity/EntityLiving.java -@@ -121,6 +121,7 @@ +@@ -171,6 +171,7 @@ public void func_70624_b(EntityLivingBase p_70624_1_) { this.field_70696_bz = p_70624_1_; @@ -8,7 +8,7 @@ } public boolean func_70686_a(Class p_70686_1_) -@@ -498,10 +499,22 @@ +@@ -699,10 +700,22 @@ protected void func_70623_bb() { @@ -31,8 +31,8 @@ else { Entity entity = this.field_70170_p.func_72890_a(this, -1.0D); -@@ -621,7 +634,6 @@ - return this.field_70170_p.func_72917_a(this.func_174813_aQ(), this) && this.field_70170_p.func_72945_a(this, this.func_174813_aQ()).isEmpty() && !this.field_70170_p.func_72953_d(this.func_174813_aQ()); +@@ -835,7 +848,6 @@ + return !this.field_70170_p.func_72953_d(this.func_174813_aQ()) && this.field_70170_p.func_184144_a(this, this.func_174813_aQ()).isEmpty() && this.field_70170_p.func_72917_a(this.func_174813_aQ(), this); } - @SideOnly(Side.CLIENT) diff --git a/patches/minecraft/net/minecraft/entity/EntityLivingBase.java.patch b/patches/minecraft/net/minecraft/entity/EntityLivingBase.java.patch index 7906ba9b3b..1715d44ced 100644 --- a/patches/minecraft/net/minecraft/entity/EntityLivingBase.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityLivingBase.java.patch @@ -1,24 +1,29 @@ --- ../src-base/minecraft/net/minecraft/entity/EntityLivingBase.java +++ ../src-work/minecraft/net/minecraft/entity/EntityLivingBase.java -@@ -170,6 +170,7 @@ - } +@@ -189,10 +189,11 @@ + { + float f = (float)MathHelper.func_76123_f(this.field_70143_R - 3.0F); +- if (p_184231_4_.func_185904_a() != Material.field_151579_a) ++ if (!p_184231_4_.func_177230_c().isAir(p_184231_4_, field_70170_p, p_184231_5_)) + { + double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D); int i = (int)(150.0D * d0); -+ if ( !block.addLandingEffects( (WorldServer)this.field_70170_p, p_180433_5_, iblockstate, this, i ) ) - ((WorldServer)this.field_70170_p).func_175739_a(EnumParticleTypes.BLOCK_DUST, this.field_70165_t, this.field_70163_u, this.field_70161_v, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.func_176210_f(iblockstate)}); ++ if (!p_184231_4_.func_177230_c().addLandingEffects(p_184231_4_, (WorldServer)this.field_70170_p, p_184231_5_, p_184231_4_, this, i)) + ((WorldServer)this.field_70170_p).func_175739_a(EnumParticleTypes.BLOCK_DUST, this.field_70165_t, this.field_70163_u, this.field_70161_v, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.func_176210_f(p_184231_4_)}); } } -@@ -237,7 +238,7 @@ +@@ -264,7 +265,7 @@ } } -- if (!this.field_70170_p.field_72995_K && this.func_70115_ae() && this.field_70154_o instanceof EntityLivingBase) -+ if (!this.field_70170_p.field_72995_K && this.func_70115_ae() && this.field_70154_o != null && field_70154_o.shouldDismountInWater(this)) +- if (!this.field_70170_p.field_72995_K && this.func_184218_aH() && this.func_184187_bx() instanceof EntityLivingBase) ++ if (!this.field_70170_p.field_72995_K && this.func_184218_aH() && this.func_184187_bx() != null && this.func_184187_bx().shouldDismountInWater(this)) { - this.func_70078_a((Entity)null); + this.func_184210_p(); } -@@ -319,7 +320,7 @@ - if (!this.field_70170_p.field_72995_K && (this.field_70718_bc > 0 || this.func_70684_aJ()) && this.func_146066_aG() && this.field_70170_p.func_82736_K().func_82766_b("doMobLoot")) +@@ -363,7 +364,7 @@ + if (!this.field_70170_p.field_72995_K && (this.func_70684_aJ() || this.field_70718_bc > 0 && this.func_146066_aG() && this.field_70170_p.func_82736_K().func_82766_b("doMobLoot"))) { int i = this.func_70693_a(this.field_70717_bb); - @@ -26,7 +31,7 @@ while (i > 0) { int j = EntityXPOrb.func_70527_a(i); -@@ -380,6 +381,7 @@ +@@ -424,6 +425,7 @@ { this.field_70755_b = p_70604_1_; this.field_70756_c = this.field_70173_aa; @@ -34,15 +39,7 @@ } public EntityLivingBase func_110144_aD() -@@ -663,7 +665,6 @@ - return this.func_70668_bt() == EnumCreatureAttribute.UNDEAD; - } - -- @SideOnly(Side.CLIENT) - public void func_70618_n(int p_70618_1_) - { - this.field_70713_bf.remove(Integer.valueOf(p_70618_1_)); -@@ -712,6 +713,8 @@ +@@ -775,6 +777,8 @@ public void func_70691_i(float p_70691_1_) { @@ -51,7 +48,7 @@ float f = this.func_110143_aJ(); if (f > 0.0F) -@@ -732,6 +735,7 @@ +@@ -795,6 +799,7 @@ public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { @@ -59,7 +56,7 @@ if (this.func_180431_b(p_70097_1_)) { return false; -@@ -797,9 +801,9 @@ +@@ -883,9 +888,9 @@ this.field_70718_bc = 100; this.field_70717_bb = (EntityPlayer)entity; } @@ -71,51 +68,49 @@ if (entitywolf.func_70909_n()) { -@@ -883,6 +887,7 @@ +@@ -1007,6 +1012,7 @@ public void func_70645_a(DamageSource p_70645_1_) { + if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_70645_1_)) return; - Entity entity = p_70645_1_.func_76346_g(); - EntityLivingBase entitylivingbase = this.func_94060_bK(); - -@@ -908,6 +913,9 @@ - i = EnchantmentHelper.func_77519_f((EntityLivingBase)entity); - } - -+ captureDrops = true; -+ capturedDrops.clear(); -+ - if (this.func_146066_aG() && this.field_70170_p.func_82736_K().func_82766_b("doMobLoot")) - { - this.func_70628_a(this.field_70718_bc > 0, i); -@@ -918,6 +926,16 @@ - this.func_82164_bB(); + if (!this.field_70729_aU) + { + Entity entity = p_70645_1_.func_76346_g(); +@@ -1034,11 +1040,24 @@ + i = EnchantmentHelper.func_185283_h((EntityLivingBase)entity); } - } -+ -+ captureDrops = false; -+ -+ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, p_70645_1_, capturedDrops, i, field_70718_bc > 0)) -+ { -+ for (EntityItem item : capturedDrops) -+ { -+ field_70170_p.func_72838_d(item); -+ } -+ } - } - this.field_70170_p.func_72960_a(this, (byte)3); -@@ -972,7 +990,7 @@ - int j = MathHelper.func_76128_c(this.func_174813_aQ().field_72338_b); - int k = MathHelper.func_76128_c(this.field_70161_v); - Block block = this.field_70170_p.func_180495_p(new BlockPos(i, j, k)).func_177230_c(); -- return (block == Blocks.field_150468_ap || block == Blocks.field_150395_bd) && (!(this instanceof EntityPlayer) || !((EntityPlayer)this).func_175149_v()); -+ return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(block, field_70170_p, new BlockPos(i, j, k), this); ++ captureDrops = true; ++ capturedDrops.clear(); ++ + if (this.func_146066_aG() && this.field_70170_p.func_82736_K().func_82766_b("doMobLoot")) + { + boolean flag = this.field_70718_bc > 0; + this.func_184610_a(flag, i, p_70645_1_); + } ++ ++ captureDrops = false; ++ ++ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, p_70645_1_, capturedDrops, i, field_70718_bc > 0)) ++ { ++ for (EntityItem item : capturedDrops) ++ { ++ field_70170_p.func_72838_d(item); ++ } ++ } + } + + this.field_70170_p.func_72960_a(this, (byte)3); +@@ -1113,7 +1132,7 @@ + BlockPos blockpos = new BlockPos(i, j, k); + IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); + Block block = iblockstate.func_177230_c(); +- return block != Blocks.field_150468_ap && block != Blocks.field_150395_bd ? block instanceof BlockTrapDoor && this.func_184604_a(blockpos, iblockstate) : true; ++ return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(iblockstate, field_70170_p, new BlockPos(i, j, k), this); + } } - public boolean func_70089_S() -@@ -982,6 +1000,9 @@ +@@ -1139,6 +1158,9 @@ public void func_180430_e(float p_180430_1_, float p_180430_2_) { @@ -123,9 +118,9 @@ + if (ret == null) return; + p_180430_1_ = ret[0]; p_180430_2_ = ret[1]; super.func_180430_e(p_180430_1_, p_180430_2_); - PotionEffect potioneffect = this.func_70660_b(Potion.field_76430_j); - float f = potioneffect != null ? (float)(potioneffect.func_76458_c() + 1) : 0.0F; -@@ -1094,6 +1115,8 @@ + PotionEffect potioneffect = this.func_70660_b(MobEffects.field_76430_j); + float f = potioneffect == null ? 0.0F : (float)(potioneffect.func_76458_c() + 1); +@@ -1231,6 +1253,8 @@ { if (!this.func_180431_b(p_70665_1_)) { @@ -134,11 +129,11 @@ p_70665_2_ = this.func_70655_b(p_70665_1_, p_70665_2_); p_70665_2_ = this.func_70672_c(p_70665_1_, p_70665_2_); float f = p_70665_2_; -@@ -1142,6 +1165,11 @@ +@@ -1279,6 +1303,11 @@ - public void func_71038_i() + public void func_184609_a(EnumHand p_184609_1_) { -+ ItemStack stack = this.func_70694_bm(); ++ ItemStack stack = this.func_184586_b(p_184609_1_); + if (stack != null && stack.func_77973_b() != null) + { + if (stack.func_77973_b().onEntitySwing(this, stack)) return; @@ -146,15 +141,41 @@ if (!this.field_82175_bq || this.field_110158_av >= this.func_82166_i() / 2 || this.field_110158_av < 0) { this.field_110158_av = -1; -@@ -1281,6 +1309,7 @@ +@@ -1476,6 +1505,7 @@ public void func_110145_l(Entity p_110145_1_) { -+ if(!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_110145_1_, false)){ return; } - double d0 = p_110145_1_.field_70165_t; - double d1 = p_110145_1_.func_174813_aQ().field_72338_b + (double)p_110145_1_.field_70131_O; - double d2 = p_110145_1_.field_70161_v; -@@ -1346,6 +1375,7 @@ ++ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_110145_1_, false)) return; + if (!(p_110145_1_ instanceof EntityBoat) && !(p_110145_1_ instanceof EntityHorse)) + { + double d1 = p_110145_1_.field_70165_t; +@@ -1500,7 +1530,7 @@ + + if (!this.field_70170_p.func_184143_b(axisalignedbb1)) + { +- if (this.field_70170_p.func_180495_p(new BlockPos(d11, this.field_70163_u, d12)).func_185896_q()) ++ if (this.field_70170_p.func_180495_p(new BlockPos(d11, this.field_70163_u, d12)).isSideSolid(field_70170_p, new BlockPos(d11, this.field_70163_u, d12), EnumFacing.UP)) + { + this.func_70634_a(d11, this.field_70163_u + 1.0D, d12); + return; +@@ -1508,14 +1538,14 @@ + + BlockPos blockpos = new BlockPos(d11, this.field_70163_u - 1.0D, d12); + +- if (this.field_70170_p.func_180495_p(blockpos).func_185896_q() || this.field_70170_p.func_180495_p(blockpos).func_185904_a() == Material.field_151586_h) ++ if (this.field_70170_p.func_180495_p(blockpos).isSideSolid(field_70170_p, blockpos, EnumFacing.UP) || this.field_70170_p.func_180495_p(blockpos).func_185904_a() == Material.field_151586_h) + { + d1 = d11; + d13 = this.field_70163_u + 1.0D; + d14 = d12; + } + } +- else if (!this.field_70170_p.func_184143_b(axisalignedbb1.func_72317_d(0.0D, 1.0D, 0.0D)) && this.field_70170_p.func_180495_p(new BlockPos(d11, this.field_70163_u + 1.0D, d12)).func_185896_q()) ++ else if (!this.field_70170_p.func_184143_b(axisalignedbb1.func_72317_d(0.0D, 1.0D, 0.0D)) && this.field_70170_p.func_180495_p(new BlockPos(d11, this.field_70163_u + 1.0D, d12)).isSideSolid(field_70170_p, new BlockPos(d11, this.field_70163_u + 1.0D, d12), EnumFacing.UP)) + { + d1 = d11; + d13 = this.field_70163_u + 2.0D; +@@ -1586,6 +1616,7 @@ } this.field_70160_al = true; @@ -162,45 +183,35 @@ } protected void func_70629_bd() -@@ -1530,6 +1560,7 @@ +@@ -1845,6 +1876,7 @@ public void func_70071_h_() { + if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return; super.func_70071_h_(); + this.func_184608_ct(); - if (!this.field_70170_p.field_72995_K) -@@ -1817,6 +1848,7 @@ - - public void func_70078_a(Entity p_70078_1_) - { -+ if(!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_70078_1_, true)){ return; } - if (this.field_70154_o != null && p_70078_1_ == null) - { - if (!this.field_70170_p.field_72995_K) -@@ -1998,4 +2030,39 @@ - { +@@ -2351,6 +2383,40 @@ this.field_70752_e = true; } -+ + + /*** + * Removes all potion effects that have curativeItem as a curative item for its effect + * @param curativeItem The itemstack we are using to cure potion effects + */ + public void curePotionEffects(ItemStack curativeItem) + { -+ Iterator potionKey = field_70713_bf.keySet().iterator(); + if (field_70170_p.field_72995_K) return; ++ Iterator iterator = this.field_70713_bf.values().iterator(); + -+ while (potionKey.hasNext()) ++ while (iterator.hasNext()) + { -+ Integer key = potionKey.next(); -+ PotionEffect effect = (PotionEffect)field_70713_bf.get(key); ++ PotionEffect effect = iterator.next(); + + if (effect.isCurativeItem(curativeItem)) + { -+ potionKey.remove(); + func_70688_c(effect); ++ iterator.remove(); + this.field_70752_e = true; + } + } @@ -216,5 +227,94 @@ + public boolean shouldRiderFaceForward(EntityPlayer player) + { + return this instanceof net.minecraft.entity.passive.EntityPig; ++ } ++ + public abstract EnumHandSide func_184591_cq(); + + public boolean func_184587_cr() +@@ -2369,8 +2435,16 @@ + { + ItemStack itemstack = this.func_184586_b(this.func_184600_cs()); + +- if (itemstack == this.field_184627_bm) ++ if (itemstack == this.field_184627_bm && itemstack != null) + { ++ field_184628_bn = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, field_184627_bm, field_184628_bn); ++ if (field_184628_bn <= 0) ++ { ++ this.func_71036_o(); ++ } ++ else ++ { // Forge Keep unindented to lower patch ++ field_184627_bm.func_77973_b().onUsingTick(field_184627_bm, this, field_184628_bn); //Forge Added + if (this.func_184605_cv() <= 25 && this.func_184605_cv() % 4 == 0) + { + this.func_184584_a(this.field_184627_bm, 5); +@@ -2380,6 +2454,7 @@ + { + this.func_71036_o(); + } ++ } + } + else + { +@@ -2394,8 +2469,10 @@ + + if (itemstack != null && !this.func_184587_cr()) + { ++ int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.func_77988_m()); ++ if (duration <= 0) return; + this.field_184627_bm = itemstack; +- this.field_184628_bn = itemstack.func_77988_m(); ++ this.field_184628_bn = duration; + + if (!this.field_70170_p.field_72995_K) + { +@@ -2478,6 +2555,8 @@ + this.func_184584_a(this.field_184627_bm, 16); + ItemStack itemstack = this.field_184627_bm.func_77950_b(this.field_70170_p, this); + ++ itemstack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, field_184627_bm, func_184605_cv(), itemstack); ++ + if (itemstack != null && itemstack.field_77994_a == 0) + { + itemstack = null; +@@ -2507,7 +2586,8 @@ + { + if (this.field_184627_bm != null) + { +- this.field_184627_bm.func_77974_b(this.field_70170_p, this, this.func_184605_cv()); ++ if (!net.minecraftforge.event.ForgeEventFactory.onUseItemStop(this, field_184627_bm, this.func_184605_cv())) ++ this.field_184627_bm.func_77974_b(this.field_70170_p, this, this.func_184605_cv()); + } + + this.func_184602_cy(); +@@ -2626,4 +2706,28 @@ + { + return true; + } ++ ++ // FORGE ++ private final net.minecraftforge.items.IItemHandlerModifiable handHandler = new net.minecraftforge.items.ItemStackHandler(field_184630_bs); ++ private final net.minecraftforge.items.IItemHandlerModifiable armorHandler = new net.minecraftforge.items.ItemStackHandler(field_184631_bt); ++ private final net.minecraftforge.items.IItemHandler joinedHandler = new net.minecraftforge.items.wrapper.CombinedInvWrapper(armorHandler, handHandler); ++ ++ @SuppressWarnings("unchecked") ++ @Override ++ public T getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) ++ { ++ if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) ++ { ++ if (facing == null) return (T) joinedHandler; ++ else if (facing.func_176740_k().func_176720_b()) return (T) handHandler; ++ else if (facing.func_176740_k().func_176722_c()) return (T) armorHandler; ++ } ++ return super.getCapability(capability, facing); ++ } ++ ++ @Override ++ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) ++ { ++ return capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); + } } diff --git a/patches/minecraft/net/minecraft/entity/EntityMinecartCommandBlock.java.patch b/patches/minecraft/net/minecraft/entity/EntityMinecartCommandBlock.java.patch deleted file mode 100644 index 9f22ee7e1f..0000000000 --- a/patches/minecraft/net/minecraft/entity/EntityMinecartCommandBlock.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/entity/EntityMinecartCommandBlock.java -+++ ../src-work/minecraft/net/minecraft/entity/EntityMinecartCommandBlock.java -@@ -109,6 +109,7 @@ - - public boolean func_130002_c(EntityPlayer p_130002_1_) - { -+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_130002_1_))) return true; - this.field_145824_a.func_175574_a(p_130002_1_); - return false; - } diff --git a/patches/minecraft/net/minecraft/entity/EntityTracker.java.patch b/patches/minecraft/net/minecraft/entity/EntityTracker.java.patch index ba155b961e..1a78df1c33 100644 --- a/patches/minecraft/net/minecraft/entity/EntityTracker.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityTracker.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/EntityTracker.java +++ ../src-work/minecraft/net/minecraft/entity/EntityTracker.java -@@ -56,6 +56,8 @@ +@@ -75,6 +75,8 @@ public void func_72786_a(Entity p_72786_1_) { @@ -9,11 +9,10 @@ if (p_72786_1_ instanceof EntityPlayerMP) { this.func_72791_a(p_72786_1_, 512, 2); -@@ -331,4 +333,23 @@ - } +@@ -329,6 +331,25 @@ } } -+ + + /* ======================================== FORGE START =====================================*/ + + // don't expose the EntityTrackerEntry directly so mods can't mess with the data in there as easily @@ -32,4 +31,7 @@ + } + + /* ======================================== FORGE END =====================================*/ - } ++ + public void func_151248_b(Entity p_151248_1_, Packet p_151248_2_) + { + EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)this.field_72794_c.func_76041_a(p_151248_1_.func_145782_y()); diff --git a/patches/minecraft/net/minecraft/entity/EntityTrackerEntry.java.patch b/patches/minecraft/net/minecraft/entity/EntityTrackerEntry.java.patch index 20e203ef1c..af7161360d 100644 --- a/patches/minecraft/net/minecraft/entity/EntityTrackerEntry.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityTrackerEntry.java.patch @@ -1,36 +1,22 @@ --- ../src-base/minecraft/net/minecraft/entity/EntityTrackerEntry.java +++ ../src-work/minecraft/net/minecraft/entity/EntityTrackerEntry.java -@@ -379,6 +379,14 @@ - this.field_73138_k = this.field_73132_a.field_70181_x; - this.field_73135_l = this.field_73132_a.field_70179_y; +@@ -438,6 +438,7 @@ -+ int posX = MathHelper.func_76128_c(this.field_73132_a.field_70165_t * 32.0D); -+ int posY = MathHelper.func_76128_c(this.field_73132_a.field_70163_u * 32.0D); -+ int posZ = MathHelper.func_76128_c(this.field_73132_a.field_70161_v * 32.0D); -+ if (posX != this.field_73128_d || posY != this.field_73129_e || posZ != this.field_73126_f) -+ { -+ net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.makeEntitySpawnAdjustment(this.field_73132_a, p_73117_1_, this.field_73128_d, this.field_73129_e, this.field_73126_f); -+ } -+ - if (this.field_73143_t && !(packet instanceof S0FPacketSpawnMob)) - { - p_73117_1_.field_71135_a.func_147359_a(new S12PacketEntityVelocity(this.field_73132_a.func_145782_y(), this.field_73132_a.field_70159_w, this.field_73132_a.field_70181_x, this.field_73132_a.field_70179_y)); -@@ -426,12 +434,14 @@ - p_73117_1_.field_71135_a.func_147359_a(new S1DPacketEntityEffect(this.field_73132_a.func_145782_y(), potioneffect)); - } - } + this.field_73132_a.func_184178_b(p_73117_1_); + p_73117_1_.func_184848_d(this.field_73132_a); + net.minecraftforge.event.ForgeEventFactory.onStartEntityTracking(field_73132_a, p_73117_1_); } } else if (this.field_73134_o.contains(p_73117_1_)) - { +@@ -445,6 +446,7 @@ this.field_73134_o.remove(p_73117_1_); + this.field_73132_a.func_184203_c(p_73117_1_); p_73117_1_.func_152339_d(this.field_73132_a); + net.minecraftforge.event.ForgeEventFactory.onStopEntityTracking(field_73132_a, p_73117_1_); } } } -@@ -463,6 +473,9 @@ +@@ -477,6 +479,9 @@ field_151262_p.warn("Fetching addPacket for removed entity"); } @@ -39,4 +25,4 @@ + if (this.field_73132_a instanceof EntityItem) { - return new S0EPacketSpawnObject(this.field_73132_a, 2, 1); + return new SPacketSpawnObject(this.field_73132_a, 2, 1); diff --git a/patches/minecraft/net/minecraft/entity/ai/EntityAIAttackOnCollide.java.patch b/patches/minecraft/net/minecraft/entity/ai/EntityAIAttackMelee.java.patch similarity index 88% rename from patches/minecraft/net/minecraft/entity/ai/EntityAIAttackOnCollide.java.patch rename to patches/minecraft/net/minecraft/entity/ai/EntityAIAttackMelee.java.patch index 561a3c5058..2962e3ed5a 100644 --- a/patches/minecraft/net/minecraft/entity/ai/EntityAIAttackOnCollide.java.patch +++ b/patches/minecraft/net/minecraft/entity/ai/EntityAIAttackMelee.java.patch @@ -1,15 +1,15 @@ ---- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIAttackOnCollide.java -+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIAttackOnCollide.java -@@ -20,6 +20,8 @@ - private double field_151497_i; +--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIAttackMelee.java ++++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIAttackMelee.java +@@ -21,6 +21,8 @@ private double field_151495_j; private double field_151496_k; + protected final int field_188493_g = 20; + private int failedPathFindingPenalty = 0; + private boolean canPenalize = false; - public EntityAIAttackOnCollide(EntityCreature p_i1635_1_, Class p_i1635_2_, double p_i1635_3_, boolean p_i1635_5_) + public EntityAIAttackMelee(EntityCreature p_i1636_1_, double p_i1636_2_, boolean p_i1636_4_) { -@@ -54,6 +56,19 @@ +@@ -45,6 +47,19 @@ } else { @@ -29,7 +29,7 @@ this.field_75438_g = this.field_75441_b.func_70661_as().func_75494_a(entitylivingbase); return this.field_75438_g != null; } -@@ -91,6 +106,23 @@ +@@ -89,6 +104,23 @@ this.field_151496_k = entitylivingbase.field_70161_v; this.field_75445_i = 4 + this.field_75441_b.func_70681_au().nextInt(7); diff --git a/patches/minecraft/net/minecraft/entity/boss/EntityDragon.java.patch b/patches/minecraft/net/minecraft/entity/boss/EntityDragon.java.patch index 2ccf20bddb..6b9c7e6d51 100644 --- a/patches/minecraft/net/minecraft/entity/boss/EntityDragon.java.patch +++ b/patches/minecraft/net/minecraft/entity/boss/EntityDragon.java.patch @@ -1,14 +1,18 @@ --- ../src-base/minecraft/net/minecraft/entity/boss/EntityDragon.java +++ ../src-work/minecraft/net/minecraft/entity/boss/EntityDragon.java -@@ -479,9 +479,9 @@ - BlockPos blockpos = new BlockPos(k1, l1, i2); - Block block = this.field_70170_p.func_180495_p(blockpos).func_177230_c(); +@@ -474,13 +474,13 @@ + IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); + Block block = iblockstate.func_177230_c(); -- if (block.func_149688_o() != Material.field_151579_a) -+ if (!block.isAir(field_70170_p, new BlockPos(k1, l1, i2))) +- if (iblockstate.func_185904_a() != Material.field_151579_a && iblockstate.func_185904_a() != Material.field_151581_o) ++ if (!block.isAir(iblockstate, this.field_70170_p, blockpos) && iblockstate.func_185904_a() != Material.field_151581_o) { -- if (block != Blocks.field_180401_cv && block != Blocks.field_150343_Z && block != Blocks.field_150377_bs && block != Blocks.field_150357_h && block != Blocks.field_150483_bI && this.field_70170_p.func_82736_K().func_82766_b("mobGriefing")) -+ if (block.canEntityDestroy(field_70170_p, new BlockPos(k1, l1, i2), this) && this.field_70170_p.func_82736_K().func_82766_b("mobGriefing")) + if (!this.field_70170_p.func_82736_K().func_82766_b("mobGriefing")) { - flag1 = this.field_70170_p.func_175698_g(blockpos) || flag1; + flag = true; } +- else if (block != Blocks.field_180401_cv && block != Blocks.field_150343_Z && block != Blocks.field_150377_bs && block != Blocks.field_150357_h && block != Blocks.field_150384_bq && block != Blocks.field_150378_br) ++ else if (block.canEntityDestroy(iblockstate, this.field_70170_p, blockpos, this)) + { + if (block != Blocks.field_150483_bI && block != Blocks.field_185776_dc && block != Blocks.field_185777_dd && block != Blocks.field_150411_aY && block != Blocks.field_185775_db) + { diff --git a/patches/minecraft/net/minecraft/entity/boss/EntityWither.java.patch b/patches/minecraft/net/minecraft/entity/boss/EntityWither.java.patch index 38dc16d7ae..dcbec8406c 100644 --- a/patches/minecraft/net/minecraft/entity/boss/EntityWither.java.patch +++ b/patches/minecraft/net/minecraft/entity/boss/EntityWither.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/entity/boss/EntityWither.java +++ ../src-work/minecraft/net/minecraft/entity/boss/EntityWither.java -@@ -343,7 +343,7 @@ - BlockPos blockpos = new BlockPos(i3, k, l); - Block block = this.field_70170_p.func_180495_p(blockpos).func_177230_c(); +@@ -365,7 +365,7 @@ + IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); + Block block = iblockstate.func_177230_c(); -- if (block.func_149688_o() != Material.field_151579_a && func_181033_a(block)) -+ if (!block.isAir(field_70170_p,blockpos) && func_181033_a(block) && block.canEntityDestroy(field_70170_p, blockpos, this)) +- if (iblockstate.func_185904_a() != Material.field_151579_a && func_181033_a(block)) ++ if (!block.isAir(iblockstate, this.field_70170_p, blockpos) && block.canEntityDestroy(iblockstate, field_70170_p, blockpos, this)) { flag = this.field_70170_p.func_175655_b(blockpos, true) || flag; } diff --git a/patches/minecraft/net/minecraft/entity/boss/IBossDisplayData.java.patch b/patches/minecraft/net/minecraft/entity/boss/IBossDisplayData.java.patch deleted file mode 100644 index ee9c56e4c4..0000000000 --- a/patches/minecraft/net/minecraft/entity/boss/IBossDisplayData.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/entity/boss/IBossDisplayData.java -+++ ../src-work/minecraft/net/minecraft/entity/boss/IBossDisplayData.java -@@ -4,7 +4,6 @@ - import net.minecraftforge.fml.relauncher.Side; - import net.minecraftforge.fml.relauncher.SideOnly; - --@SideOnly(Side.CLIENT) - public interface IBossDisplayData - { - float func_110138_aP(); diff --git a/patches/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java.patch b/patches/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java.patch index 4778abec5d..e609188471 100644 --- a/patches/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java.patch +++ b/patches/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java +++ ../src-work/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java -@@ -90,7 +90,8 @@ +@@ -104,7 +104,8 @@ for (int i = 0; i < list.size(); ++i) { Entity entity = (Entity)list.get(i); diff --git a/patches/minecraft/net/minecraft/entity/item/EntityEnderPearl.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityEnderPearl.java.patch index 4a8b020c5b..2e5a3e8f95 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityEnderPearl.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityEnderPearl.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/item/EntityEnderPearl.java +++ ../src-work/minecraft/net/minecraft/entity/item/EntityEnderPearl.java -@@ -61,6 +61,9 @@ +@@ -84,6 +84,9 @@ if (entityplayermp.field_71135_a.func_147362_b().func_150724_d() && entityplayermp.field_70170_p == this.field_70170_p && !entityplayermp.func_70608_bn()) { @@ -10,15 +10,15 @@ if (this.field_70146_Z.nextFloat() < 0.05F && this.field_70170_p.func_82736_K().func_82766_b("doMobSpawning")) { EntityEndermite entityendermite = new EntityEndermite(this.field_70170_p); -@@ -74,9 +77,10 @@ - entitylivingbase.func_70078_a((Entity)null); +@@ -97,9 +100,10 @@ + this.func_184210_p(); } - entitylivingbase.func_70634_a(this.field_70165_t, this.field_70163_u, this.field_70161_v); -+ entitylivingbase.func_70634_a(event.targetX, event.targetY, event.targetZ); ++ entitylivingbase.func_70634_a(event.getTargetX(), event.getTargetY(), event.getTargetZ()); entitylivingbase.field_70143_R = 0.0F; - entitylivingbase.func_70097_a(DamageSource.field_76379_h, 5.0F); -+ entitylivingbase.func_70097_a(DamageSource.field_76379_h, event.attackDamage); ++ entitylivingbase.func_70097_a(DamageSource.field_76379_h, event.getAttackDamage()); + } } } diff --git a/patches/minecraft/net/minecraft/entity/item/EntityFallingBlock.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityFallingBlock.java.patch new file mode 100644 index 0000000000..456c02616d --- /dev/null +++ b/patches/minecraft/net/minecraft/entity/item/EntityFallingBlock.java.patch @@ -0,0 +1,10 @@ +--- ../src-base/minecraft/net/minecraft/entity/item/EntityFallingBlock.java ++++ ../src-work/minecraft/net/minecraft/entity/item/EntityFallingBlock.java +@@ -129,6 +129,7 @@ + { + IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos1); + ++ if (this.field_70170_p.func_175623_d(new BlockPos(this.field_70165_t, this.field_70163_u - 0.009999999776482582D, this.field_70161_v))) //Forge: Don't indent below. + if (BlockFalling.func_185759_i(this.field_70170_p.func_180495_p(new BlockPos(this.field_70165_t, this.field_70163_u - 0.009999999776482582D, this.field_70161_v)))) + { + this.field_70122_E = false; diff --git a/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch index 283be7c908..d375ace01f 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityItem.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/item/EntityItem.java +++ ../src-work/minecraft/net/minecraft/entity/item/EntityItem.java -@@ -29,6 +29,11 @@ +@@ -37,6 +37,11 @@ private String field_145802_g; public float field_70290_d; @@ -12,7 +12,7 @@ public EntityItem(World p_i1709_1_, double p_i1709_2_, double p_i1709_4_, double p_i1709_6_) { super(p_i1709_1_); -@@ -46,6 +51,7 @@ +@@ -54,6 +59,7 @@ { this(p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_); this.func_92058_a(p_i1710_8_); @@ -20,21 +20,21 @@ } protected boolean func_70041_e_() -@@ -69,6 +75,8 @@ +@@ -77,6 +83,8 @@ public void func_70071_h_() { -+ ItemStack stack = this.func_70096_w().func_82710_f(10); ++ ItemStack stack = this.func_184212_Q().func_187225_a(field_184533_c).orNull(); + if (stack != null && stack.func_77973_b() != null && stack.func_77973_b().onEntityItemUpdate(this)) return; if (this.func_92059_d() == null) { this.func_70106_y(); -@@ -129,8 +137,16 @@ +@@ -137,8 +145,16 @@ this.func_70072_I(); - if (!this.field_70170_p.field_72995_K && this.field_70292_b >= 6000) -+ ItemStack item = func_70096_w().func_82710_f(10); ++ ItemStack item = this.func_184212_Q().func_187225_a(field_184533_c).orNull(); + + if (!this.field_70170_p.field_72995_K && this.field_70292_b >= lifespan) { @@ -47,15 +47,15 @@ this.func_70106_y(); } } -@@ -271,6 +287,7 @@ - p_70014_1_.func_74777_a("Health", (short)((byte)this.field_70291_e)); +@@ -279,6 +295,7 @@ + p_70014_1_.func_74777_a("Health", (short)this.field_70291_e); p_70014_1_.func_74777_a("Age", (short)this.field_70292_b); p_70014_1_.func_74777_a("PickupDelay", (short)this.field_145804_b); + p_70014_1_.func_74768_a("Lifespan", lifespan); if (this.func_145800_j() != null) { -@@ -311,20 +328,23 @@ +@@ -319,20 +336,23 @@ NBTTagCompound nbttagcompound = p_70037_1_.func_74775_l("Item"); this.func_92058_a(ItemStack.func_77949_a(nbttagcompound)); @@ -63,7 +63,7 @@ - { - this.func_70106_y(); - } -+ ItemStack item = func_70096_w().func_82710_f(10); ++ ItemStack item = this.func_184212_Q().func_187225_a(field_184533_c).orNull(); + if (item == null || item.field_77994_a <= 0) this.func_70106_y(); + if (p_70037_1_.func_74764_b("Lifespan")) lifespan = p_70037_1_.func_74762_e("Lifespan"); } @@ -84,15 +84,15 @@ { if (itemstack.func_77973_b() == Item.func_150898_a(Blocks.field_150364_r)) { -@@ -361,6 +381,7 @@ +@@ -369,6 +389,7 @@ } } + net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerItemPickupEvent(p_70100_1_, this); if (!this.func_174814_R()) { - this.field_70170_p.func_72956_a(p_70100_1_, "random.pop", 0.2F, ((this.field_70146_Z.nextFloat() - this.field_70146_Z.nextFloat()) * 0.7F + 1.0F) * 2.0F); -@@ -402,11 +423,6 @@ + this.field_70170_p.func_184148_a((EntityPlayer)null, p_70100_1_.field_70165_t, p_70100_1_.field_70163_u, p_70100_1_.field_70161_v, SoundEvents.field_187638_cR, SoundCategory.PLAYERS, 0.2F, ((this.field_70146_Z.nextFloat() - this.field_70146_Z.nextFloat()) * 0.7F + 1.0F) * 2.0F); +@@ -414,11 +435,6 @@ if (itemstack == null) { @@ -104,7 +104,7 @@ return new ItemStack(Blocks.field_150348_b); } else -@@ -480,6 +496,6 @@ +@@ -492,6 +508,6 @@ public void func_174870_v() { this.func_174871_r(); diff --git a/patches/minecraft/net/minecraft/entity/item/EntityItemFrame.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityItemFrame.java.patch index dfb0cf0e5a..122e9e82da 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityItemFrame.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityItemFrame.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/item/EntityItemFrame.java +++ ../src-work/minecraft/net/minecraft/entity/item/EntityItemFrame.java -@@ -122,7 +122,7 @@ +@@ -137,7 +137,7 @@ { if (p_110131_1_ != null) { diff --git a/patches/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch index 324ff39fb5..68d0f1ab3a 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityMinecart.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/item/EntityMinecart.java +++ ../src-work/minecraft/net/minecraft/entity/item/EntityMinecart.java -@@ -50,6 +50,20 @@ +@@ -54,6 +54,20 @@ @SideOnly(Side.CLIENT) private double field_70506_as; @@ -21,7 +21,7 @@ public EntityMinecart(World p_i1712_1_) { super(p_i1712_1_); -@@ -95,17 +109,19 @@ +@@ -99,17 +113,19 @@ public AxisAlignedBB func_70114_g(Entity p_70114_1_) { @@ -42,7 +42,7 @@ } public EntityMinecart(World p_i1713_1_, double p_i1713_2_, double p_i1713_4_, double p_i1713_6_) -@@ -309,7 +325,7 @@ +@@ -315,7 +331,7 @@ BlockPos blockpos = new BlockPos(k, l, i1); IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); @@ -51,7 +51,7 @@ { this.func_180460_a(blockpos, iblockstate); -@@ -348,7 +364,10 @@ +@@ -354,7 +370,10 @@ this.func_70101_b(this.field_70177_z, this.field_70125_A); @@ -61,9 +61,9 @@ + else box = this.func_174813_aQ().func_72314_b(0.20000000298023224D, 0.0D, 0.20000000298023224D); + for (Entity entity : this.field_70170_p.func_72839_b(this, box)) { - if (entity != this.field_70153_n && entity.func_70104_M() && entity instanceof EntityMinecart) + if (!this.func_184196_w(entity) && entity.func_70104_M() && entity instanceof EntityMinecart) { -@@ -367,6 +386,7 @@ +@@ -363,6 +382,7 @@ } this.func_70072_I(); @@ -71,7 +71,7 @@ } } -@@ -381,10 +401,21 @@ +@@ -377,10 +397,21 @@ protected void func_180459_n() { @@ -94,7 +94,7 @@ if (this.field_70122_E) { this.field_70159_w *= 0.5D; -@@ -392,13 +423,13 @@ +@@ -388,13 +419,13 @@ this.field_70179_y *= 0.5D; } @@ -112,7 +112,7 @@ } } -@@ -418,25 +449,25 @@ +@@ -414,25 +445,25 @@ flag1 = !flag; } @@ -144,7 +144,7 @@ ++this.field_70163_u; } -@@ -481,7 +512,7 @@ +@@ -478,7 +509,7 @@ } } @@ -153,7 +153,7 @@ { double d17 = Math.sqrt(this.field_70159_w * this.field_70159_w + this.field_70179_y * this.field_70179_y); -@@ -527,20 +558,8 @@ +@@ -524,20 +555,8 @@ this.field_70165_t = d19 + d1 * d18; this.field_70161_v = d20 + d2 * d18; this.func_70107_b(this.field_70165_t, this.field_70163_u, this.field_70161_v); @@ -161,7 +161,7 @@ - double d23 = this.field_70179_y; + this.moveMinecartOnRail(p_180460_1_); -- if (this.field_70153_n != null) +- if (this.func_184207_aI()) - { - d22 *= 0.75D; - d23 *= 0.75D; @@ -175,7 +175,7 @@ if (aint[0][1] != 0 && MathHelper.func_76128_c(this.field_70165_t) - p_180460_1_.func_177958_n() == aint[0][0] && MathHelper.func_76128_c(this.field_70161_v) - p_180460_1_.func_177952_p() == aint[0][2]) { this.func_70107_b(this.field_70165_t, this.field_70163_u + (double)aint[0][1], this.field_70161_v); -@@ -577,8 +596,14 @@ +@@ -574,8 +593,14 @@ this.field_70179_y = d5 * (double)(i - p_180460_1_.func_177952_p()); } @@ -191,29 +191,10 @@ double d15 = Math.sqrt(this.field_70159_w * this.field_70159_w + this.field_70179_y * this.field_70179_y); if (d15 > 0.01D) -@@ -654,7 +679,7 @@ - - if (BlockRailBase.func_176563_d(iblockstate)) - { -- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)iblockstate.func_177229_b(((BlockRailBase)iblockstate.func_177230_c()).func_176560_l()); -+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = ((BlockRailBase)iblockstate.func_177230_c()).getRailDirection(field_70170_p, new BlockPos(i, j, k), iblockstate, this); - p_70495_3_ = (double)j; - - if (blockrailbase$enumraildirection.func_177018_c()) -@@ -703,7 +728,7 @@ - - if (BlockRailBase.func_176563_d(iblockstate)) - { -- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)iblockstate.func_177229_b(((BlockRailBase)iblockstate.func_177230_c()).func_176560_l()); -+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = ((BlockRailBase)iblockstate.func_177230_c()).getRailDirection(field_70170_p, new BlockPos(i, j, k), iblockstate, this); - int[][] aint = field_70500_g[blockrailbase$enumraildirection.func_177015_a()]; - double d0 = 0.0D; - double d1 = (double)i + 0.5D + (double)aint[0][0] * 0.5D; -@@ -817,13 +842,20 @@ +@@ -795,13 +820,19 @@ public void func_70108_f(Entity p_70108_1_) { -+ + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartCollisionEvent(this, p_70108_1_)); + if (getCollisionHandler() != null) + { @@ -224,33 +205,33 @@ { if (!p_70108_1_.field_70145_X && !this.field_70145_X) { - if (p_70108_1_ != this.field_70153_n) + if (!this.func_184196_w(p_70108_1_)) { -- if (p_70108_1_ instanceof EntityLivingBase && !(p_70108_1_ instanceof EntityPlayer) && !(p_70108_1_ instanceof EntityIronGolem) && this.func_180456_s() == EntityMinecart.EnumMinecartType.RIDEABLE && this.field_70159_w * this.field_70159_w + this.field_70179_y * this.field_70179_y > 0.01D && this.field_70153_n == null && p_70108_1_.field_70154_o == null) -+ if (p_70108_1_ instanceof EntityLivingBase && !(p_70108_1_ instanceof EntityPlayer) && !(p_70108_1_ instanceof EntityIronGolem) && canBeRidden() && this.field_70159_w * this.field_70159_w + this.field_70179_y * this.field_70179_y > 0.01D && this.field_70153_n == null && p_70108_1_.field_70154_o == null) +- if (p_70108_1_ instanceof EntityLivingBase && this.func_184264_v() == EntityMinecart.Type.RIDEABLE && this.field_70159_w * this.field_70159_w + this.field_70179_y * this.field_70179_y > 0.01D && !(p_70108_1_ instanceof EntityPlayer) && !(p_70108_1_ instanceof EntityIronGolem) && !this.func_184207_aI() && !p_70108_1_.func_184218_aH()) ++ if (p_70108_1_ instanceof EntityLivingBase && canBeRidden() && this.field_70159_w * this.field_70159_w + this.field_70179_y * this.field_70179_y > 0.01D && !(p_70108_1_ instanceof EntityPlayer) && !(p_70108_1_ instanceof EntityIronGolem) && !this.func_184207_aI() && !p_70108_1_.func_184218_aH()) { - p_70108_1_.func_70078_a(this); + p_70108_1_.func_184220_m(this); } -@@ -869,7 +901,7 @@ +@@ -847,7 +878,7 @@ double d7 = p_70108_1_.field_70159_w + this.field_70159_w; double d8 = p_70108_1_.field_70179_y + this.field_70179_y; -- if (((EntityMinecart)p_70108_1_).func_180456_s() == EntityMinecart.EnumMinecartType.FURNACE && this.func_180456_s() != EntityMinecart.EnumMinecartType.FURNACE) +- if (((EntityMinecart)p_70108_1_).func_184264_v() == EntityMinecart.Type.FURNACE && this.func_184264_v() != EntityMinecart.Type.FURNACE) + if (((EntityMinecart)p_70108_1_).isPoweredCart() && !isPoweredCart()) { this.field_70159_w *= 0.20000000298023224D; this.field_70179_y *= 0.20000000298023224D; -@@ -877,7 +909,7 @@ +@@ -855,7 +886,7 @@ p_70108_1_.field_70159_w *= 0.949999988079071D; p_70108_1_.field_70179_y *= 0.949999988079071D; } -- else if (((EntityMinecart)p_70108_1_).func_180456_s() != EntityMinecart.EnumMinecartType.FURNACE && this.func_180456_s() == EntityMinecart.EnumMinecartType.FURNACE) -+ else if (((EntityMinecart)p_70108_1_).isPoweredCart() && isPoweredCart()) +- else if (((EntityMinecart)p_70108_1_).func_184264_v() != EntityMinecart.Type.FURNACE && this.func_184264_v() == EntityMinecart.Type.FURNACE) ++ else if (!((EntityMinecart)p_70108_1_).isPoweredCart() && isPoweredCart()) { p_70108_1_.field_70159_w *= 0.20000000298023224D; p_70108_1_.field_70179_y *= 0.20000000298023224D; -@@ -1042,6 +1074,221 @@ - } +@@ -982,6 +1013,221 @@ + this.func_184212_Q().func_187227_b(field_184270_f, Boolean.valueOf(p_94096_1_)); } + /* =================================== FORGE START ===========================================*/ @@ -284,7 +265,7 @@ + double mX = this.field_70159_w; + double mZ = this.field_70179_y; + -+ if (this.field_70153_n != null) ++ if (this.func_184207_aI()) + { + mX *= 0.75D; + mZ *= 0.75D; @@ -382,7 +363,7 @@ + */ + public boolean isPoweredCart() + { -+ return func_180456_s() == EntityMinecart.EnumMinecartType.FURNACE; ++ return func_184264_v() == EntityMinecart.Type.FURNACE; + } + + /** @@ -391,7 +372,7 @@ + */ + public boolean canBeRidden() + { -+ return this.func_180456_s() == EntityMinecart.EnumMinecartType.RIDEABLE; ++ return this.func_184264_v() == EntityMinecart.Type.RIDEABLE; + } + + /** @@ -468,6 +449,6 @@ + + /* =================================== FORGE END ===========================================*/ + - public static enum EnumMinecartType + public static enum Type { RIDEABLE(0, "MinecartRideable"), diff --git a/patches/minecraft/net/minecraft/entity/item/EntityMinecartCommandBlock.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityMinecartCommandBlock.java.patch new file mode 100644 index 0000000000..bd1a8f256b --- /dev/null +++ b/patches/minecraft/net/minecraft/entity/item/EntityMinecartCommandBlock.java.patch @@ -0,0 +1,10 @@ +--- ../src-base/minecraft/net/minecraft/entity/item/EntityMinecartCommandBlock.java ++++ ../src-work/minecraft/net/minecraft/entity/item/EntityMinecartCommandBlock.java +@@ -122,6 +122,7 @@ + + public boolean func_184230_a(EntityPlayer p_184230_1_, ItemStack p_184230_2_, EnumHand p_184230_3_) + { ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_184230_1_, p_184230_2_, p_184230_3_))) return true; + this.field_145824_a.func_175574_a(p_184230_1_); + return false; + } diff --git a/patches/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java.patch index b40c6c37c3..5fa7ee0d0b 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java.patch @@ -1,20 +1,20 @@ --- ../src-base/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java +++ ../src-work/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java -@@ -180,6 +180,7 @@ +@@ -200,6 +200,7 @@ - public boolean func_130002_c(EntityPlayer p_130002_1_) + public boolean func_184230_a(EntityPlayer p_184230_1_, ItemStack p_184230_2_, EnumHand p_184230_3_) { -+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_130002_1_))) return true; ++ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_184230_1_, p_184230_2_, p_184230_3_))) return true; if (!this.field_70170_p.field_72995_K) { - p_130002_1_.func_71007_a(this); -@@ -232,4 +233,22 @@ - this.field_94113_a[i] = null; + p_184230_1_.func_71007_a(this); +@@ -279,6 +280,25 @@ } } -+ + + public net.minecraftforge.items.IItemHandler itemHandler = new net.minecraftforge.items.wrapper.InvWrapper(this); + ++ @SuppressWarnings("unchecked") + @Override + public T getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) + { @@ -30,4 +30,7 @@ + { + return capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); + } - } ++ + public void func_174888_l() + { + this.func_184288_f((EntityPlayer)null); diff --git a/patches/minecraft/net/minecraft/entity/item/EntityMinecartEmpty.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityMinecartEmpty.java.patch index 807d5622e3..91c23ee227 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityMinecartEmpty.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityMinecartEmpty.java.patch @@ -1,10 +1,11 @@ --- ../src-base/minecraft/net/minecraft/entity/item/EntityMinecartEmpty.java +++ ../src-work/minecraft/net/minecraft/entity/item/EntityMinecartEmpty.java -@@ -18,6 +18,7 @@ +@@ -19,6 +19,8 @@ - public boolean func_130002_c(EntityPlayer p_130002_1_) + public boolean func_184230_a(EntityPlayer p_184230_1_, ItemStack p_184230_2_, EnumHand p_184230_3_) { -+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_130002_1_))) return true; - if (this.field_70153_n != null && this.field_70153_n instanceof EntityPlayer && this.field_70153_n != p_130002_1_) ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_184230_1_, p_184230_2_, p_184230_3_))) return true; ++ + if (p_184230_1_.func_70093_af()) { - return true; + return false; diff --git a/patches/minecraft/net/minecraft/entity/item/EntityMinecartFurnace.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityMinecartFurnace.java.patch index a051aba6bc..3e1299398b 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityMinecartFurnace.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityMinecartFurnace.java.patch @@ -1,10 +1,11 @@ --- ../src-base/minecraft/net/minecraft/entity/item/EntityMinecartFurnace.java +++ ../src-work/minecraft/net/minecraft/entity/item/EntityMinecartFurnace.java -@@ -131,6 +131,7 @@ +@@ -136,6 +136,8 @@ - public boolean func_130002_c(EntityPlayer p_130002_1_) + public boolean func_184230_a(EntityPlayer p_184230_1_, ItemStack p_184230_2_, EnumHand p_184230_3_) { -+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_130002_1_))) return true; - ItemStack itemstack = p_130002_1_.field_71071_by.func_70448_g(); - - if (itemstack != null && itemstack.func_77973_b() == Items.field_151044_h) ++ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_184230_1_, p_184230_2_, p_184230_3_))) return true; ++ + if (p_184230_2_ != null && p_184230_2_.func_77973_b() == Items.field_151044_h && this.field_94110_c + 3600 <= 32000) + { + if (!p_184230_1_.field_71075_bZ.field_75098_d) diff --git a/patches/minecraft/net/minecraft/entity/item/EntityMinecartHopper.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityMinecartHopper.java.patch index 7fc5668b90..c208299213 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityMinecartHopper.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityMinecartHopper.java.patch @@ -1,10 +1,10 @@ --- ../src-base/minecraft/net/minecraft/entity/item/EntityMinecartHopper.java +++ ../src-work/minecraft/net/minecraft/entity/item/EntityMinecartHopper.java -@@ -54,6 +54,7 @@ +@@ -56,6 +56,7 @@ - public boolean func_130002_c(EntityPlayer p_130002_1_) + public boolean func_184230_a(EntityPlayer p_184230_1_, ItemStack p_184230_2_, EnumHand p_184230_3_) { -+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_130002_1_))) return true; ++ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, p_184230_1_, p_184230_2_, p_184230_3_))) return true; if (!this.field_70170_p.field_72995_K) { - p_130002_1_.func_71007_a(this); + p_184230_1_.func_71007_a(this); diff --git a/patches/minecraft/net/minecraft/entity/item/EntityXPOrb.java.patch b/patches/minecraft/net/minecraft/entity/item/EntityXPOrb.java.patch index f0c991f619..dbdf0519de 100644 --- a/patches/minecraft/net/minecraft/entity/item/EntityXPOrb.java.patch +++ b/patches/minecraft/net/minecraft/entity/item/EntityXPOrb.java.patch @@ -1,10 +1,10 @@ --- ../src-base/minecraft/net/minecraft/entity/item/EntityXPOrb.java +++ ../src-work/minecraft/net/minecraft/entity/item/EntityXPOrb.java -@@ -199,6 +199,7 @@ +@@ -204,6 +204,7 @@ { if (this.field_70532_c == 0 && p_70100_1_.field_71090_bL == 0) { + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerPickupXpEvent(p_70100_1_, this))) return; p_70100_1_.field_71090_bL = 2; - this.field_70170_p.func_72956_a(p_70100_1_, "random.orb", 0.1F, 0.5F * ((this.field_70146_Z.nextFloat() - this.field_70146_Z.nextFloat()) * 0.7F + 1.8F)); + this.field_70170_p.func_184148_a((EntityPlayer)null, p_70100_1_.field_70165_t, p_70100_1_.field_70163_u, p_70100_1_.field_70161_v, SoundEvents.field_187607_bg, SoundCategory.PLAYERS, 0.1F, 0.5F * ((this.field_70146_Z.nextFloat() - this.field_70146_Z.nextFloat()) * 0.7F + 1.8F)); p_70100_1_.func_71001_a(this, 1); diff --git a/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch index 3f5db488ad..e085803348 100644 --- a/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch +++ b/patches/minecraft/net/minecraft/entity/monster/EntityEnderman.java.patch @@ -1,24 +1,17 @@ --- ../src-base/minecraft/net/minecraft/entity/monster/EntityEnderman.java +++ ../src-work/minecraft/net/minecraft/entity/monster/EntityEnderman.java -@@ -198,12 +198,14 @@ +@@ -259,7 +259,9 @@ - protected boolean func_70825_j(double p_70825_1_, double p_70825_3_, double p_70825_5_) + private boolean func_70825_j(double p_70825_1_, double p_70825_3_, double p_70825_5_) { +- boolean flag = this.func_184595_k(p_70825_1_, p_70825_3_, p_70825_5_); + net.minecraftforge.event.entity.living.EnderTeleportEvent event = new net.minecraftforge.event.entity.living.EnderTeleportEvent(this, p_70825_1_, p_70825_3_, p_70825_5_, 0); + if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return false; - double d0 = this.field_70165_t; - double d1 = this.field_70163_u; - double d2 = this.field_70161_v; -- this.field_70165_t = p_70825_1_; -- this.field_70163_u = p_70825_3_; -- this.field_70161_v = p_70825_5_; -+ this.field_70165_t = event.targetX; -+ this.field_70163_u = event.targetY; -+ this.field_70161_v = event.targetZ; - boolean flag = false; - BlockPos blockpos = new BlockPos(this.field_70165_t, this.field_70163_u, this.field_70161_v); ++ boolean flag = this.func_184595_k(event.getTargetX(), event.getTargetY(), event.getTargetZ()); -@@ -364,6 +366,18 @@ + if (flag) + { +@@ -342,6 +344,18 @@ } } @@ -36,4 +29,4 @@ + public boolean func_70823_r() { - return this.field_70180_af.func_75683_a(18) > 0; + return ((Boolean)this.field_70180_af.func_187225_a(field_184719_bw)).booleanValue(); diff --git a/patches/minecraft/net/minecraft/entity/monster/EntityMagmaCube.java.patch b/patches/minecraft/net/minecraft/entity/monster/EntityMagmaCube.java.patch index 72690ba3f9..e44b7a1f83 100644 --- a/patches/minecraft/net/minecraft/entity/monster/EntityMagmaCube.java.patch +++ b/patches/minecraft/net/minecraft/entity/monster/EntityMagmaCube.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/monster/EntityMagmaCube.java +++ ../src-work/minecraft/net/minecraft/entity/monster/EntityMagmaCube.java -@@ -103,6 +103,7 @@ +@@ -86,6 +86,7 @@ { this.field_70181_x = (double)(0.42F + (float)this.func_70809_q() * 0.1F); this.field_70160_al = true; diff --git a/patches/minecraft/net/minecraft/entity/monster/EntitySlime.java.patch b/patches/minecraft/net/minecraft/entity/monster/EntitySlime.java.patch index 8bd8f7dce3..986396cb2b 100644 --- a/patches/minecraft/net/minecraft/entity/monster/EntitySlime.java.patch +++ b/patches/minecraft/net/minecraft/entity/monster/EntitySlime.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/monster/EntitySlime.java +++ ../src-work/minecraft/net/minecraft/entity/monster/EntitySlime.java -@@ -111,7 +111,7 @@ +@@ -125,7 +125,7 @@ if (this.field_70122_E && !this.field_175452_bi) { int i = this.func_70809_q(); @@ -8,8 +8,8 @@ + if (spawnCustomParticles()) { i = 0; } // don't spawn particles if it's handled by the implementation itself for (int j = 0; j < i * 8; ++j) { - float f = this.field_70146_Z.nextFloat() * (float)Math.PI * 2.0F; -@@ -271,7 +271,7 @@ + float f = this.field_70146_Z.nextFloat() * ((float)Math.PI * 2F); +@@ -291,7 +291,7 @@ BlockPos blockpos = new BlockPos(MathHelper.func_76128_c(this.field_70165_t), 0, MathHelper.func_76128_c(this.field_70161_v)); Chunk chunk = this.field_70170_p.func_175726_f(blockpos); @@ -18,8 +18,8 @@ { return false; } -@@ -336,6 +336,14 @@ - return super.func_180482_a(p_180482_1_, p_180482_2_); +@@ -356,6 +356,14 @@ + return this.func_189101_db() ? SoundEvents.field_189110_fE : SoundEvents.field_187882_fq; } + /* ======================================== FORGE START =====================================*/ diff --git a/patches/minecraft/net/minecraft/entity/monster/EntityZombie.java.patch b/patches/minecraft/net/minecraft/entity/monster/EntityZombie.java.patch index 5e5a32c790..f40c0b6316 100644 --- a/patches/minecraft/net/minecraft/entity/monster/EntityZombie.java.patch +++ b/patches/minecraft/net/minecraft/entity/monster/EntityZombie.java.patch @@ -1,37 +1,36 @@ --- ../src-base/minecraft/net/minecraft/entity/monster/EntityZombie.java +++ ../src-work/minecraft/net/minecraft/entity/monster/EntityZombie.java -@@ -87,7 +87,7 @@ - this.func_110148_a(SharedMonsterAttributes.field_111265_b).func_111128_a(35.0D); +@@ -101,7 +101,7 @@ this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.23000000417232513D); this.func_110148_a(SharedMonsterAttributes.field_111264_e).func_111128_a(3.0D); + this.func_110148_a(SharedMonsterAttributes.field_188791_g).func_111128_a(2.0D); - this.func_110140_aT().func_111150_b(field_110186_bp).func_111128_a(this.field_70146_Z.nextDouble() * 0.10000000149011612D); + this.func_110140_aT().func_111150_b(field_110186_bp).func_111128_a(this.field_70146_Z.nextDouble() * net.minecraftforge.common.ForgeModContainer.zombieSummonBaseChance); } protected void func_70088_a() -@@ -229,12 +229,25 @@ +@@ -259,12 +259,24 @@ entitylivingbase = (EntityLivingBase)p_70097_1_.func_76346_g(); } -- if (entitylivingbase != null && this.field_70170_p.func_175659_aa() == EnumDifficulty.HARD && (double)this.field_70146_Z.nextFloat() < this.func_110148_a(field_110186_bp).func_111126_e()) +- if (entitylivingbase != null && this.field_70170_p.func_175659_aa() == EnumDifficulty.HARD && (double)this.field_70146_Z.nextFloat() < this.func_110148_a(field_110186_bp).func_111126_e() && this.field_70170_p.func_82736_K().func_82766_b("doMobSpawning")) + int i = MathHelper.func_76128_c(this.field_70165_t); + int j = MathHelper.func_76128_c(this.field_70163_u); + int k = MathHelper.func_76128_c(this.field_70161_v); -+ + net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent summonAid = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, field_70170_p, i, j, k, entitylivingbase, this.func_110148_a(field_110186_bp).func_111126_e()); + if (summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return true; + + if (summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW || -+ entitylivingbase != null && this.field_70170_p.func_175659_aa() == EnumDifficulty.HARD && (double)this.field_70146_Z.nextFloat() < this.func_110148_a(field_110186_bp).func_111126_e()) ++ entitylivingbase != null && this.field_70170_p.func_175659_aa() == EnumDifficulty.HARD && (double)this.field_70146_Z.nextFloat() < this.func_110148_a(field_110186_bp).func_111126_e() && this.field_70170_p.func_82736_K().func_82766_b("doMobSpawning")) { - int i = MathHelper.func_76128_c(this.field_70165_t); - int j = MathHelper.func_76128_c(this.field_70163_u); - int k = MathHelper.func_76128_c(this.field_70161_v); - EntityZombie entityzombie = new EntityZombie(this.field_70170_p); + EntityZombie entityzombie; -+ if (summonAid.customSummonedAid != null && summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW) ++ if (summonAid.getCustomSummonedAid() != null && summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW) + { -+ entityzombie = summonAid.customSummonedAid; ++ entityzombie = summonAid.getCustomSummonedAid(); + } + else + { @@ -40,8 +39,16 @@ for (int l = 0; l < 50; ++l) { -@@ -249,7 +262,7 @@ - if (!this.field_70170_p.func_175636_b((double)i1, (double)j1, (double)k1, 7.0D) && this.field_70170_p.func_72917_a(entityzombie.func_174813_aQ(), entityzombie) && this.field_70170_p.func_72945_a(entityzombie, entityzombie.func_174813_aQ()).isEmpty() && !this.field_70170_p.func_72953_d(entityzombie.func_174813_aQ())) +@@ -272,14 +284,14 @@ + int j1 = j + MathHelper.func_76136_a(this.field_70146_Z, 7, 40) * MathHelper.func_76136_a(this.field_70146_Z, -1, 1); + int k1 = k + MathHelper.func_76136_a(this.field_70146_Z, 7, 40) * MathHelper.func_76136_a(this.field_70146_Z, -1, 1); + +- if (this.field_70170_p.func_180495_p(new BlockPos(i1, j1 - 1, k1)).func_185896_q() && this.field_70170_p.func_175671_l(new BlockPos(i1, j1, k1)) < 10) ++ if (this.field_70170_p.func_180495_p(new BlockPos(i1, j1 - 1, k1)).isSideSolid(this.field_70170_p, new BlockPos(i1, j1 - 1, k1), net.minecraft.util.EnumFacing.UP) && this.field_70170_p.func_175671_l(new BlockPos(i1, j1, k1)) < 10) + { + entityzombie.func_70107_b((double)i1, (double)j1, (double)k1); + + if (!this.field_70170_p.func_175636_b((double)i1, (double)j1, (double)k1, 7.0D) && this.field_70170_p.func_72917_a(entityzombie.func_174813_aQ(), entityzombie) && this.field_70170_p.func_184144_a(entityzombie, entityzombie.func_174813_aQ()).isEmpty() && !this.field_70170_p.func_72953_d(entityzombie.func_174813_aQ())) { this.field_70170_p.func_72838_d(entityzombie); - entityzombie.func_70624_b(entitylivingbase); @@ -49,7 +56,7 @@ entityzombie.func_180482_a(this.field_70170_p.func_175649_E(new BlockPos(entityzombie)), (IEntityLivingData)null); this.func_110148_a(field_110186_bp).func_111121_a(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0)); entityzombie.func_110148_a(field_110186_bp).func_111121_a(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0)); -@@ -465,7 +478,7 @@ +@@ -483,7 +495,7 @@ if (p_180482_2_ == null) { diff --git a/patches/minecraft/net/minecraft/entity/passive/EntityHorse.java.patch b/patches/minecraft/net/minecraft/entity/passive/EntityHorse.java.patch index 988e8b5871..5c100f3b41 100644 --- a/patches/minecraft/net/minecraft/entity/passive/EntityHorse.java.patch +++ b/patches/minecraft/net/minecraft/entity/passive/EntityHorse.java.patch @@ -1,6 +1,14 @@ --- ../src-base/minecraft/net/minecraft/entity/passive/EntityHorse.java +++ ../src-work/minecraft/net/minecraft/entity/passive/EntityHorse.java -@@ -1247,6 +1247,7 @@ +@@ -433,6 +433,7 @@ + + this.field_110296_bG.func_110134_a(this); + this.func_110232_cE(); ++ this.itemHandler = new net.minecraftforge.items.wrapper.InvWrapper(this.field_110296_bG); + } + + private void func_110232_cE() +@@ -1200,6 +1201,7 @@ } this.field_110277_bt = 0.0F; @@ -8,3 +16,25 @@ } this.field_70138_W = 1.0F; +@@ -1793,4 +1795,21 @@ + this.field_188477_b = p_i46589_2_; + } + } ++ ++ // FORGE ++ private net.minecraftforge.items.IItemHandler itemHandler = null; // Initialized by initHorseChest above. ++ ++ @SuppressWarnings("unchecked") ++ @Override ++ public T getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) ++ { ++ if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) return (T) itemHandler; ++ return super.getCapability(capability, facing); ++ } ++ ++ @Override ++ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) ++ { ++ return capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); ++ } + } diff --git a/patches/minecraft/net/minecraft/entity/passive/EntityMooshroom.java.patch b/patches/minecraft/net/minecraft/entity/passive/EntityMooshroom.java.patch index e996a2886e..3926c9c077 100644 --- a/patches/minecraft/net/minecraft/entity/passive/EntityMooshroom.java.patch +++ b/patches/minecraft/net/minecraft/entity/passive/EntityMooshroom.java.patch @@ -1,39 +1,38 @@ --- ../src-base/minecraft/net/minecraft/entity/passive/EntityMooshroom.java +++ ../src-work/minecraft/net/minecraft/entity/passive/EntityMooshroom.java -@@ -9,7 +9,7 @@ - import net.minecraft.util.EnumParticleTypes; +@@ -13,7 +13,7 @@ import net.minecraft.world.World; + import net.minecraft.world.storage.loot.LootTableList; -public class EntityMooshroom extends EntityCow +public class EntityMooshroom extends EntityCow implements net.minecraftforge.common.IShearable { public EntityMooshroom(World p_i1687_1_) { -@@ -18,6 +18,7 @@ +@@ -22,6 +22,7 @@ this.field_175506_bl = Blocks.field_150391_bh; } + @SuppressWarnings("unused") - public boolean func_70085_c(EntityPlayer p_70085_1_) + public boolean func_184645_a(EntityPlayer p_184645_1_, EnumHand p_184645_2_, ItemStack p_184645_3_) { - ItemStack itemstack = p_70085_1_.field_71071_by.func_70448_g(); + if (p_184645_3_ != null && p_184645_3_.func_77973_b() == Items.field_151054_z && this.func_70874_b() >= 0 && !p_184645_1_.field_71075_bZ.field_75098_d) @@ -37,7 +38,7 @@ - } - } -- if (itemstack != null && itemstack.func_77973_b() == Items.field_151097_aZ && this.func_70874_b() >= 0) -+ if (false && itemstack != null && itemstack.func_77973_b() == Items.field_151097_aZ && this.func_70874_b() >= 0) //Forge Disable, Moved to onSheared + return true; + } +- else if (p_184645_3_ != null && p_184645_3_.func_77973_b() == Items.field_151097_aZ && this.func_70874_b() >= 0) ++ else if (false && p_184645_3_ != null && p_184645_3_.func_77973_b() == Items.field_151097_aZ && this.func_70874_b() >= 0) //Forge Disable, Moved to onSheared { this.func_70106_y(); this.field_70170_p.func_175688_a(EnumParticleTypes.EXPLOSION_LARGE, this.field_70165_t, this.field_70163_u + (double)(this.field_70131_O / 2.0F), this.field_70161_v, 0.0D, 0.0D, 0.0D, new int[0]); -@@ -77,4 +78,33 @@ - { +@@ -78,6 +79,35 @@ return new EntityMooshroom(this.field_70170_p); } -+ -+ @Override public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, net.minecraft.util.BlockPos pos){ return func_70874_b() >= 0; } + ++ @Override public boolean isShearable(ItemStack item, net.minecraft.world.IBlockAccess world, net.minecraft.util.math.BlockPos pos){ return func_70874_b() >= 0; } + @Override -+ public java.util.List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, net.minecraft.util.BlockPos pos, int fortune) ++ public java.util.List onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, net.minecraft.util.math.BlockPos pos, int fortune) + { + this.func_70106_y(); + this.field_70170_p.func_175688_a(EnumParticleTypes.EXPLOSION_LARGE, this.field_70165_t, this.field_70163_u + (double)(this.field_70131_O / 2.0F), this.field_70161_v, 0.0D, 0.0D, 0.0D, new int[0]); @@ -56,7 +55,10 @@ + ret.add(new ItemStack(Blocks.field_150337_Q)); + } + -+ this.func_85030_a("mob.sheep.shear", 1.0F, 1.0F); ++ this.func_184185_a(SoundEvents.field_187784_dt, 1.0F, 1.0F); + return ret; + } - } ++ + protected ResourceLocation func_184647_J() + { + return LootTableList.field_186400_H; diff --git a/patches/minecraft/net/minecraft/entity/passive/EntityOcelot.java.patch b/patches/minecraft/net/minecraft/entity/passive/EntityOcelot.java.patch index ec6eaae580..921dfecbad 100644 --- a/patches/minecraft/net/minecraft/entity/passive/EntityOcelot.java.patch +++ b/patches/minecraft/net/minecraft/entity/passive/EntityOcelot.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/entity/passive/EntityOcelot.java +++ ../src-work/minecraft/net/minecraft/entity/passive/EntityOcelot.java -@@ -279,7 +279,7 @@ +@@ -285,7 +285,7 @@ + IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos.func_177977_b()); + Block block = iblockstate.func_177230_c(); - Block block = this.field_70170_p.func_180495_p(blockpos.func_177977_b()).func_177230_c(); - -- if (block == Blocks.field_150349_c || block.func_149688_o() == Material.field_151584_j) -+ if (block == Blocks.field_150349_c || block.isLeaves(field_70170_p, blockpos.func_177977_b())) +- if (block == Blocks.field_150349_c || iblockstate.func_185904_a() == Material.field_151584_j) ++ if (block == Blocks.field_150349_c || block.isLeaves(iblockstate, this.field_70170_p, blockpos.func_177977_b())) { return true; } diff --git a/patches/minecraft/net/minecraft/entity/passive/EntitySheep.java.patch b/patches/minecraft/net/minecraft/entity/passive/EntitySheep.java.patch index 7d9799ce8f..7552ad7052 100644 --- a/patches/minecraft/net/minecraft/entity/passive/EntitySheep.java.patch +++ b/patches/minecraft/net/minecraft/entity/passive/EntitySheep.java.patch @@ -1,29 +1,27 @@ --- ../src-base/minecraft/net/minecraft/entity/passive/EntitySheep.java +++ ../src-work/minecraft/net/minecraft/entity/passive/EntitySheep.java -@@ -35,7 +35,7 @@ +@@ -42,7 +42,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class EntitySheep extends EntityAnimal +public class EntitySheep extends EntityAnimal implements net.minecraftforge.common.IShearable { + private static final DataParameter field_184774_bv = EntityDataManager.func_187226_a(EntitySheep.class, DataSerializers.field_187191_a); private final InventoryCrafting field_90016_e = new InventoryCrafting(new Container() - { -@@ -140,11 +140,12 @@ +@@ -171,9 +171,10 @@ } } + @SuppressWarnings("unused") - public boolean func_70085_c(EntityPlayer p_70085_1_) + public boolean func_184645_a(EntityPlayer p_184645_1_, EnumHand p_184645_2_, ItemStack p_184645_3_) { - ItemStack itemstack = p_70085_1_.field_71071_by.func_70448_g(); - -- if (itemstack != null && itemstack.func_77973_b() == Items.field_151097_aZ && !this.func_70892_o() && !this.func_70631_g_()) -+ if (false && itemstack != null && itemstack.func_77973_b() == Items.field_151097_aZ && !this.func_70892_o() && !this.func_70631_g_()) //Forge: Moved to onSheared +- if (p_184645_3_ != null && p_184645_3_.func_77973_b() == Items.field_151097_aZ && !this.func_70892_o() && !this.func_70631_g_()) ++ if (false && p_184645_3_ != null && p_184645_3_.func_77973_b() == Items.field_151097_aZ && !this.func_70892_o() && !this.func_70631_g_()) //Forge: Moved to onSheared { if (!this.field_70170_p.field_72995_K) { -@@ -327,4 +328,19 @@ +@@ -356,4 +357,19 @@ field_175514_bm.put(EnumDyeColor.RED, new float[] {0.6F, 0.2F, 0.2F}); field_175514_bm.put(EnumDyeColor.BLACK, new float[] {0.1F, 0.1F, 0.1F}); } @@ -39,7 +37,7 @@ + for (int j = 0; j < i; ++j) + ret.add(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, this.func_175509_cj().func_176765_a())); + -+ this.func_85030_a("mob.sheep.shear", 1.0F, 1.0F); ++ this.func_184185_a(SoundEvents.field_187763_eJ, 1.0F, 1.0F); + return ret; + } } diff --git a/patches/minecraft/net/minecraft/entity/passive/EntityVillager.java.patch b/patches/minecraft/net/minecraft/entity/passive/EntityVillager.java.patch index 9648a8f595..f6a41feba6 100644 --- a/patches/minecraft/net/minecraft/entity/passive/EntityVillager.java.patch +++ b/patches/minecraft/net/minecraft/entity/passive/EntityVillager.java.patch @@ -1,39 +1,151 @@ --- ../src-base/minecraft/net/minecraft/entity/passive/EntityVillager.java +++ ../src-work/minecraft/net/minecraft/entity/passive/EntityVillager.java -@@ -81,6 +81,7 @@ +@@ -74,6 +74,7 @@ + public class EntityVillager extends EntityAgeable implements IMerchant, INpc + { + private static final DataParameter field_184752_bw = EntityDataManager.func_187226_a(EntityVillager.class, DataSerializers.field_187192_b); ++ private static final DataParameter PROFESSION_STR = EntityDataManager.func_187226_a(EntityVillager.class, DataSerializers.field_187194_d); + private int field_70955_e; + private boolean field_70952_f; + private boolean field_70953_g; +@@ -90,6 +91,7 @@ private boolean field_82190_bM; private boolean field_175564_by; private InventoryBasic field_175560_bz; + @Deprecated //Use VillagerRegistry - private static final EntityVillager.ITradeList[][][][] field_175561_bA = new EntityVillager.ITradeList[][][][] {{{{new EntityVillager.EmeraldForItems(Items.field_151015_O, new EntityVillager.PriceInfo(18, 22)), new EntityVillager.EmeraldForItems(Items.field_151174_bG, new EntityVillager.PriceInfo(15, 19)), new EntityVillager.EmeraldForItems(Items.field_151172_bF, new EntityVillager.PriceInfo(15, 19)), new EntityVillager.ListItemForEmeralds(Items.field_151025_P, new EntityVillager.PriceInfo(-4, -2))}, {new EntityVillager.EmeraldForItems(Item.func_150898_a(Blocks.field_150423_aK), new EntityVillager.PriceInfo(8, 13)), new EntityVillager.ListItemForEmeralds(Items.field_151158_bO, new EntityVillager.PriceInfo(-3, -2))}, {new EntityVillager.EmeraldForItems(Item.func_150898_a(Blocks.field_150440_ba), new EntityVillager.PriceInfo(7, 12)), new EntityVillager.ListItemForEmeralds(Items.field_151034_e, new EntityVillager.PriceInfo(-5, -7))}, {new EntityVillager.ListItemForEmeralds(Items.field_151106_aX, new EntityVillager.PriceInfo(-6, -10)), new EntityVillager.ListItemForEmeralds(Items.field_151105_aU, new EntityVillager.PriceInfo(1, 1))}}, {{new EntityVillager.EmeraldForItems(Items.field_151007_F, new EntityVillager.PriceInfo(15, 20)), new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ItemAndEmeraldToItem(Items.field_151115_aP, new EntityVillager.PriceInfo(6, 6), Items.field_179566_aV, new EntityVillager.PriceInfo(6, 6))}, {new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151112_aM, new EntityVillager.PriceInfo(7, 8))}}, {{new EntityVillager.EmeraldForItems(Item.func_150898_a(Blocks.field_150325_L), new EntityVillager.PriceInfo(16, 22)), new EntityVillager.ListItemForEmeralds(Items.field_151097_aZ, new EntityVillager.PriceInfo(3, 4))}, {new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 0), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 1), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 2), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 3), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 4), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 5), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 6), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 7), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 8), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 9), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 10), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 11), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 12), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 13), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 14), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 15), new EntityVillager.PriceInfo(1, 2))}}, {{new EntityVillager.EmeraldForItems(Items.field_151007_F, new EntityVillager.PriceInfo(15, 20)), new EntityVillager.ListItemForEmeralds(Items.field_151032_g, new EntityVillager.PriceInfo(-12, -8))}, {new EntityVillager.ListItemForEmeralds(Items.field_151031_f, new EntityVillager.PriceInfo(2, 3)), new EntityVillager.ItemAndEmeraldToItem(Item.func_150898_a(Blocks.field_150351_n), new EntityVillager.PriceInfo(10, 10), Items.field_151145_ak, new EntityVillager.PriceInfo(6, 10))}}}, {{{new EntityVillager.EmeraldForItems(Items.field_151121_aF, new EntityVillager.PriceInfo(24, 36)), new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.EmeraldForItems(Items.field_151122_aG, new EntityVillager.PriceInfo(8, 10)), new EntityVillager.ListItemForEmeralds(Items.field_151111_aL, new EntityVillager.PriceInfo(10, 12)), new EntityVillager.ListItemForEmeralds(Item.func_150898_a(Blocks.field_150342_X), new EntityVillager.PriceInfo(3, 4))}, {new EntityVillager.EmeraldForItems(Items.field_151164_bB, new EntityVillager.PriceInfo(2, 2)), new EntityVillager.ListItemForEmeralds(Items.field_151113_aN, new EntityVillager.PriceInfo(10, 12)), new EntityVillager.ListItemForEmeralds(Item.func_150898_a(Blocks.field_150359_w), new EntityVillager.PriceInfo(-5, -3))}, {new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.ListItemForEmeralds(Items.field_151057_cb, new EntityVillager.PriceInfo(20, 22))}}}, {{{new EntityVillager.EmeraldForItems(Items.field_151078_bh, new EntityVillager.PriceInfo(36, 40)), new EntityVillager.EmeraldForItems(Items.field_151043_k, new EntityVillager.PriceInfo(8, 10))}, {new EntityVillager.ListItemForEmeralds(Items.field_151137_ax, new EntityVillager.PriceInfo(-4, -1)), new EntityVillager.ListItemForEmeralds(new ItemStack(Items.field_151100_aR, 1, EnumDyeColor.BLUE.func_176767_b()), new EntityVillager.PriceInfo(-2, -1))}, {new EntityVillager.ListItemForEmeralds(Items.field_151061_bv, new EntityVillager.PriceInfo(7, 11)), new EntityVillager.ListItemForEmeralds(Item.func_150898_a(Blocks.field_150426_aN), new EntityVillager.PriceInfo(-3, -1))}, {new EntityVillager.ListItemForEmeralds(Items.field_151062_by, new EntityVillager.PriceInfo(3, 11))}}}, {{{new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListItemForEmeralds(Items.field_151028_Y, new EntityVillager.PriceInfo(4, 6))}, {new EntityVillager.EmeraldForItems(Items.field_151042_j, new EntityVillager.PriceInfo(7, 9)), new EntityVillager.ListItemForEmeralds(Items.field_151030_Z, new EntityVillager.PriceInfo(10, 14))}, {new EntityVillager.EmeraldForItems(Items.field_151045_i, new EntityVillager.PriceInfo(3, 4)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151163_ad, new EntityVillager.PriceInfo(16, 19))}, {new EntityVillager.ListItemForEmeralds(Items.field_151029_X, new EntityVillager.PriceInfo(5, 7)), new EntityVillager.ListItemForEmeralds(Items.field_151022_W, new EntityVillager.PriceInfo(9, 11)), new EntityVillager.ListItemForEmeralds(Items.field_151020_U, new EntityVillager.PriceInfo(5, 7)), new EntityVillager.ListItemForEmeralds(Items.field_151023_V, new EntityVillager.PriceInfo(11, 15))}}, {{new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListItemForEmeralds(Items.field_151036_c, new EntityVillager.PriceInfo(6, 8))}, {new EntityVillager.EmeraldForItems(Items.field_151042_j, new EntityVillager.PriceInfo(7, 9)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151040_l, new EntityVillager.PriceInfo(9, 10))}, {new EntityVillager.EmeraldForItems(Items.field_151045_i, new EntityVillager.PriceInfo(3, 4)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151048_u, new EntityVillager.PriceInfo(12, 15)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151056_x, new EntityVillager.PriceInfo(9, 12))}}, {{new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151037_a, new EntityVillager.PriceInfo(5, 7))}, {new EntityVillager.EmeraldForItems(Items.field_151042_j, new EntityVillager.PriceInfo(7, 9)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151035_b, new EntityVillager.PriceInfo(9, 11))}, {new EntityVillager.EmeraldForItems(Items.field_151045_i, new EntityVillager.PriceInfo(3, 4)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151046_w, new EntityVillager.PriceInfo(12, 15))}}}, {{{new EntityVillager.EmeraldForItems(Items.field_151147_al, new EntityVillager.PriceInfo(14, 18)), new EntityVillager.EmeraldForItems(Items.field_151076_bf, new EntityVillager.PriceInfo(14, 18))}, {new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListItemForEmeralds(Items.field_151157_am, new EntityVillager.PriceInfo(-7, -5)), new EntityVillager.ListItemForEmeralds(Items.field_151077_bg, new EntityVillager.PriceInfo(-8, -6))}}, {{new EntityVillager.EmeraldForItems(Items.field_151116_aA, new EntityVillager.PriceInfo(9, 12)), new EntityVillager.ListItemForEmeralds(Items.field_151026_S, new EntityVillager.PriceInfo(2, 4))}, {new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151027_R, new EntityVillager.PriceInfo(7, 12))}, {new EntityVillager.ListItemForEmeralds(Items.field_151141_av, new EntityVillager.PriceInfo(8, 10))}}}}; + private static final EntityVillager.ITradeList[][][][] field_175561_bA = new EntityVillager.ITradeList[][][][] {{{{new EntityVillager.EmeraldForItems(Items.field_151015_O, new EntityVillager.PriceInfo(18, 22)), new EntityVillager.EmeraldForItems(Items.field_151174_bG, new EntityVillager.PriceInfo(15, 19)), new EntityVillager.EmeraldForItems(Items.field_151172_bF, new EntityVillager.PriceInfo(15, 19)), new EntityVillager.ListItemForEmeralds(Items.field_151025_P, new EntityVillager.PriceInfo(-4, -2))}, {new EntityVillager.EmeraldForItems(Item.func_150898_a(Blocks.field_150423_aK), new EntityVillager.PriceInfo(8, 13)), new EntityVillager.ListItemForEmeralds(Items.field_151158_bO, new EntityVillager.PriceInfo(-3, -2))}, {new EntityVillager.EmeraldForItems(Item.func_150898_a(Blocks.field_150440_ba), new EntityVillager.PriceInfo(7, 12)), new EntityVillager.ListItemForEmeralds(Items.field_151034_e, new EntityVillager.PriceInfo(-5, -7))}, {new EntityVillager.ListItemForEmeralds(Items.field_151106_aX, new EntityVillager.PriceInfo(-6, -10)), new EntityVillager.ListItemForEmeralds(Items.field_151105_aU, new EntityVillager.PriceInfo(1, 1))}}, {{new EntityVillager.EmeraldForItems(Items.field_151007_F, new EntityVillager.PriceInfo(15, 20)), new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ItemAndEmeraldToItem(Items.field_151115_aP, new EntityVillager.PriceInfo(6, 6), Items.field_179566_aV, new EntityVillager.PriceInfo(6, 6))}, {new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151112_aM, new EntityVillager.PriceInfo(7, 8))}}, {{new EntityVillager.EmeraldForItems(Item.func_150898_a(Blocks.field_150325_L), new EntityVillager.PriceInfo(16, 22)), new EntityVillager.ListItemForEmeralds(Items.field_151097_aZ, new EntityVillager.PriceInfo(3, 4))}, {new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L)), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 1), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 2), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 3), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 4), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 5), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 6), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 7), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 8), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 9), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 10), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 11), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 12), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 13), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 14), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.func_150898_a(Blocks.field_150325_L), 1, 15), new EntityVillager.PriceInfo(1, 2))}}, {{new EntityVillager.EmeraldForItems(Items.field_151007_F, new EntityVillager.PriceInfo(15, 20)), new EntityVillager.ListItemForEmeralds(Items.field_151032_g, new EntityVillager.PriceInfo(-12, -8))}, {new EntityVillager.ListItemForEmeralds(Items.field_151031_f, new EntityVillager.PriceInfo(2, 3)), new EntityVillager.ItemAndEmeraldToItem(Item.func_150898_a(Blocks.field_150351_n), new EntityVillager.PriceInfo(10, 10), Items.field_151145_ak, new EntityVillager.PriceInfo(6, 10))}}}, {{{new EntityVillager.EmeraldForItems(Items.field_151121_aF, new EntityVillager.PriceInfo(24, 36)), new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.EmeraldForItems(Items.field_151122_aG, new EntityVillager.PriceInfo(8, 10)), new EntityVillager.ListItemForEmeralds(Items.field_151111_aL, new EntityVillager.PriceInfo(10, 12)), new EntityVillager.ListItemForEmeralds(Item.func_150898_a(Blocks.field_150342_X), new EntityVillager.PriceInfo(3, 4))}, {new EntityVillager.EmeraldForItems(Items.field_151164_bB, new EntityVillager.PriceInfo(2, 2)), new EntityVillager.ListItemForEmeralds(Items.field_151113_aN, new EntityVillager.PriceInfo(10, 12)), new EntityVillager.ListItemForEmeralds(Item.func_150898_a(Blocks.field_150359_w), new EntityVillager.PriceInfo(-5, -3))}, {new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.ListItemForEmeralds(Items.field_151057_cb, new EntityVillager.PriceInfo(20, 22))}}}, {{{new EntityVillager.EmeraldForItems(Items.field_151078_bh, new EntityVillager.PriceInfo(36, 40)), new EntityVillager.EmeraldForItems(Items.field_151043_k, new EntityVillager.PriceInfo(8, 10))}, {new EntityVillager.ListItemForEmeralds(Items.field_151137_ax, new EntityVillager.PriceInfo(-4, -1)), new EntityVillager.ListItemForEmeralds(new ItemStack(Items.field_151100_aR, 1, EnumDyeColor.BLUE.func_176767_b()), new EntityVillager.PriceInfo(-2, -1))}, {new EntityVillager.ListItemForEmeralds(Items.field_151079_bi, new EntityVillager.PriceInfo(4, 7)), new EntityVillager.ListItemForEmeralds(Item.func_150898_a(Blocks.field_150426_aN), new EntityVillager.PriceInfo(-3, -1))}, {new EntityVillager.ListItemForEmeralds(Items.field_151062_by, new EntityVillager.PriceInfo(3, 11))}}}, {{{new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListItemForEmeralds(Items.field_151028_Y, new EntityVillager.PriceInfo(4, 6))}, {new EntityVillager.EmeraldForItems(Items.field_151042_j, new EntityVillager.PriceInfo(7, 9)), new EntityVillager.ListItemForEmeralds(Items.field_151030_Z, new EntityVillager.PriceInfo(10, 14))}, {new EntityVillager.EmeraldForItems(Items.field_151045_i, new EntityVillager.PriceInfo(3, 4)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151163_ad, new EntityVillager.PriceInfo(16, 19))}, {new EntityVillager.ListItemForEmeralds(Items.field_151029_X, new EntityVillager.PriceInfo(5, 7)), new EntityVillager.ListItemForEmeralds(Items.field_151022_W, new EntityVillager.PriceInfo(9, 11)), new EntityVillager.ListItemForEmeralds(Items.field_151020_U, new EntityVillager.PriceInfo(5, 7)), new EntityVillager.ListItemForEmeralds(Items.field_151023_V, new EntityVillager.PriceInfo(11, 15))}}, {{new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListItemForEmeralds(Items.field_151036_c, new EntityVillager.PriceInfo(6, 8))}, {new EntityVillager.EmeraldForItems(Items.field_151042_j, new EntityVillager.PriceInfo(7, 9)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151040_l, new EntityVillager.PriceInfo(9, 10))}, {new EntityVillager.EmeraldForItems(Items.field_151045_i, new EntityVillager.PriceInfo(3, 4)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151048_u, new EntityVillager.PriceInfo(12, 15)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151056_x, new EntityVillager.PriceInfo(9, 12))}}, {{new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151037_a, new EntityVillager.PriceInfo(5, 7))}, {new EntityVillager.EmeraldForItems(Items.field_151042_j, new EntityVillager.PriceInfo(7, 9)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151035_b, new EntityVillager.PriceInfo(9, 11))}, {new EntityVillager.EmeraldForItems(Items.field_151045_i, new EntityVillager.PriceInfo(3, 4)), new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151046_w, new EntityVillager.PriceInfo(12, 15))}}}, {{{new EntityVillager.EmeraldForItems(Items.field_151147_al, new EntityVillager.PriceInfo(14, 18)), new EntityVillager.EmeraldForItems(Items.field_151076_bf, new EntityVillager.PriceInfo(14, 18))}, {new EntityVillager.EmeraldForItems(Items.field_151044_h, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListItemForEmeralds(Items.field_151157_am, new EntityVillager.PriceInfo(-7, -5)), new EntityVillager.ListItemForEmeralds(Items.field_151077_bg, new EntityVillager.PriceInfo(-8, -6))}}, {{new EntityVillager.EmeraldForItems(Items.field_151116_aA, new EntityVillager.PriceInfo(9, 12)), new EntityVillager.ListItemForEmeralds(Items.field_151026_S, new EntityVillager.PriceInfo(2, 4))}, {new EntityVillager.ListEnchantedItemForEmeralds(Items.field_151027_R, new EntityVillager.PriceInfo(7, 12))}, {new EntityVillager.ListItemForEmeralds(Items.field_151141_av, new EntityVillager.PriceInfo(8, 10))}}}}; public EntityVillager(World p_i1747_1_) -@@ -210,7 +211,7 @@ - ItemStack itemstack = p_70085_1_.field_71071_by.func_70448_g(); - boolean flag = itemstack != null && itemstack.func_77973_b() == Items.field_151063_bx; +@@ -221,7 +223,7 @@ + { + boolean flag = p_184645_3_ != null && p_184645_3_.func_77973_b() == Items.field_151063_bx; - if (!flag && this.func_70089_S() && !this.func_70940_q() && !this.func_70631_g_()) -+ if (!flag && this.func_70089_S() && !this.func_70940_q() && !this.func_70631_g_() && !p_70085_1_.func_70093_af()) ++ if (!flag && this.func_70089_S() && !this.func_70940_q() && !this.func_70631_g_() && !p_184645_1_.func_70093_af()) { - if (!this.field_70170_p.field_72995_K && (this.field_70963_i == null || this.field_70963_i.size() > 0)) + if (!this.field_70170_p.field_72995_K && (this.field_70963_i == null || !this.field_70963_i.isEmpty())) { -@@ -522,6 +523,7 @@ +@@ -242,12 +244,14 @@ + { + super.func_70088_a(); + this.field_70180_af.func_187214_a(field_184752_bw, Integer.valueOf(0)); ++ this.field_70180_af.func_187214_a(PROFESSION_STR, "minecraft:farmer"); + } + + public void func_70014_b(NBTTagCompound p_70014_1_) + { + super.func_70014_b(p_70014_1_); + p_70014_1_.func_74768_a("Profession", this.func_70946_n()); ++ p_70014_1_.func_74778_a("ProfessionName", this.getProfessionForge().getRegistryName().toString()); + p_70014_1_.func_74768_a("Riches", this.field_70956_bz); + p_70014_1_.func_74768_a("Career", this.field_175563_bv); + p_70014_1_.func_74768_a("CareerLevel", this.field_175562_bw); +@@ -277,6 +281,14 @@ + { + super.func_70037_a(p_70037_1_); + this.func_70938_b(p_70037_1_.func_74762_e("Profession")); ++ if (p_70037_1_.func_74764_b("ProfessionName")) ++ { ++ net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession p = ++ net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(new net.minecraft.util.ResourceLocation(p_70037_1_.func_74779_i("ProfessionName"))); ++ if (p == null) ++ p = net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(new net.minecraft.util.ResourceLocation("minecraft:farmer")); ++ this.setProfession(p); ++ } + this.field_70956_bz = p_70037_1_.func_74762_e("Riches"); + this.field_175563_bv = p_70037_1_.func_74762_e("Career"); + this.field_175562_bw = p_70037_1_.func_74762_e("CareerLevel"); +@@ -327,6 +339,7 @@ + public void func_70938_b(int p_70938_1_) + { + this.field_70180_af.func_187227_b(field_184752_bw, Integer.valueOf(p_70938_1_)); ++ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, p_70938_1_); + } + + public int func_70946_n() +@@ -334,6 +347,39 @@ + return Math.max(((Integer)this.field_70180_af.func_187225_a(field_184752_bw)).intValue() % 5, 0); + } + ++ private net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof; ++ public void setProfession(net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof) ++ { ++ this.field_70180_af.func_187227_b(PROFESSION_STR, prof.getRegistryName().toString()); ++ this.prof = prof; ++ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, prof); ++ } ++ ++ public net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession getProfessionForge() ++ { ++ if (this.prof == null) ++ { ++ String p = this.field_70180_af.func_187225_a(PROFESSION_STR); ++ net.minecraft.util.ResourceLocation res = new net.minecraft.util.ResourceLocation(p == null ? "minecraft:farmer" : p); ++ this.prof = net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(res); ++ if (this.prof == null) ++ return net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(new net.minecraft.util.ResourceLocation("minecraft:farmer")); ++ } ++ return this.prof; ++ } ++ ++ @Override ++ public void func_184206_a(DataParameter key) ++ { ++ super.func_184206_a(key); ++ if(key == PROFESSION_STR) ++ { ++ String p = this.field_70180_af.func_187225_a(PROFESSION_STR); ++ net.minecraft.util.ResourceLocation res = new net.minecraft.util.ResourceLocation(p == null ? "minecraft:farmer" : p); ++ this.prof = net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(res); ++ } ++ } ++ + public boolean func_70941_o() + { + return this.field_70952_f; +@@ -533,15 +579,13 @@ private void func_175554_cu() { -+ //TODO: Hook into VillagerRegistry - EntityVillager.ITradeList[][][] aentityvillager$itradelist = field_175561_bA[this.func_70946_n()]; - +- EntityVillager.ITradeList[][][] aentityvillager$itradelist = field_175561_bA[this.func_70946_n()]; +- if (this.field_175563_bv != 0 && this.field_175562_bw != 0) -@@ -635,6 +637,7 @@ + { + ++this.field_175562_bw; + } + else + { +- this.field_175563_bv = this.field_70146_Z.nextInt(aentityvillager$itradelist.length) + 1; ++ this.field_175563_bv = this.getProfessionForge().getRandomCareer(this.field_70146_Z) + 1; + this.field_175562_bw = 1; + } + +@@ -552,7 +596,7 @@ + + int i = this.field_175563_bv - 1; + int j = this.field_175562_bw - 1; +- EntityVillager.ITradeList[][] aentityvillager$itradelist1 = aentityvillager$itradelist[i]; ++ EntityVillager.ITradeList[][] aentityvillager$itradelist1 = this.getProfessionForge().getCareer(i).getTrades(); + + if (j >= 0 && j < aentityvillager$itradelist1.length) + { +@@ -647,9 +691,14 @@ } } ++ if (s1 == null) ++ s1 = this.getProfessionForge().getCareer(this.field_175563_bv).getName(); ++ else ++ s1 = "entity.Villager." + s1; + //TODO: Hook into VillagerRegistry to get name if (s1 != null) { - ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("entity.Villager." + s1, new Object[0]); -@@ -697,7 +700,7 @@ +- TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("entity.Villager." + s1, new Object[0]); ++ TextComponentTranslation textcomponenttranslation = new TextComponentTranslation(s1, new Object[0]); + textcomponenttranslation.func_150256_b().func_150209_a(this.func_174823_aP()); + textcomponenttranslation.func_150256_b().func_179989_a(this.func_110124_au().toString()); + +@@ -708,7 +757,7 @@ public IEntityLivingData func_180482_a(DifficultyInstance p_180482_1_, IEntityLivingData p_180482_2_) { p_180482_2_ = super.func_180482_a(p_180482_1_, p_180482_2_); diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch index 20055aad97..8da477eb31 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayer.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/entity/player/EntityPlayer.java +++ ../src-work/minecraft/net/minecraft/entity/player/EntityPlayer.java -@@ -80,6 +80,11 @@ +@@ -93,6 +93,11 @@ @SuppressWarnings("incomplete-switch") public abstract class EntityPlayer extends EntityLivingBase { @@ -9,20 +9,10 @@ + private java.util.HashMap spawnForcedMap = new java.util.HashMap(); + public float eyeHeight = this.getDefaultEyeHeight(); + - public InventoryPlayer field_71071_by = new InventoryPlayer(this); - private InventoryEnderChest field_71078_a = new InventoryEnderChest(); - public Container field_71069_bz; -@@ -175,7 +180,8 @@ - { - if (this.field_71074_e != null) - { -- this.field_71074_e.func_77974_b(this.field_70170_p, this, this.field_71072_f); -+ if (!net.minecraftforge.event.ForgeEventFactory.onUseItemStop(this, field_71074_e, this.field_71072_f)) -+ this.field_71074_e.func_77974_b(this.field_70170_p, this, this.field_71072_f); - } - - this.func_71041_bz(); -@@ -199,6 +205,7 @@ + private static final DataParameter field_184829_a = EntityDataManager.func_187226_a(EntityPlayer.class, DataSerializers.field_187193_c); + private static final DataParameter field_184830_b = EntityDataManager.func_187226_a(EntityPlayer.class, DataSerializers.field_187192_b); + protected static final DataParameter field_184827_bp = EntityDataManager.func_187226_a(EntityPlayer.class, DataSerializers.field_187191_a); +@@ -174,6 +179,7 @@ public void func_70071_h_() { @@ -30,30 +20,7 @@ this.field_70145_X = this.func_175149_v(); if (this.func_175149_v()) -@@ -212,6 +219,14 @@ - - if (itemstack == this.field_71074_e) - { -+ field_71072_f = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, field_71074_e, field_71072_f); -+ if (field_71072_f <= 0) -+ { -+ this.func_71036_o(); -+ } -+ else -+ { // Forge Keep unindented to lower patch -+ field_71074_e.func_77973_b().onUsingTick(field_71074_e, this, field_71072_f); //Forge Added - if (this.field_71072_f <= 25 && this.field_71072_f % 4 == 0) - { - this.func_71010_c(itemstack, 5); -@@ -221,6 +236,7 @@ - { - this.func_71036_o(); - } -+ } - } - else - { -@@ -266,7 +282,7 @@ +@@ -219,7 +225,7 @@ super.func_70071_h_(); @@ -62,43 +29,29 @@ { this.func_71053_j(); this.field_71070_bA = this.field_71069_bz; -@@ -343,6 +359,7 @@ - { - this.func_70107_b(d3, this.field_70163_u, d4); +@@ -360,6 +366,7 @@ + this.func_70105_a(f, f1); + } } + net.minecraftforge.fml.common.FMLCommonHandler.instance().onPlayerPostTick(this); } public int func_82145_z() -@@ -412,11 +429,12 @@ - int i = this.field_71074_e.field_77994_a; - ItemStack itemstack = this.field_71074_e.func_77950_b(this.field_70170_p, this); - -+ itemstack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, field_71074_e, field_71072_f, itemstack); - if (itemstack != this.field_71074_e || itemstack != null && itemstack.field_77994_a != i) - { - this.field_71071_by.field_70462_a[this.field_71071_by.field_70461_c] = itemstack; - -- if (itemstack.field_77994_a == 0) -+ if (itemstack != null && itemstack.field_77994_a == 0) - { - this.field_71071_by.field_70462_a[this.field_71071_by.field_70461_c] = null; - } -@@ -476,11 +494,11 @@ +@@ -442,11 +449,11 @@ this.field_71109_bG = 0.0F; this.func_71015_k(this.field_70165_t - d0, this.field_70163_u - d1, this.field_70161_v - d2); -- if (this.field_70154_o instanceof EntityPig) -+ if (this.field_70154_o instanceof EntityLivingBase && ((EntityLivingBase)field_70154_o).shouldRiderFaceForward(this)) +- if (this.func_184187_bx() instanceof EntityPig) ++ if (this.func_184187_bx() instanceof EntityLivingBase && ((EntityLivingBase)this.func_184187_bx()).shouldRiderFaceForward(this)) { this.field_70125_A = f1; this.field_70177_z = f; -- this.field_70761_aq = ((EntityPig)this.field_70154_o).field_70761_aq; -+ this.field_70761_aq = ((EntityLivingBase)this.field_70154_o).field_70761_aq; +- this.field_70761_aq = ((EntityPig)this.func_184187_bx()).field_70761_aq; ++ this.field_70761_aq = ((EntityLivingBase)this.func_184187_bx()).field_70761_aq; } } } -@@ -610,11 +628,15 @@ +@@ -576,11 +583,15 @@ public void func_70645_a(DamageSource p_70645_1_) { @@ -114,7 +67,7 @@ if (this.func_70005_c_().equals("Notch")) { this.func_146097_a(new ItemStack(Items.field_151034_e, 1), true, false); -@@ -625,6 +647,9 @@ +@@ -591,6 +602,9 @@ this.field_71071_by.func_70436_m(); } @@ -123,8 +76,8 @@ + if (p_70645_1_ != null) { - this.field_70159_w = (double)(-MathHelper.func_76134_b((this.field_70739_aP + this.field_70177_z) * (float)Math.PI / 180.0F) * 0.1F); -@@ -707,12 +732,25 @@ + this.field_70159_w = (double)(-MathHelper.func_76134_b((this.field_70739_aP + this.field_70177_z) * 0.017453292F) * 0.1F); +@@ -678,12 +692,25 @@ public EntityItem func_71040_bB(boolean p_71040_1_) { @@ -152,34 +105,31 @@ } public EntityItem func_146097_a(ItemStack p_146097_1_, boolean p_146097_2_, boolean p_146097_3_) -@@ -770,13 +808,25 @@ +@@ -746,15 +773,22 @@ - public void func_71012_a(EntityItem p_71012_1_) + public ItemStack func_184816_a(EntityItem p_184816_1_) { -+ if (captureDrops) -+ { -+ capturedDrops.add(p_71012_1_); -+ return; -+ } -+ - this.field_70170_p.func_72838_d(p_71012_1_); ++ if (captureDrops) capturedDrops.add(p_184816_1_); ++ else // Forge: Don't indent to keep patch smaller. + this.field_70170_p.func_72838_d(p_184816_1_); + ItemStack itemstack = p_184816_1_.func_92059_d(); + return itemstack; } + @Deprecated //Use location sensitive version below - public float func_180471_a(Block p_180471_1_) + public float func_184813_a(IBlockState p_184813_1_) { -- float f = this.field_71071_by.func_146023_a(p_180471_1_); -+ return getBreakSpeed(p_180471_1_.func_176223_P(), new BlockPos(0, -1, 0)); +- float f = this.field_71071_by.func_184438_a(p_184813_1_); ++ return getBreakSpeed(p_184813_1_, new BlockPos(0, -1, 0)); + } + public float getBreakSpeed(IBlockState state, BlockPos pos) + { -+ ItemStack stack = field_71071_by.func_70448_g(); -+ float f = (stack == null ? 1.0F : stack.func_77973_b().getDigSpeed(stack, state)); ++ float f = this.field_71071_by.func_184438_a(state); if (f > 1.0F) { - int i = EnchantmentHelper.func_77509_b(this); -@@ -826,12 +876,13 @@ + int i = EnchantmentHelper.func_185293_e(this); +@@ -804,12 +838,13 @@ f /= 5.0F; } @@ -188,14 +138,14 @@ + return (f < 0 ? 0 : f); } - public boolean func_146099_a(Block p_146099_1_) + public boolean func_184823_b(IBlockState p_184823_1_) { -- return this.field_71071_by.func_146025_b(p_146099_1_); -+ return net.minecraftforge.event.ForgeEventFactory.doPlayerHarvestCheck(this, p_146099_1_, this.field_71071_by.func_146025_b(p_146099_1_)); +- return this.field_71071_by.func_184432_b(p_184823_1_); ++ return net.minecraftforge.event.ForgeEventFactory.doPlayerHarvestCheck(this, p_184823_1_, this.field_71071_by.func_184432_b(p_184823_1_)); } public void func_70037_a(NBTTagCompound p_70037_1_) -@@ -867,6 +918,16 @@ +@@ -845,6 +880,16 @@ this.field_82248_d = p_70037_1_.func_74767_n("SpawnForced"); } @@ -212,7 +162,7 @@ this.field_71100_bB.func_75112_a(p_70037_1_); this.field_71075_bZ.func_75095_b(p_70037_1_); -@@ -898,6 +959,23 @@ +@@ -877,6 +922,23 @@ p_70014_1_.func_74757_a("SpawnForced", this.field_82248_d); } @@ -236,7 +186,7 @@ this.field_71100_bB.func_75117_b(p_70014_1_); this.field_71075_bZ.func_75091_a(p_70014_1_); p_70014_1_.func_74782_a("EnderItems", this.field_71078_a.func_70487_g()); -@@ -911,6 +989,7 @@ +@@ -884,6 +946,7 @@ public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_) { @@ -244,42 +194,35 @@ if (this.func_180431_b(p_70097_1_)) { return false; -@@ -1007,12 +1086,15 @@ +@@ -966,6 +1029,7 @@ + if (this.field_184627_bm.field_77994_a <= 0) + { + EnumHand enumhand = this.func_184600_cs(); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, this.field_184627_bm, enumhand); + + if (enumhand == EnumHand.MAIN_HAND) + { +@@ -1001,7 +1065,10 @@ { if (!this.func_180431_b(p_70665_1_)) { +- p_70665_2_ = this.func_70655_b(p_70665_1_, p_70665_2_); + p_70665_2_ = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_); + if (p_70665_2_ <= 0) return; - if (!p_70665_1_.func_76363_c() && this.func_70632_aY() && p_70665_2_ > 0.0F) - { - p_70665_2_ = (1.0F + p_70665_2_) * 0.5F; - } - -- p_70665_2_ = this.func_70655_b(p_70665_1_, p_70665_2_); + p_70665_2_ = net.minecraftforge.common.ISpecialArmor.ArmorProperties.applyArmor(this, field_71071_by.field_70460_b, p_70665_1_, p_70665_2_); + if (p_70665_2_ <= 0) return; p_70665_2_ = this.func_70672_c(p_70665_1_, p_70665_2_); float f = p_70665_2_; p_70665_2_ = Math.max(p_70665_2_ - this.func_110139_bj(), 0.0F); -@@ -1074,6 +1156,7 @@ +@@ -1067,6 +1134,7 @@ } else { -+ if (!net.minecraftforge.event.ForgeEventFactory.canInteractWith(this, p_70998_1_)) return false; - ItemStack itemstack = this.func_71045_bC(); - ItemStack itemstack1 = itemstack != null ? itemstack.func_77946_l() : null; ++ if (net.minecraftforge.common.ForgeHooks.onInteractEntity(this, p_184822_1_, p_184822_2_, p_184822_3_)) return EnumActionResult.PASS; + ItemStack itemstack = p_184822_2_ != null ? p_184822_2_.func_77946_l() : null; -@@ -1125,7 +1208,9 @@ - - public void func_71028_bD() - { -+ ItemStack orig = func_71045_bC(); - this.field_71071_by.func_70299_a(this.field_71071_by.field_70461_c, (ItemStack)null); -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, orig); - } - - public double func_70033_W() -@@ -1135,6 +1220,7 @@ + if (!p_184822_1_.func_184230_a(this, p_184822_2_, p_184822_3_)) +@@ -1123,6 +1191,7 @@ public void func_71059_n(Entity p_71059_1_) { @@ -287,7 +230,7 @@ if (p_71059_1_.func_70075_an()) { if (!p_71059_1_.func_85031_j(this)) -@@ -1311,6 +1397,8 @@ +@@ -1410,6 +1479,8 @@ public EntityPlayer.EnumStatus func_180469_a(BlockPos p_180469_1_) { @@ -296,19 +239,21 @@ if (!this.field_70170_p.field_72995_K) { if (this.func_70608_bn() || !this.func_70089_S()) -@@ -1350,9 +1438,9 @@ +@@ -1449,9 +1520,10 @@ this.func_70105_a(0.2F, 0.2F); - if (this.field_70170_p.func_175667_e(p_180469_1_)) -+ if (this.field_70170_p.func_175667_e(p_180469_1_) && field_70170_p.func_180495_p(p_180469_1_).func_177230_c().isBed(field_70170_p, p_180469_1_, this)) - { -- EnumFacing enumfacing = (EnumFacing)this.field_70170_p.func_180495_p(p_180469_1_).func_177229_b(BlockDirectional.field_176387_N); -+ EnumFacing enumfacing = this.field_70170_p.func_180495_p(p_180469_1_).func_177230_c().getBedDirection(field_70170_p, p_180469_1_); +- { +- EnumFacing enumfacing = (EnumFacing)this.field_70170_p.func_180495_p(p_180469_1_).func_177229_b(BlockHorizontal.field_185512_D); ++ IBlockState state = null; ++ if (this.field_70170_p.func_175667_e(p_180469_1_)) state = this.field_70170_p.func_180495_p(p_180469_1_); ++ if (state != null && state.func_177230_c().isBed(state, this.field_70170_p, p_180469_1_, this)) { ++ EnumFacing enumfacing = state.func_177230_c().getBedDirection(state, this.field_70170_p, p_180469_1_); float f = 0.5F; float f1 = 0.5F; -@@ -1415,13 +1503,14 @@ +@@ -1514,13 +1586,14 @@ public void func_70999_a(boolean p_70999_1_, boolean p_70999_2_, boolean p_70999_3_) { @@ -317,16 +262,16 @@ IBlockState iblockstate = this.field_70170_p.func_180495_p(this.field_71081_bT); - if (this.field_71081_bT != null && iblockstate.func_177230_c() == Blocks.field_150324_C) -+ if (this.field_71081_bT != null && iblockstate.func_177230_c().isBed(field_70170_p, field_71081_bT, this)) ++ if (this.field_71081_bT != null && iblockstate.func_177230_c().isBed(iblockstate, field_70170_p, field_71081_bT, this)) { - this.field_70170_p.func_180501_a(this.field_71081_bT, iblockstate.func_177226_a(BlockBed.field_176471_b, Boolean.valueOf(false)), 4); - BlockPos blockpos = BlockBed.func_176468_a(this.field_70170_p, this.field_71081_bT, 0); + iblockstate.func_177230_c().setBedOccupied(field_70170_p, field_71081_bT, this, false); -+ BlockPos blockpos = iblockstate.func_177230_c().getBedSpawnPosition(field_70170_p, field_71081_bT, this); ++ BlockPos blockpos = iblockstate.func_177230_c().getBedSpawnPosition(iblockstate, field_70170_p, field_71081_bT, this); if (blockpos == null) { -@@ -1430,6 +1519,10 @@ +@@ -1529,6 +1602,10 @@ this.func_70107_b((double)((float)blockpos.func_177958_n() + 0.5F), (double)((float)blockpos.func_177956_o() + 0.1F), (double)((float)blockpos.func_177952_p() + 0.5F)); } @@ -337,7 +282,7 @@ this.field_71083_bS = false; -@@ -1448,14 +1541,14 @@ +@@ -1547,14 +1624,15 @@ private boolean func_175143_p() { @@ -347,19 +292,21 @@ public static BlockPos func_180467_a(World p_180467_0_, BlockPos p_180467_1_, boolean p_180467_2_) { - Block block = p_180467_0_.func_180495_p(p_180467_1_).func_177230_c(); +- Block block = p_180467_0_.func_180495_p(p_180467_1_).func_177230_c(); ++ IBlockState state = p_180467_0_.func_180495_p(p_180467_1_); ++ Block block = state.func_177230_c(); - if (block != Blocks.field_150324_C) -+ if (!block.isBed(p_180467_0_, p_180467_1_, null)) ++ if (!block.isBed(state, p_180467_0_, p_180467_1_, null)) { if (!p_180467_2_) { -@@ -1470,16 +1563,16 @@ +@@ -1569,16 +1647,17 @@ } else { - return BlockBed.func_176468_a(p_180467_0_, p_180467_1_, 0); -+ return p_180467_0_.func_180495_p(p_180467_1_).func_177230_c().getBedSpawnPosition(p_180467_0_, p_180467_1_, null); ++ return block.getBedSpawnPosition(state, p_180467_0_, p_180467_1_, null); } } @@ -367,14 +314,15 @@ public float func_71051_bG() { - if (this.field_71081_bT != null) -+ if (this.field_71081_bT != null && field_70170_p.func_180495_p(field_71081_bT).func_177230_c().isBed(field_70170_p, field_71081_bT, this)) ++ IBlockState state = this.field_71081_bT == null ? null : this.field_70170_p.func_180495_p(field_71081_bT); ++ if (state != null && state.func_177230_c().isBed(state, field_70170_p, field_71081_bT, this)) { -- EnumFacing enumfacing = (EnumFacing)this.field_70170_p.func_180495_p(this.field_71081_bT).func_177229_b(BlockDirectional.field_176387_N); -+ EnumFacing enumfacing = this.field_70170_p.func_180495_p(this.field_71081_bT).func_177230_c().getBedDirection(field_70170_p, field_71081_bT); +- EnumFacing enumfacing = (EnumFacing)this.field_70170_p.func_180495_p(this.field_71081_bT).func_177229_b(BlockHorizontal.field_185512_D); ++ EnumFacing enumfacing = state.func_177230_c().getBedDirection(state, field_70170_p, field_71081_bT); switch (enumfacing) { -@@ -1519,16 +1612,24 @@ +@@ -1618,16 +1697,24 @@ public BlockPos func_180470_cg() { @@ -401,7 +349,7 @@ if (p_180473_1_ != null) { this.field_71077_c = p_180473_1_; -@@ -1712,6 +1813,10 @@ +@@ -1822,6 +1909,10 @@ super.func_180430_e(p_180430_1_, p_180430_2_); } @@ -412,38 +360,10 @@ } protected void func_71061_d_() -@@ -1735,6 +1840,7 @@ - } - - EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.field_75627_a.get(Integer.valueOf(EntityList.func_75619_a(p_70074_1_))); -+ if (entitylist$entityegginfo == null) entitylist$entityegginfo = net.minecraftforge.fml.common.registry.EntityRegistry.getEggs().get(EntityList.func_75621_b(p_70074_1_)); - - if (entitylist$entityegginfo != null) - { -@@ -1847,6 +1953,8 @@ - { - if (p_71008_1_ != this.field_71074_e) - { -+ p_71008_2_ = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, p_71008_1_, p_71008_2_); -+ if (p_71008_2_ <= 0) return; - this.field_71074_e = p_71008_1_; - this.field_71072_f = p_71008_2_; - -@@ -1918,6 +2026,10 @@ - this.field_181016_an = p_71049_1_.field_181016_an; - this.field_181017_ao = p_71049_1_.field_181017_ao; - this.field_181018_ap = p_71049_1_.field_181018_ap; -+ //Copy and re-init ExtendedProperties when switching dimensions. -+ this.extendedProperties = p_71049_1_.extendedProperties; -+ for (net.minecraftforge.common.IExtendedEntityProperties p : this.extendedProperties.values()) -+ p.init(this, this.field_70170_p); - } - else if (this.field_70170_p.func_82736_K().func_82766_b("keepInventory")) - { -@@ -1931,6 +2043,18 @@ +@@ -2022,6 +2113,18 @@ this.field_175152_f = p_71049_1_.field_175152_f; this.field_71078_a = p_71049_1_.field_71078_a; - this.func_70096_w().func_75692_b(10, Byte.valueOf(p_71049_1_.func_70096_w().func_75683_a(10))); + this.func_184212_Q().func_187227_b(field_184827_bp, p_71049_1_.func_184212_Q().func_187225_a(field_184827_bp)); + + this.spawnChunkMap = p_71049_1_.spawnChunkMap; + this.spawnForcedMap = p_71049_1_.spawnForcedMap; @@ -459,35 +379,19 @@ } protected boolean func_70041_e_() -@@ -1968,7 +2092,14 @@ +@@ -2120,7 +2223,10 @@ - public void func_70062_b(int p_70062_1_, ItemStack p_70062_2_) + public ITextComponent func_145748_c_() { -- this.field_71071_by.field_70460_b[p_70062_1_] = p_70062_2_; -+ if (p_70062_1_ == 0) //Forge: Fix issue in Player where it doen't take into account selected item -+ { -+ this.field_71071_by.field_70462_a[this.field_71071_by.field_70461_c] = p_70062_2_; -+ } -+ else -+ { -+ this.field_71071_by.field_70460_b[p_70062_1_ - 1] = p_70062_2_; -+ } - } - - @SideOnly(Side.CLIENT) -@@ -2013,7 +2144,10 @@ - - public IChatComponent func_145748_c_() - { -- IChatComponent ichatcomponent = new ChatComponentText(ScorePlayerTeam.func_96667_a(this.func_96124_cp(), this.func_70005_c_())); -+ IChatComponent ichatcomponent = new ChatComponentText(""); -+ if (!prefixes.isEmpty()) for (net.minecraft.util.IChatComponent prefix : prefixes) ichatcomponent.func_150257_a(prefix); -+ ichatcomponent.func_150257_a(new ChatComponentText(ScorePlayerTeam.func_96667_a(this.func_96124_cp(), this.getDisplayNameString()))); -+ if (!suffixes.isEmpty()) for (net.minecraft.util.IChatComponent suffix : suffixes) ichatcomponent.func_150257_a(suffix); - ichatcomponent.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.func_70005_c_() + " ")); - ichatcomponent.func_150256_b().func_150209_a(this.func_174823_aP()); - ichatcomponent.func_150256_b().func_179989_a(this.func_70005_c_()); -@@ -2022,7 +2156,7 @@ +- ITextComponent itextcomponent = new TextComponentString(ScorePlayerTeam.func_96667_a(this.func_96124_cp(), this.func_70005_c_())); ++ ITextComponent itextcomponent = new TextComponentString(""); ++ if (!prefixes.isEmpty()) for (ITextComponent prefix : prefixes) itextcomponent.func_150257_a(prefix); ++ itextcomponent.func_150257_a(new TextComponentString(ScorePlayerTeam.func_96667_a(this.func_96124_cp(), this.getDisplayNameString()))); ++ if (!suffixes.isEmpty()) for (ITextComponent suffix : suffixes) itextcomponent.func_150257_a(suffix); + itextcomponent.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.func_70005_c_() + " ")); + itextcomponent.func_150256_b().func_150209_a(this.func_174823_aP()); + itextcomponent.func_150256_b().func_179989_a(this.func_70005_c_()); +@@ -2129,7 +2235,7 @@ public float func_70047_e() { @@ -496,8 +400,8 @@ if (this.func_70608_bn()) { -@@ -2155,6 +2289,136 @@ - this.field_175153_bG = p_175150_1_; +@@ -2340,6 +2446,161 @@ + return (float)this.func_110148_a(SharedMonsterAttributes.field_188792_h).func_111126_e(); } + /** @@ -610,23 +514,48 @@ + this.displayname = net.minecraftforge.event.ForgeEventFactory.getPlayerDisplayName(this, this.func_70005_c_()); + } + -+ private final java.util.Collection prefixes = new java.util.LinkedList(); -+ private final java.util.Collection suffixes = new java.util.LinkedList(); ++ private final java.util.Collection prefixes = new java.util.LinkedList(); ++ private final java.util.Collection suffixes = new java.util.LinkedList(); + + /** + * Add a prefix to the player's username in chat + * @param prefix The prefix + */ -+ public void addPrefix(net.minecraft.util.IChatComponent prefix) { prefixes.add(prefix); } ++ public void addPrefix(ITextComponent prefix) { prefixes.add(prefix); } + + /** + * Add a suffix to the player's username in chat + * @param suffix The suffix + */ -+ public void addSuffix(net.minecraft.util.IChatComponent suffix) { suffixes.add(suffix); } ++ public void addSuffix(ITextComponent suffix) { suffixes.add(suffix); } + -+ public java.util.Collection getPrefixes() { return this.prefixes; } -+ public java.util.Collection getSuffixes() { return this.suffixes; } ++ public java.util.Collection getPrefixes() { return this.prefixes; } ++ public java.util.Collection getSuffixes() { return this.suffixes; } ++ ++ private final net.minecraftforge.items.IItemHandler playerMainHandler = new net.minecraftforge.items.wrapper.PlayerMainInvWrapper(field_71071_by); ++ private final net.minecraftforge.items.IItemHandler playerEquipmentHandler = new net.minecraftforge.items.wrapper.CombinedInvWrapper( ++ new net.minecraftforge.items.wrapper.PlayerArmorInvWrapper(field_71071_by), ++ new net.minecraftforge.items.wrapper.PlayerOffhandInvWrapper(field_71071_by)); ++ private final net.minecraftforge.items.IItemHandler playerJoinedHandler = new net.minecraftforge.items.wrapper.PlayerInvWrapper(field_71071_by); ++ ++ @SuppressWarnings("unchecked") ++ @Override ++ public T getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) ++ { ++ if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) ++ { ++ if (facing == null) return (T) playerJoinedHandler; ++ else if (facing.func_176740_k().func_176720_b()) return (T) playerMainHandler; ++ else if (facing.func_176740_k().func_176722_c()) return (T) playerEquipmentHandler; ++ } ++ return super.getCapability(capability, facing); ++ } ++ ++ @Override ++ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) ++ { ++ return capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); ++ } + + /* ======================================== FORGE END =====================================*/ + diff --git a/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch b/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch index 0dd5fb674a..e61f8cfbae 100644 --- a/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/EntityPlayerMP.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/entity/player/EntityPlayerMP.java +++ ../src-work/minecraft/net/minecraft/entity/player/EntityPlayerMP.java -@@ -123,14 +123,15 @@ +@@ -134,14 +134,15 @@ public int field_71138_i; public boolean field_71136_j; + @SuppressWarnings("unused") - public EntityPlayerMP(MinecraftServer p_i45285_1_, WorldServer p_i45285_2_, GameProfile p_i45285_3_, ItemInWorldManager p_i45285_4_) + public EntityPlayerMP(MinecraftServer p_i45285_1_, WorldServer p_i45285_2_, GameProfile p_i45285_3_, PlayerInteractionManager p_i45285_4_) { super(p_i45285_2_, p_i45285_3_); p_i45285_4_.field_73090_b = this; @@ -16,9 +16,9 @@ - if (!p_i45285_2_.field_73011_w.func_177495_o() && p_i45285_2_.func_72912_H().func_76077_q() != WorldSettings.GameType.ADVENTURE) + if (false && !p_i45285_2_.field_73011_w.func_177495_o() && p_i45285_2_.func_72912_H().func_76077_q() != WorldSettings.GameType.ADVENTURE) { - int i = Math.max(5, p_i45285_1_.func_82357_ak() - 6); + int i = Math.max(0, p_i45285_1_.func_184108_a(p_i45285_2_)); int j = MathHelper.func_76128_c(p_i45285_2_.func_175723_af().func_177729_b((double)blockpos.func_177958_n(), (double)blockpos.func_177952_p())); -@@ -223,7 +224,7 @@ +@@ -250,7 +251,7 @@ this.field_71070_bA.func_75142_b(); @@ -27,25 +27,17 @@ { this.func_71053_j(); this.field_71070_bA = this.field_71069_bz; -@@ -294,6 +295,7 @@ - for (Chunk chunk1 : list) - { - this.func_71121_q().func_73039_n().func_85172_a(this, chunk1); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkWatchEvent.Watch(chunk1.func_76632_l(), this)); - } - } - } -@@ -424,6 +426,7 @@ +@@ -433,6 +434,7 @@ public void func_70645_a(DamageSource p_70645_1_) { + if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_70645_1_)) return; - if (this.field_70170_p.func_82736_K().func_82766_b("showDeathMessages")) - { - Team team = this.func_96124_cp(); -@@ -447,7 +450,20 @@ + boolean flag = this.field_70170_p.func_82736_K().func_82766_b("showDeathMessages"); + this.field_71135_a.func_147359_a(new SPacketCombatEvent(this.func_110142_aN(), SPacketCombatEvent.Event.ENTITY_DIED, flag)); - if (!this.field_70170_p.func_82736_K().func_82766_b("keepInventory")) +@@ -459,7 +461,20 @@ + + if (!this.field_70170_p.func_82736_K().func_82766_b("keepInventory") && !this.func_175149_v()) { + captureDrops = true; + capturedDrops.clear(); @@ -58,29 +50,30 @@ + { + for (net.minecraft.entity.item.EntityItem item : capturedDrops) + { -+ func_71012_a(item); ++ this.field_70170_p.func_72838_d(item); + } + } } - for (ScoreObjective scoreobjective : this.field_70170_p.func_96441_U().func_96520_a(IScoreObjectiveCriteria.field_96642_c)) -@@ -461,6 +477,7 @@ - if (entitylivingbase != null) - { - EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.field_75627_a.get(Integer.valueOf(EntityList.func_75619_a(entitylivingbase))); -+ if (entitylist$entityegginfo == null) entitylist$entityegginfo = net.minecraftforge.fml.common.registry.EntityRegistry.getEggs().get(EntityList.func_75621_b(entitylivingbase)); + for (ScoreObjective scoreobjective : this.field_70170_p.func_96441_U().func_96520_a(IScoreCriteria.field_96642_c)) +@@ -540,6 +555,7 @@ - if (entitylist$entityegginfo != null) - { -@@ -528,6 +545,7 @@ - - public void func_71027_c(int p_71027_1_) + public Entity func_184204_a(int p_184204_1_) { -+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_71027_1_)) return; - if (this.field_71093_bK == 1 && p_71027_1_ == 1) ++ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_184204_1_)) return this; + this.field_184851_cj = true; + + if (this.field_71093_bK == 1 && p_184204_1_ == 1) +@@ -697,7 +713,7 @@ + BlockPos blockpos = new BlockPos(i, j, k); + IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); + +- if (iblockstate.func_185904_a() == Material.field_151579_a) ++ if (iblockstate.func_177230_c().isAir(iblockstate, this.field_70170_p, blockpos)) { - this.func_71029_a(AchievementList.field_76003_C); -@@ -831,6 +849,7 @@ + BlockPos blockpos1 = blockpos.func_177977_b(); + IBlockState iblockstate1 = this.field_70170_p.func_180495_p(blockpos1); +@@ -921,6 +937,7 @@ { if (p_71064_1_ != null) { diff --git a/patches/minecraft/net/minecraft/entity/player/InventoryPlayer.java.patch b/patches/minecraft/net/minecraft/entity/player/InventoryPlayer.java.patch index f597943110..879c821bdc 100644 --- a/patches/minecraft/net/minecraft/entity/player/InventoryPlayer.java.patch +++ b/patches/minecraft/net/minecraft/entity/player/InventoryPlayer.java.patch @@ -1,22 +1,23 @@ --- ../src-base/minecraft/net/minecraft/entity/player/InventoryPlayer.java +++ ../src-work/minecraft/net/minecraft/entity/player/InventoryPlayer.java -@@ -272,12 +272,8 @@ - { - if (this.field_70462_a[j] == null) +@@ -270,13 +270,8 @@ + + if (itemstack == null) { -- this.field_70462_a[j] = new ItemStack(item, 0, p_70452_1_.func_77960_j()); +- itemstack = new ItemStack(item, 0, p_70452_1_.func_77960_j()); - - if (p_70452_1_.func_77942_o()) - { -- this.field_70462_a[j].func_77982_d((NBTTagCompound)p_70452_1_.func_77978_p().func_74737_b()); +- itemstack.func_77982_d((NBTTagCompound)p_70452_1_.func_77978_p().func_74737_b()); - } -+ this.field_70462_a[j] = p_70452_1_.func_77946_l(); // Forge: Replace Item clone above to preserve item capabilities when picking the item up. -+ this.field_70462_a[j].field_77994_a = 0; +- ++ itemstack = p_70452_1_.func_77946_l(); // Forge: Replace Item clone above to preserve item capabilities when picking the item up. ++ itemstack.field_77994_a = 0; + this.func_70299_a(j, itemstack); } - int k = i; -@@ -315,6 +311,14 @@ - this.field_70462_a[i].func_77945_a(this.field_70458_d.field_70170_p, this.field_70458_d, i, this.field_70461_c == i); +@@ -344,6 +339,14 @@ + } } } + @@ -29,4 +30,4 @@ + } } - public boolean func_146026_a(Item p_146026_1_) + public boolean func_70441_a(final ItemStack p_70441_1_) diff --git a/patches/minecraft/net/minecraft/entity/projectile/EntityFishHook.java.patch b/patches/minecraft/net/minecraft/entity/projectile/EntityFishHook.java.patch deleted file mode 100644 index b859938dab..0000000000 --- a/patches/minecraft/net/minecraft/entity/projectile/EntityFishHook.java.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/entity/projectile/EntityFishHook.java -+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityFishHook.java -@@ -567,11 +567,19 @@ - } - } - -+ @SuppressWarnings("unused") - private ItemStack func_146033_f() - { - float f = this.field_70170_p.field_73012_v.nextFloat(); - int i = EnchantmentHelper.func_151386_g(this.field_146042_b); - int j = EnchantmentHelper.func_151387_h(this.field_146042_b); -+ -+ if (true) -+ { -+ this.field_146042_b.func_71064_a(net.minecraftforge.common.FishingHooks.getFishableCategory(f, i, j).stat, 1); -+ return net.minecraftforge.common.FishingHooks.getRandomFishable(this.field_70146_Z, f, i, j); -+ } -+ - float f1 = 0.1F - (float)i * 0.025F - (float)j * 0.01F; - float f2 = 0.05F + (float)i * 0.01F - (float)j * 0.01F; - f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F); diff --git a/patches/minecraft/net/minecraft/init/Bootstrap.java.patch b/patches/minecraft/net/minecraft/init/Bootstrap.java.patch index 4b2ed93f31..21ca820f97 100644 --- a/patches/minecraft/net/minecraft/init/Bootstrap.java.patch +++ b/patches/minecraft/net/minecraft/init/Bootstrap.java.patch @@ -1,261 +1,10 @@ --- ../src-base/minecraft/net/minecraft/init/Bootstrap.java +++ ../src-work/minecraft/net/minecraft/init/Bootstrap.java -@@ -65,6 +65,7 @@ - return field_151355_a; +@@ -541,6 +541,7 @@ + StatList.func_151178_a(); + BiomeGenBase.func_185358_q(); + func_151353_a(); ++ net.minecraftforge.fml.common.registry.GameData.vanillaSnapshot(); + } } -+ @SuppressWarnings("unused") - static void func_151353_a() - { - BlockDispenser.field_149943_a.func_82595_a(Items.field_151032_g, new BehaviorProjectileDispense() -@@ -78,23 +79,23 @@ - }); - BlockDispenser.field_149943_a.func_82595_a(Items.field_151110_aK, new BehaviorProjectileDispense() - { -- protected IProjectile func_82499_a(World p_82499_1_, IPosition p_82499_2_) -+ protected IProjectile func_82499_a(World worldIn, IPosition position) - { -- return new EntityEgg(p_82499_1_, p_82499_2_.func_82615_a(), p_82499_2_.func_82617_b(), p_82499_2_.func_82616_c()); -+ return new EntityEgg(worldIn, position.func_82615_a(), position.func_82617_b(), position.func_82616_c()); - } - }); - BlockDispenser.field_149943_a.func_82595_a(Items.field_151126_ay, new BehaviorProjectileDispense() - { -- protected IProjectile func_82499_a(World p_82499_1_, IPosition p_82499_2_) -+ protected IProjectile func_82499_a(World worldIn, IPosition position) - { -- return new EntitySnowball(p_82499_1_, p_82499_2_.func_82615_a(), p_82499_2_.func_82617_b(), p_82499_2_.func_82616_c()); -+ return new EntitySnowball(worldIn, position.func_82615_a(), position.func_82617_b(), position.func_82616_c()); - } - }); - BlockDispenser.field_149943_a.func_82595_a(Items.field_151062_by, new BehaviorProjectileDispense() - { -- protected IProjectile func_82499_a(World p_82499_1_, IPosition p_82499_2_) -+ protected IProjectile func_82499_a(World worldIn, IPosition position) - { -- return new EntityExpBottle(p_82499_1_, p_82499_2_.func_82615_a(), p_82499_2_.func_82617_b(), p_82499_2_.func_82616_c()); -+ return new EntityExpBottle(worldIn, position.func_82615_a(), position.func_82617_b(), position.func_82616_c()); - } - protected float func_82498_a() - { -@@ -108,13 +109,13 @@ - BlockDispenser.field_149943_a.func_82595_a(Items.field_151068_bn, new IBehaviorDispenseItem() - { - private final BehaviorDefaultDispenseItem field_150843_b = new BehaviorDefaultDispenseItem(); -- public ItemStack func_82482_a(IBlockSource p_82482_1_, final ItemStack p_82482_2_) -+ public ItemStack func_82482_a(IBlockSource source, final ItemStack stack) - { -- return ItemPotion.func_77831_g(p_82482_2_.func_77960_j()) ? (new BehaviorProjectileDispense() -+ return ItemPotion.func_77831_g(stack.func_77960_j()) ? (new BehaviorProjectileDispense() - { -- protected IProjectile func_82499_a(World p_82499_1_, IPosition p_82499_2_) -+ protected IProjectile func_82499_a(World worldIn, IPosition position) - { -- return new EntityPotion(p_82499_1_, p_82499_2_.func_82615_a(), p_82499_2_.func_82617_b(), p_82499_2_.func_82616_c(), p_82482_2_.func_77946_l()); -+ return new EntityPotion(worldIn, position.func_82615_a(), position.func_82617_b(), position.func_82616_c(), stack.func_77946_l()); - } - protected float func_82498_a() - { -@@ -124,7 +125,7 @@ - { - return super.func_82500_b() * 1.25F; - } -- }).func_82482_a(p_82482_1_, p_82482_2_): this.field_150843_b.func_82482_a(p_82482_1_, p_82482_2_); -+ }).func_82482_a(source, stack): this.field_150843_b.func_82482_a(source, stack); - } - }); - BlockDispenser.field_149943_a.func_82595_a(Items.field_151063_bx, new BehaviorDefaultDispenseItem() -@@ -135,7 +136,7 @@ - double d0 = p_82487_1_.func_82615_a() + (double)enumfacing.func_82601_c(); - double d1 = (double)((float)p_82487_1_.func_180699_d().func_177956_o() + 0.2F); - double d2 = p_82487_1_.func_82616_c() + (double)enumfacing.func_82599_e(); -- Entity entity = ItemMonsterPlacer.func_77840_a(p_82487_1_.func_82618_k(), p_82487_2_.func_77960_j(), d0, d1, d2); -+ Entity entity = ItemMonsterPlacer.spawnCreature(p_82487_1_.func_82618_k(), ItemMonsterPlacer.getEntityName(p_82487_2_), d0, d1, d2); - - if (entity instanceof EntityLivingBase && p_82487_2_.func_82837_s()) - { -@@ -190,14 +191,14 @@ - BlockDispenser.field_149943_a.func_82595_a(Items.field_151124_az, new BehaviorDefaultDispenseItem() - { - private final BehaviorDefaultDispenseItem field_150842_b = new BehaviorDefaultDispenseItem(); -- public ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) -+ public ItemStack func_82487_b(IBlockSource source, ItemStack stack) - { -- EnumFacing enumfacing = BlockDispenser.func_149937_b(p_82487_1_.func_82620_h()); -- World world = p_82487_1_.func_82618_k(); -- double d0 = p_82487_1_.func_82615_a() + (double)((float)enumfacing.func_82601_c() * 1.125F); -- double d1 = p_82487_1_.func_82617_b() + (double)((float)enumfacing.func_96559_d() * 1.125F); -- double d2 = p_82487_1_.func_82616_c() + (double)((float)enumfacing.func_82599_e() * 1.125F); -- BlockPos blockpos = p_82487_1_.func_180699_d().func_177972_a(enumfacing); -+ EnumFacing enumfacing = BlockDispenser.func_149937_b(source.func_82620_h()); -+ World world = source.func_82618_k(); -+ double d0 = source.func_82615_a() + (double)((float)enumfacing.func_82601_c() * 1.125F); -+ double d1 = source.func_82617_b() + (double)((float)enumfacing.func_96559_d() * 1.125F); -+ double d2 = source.func_82616_c() + (double)((float)enumfacing.func_82599_e() * 1.125F); -+ BlockPos blockpos = source.func_180699_d().func_177972_a(enumfacing); - Material material = world.func_180495_p(blockpos).func_177230_c().func_149688_o(); - double d3; - -@@ -209,7 +210,7 @@ - { - if (!Material.field_151579_a.equals(material) || !Material.field_151586_h.equals(world.func_180495_p(blockpos.func_177977_b()).func_177230_c().func_149688_o())) - { -- return this.field_150842_b.func_82482_a(p_82487_1_, p_82487_2_); -+ return this.field_150842_b.func_82482_a(source, stack); - } - - d3 = 0.0D; -@@ -217,31 +218,31 @@ - - EntityBoat entityboat = new EntityBoat(world, d0, d1 + d3, d2); - world.func_72838_d(entityboat); -- p_82487_2_.func_77979_a(1); -- return p_82487_2_; -+ stack.func_77979_a(1); -+ return stack; - } -- protected void func_82485_a(IBlockSource p_82485_1_) -+ protected void func_82485_a(IBlockSource source) - { -- p_82485_1_.func_82618_k().func_175718_b(1000, p_82485_1_.func_180699_d(), 0); -+ source.func_82618_k().func_175718_b(1000, source.func_180699_d(), 0); - } - }); - IBehaviorDispenseItem ibehaviordispenseitem = new BehaviorDefaultDispenseItem() - { - private final BehaviorDefaultDispenseItem field_150841_b = new BehaviorDefaultDispenseItem(); -- public ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) -+ public ItemStack func_82487_b(IBlockSource source, ItemStack stack) - { -- ItemBucket itembucket = (ItemBucket)p_82487_2_.func_77973_b(); -- BlockPos blockpos = p_82487_1_.func_180699_d().func_177972_a(BlockDispenser.func_149937_b(p_82487_1_.func_82620_h())); -+ ItemBucket itembucket = (ItemBucket)stack.func_77973_b(); -+ BlockPos blockpos = source.func_180699_d().func_177972_a(BlockDispenser.func_149937_b(source.func_82620_h())); - -- if (itembucket.func_180616_a(p_82487_1_.func_82618_k(), blockpos)) -+ if (itembucket.func_180616_a(source.func_82618_k(), blockpos)) - { -- p_82487_2_.func_150996_a(Items.field_151133_ar); -- p_82487_2_.field_77994_a = 1; -- return p_82487_2_; -+ stack.func_150996_a(Items.field_151133_ar); -+ stack.field_77994_a = 1; -+ return stack; - } - else - { -- return this.field_150841_b.func_82482_a(p_82487_1_, p_82487_2_); -+ return this.field_150841_b.func_82482_a(source, stack); - } - } - }; -@@ -250,10 +251,10 @@ - BlockDispenser.field_149943_a.func_82595_a(Items.field_151133_ar, new BehaviorDefaultDispenseItem() - { - private final BehaviorDefaultDispenseItem field_150840_b = new BehaviorDefaultDispenseItem(); -- public ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) -+ public ItemStack func_82487_b(IBlockSource source, ItemStack stack) - { -- World world = p_82487_1_.func_82618_k(); -- BlockPos blockpos = p_82487_1_.func_180699_d().func_177972_a(BlockDispenser.func_149937_b(p_82487_1_.func_82620_h())); -+ World world = source.func_82618_k(); -+ BlockPos blockpos = source.func_180699_d().func_177972_a(BlockDispenser.func_149937_b(source.func_82620_h())); - IBlockState iblockstate = world.func_180495_p(blockpos); - Block block = iblockstate.func_177230_c(); - Material material = block.func_149688_o(); -@@ -267,7 +268,7 @@ - { - if (!Material.field_151587_i.equals(material) || !(block instanceof BlockLiquid) || ((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue() != 0) - { -- return super.func_82487_b(p_82487_1_, p_82487_2_); -+ return super.func_82487_b(source, stack); - } - - item = Items.field_151129_at; -@@ -275,34 +276,34 @@ - - world.func_175698_g(blockpos); - -- if (--p_82487_2_.field_77994_a == 0) -+ if (--stack.field_77994_a == 0) - { -- p_82487_2_.func_150996_a(item); -- p_82487_2_.field_77994_a = 1; -+ stack.func_150996_a(item); -+ stack.field_77994_a = 1; - } -- else if (((TileEntityDispenser)p_82487_1_.func_150835_j()).func_146019_a(new ItemStack(item)) < 0) -+ else if (((TileEntityDispenser)source.func_150835_j()).func_146019_a(new ItemStack(item)) < 0) - { -- this.field_150840_b.func_82482_a(p_82487_1_, new ItemStack(item)); -+ this.field_150840_b.func_82482_a(source, new ItemStack(item)); - } - -- return p_82487_2_; -+ return stack; - } - }); - BlockDispenser.field_149943_a.func_82595_a(Items.field_151033_d, new BehaviorDefaultDispenseItem() - { - private boolean field_150839_b = true; -- protected ItemStack func_82487_b(IBlockSource p_82487_1_, ItemStack p_82487_2_) -+ protected ItemStack func_82487_b(IBlockSource source, ItemStack stack) - { -- World world = p_82487_1_.func_82618_k(); -- BlockPos blockpos = p_82487_1_.func_180699_d().func_177972_a(BlockDispenser.func_149937_b(p_82487_1_.func_82620_h())); -+ World world = source.func_82618_k(); -+ BlockPos blockpos = source.func_180699_d().func_177972_a(BlockDispenser.func_149937_b(source.func_82620_h())); - - if (world.func_175623_d(blockpos)) - { - world.func_175656_a(blockpos, Blocks.field_150480_ab.func_176223_P()); - -- if (p_82487_2_.func_96631_a(1, world.field_73012_v)) -+ if (stack.func_96631_a(1, world.field_73012_v)) - { -- p_82487_2_.field_77994_a = 0; -+ stack.field_77994_a = 0; - } - } - else if (world.func_180495_p(blockpos).func_177230_c() == Blocks.field_150335_W) -@@ -315,17 +316,17 @@ - this.field_150839_b = false; - } - -- return p_82487_2_; -+ return stack; - } -- protected void func_82485_a(IBlockSource p_82485_1_) -+ protected void func_82485_a(IBlockSource source) - { - if (this.field_150839_b) - { -- p_82485_1_.func_82618_k().func_175718_b(1000, p_82485_1_.func_180699_d(), 0); -+ source.func_82618_k().func_175718_b(1000, source.func_180699_d(), 0); - } - else - { -- p_82485_1_.func_82618_k().func_175718_b(1001, p_82485_1_.func_180699_d(), 0); -+ source.func_82618_k().func_175718_b(1001, source.func_180699_d(), 0); - } - } - }); -@@ -358,15 +359,15 @@ - return super.func_82487_b(p_82487_1_, p_82487_2_); - } - } -- protected void func_82485_a(IBlockSource p_82485_1_) -+ protected void func_82485_a(IBlockSource source) - { - if (this.field_150838_b) - { -- p_82485_1_.func_82618_k().func_175718_b(1000, p_82485_1_.func_180699_d(), 0); -+ source.func_82618_k().func_175718_b(1000, source.func_180699_d(), 0); - } - else - { -- p_82485_1_.func_82618_k().func_175718_b(1001, p_82485_1_.func_180699_d(), 0); -+ source.func_82618_k().func_175718_b(1001, source.func_180699_d(), 0); - } - } - }); diff --git a/patches/minecraft/net/minecraft/inventory/Container.java.patch b/patches/minecraft/net/minecraft/inventory/Container.java.patch index 0fdc592c4e..a14906ef94 100644 --- a/patches/minecraft/net/minecraft/inventory/Container.java.patch +++ b/patches/minecraft/net/minecraft/inventory/Container.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/inventory/Container.java +++ ../src-work/minecraft/net/minecraft/inventory/Container.java -@@ -608,7 +608,7 @@ +@@ -646,7 +646,7 @@ Slot slot1 = (Slot)this.field_75151_b.get(i); ItemStack itemstack1 = slot1.func_75211_c(); diff --git a/patches/minecraft/net/minecraft/inventory/ContainerBrewingStand.java.patch b/patches/minecraft/net/minecraft/inventory/ContainerBrewingStand.java.patch index 4e3f446a32..cf54412a45 100644 --- a/patches/minecraft/net/minecraft/inventory/ContainerBrewingStand.java.patch +++ b/patches/minecraft/net/minecraft/inventory/ContainerBrewingStand.java.patch @@ -1,29 +1,21 @@ --- ../src-base/minecraft/net/minecraft/inventory/ContainerBrewingStand.java +++ ../src-work/minecraft/net/minecraft/inventory/ContainerBrewingStand.java -@@ -154,7 +154,7 @@ +@@ -196,7 +196,7 @@ - public boolean func_75214_a(ItemStack p_75214_1_) - { -- return p_75214_1_ != null ? p_75214_1_.func_77973_b().func_150892_m(p_75214_1_) : false; -+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_75214_1_); - } - - public int func_75219_a() -@@ -185,7 +185,7 @@ - - public void func_82870_a(EntityPlayer p_82870_1_, ItemStack p_82870_2_) + public boolean func_75214_a(ItemStack p_75214_1_) { -- if (p_82870_2_.func_77973_b() == Items.field_151068_bn && p_82870_2_.func_77960_j() > 0) -+ if (p_82870_2_.func_77973_b() instanceof net.minecraft.item.ItemPotion && p_82870_2_.func_77960_j() > 0) - { - this.field_75244_a.func_71029_a(AchievementList.field_76001_A); +- return p_75214_1_ != null && PotionHelper.func_185205_a(p_75214_1_); ++ return p_75214_1_ != null && net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_75214_1_); + } + + public int func_75219_a() +@@ -243,8 +243,7 @@ + } + else + { +- Item item = p_75243_0_.func_77973_b(); +- return item == Items.field_151068_bn || item == Items.field_151069_bo || item == Items.field_185155_bH || item == Items.field_185156_bI; ++ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_75243_0_); } -@@ -195,7 +195,7 @@ - - public static boolean func_75243_a_(ItemStack p_75243_0_) - { -- return p_75243_0_ != null && (p_75243_0_.func_77973_b() == Items.field_151068_bn || p_75243_0_.func_77973_b() == Items.field_151069_bo); -+ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_75243_0_); } } - } diff --git a/patches/minecraft/net/minecraft/inventory/ContainerEnchantment.java.patch b/patches/minecraft/net/minecraft/inventory/ContainerEnchantment.java.patch index 79534c19de..6eb1cab477 100644 --- a/patches/minecraft/net/minecraft/inventory/ContainerEnchantment.java.patch +++ b/patches/minecraft/net/minecraft/inventory/ContainerEnchantment.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/inventory/ContainerEnchantment.java +++ ../src-work/minecraft/net/minecraft/inventory/ContainerEnchantment.java -@@ -65,9 +65,12 @@ +@@ -68,9 +68,12 @@ }); this.func_75146_a(new Slot(this.field_75168_e, 1, 35, 47) { @@ -14,7 +14,7 @@ } }); -@@ -146,6 +149,7 @@ +@@ -155,6 +158,7 @@ if (!this.field_75172_h.field_72995_K) { int l = 0; @@ -22,7 +22,7 @@ for (int j = -1; j <= 1; ++j) { -@@ -153,37 +157,14 @@ +@@ -162,37 +166,14 @@ { if ((j != 0 || k != 0) && this.field_75172_h.func_175623_d(this.field_178150_j.func_177982_a(k, 0, j)) && this.field_75172_h.func_175623_d(this.field_178150_j.func_177982_a(k, 1, j))) { @@ -66,12 +66,12 @@ } } } -@@ -193,7 +174,7 @@ +@@ -202,7 +183,7 @@ for (int i1 = 0; i1 < 3; ++i1) { - this.field_75167_g[i1] = EnchantmentHelper.func_77514_a(this.field_75169_l, i1, l, itemstack); + this.field_75167_g[i1] = EnchantmentHelper.func_77514_a(this.field_75169_l, i1, (int)power, itemstack); - this.field_178151_h[i1] = -1; + this.field_185001_h[i1] = -1; + this.field_185002_i[i1] = -1; - if (this.field_75167_g[i1] < i1 + 1) diff --git a/patches/minecraft/net/minecraft/inventory/ContainerPlayer.java.patch b/patches/minecraft/net/minecraft/inventory/ContainerPlayer.java.patch index b34ce82312..a77e0a042f 100644 --- a/patches/minecraft/net/minecraft/inventory/ContainerPlayer.java.patch +++ b/patches/minecraft/net/minecraft/inventory/ContainerPlayer.java.patch @@ -1,12 +1,12 @@ --- ../src-base/minecraft/net/minecraft/inventory/ContainerPlayer.java +++ ../src-work/minecraft/net/minecraft/inventory/ContainerPlayer.java -@@ -43,7 +43,8 @@ - } - public boolean func_75214_a(ItemStack p_75214_1_) - { -- return p_75214_1_ == null ? false : (p_75214_1_.func_77973_b() instanceof ItemArmor ? ((ItemArmor)p_75214_1_.func_77973_b()).field_77881_a == k_f : (p_75214_1_.func_77973_b() != Item.func_150898_a(Blocks.field_150423_aK) && p_75214_1_.func_77973_b() != Items.field_151144_bL ? false : k_f == 0)); -+ if (p_75214_1_ == null) return false; -+ return p_75214_1_.func_77973_b().isValidArmor(p_75214_1_, k_f, field_82862_h); +@@ -48,8 +48,7 @@ + } + else + { +- EntityEquipmentSlot entityequipmentslot1 = EntityLiving.func_184640_d(p_75214_1_); +- return entityequipmentslot1 == entityequipmentslot; ++ return p_75214_1_.func_77973_b().isValidArmor(p_75214_1_, entityequipmentslot, field_82862_h); + } } @SideOnly(Side.CLIENT) - public String func_178171_c() diff --git a/patches/minecraft/net/minecraft/inventory/ContainerRepair.java.patch b/patches/minecraft/net/minecraft/inventory/ContainerRepair.java.patch index aad74b86da..78d93064aa 100644 --- a/patches/minecraft/net/minecraft/inventory/ContainerRepair.java.patch +++ b/patches/minecraft/net/minecraft/inventory/ContainerRepair.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/inventory/ContainerRepair.java +++ ../src-work/minecraft/net/minecraft/inventory/ContainerRepair.java -@@ -70,6 +70,8 @@ +@@ -69,6 +69,8 @@ p_82870_1_.func_82242_a(-ContainerRepair.this.field_82854_e); } @@ -9,7 +9,7 @@ ContainerRepair.this.field_82853_g.func_70299_a(0, (ItemStack)null); if (ContainerRepair.this.field_82856_l > 0) -@@ -94,7 +96,7 @@ +@@ -93,7 +95,7 @@ ContainerRepair.this.field_82854_e = 0; IBlockState iblockstate = p_i45807_2_.func_180495_p(p_i45807_3_); @@ -18,25 +18,30 @@ { int l = ((Integer)iblockstate.func_177229_b(BlockAnvil.field_176505_b)).intValue(); ++l; -@@ -172,6 +174,7 @@ +@@ -160,10 +162,12 @@ + Map map = EnchantmentHelper.func_82781_a(itemstack1); + j = j + itemstack.func_82838_A() + (itemstack2 == null ? 0 : itemstack2.func_82838_A()); + this.field_82856_l = 0; ++ boolean flag = false; if (itemstack2 != null) { -+ if (!net.minecraftforge.common.ForgeHooks.onAnvilChange(this, itemstack, itemstack2, field_82852_f, field_82857_m, i2)) return; - flag = itemstack2.func_77973_b() == Items.field_151134_bR && Items.field_151134_bR.func_92110_g(itemstack2).func_74745_c() > 0; +- boolean flag = itemstack2.func_77973_b() == Items.field_151134_bR && !Items.field_151134_bR.func_92110_g(itemstack2).func_82582_d(); ++ if (!net.minecraftforge.common.ForgeHooks.onAnvilChange(this, itemstack, itemstack2, field_82852_f, field_82857_m, j)) return; ++ flag = itemstack2.func_77973_b() == Items.field_151134_bR && !Items.field_151134_bR.func_92110_g(itemstack2).func_82582_d(); if (itemstack1.func_77984_f() && itemstack1.func_77973_b().func_82789_a(itemstack, itemstack2)) -@@ -264,7 +267,8 @@ - { - int i4 = ((Integer)iterator.next()).intValue(); + { +@@ -235,7 +239,7 @@ -- if (i4 != i5 && !enchantment.func_77326_a(Enchantment.func_180306_c(i4))) -+ Enchantment e2 = Enchantment.func_180306_c(i4); -+ if (i4 != i5 && !(enchantment.func_77326_a(e2) && e2.func_77326_a(enchantment))) //Forge BugFix: Let Both enchantments veto being together + for (Enchantment enchantment : map.keySet()) + { +- if (enchantment != enchantment1 && !enchantment1.func_77326_a(enchantment)) ++ if (enchantment != enchantment1 && !(enchantment1.func_77326_a(enchantment) && enchantment.func_77326_a(enchantment1))) //Forge BugFix: Let Both enchantments veto being together { flag1 = false; - ++l1; -@@ -315,6 +319,8 @@ + ++i; +@@ -279,6 +283,8 @@ } } diff --git a/patches/minecraft/net/minecraft/inventory/SlotCrafting.java.patch b/patches/minecraft/net/minecraft/inventory/SlotCrafting.java.patch index 58adc5a1a1..a35783d0c8 100644 --- a/patches/minecraft/net/minecraft/inventory/SlotCrafting.java.patch +++ b/patches/minecraft/net/minecraft/inventory/SlotCrafting.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/inventory/SlotCrafting.java +++ ../src-work/minecraft/net/minecraft/inventory/SlotCrafting.java -@@ -112,8 +112,11 @@ +@@ -107,8 +107,11 @@ public void func_82870_a(EntityPlayer p_82870_1_, ItemStack p_82870_2_) { diff --git a/patches/minecraft/net/minecraft/inventory/SlotFurnaceOutput.java.patch b/patches/minecraft/net/minecraft/inventory/SlotFurnaceOutput.java.patch index 33dcc7b7e7..090b18f534 100644 --- a/patches/minecraft/net/minecraft/inventory/SlotFurnaceOutput.java.patch +++ b/patches/minecraft/net/minecraft/inventory/SlotFurnaceOutput.java.patch @@ -8,4 +8,4 @@ + if (p_75208_1_.func_77973_b() == Items.field_151042_j) { - this.field_75229_a.func_71029_a(AchievementList.field_76016_k); + this.field_75229_a.func_71029_a(AchievementList.field_187987_k); diff --git a/patches/minecraft/net/minecraft/item/Item.java.patch b/patches/minecraft/net/minecraft/item/Item.java.patch index 9bbc3ff944..27cfd57bec 100644 --- a/patches/minecraft/net/minecraft/item/Item.java.patch +++ b/patches/minecraft/net/minecraft/item/Item.java.patch @@ -1,27 +1,20 @@ --- ../src-base/minecraft/net/minecraft/item/Item.java +++ ../src-work/minecraft/net/minecraft/item/Item.java -@@ -48,8 +48,8 @@ +@@ -56,10 +56,10 @@ + import net.minecraftforge.fml.relauncher.Side; + import net.minecraftforge.fml.relauncher.SideOnly; - public class Item +-public class Item ++public class Item extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl { - public static final RegistryNamespaced field_150901_e = new RegistryNamespaced(); - private static final Map field_179220_a = Maps.newHashMap(); -+ public static final RegistryNamespaced field_150901_e = net.minecraftforge.fml.common.registry.GameData.getItemRegistry(); ++ public static final RegistryNamespaced field_150901_e = net.minecraftforge.fml.common.registry.GameData.getItemRegistry();; + private static final Map field_179220_a = net.minecraftforge.fml.common.registry.GameData.getBlockItemMap(); - protected static final UUID field_111210_e = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); - private CreativeTabs field_77701_a; - protected static Random field_77697_d = new Random(); -@@ -61,6 +61,9 @@ - private String field_77785_bY; - private String field_77774_bZ; - -+ public final net.minecraftforge.fml.common.registry.RegistryDelegate delegate = -+ ((net.minecraftforge.fml.common.registry.FMLControlledNamespacedRegistry)field_150901_e).getDelegate(this, Item.class); -+ - public static int func_150891_b(Item p_150891_0_) + private static final IItemPropertyGetter field_185046_b = new IItemPropertyGetter() { - return p_150891_0_ == null ? 0 : field_150901_e.func_148757_b(p_150891_0_); -@@ -126,6 +129,7 @@ + @SideOnly(Side.CLIENT) +@@ -192,6 +192,7 @@ return p_77654_1_; } @@ -29,7 +22,7 @@ public int func_77639_j() { return this.field_77777_bU; -@@ -239,6 +243,7 @@ +@@ -312,6 +313,7 @@ return this.field_77700_c; } @@ -37,7 +30,7 @@ public boolean func_77634_r() { return this.field_77700_c != null; -@@ -316,7 +321,7 @@ +@@ -367,7 +369,7 @@ public boolean func_77616_k(ItemStack p_77616_1_) { @@ -45,8 +38,8 @@ + return this.getItemStackLimit(p_77616_1_) == 1 && this.func_77645_m(); } - protected MovingObjectPosition func_77621_a(World p_77621_1_, EntityPlayer p_77621_2_, boolean p_77621_3_) -@@ -334,6 +339,10 @@ + protected RayTraceResult func_77621_a(World p_77621_1_, EntityPlayer p_77621_2_, boolean p_77621_3_) +@@ -385,6 +387,10 @@ float f6 = f3 * f4; float f7 = f2 * f4; double d3 = 5.0D; @@ -54,15 +47,15 @@ + { + d3 = ((net.minecraft.entity.player.EntityPlayerMP)p_77621_2_).field_71134_c.getBlockReachDistance(); + } - Vec3 vec31 = vec3.func_72441_c((double)f6 * d3, (double)f5 * d3, (double)f7 * d3); - return p_77621_1_.func_147447_a(vec3, vec31, p_77621_3_, !p_77621_3_, false); + Vec3d vec3d1 = vec3d.func_72441_c((double)f6 * d3, (double)f5 * d3, (double)f7 * d3); + return p_77621_1_.func_147447_a(vec3d, vec3d1, p_77621_3_, !p_77621_3_, false); } -@@ -371,11 +380,670 @@ +@@ -422,11 +428,557 @@ return false; } + @Deprecated // Use ItemStack sensitive version below. - public Multimap func_111205_h() + public Multimap func_111205_h(EntityEquipmentSlot p_111205_1_) { return HashMultimap.create(); } @@ -71,9 +64,9 @@ + /** + * ItemStack sensitive version of getItemAttributeModifiers + */ -+ public Multimap getAttributeModifiers(ItemStack stack) ++ public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) + { -+ return this.func_111205_h(); ++ return this.func_111205_h(slot); + } + + /** @@ -96,7 +89,7 @@ + * by a user in the displayed name, such as a mode of operation. + * + * @param item the ItemStack for the item. -+ * @param the name that will be displayed unless it is changed in this method. ++ * @param displayName the name that will be displayed unless it is changed in this method. + */ + public String getHighlightTip( ItemStack item, String displayName ) + { @@ -110,25 +103,14 @@ + * @param world The Current World + * @param pos Target position + * @param side The side of the target hit -+ * @return Return true to prevent any further processing. ++ * @param hand Which hand the item is being held in. ++ * @return Return PASS to allow vanilla handling, any other to skip normal code. + */ -+ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) ++ public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) + { -+ return false; ++ return EnumActionResult.PASS; + } + -+ /** -+ * Metadata-sensitive version of getStrVsBlock -+ * @param itemstack The Item Stack -+ * @param state The block state -+ * @return The damage strength -+ */ -+ public float getDigSpeed(ItemStack itemstack, net.minecraft.block.state.IBlockState state) -+ { -+ return func_150893_a(itemstack, state.func_177230_c()); -+ } -+ -+ + protected boolean canRepair = true; + /** + * Called by CraftingManager to determine if an item is reparable. @@ -170,7 +152,7 @@ + * @param player The Player using the item + * @param count The amount of time in tick the item has been used for continuously + */ -+ public void onUsingTick(ItemStack stack, EntityPlayer player, int count) ++ public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) + { + } + @@ -190,20 +172,6 @@ + } + + /** -+ * Player, Render pass, and item usage sensitive version of getIconIndex. -+ * -+ * @param stack The item stack to get the icon for. -+ * @param player The player holding the item -+ * @param useRemaining The ticks remaining for the active item. -+ * @return Null to use default model, or a custom ModelResourceLocation for the stage of use. -+ */ -+ @SideOnly(Side.CLIENT) -+ public net.minecraft.client.resources.model.ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) -+ { -+ return null; -+ } -+ -+ /** + * ItemStack sensitive version of getContainerItem. + * Returns a full ItemStack instance of the result. + * @@ -308,40 +276,6 @@ + } + + /** -+ * Return the correct icon for rendering based on the supplied ItemStack and render pass. -+ * -+ * Defers to {@link #getIconFromDamageForRenderPass(int, int)} -+ * @param stack to render for -+ * @param pass the multi-render pass -+ * @return the icon -+ * / -+ public IIcon getIcon(ItemStack stack, int pass) -+ { -+ return func_77618_c(stack.getMetadata(), pass); -+ } -+ */ -+ -+ /** -+ * Generates the base Random item for a specific instance of the chest gen, -+ * Enchanted books use this to pick a random enchantment. -+ * -+ * @param chest The chest category to generate for -+ * @param rnd World RNG -+ * @param original Original result registered with the chest gen hooks. -+ * @return New values to use as the random item, typically this will be original -+ */ -+ public net.minecraft.util.WeightedRandomChestContent getChestGenBase(net.minecraftforge.common.ChestGenHooks chest, Random rnd, net.minecraft.util.WeightedRandomChestContent original) -+ { -+ if (this instanceof ItemEnchantedBook) -+ { -+ return ((ItemEnchantedBook)this).func_92112_a(rnd, -+ original.field_76295_d, -+ original.field_76296_e, original.field_76292_a); -+ } -+ return original; -+ } -+ -+ /** + * + * Should this item, when held, allow sneak-clicks to pass through to the underlying block? + * @@ -350,7 +284,7 @@ + * @param player The Player that is wielding the item + * @return + */ -+ public boolean doesSneakBypassUse(World world, BlockPos pos, EntityPlayer player) ++ public boolean doesSneakBypassUse(ItemStack stack, net.minecraft.world.IBlockAccess world, BlockPos pos, EntityPlayer player) + { + return false; + } @@ -368,19 +302,9 @@ + * @param entity The entity trying to equip the armor + * @return True if the given ItemStack can be inserted in the slot + */ -+ public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) ++ public boolean isValidArmor(ItemStack stack, EntityEquipmentSlot armorType, Entity entity) + { -+ if (this instanceof ItemArmor) -+ { -+ return ((ItemArmor)this).field_77881_a == armorType; -+ } -+ -+ if (armorType == 0) -+ { -+ return this == Item.func_150898_a(Blocks.field_150423_aK) || this == Items.field_151144_bL; -+ } -+ -+ return false; ++ return net.minecraft.entity.EntityLiving.func_184640_d(stack) == armorType; + } + + /** @@ -408,7 +332,7 @@ + * @param type The subtype, can be null or "overlay" + * @return Path of texture to bind, or null to use default + */ -+ public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) ++ public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) + { + return null; + } @@ -427,29 +351,18 @@ + } + + /** -+ * @deprecated Use 4-argument version. -+ */ -+ // remove 1.9 -+ @SideOnly(Side.CLIENT) -+ @Deprecated -+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) -+ { -+ return null; -+ } -+ -+ /** + * Override this method to have an item handle its own armor rendering. + * + * @param entityLiving The entity wearing the armor + * @param itemStack The itemStack to render the model of -+ * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet ++ * @param armorSlot The slot the armor is in + * @param _default Original armor model. Will have attributes set. + * @return A ModelBiped to render instead of the default + */ + @SideOnly(Side.CLIENT) -+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot, net.minecraft.client.model.ModelBiped _default) ++ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, net.minecraft.client.model.ModelBiped _default) + { -+ return getArmorModel(entityLiving, itemStack, armorSlot); ++ return null; + } + + /** @@ -559,14 +472,14 @@ + } + + /** -+ * ItemStack sensitive version of {@link #canHarvestBlock(Block)} -+ * @param par1Block The block trying to harvest -+ * @param itemStack The itemstack used to harvest the block ++ * ItemStack sensitive version of {@link #canHarvestBlock(IBlockState)} ++ * @param state The block trying to harvest ++ * @param stack The itemstack used to harvest the block + * @return true if can harvest the block + */ -+ public boolean canHarvestBlock(Block par1Block, ItemStack itemStack) ++ public boolean canHarvestBlock(IBlockState state, ItemStack stack) + { -+ return func_150897_b(par1Block); ++ return func_150897_b(state); + } + + /** @@ -574,7 +487,7 @@ + * This is a ItemStack (and thus NBT) sensitive version of Item.getItemStackLimit() + * + * @param stack The ItemStack -+ * @return THe maximum number this item can be stacked to ++ * @return The maximum number this item can be stacked to + */ + public int getItemStackLimit(ItemStack stack) + { @@ -641,7 +554,6 @@ + return this == Items.field_151166_bC || this == Items.field_151045_i || this == Items.field_151043_k || this == Items.field_151042_j; + } + -+ + /** + * Determine if the player switching between these two item stacks + * @param oldStack The old stack that was equipped @@ -653,57 +565,7 @@ + */ + public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) + { -+ return !ItemStack.func_77989_b(oldStack, newStack); -+ } -+ -+ -+ private ResourceLocation registryName = null; -+ /** -+ * Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item. -+ * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does. -+ * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items. -+ * -+ * The supplied name will be prefixed with the currently active mod's modId. -+ * If the supplied name already has a prefix that is different, it will be used and a warning will be logged. -+ * -+ * If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown. -+ * -+ * Returns 'this' to allow for chaining. -+ * -+ * @param name Unique registry name -+ * @return This instance -+ */ -+ public final Item setRegistryName(String name) -+ { -+ if (getRegistryName() != null) -+ throw new IllegalStateException("Attempted to set registry name on block with exisiting registry name! New: " + name + " Old: " + getRegistryName()); -+ int index = name.lastIndexOf(':'); -+ String oldPrefix = index == -1 ? "" : name.substring(0, index); -+ name = index == -1 ? name : name.substring(index + 1); -+ net.minecraftforge.fml.common.ModContainer mc = net.minecraftforge.fml.common.Loader.instance().activeModContainer(); -+ String prefix = mc == null ? "minecraft" : mc.getModId(); -+ if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0) -+ { -+ net.minecraftforge.fml.common.FMLLog.bigWarning("Dangerous alternative prefix %s for name %s, invalid registry invocation/invalid name?", oldPrefix, name); -+ prefix = oldPrefix; -+ } -+ this.registryName = new ResourceLocation(prefix, name); -+ return this; -+ } -+ public final Item setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); } -+ public final Item setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); } -+ -+ /** -+ * A unique identifier for this block, if this block is registered in the game registry it will return that name. -+ * Otherwise it will return the name set in setRegistryName(). -+ * If neither are valid null is returned. -+ * -+ * @return Unique identifier or null. -+ */ -+ public final String getRegistryName() -+ { -+ if (delegate.getResourceName() != null) return delegate.getResourceName().toString(); -+ return registryName != null ? registryName.toString() : null; ++ return !oldStack.equals(newStack); //!ItemStack.areItemStacksEqual(oldStack, newStack); + } + + /** @@ -723,12 +585,30 @@ + { + return null; + } ++ ++ public com.google.common.collect.ImmutableMap getAnimationParameters(final ItemStack stack, final World world, final EntityLivingBase entity) ++ { ++ com.google.common.collect.ImmutableMap.Builder builder = com.google.common.collect.ImmutableMap.builder(); ++ for(ResourceLocation location : field_185051_m.func_148742_b()) ++ { ++ final IItemPropertyGetter parameter = field_185051_m.func_82594_a(location); ++ builder.put(location.toString(), new net.minecraftforge.common.animation.ITimeValue() ++ { ++ public float apply(float input) ++ { ++ return parameter.func_185085_a(stack, world, entity); ++ } ++ }); ++ } ++ return builder.build(); ++ } ++ + /* ======================================== FORGE END =====================================*/ + public static void func_150900_l() { func_179214_a(Blocks.field_150348_b, (new ItemMultiTexture(Blocks.field_150348_b, Blocks.field_150348_b, new Function() -@@ -855,6 +1523,10 @@ +@@ -935,6 +1487,10 @@ private final float field_78011_i; private final int field_78008_j; @@ -739,21 +619,21 @@ private ToolMaterial(int p_i1874_3_, int p_i1874_4_, float p_i1874_5_, float p_i1874_6_, int p_i1874_7_) { this.field_78001_f = p_i1874_3_; -@@ -889,9 +1561,36 @@ +@@ -969,9 +1525,36 @@ return this.field_78008_j; } + @Deprecated // Use getRepairItemStack below public Item func_150995_f() { -- return this == WOOD ? Item.func_150898_a(Blocks.field_150344_f) : (this == STONE ? Item.func_150898_a(Blocks.field_150347_e) : (this == GOLD ? Items.field_151043_k : (this == IRON ? Items.field_151042_j : (this == EMERALD ? Items.field_151045_i : null)))); +- return this == WOOD ? Item.func_150898_a(Blocks.field_150344_f) : (this == STONE ? Item.func_150898_a(Blocks.field_150347_e) : (this == GOLD ? Items.field_151043_k : (this == IRON ? Items.field_151042_j : (this == DIAMOND ? Items.field_151045_i : null)))); + switch (this) + { + case WOOD: return Item.func_150898_a(Blocks.field_150344_f); + case STONE: return Item.func_150898_a(Blocks.field_150347_e); + case GOLD: return Items.field_151043_k; + case IRON: return Items.field_151042_j; -+ case EMERALD: return Items.field_151045_i; ++ case DIAMOND: return Items.field_151045_i; + default: return customCraftingMaterial; + } } @@ -761,7 +641,7 @@ + public ToolMaterial setRepairItem(ItemStack stack) + { + if (this.repairMaterial != null || customCraftingMaterial != null) throw new RuntimeException("Can not change already set repair material"); -+ if (this == WOOD || this == STONE || this == GOLD || this == IRON || this == EMERALD) throw new RuntimeException("Can not change vanilla tool repair materials"); ++ if (this == WOOD || this == STONE || this == GOLD || this == IRON || this == DIAMOND) throw new RuntimeException("Can not change vanilla tool repair materials"); + this.repairMaterial = stack; + this.customCraftingMaterial = stack.func_77973_b(); + return this; diff --git a/patches/minecraft/net/minecraft/item/ItemArmor.java.patch b/patches/minecraft/net/minecraft/item/ItemArmor.java.patch index c81e15e772..8559d5846b 100644 --- a/patches/minecraft/net/minecraft/item/ItemArmor.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemArmor.java.patch @@ -1,34 +1,15 @@ --- ../src-base/minecraft/net/minecraft/item/ItemArmor.java +++ ../src-work/minecraft/net/minecraft/item/ItemArmor.java -@@ -37,7 +37,7 @@ - if (list.size() > 0) - { - EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0); -- int l = entitylivingbase instanceof EntityPlayer ? 1 : 0; -+ int l = 0;// Forge: We fix the indexes. Mojang Stop hard coding this! - int i1 = EntityLiving.func_82159_b(p_82487_2_); - ItemStack itemstack = p_82487_2_.func_77946_l(); - itemstack.field_77994_a = 1; -@@ -190,7 +190,7 @@ - - if (itemstack == null) - { -- p_77659_3_.func_70062_b(i, p_77659_1_.func_77946_l()); -+ p_77659_3_.func_70062_b(i + 1, p_77659_1_.func_77946_l()); //Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for players. - p_77659_1_.field_77994_a = 0; - } - -@@ -210,6 +210,9 @@ +@@ -235,6 +235,8 @@ private final int[] field_78049_g; private final int field_78055_h; - + private final SoundEvent field_185020_j; + //Added by forge for custom Armor materials. + public Item customCraftingMaterial = null; -+ - private ArmorMaterial(String p_i45789_3_, int p_i45789_4_, int[] p_i45789_5_, int p_i45789_6_) + + private ArmorMaterial(String p_i46796_3_, int p_i46796_4_, int[] p_i46796_5_, int p_i46796_6_, SoundEvent p_i46796_7_) { - this.field_179243_f = p_i45789_3_; -@@ -235,7 +238,15 @@ +@@ -267,7 +269,15 @@ public Item func_151685_b() { diff --git a/patches/minecraft/net/minecraft/item/ItemBlock.java.patch b/patches/minecraft/net/minecraft/item/ItemBlock.java.patch index b87dbda549..32dc0c168c 100644 --- a/patches/minecraft/net/minecraft/item/ItemBlock.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemBlock.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/item/ItemBlock.java +++ ../src-work/minecraft/net/minecraft/item/ItemBlock.java -@@ -54,16 +54,8 @@ +@@ -50,16 +50,8 @@ int i = this.func_77647_b(p_180614_1_.func_77960_j()); - IBlockState iblockstate1 = this.field_150939_a.func_180642_a(p_180614_3_, p_180614_4_, p_180614_5_, p_180614_6_, p_180614_7_, p_180614_8_, i, p_180614_2_); + IBlockState iblockstate1 = this.field_150939_a.func_180642_a(p_180614_3_, p_180614_4_, p_180614_6_, p_180614_7_, p_180614_8_, p_180614_9_, i, p_180614_2_); -- if (p_180614_3_.func_180501_a(p_180614_4_, iblockstate1, 3)) -+ if (placeBlockAt(p_180614_1_, p_180614_2_, p_180614_3_, p_180614_4_, p_180614_5_, p_180614_6_, p_180614_7_, p_180614_8_, iblockstate1)) +- if (p_180614_3_.func_180501_a(p_180614_4_, iblockstate1, 11)) ++ if (placeBlockAt(p_180614_1_, p_180614_2_, p_180614_3_, p_180614_4_, p_180614_6_, p_180614_7_, p_180614_8_, p_180614_9_, iblockstate1)) { - iblockstate1 = p_180614_3_.func_180495_p(p_180614_4_); - @@ -15,10 +15,10 @@ - this.field_150939_a.func_180633_a(p_180614_3_, p_180614_4_, iblockstate1, p_180614_2_, p_180614_1_); - } - - p_180614_3_.func_72908_a((double)((float)p_180614_4_.func_177958_n() + 0.5F), (double)((float)p_180614_4_.func_177956_o() + 0.5F), (double)((float)p_180614_4_.func_177952_p() + 0.5F), this.field_150939_a.field_149762_H.func_150496_b(), (this.field_150939_a.field_149762_H.func_150497_c() + 1.0F) / 2.0F, this.field_150939_a.field_149762_H.func_150494_d() * 0.8F); + SoundType soundtype = this.field_150939_a.func_185467_w(); + p_180614_3_.func_184133_a(p_180614_2_, p_180614_4_, soundtype.func_185841_e(), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F); --p_180614_1_.field_77994_a; - } -@@ -124,7 +116,7 @@ +@@ -121,7 +113,7 @@ { Block block = p_179222_1_.func_180495_p(p_179222_2_).func_177230_c(); @@ -27,7 +27,7 @@ { p_179222_3_ = EnumFacing.UP; } -@@ -162,4 +154,26 @@ +@@ -159,4 +151,32 @@ { return this.field_150939_a; } @@ -52,5 +52,11 @@ + } + + return true; ++ } ++ ++ @SideOnly(Side.CLIENT) ++ public void func_77624_a(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) ++ { ++ field_150939_a.addInformation(stack, playerIn, tooltip, advanced); + } } diff --git a/patches/minecraft/net/minecraft/item/ItemBow.java.patch b/patches/minecraft/net/minecraft/item/ItemBow.java.patch index 098450a80f..f8f76a314d 100644 --- a/patches/minecraft/net/minecraft/item/ItemBow.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemBow.java.patch @@ -1,22 +1,37 @@ --- ../src-base/minecraft/net/minecraft/item/ItemBow.java +++ ../src-work/minecraft/net/minecraft/item/ItemBow.java -@@ -27,6 +27,9 @@ - if (flag || p_77615_3_.field_71071_by.func_146028_b(Items.field_151032_g)) - { - int i = this.func_77626_a(p_77615_1_) - p_77615_4_; -+ net.minecraftforge.event.entity.player.ArrowLooseEvent event = new net.minecraftforge.event.entity.player.ArrowLooseEvent(p_77615_3_, p_77615_1_, i); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return; -+ i = event.charge; - float f = (float)i / 20.0F; - f = (f * f + f * 2.0F) / 3.0F; +@@ -90,6 +90,10 @@ + boolean flag = entityplayer.field_71075_bZ.field_75098_d || EnchantmentHelper.func_77506_a(Enchantments.field_185312_x, p_77615_1_) > 0; + ItemStack itemstack = this.func_185060_a(entityplayer); -@@ -104,6 +107,9 @@ - - public ItemStack func_77659_a(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) - { -+ net.minecraftforge.event.entity.player.ArrowNockEvent event = new net.minecraftforge.event.entity.player.ArrowNockEvent(p_77659_3_, p_77659_1_); -+ if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return event.result; ++ int i = this.func_77626_a(p_77615_1_) - p_77615_4_; ++ i = net.minecraftforge.event.ForgeEventFactory.onArrowLoose(p_77615_1_, p_77615_2_, (EntityPlayer)p_77615_3_, i, itemstack != null || flag); ++ if (i < 0) return; + - if (p_77659_3_.field_71075_bZ.field_75098_d || p_77659_3_.field_71071_by.func_146028_b(Items.field_151032_g)) + if (itemstack != null || flag) + { + if (itemstack == null) +@@ -97,12 +101,11 @@ + itemstack = new ItemStack(Items.field_151032_g); + } + +- int i = this.func_77626_a(p_77615_1_) - p_77615_4_; + float f = func_185059_b(i); + + if ((double)f >= 0.1D) + { +- boolean flag1 = flag && itemstack.func_77973_b() == Items.field_151032_g; ++ boolean flag1 = flag && itemstack.func_77973_b() instanceof ItemArrow; //Forge: Fix consuming custom arrows. + + if (!p_77615_2_.field_72995_K) + { +@@ -189,6 +192,9 @@ + { + boolean flag = this.func_185060_a(p_77659_3_) != null; + ++ ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onArrowNock(p_77659_1_, p_77659_2_, p_77659_3_, p_77659_4_, flag); ++ if (ret != null) return ret; ++ + if (!p_77659_3_.field_71075_bZ.field_75098_d && !flag) { - p_77659_3_.func_71008_a(p_77659_1_, this.func_77626_a(p_77659_1_)); + return !flag ? new ActionResult(EnumActionResult.FAIL, p_77659_1_) : new ActionResult(EnumActionResult.PASS, p_77659_1_); diff --git a/patches/minecraft/net/minecraft/item/ItemBucket.java.patch b/patches/minecraft/net/minecraft/item/ItemBucket.java.patch index b2f98aa456..344645f977 100644 --- a/patches/minecraft/net/minecraft/item/ItemBucket.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemBucket.java.patch @@ -1,12 +1,11 @@ --- ../src-base/minecraft/net/minecraft/item/ItemBucket.java +++ ../src-work/minecraft/net/minecraft/item/ItemBucket.java -@@ -36,6 +36,9 @@ - } - else +@@ -36,6 +36,8 @@ + { + boolean flag = this.field_77876_a == Blocks.field_150350_a; + RayTraceResult raytraceresult = this.func_77621_a(p_77659_2_, p_77659_3_, flag); ++ ActionResult ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_77659_3_, p_77659_2_, p_77659_1_, raytraceresult); ++ if (ret != null) return ret; + + if (raytraceresult == null) { -+ ItemStack ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(p_77659_3_, p_77659_2_, p_77659_1_, movingobjectposition); -+ if (ret != null) return ret; -+ - if (movingobjectposition.field_72313_a == MovingObjectPosition.MovingObjectType.BLOCK) - { - BlockPos blockpos = movingobjectposition.func_178782_a(); diff --git a/patches/minecraft/net/minecraft/item/ItemBucketMilk.java.patch b/patches/minecraft/net/minecraft/item/ItemBucketMilk.java.patch index a14a801070..3420e53274 100644 --- a/patches/minecraft/net/minecraft/item/ItemBucketMilk.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemBucketMilk.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/item/ItemBucketMilk.java +++ ../src-work/minecraft/net/minecraft/item/ItemBucketMilk.java -@@ -23,7 +23,7 @@ +@@ -27,7 +27,7 @@ if (!p_77654_2_.field_72995_K) { @@ -8,4 +8,4 @@ + p_77654_3_.curePotionEffects(p_77654_1_); } - p_77654_3_.func_71029_a(StatList.field_75929_E[Item.func_150891_b(this)]); + if (p_77654_3_ instanceof EntityPlayer) diff --git a/patches/minecraft/net/minecraft/item/ItemDye.java.patch b/patches/minecraft/net/minecraft/item/ItemDye.java.patch index a698baa69a..4ed0d3e9fd 100644 --- a/patches/minecraft/net/minecraft/item/ItemDye.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemDye.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/item/ItemDye.java +++ ../src-work/minecraft/net/minecraft/item/ItemDye.java -@@ -47,7 +47,7 @@ +@@ -50,7 +50,7 @@ if (enumdyecolor == EnumDyeColor.WHITE) { @@ -9,36 +9,47 @@ { if (!p_180614_3_.field_72995_K) { -@@ -97,8 +97,18 @@ +@@ -97,22 +97,32 @@ public static boolean func_179234_a(ItemStack p_179234_0_, World p_179234_1_, BlockPos p_179234_2_) { +- IBlockState iblockstate = p_179234_1_.func_180495_p(p_179234_2_); + if (p_179234_1_ instanceof net.minecraft.world.WorldServer) + return applyBonemeal(p_179234_0_, p_179234_1_, p_179234_2_, net.minecraftforge.common.util.FakePlayerFactory.getMinecraft((net.minecraft.world.WorldServer)p_179234_1_)); + return false; + } -+ -+ public static boolean applyBonemeal(ItemStack p_179234_0_, World p_179234_1_, BlockPos p_179234_2_, EntityPlayer player) -+ { - IBlockState iblockstate = p_179234_1_.func_180495_p(p_179234_2_); -+ int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, p_179234_1_, p_179234_2_, iblockstate, p_179234_0_); ++ public static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos target, EntityPlayer player) ++ { ++ IBlockState iblockstate = worldIn.func_180495_p(target); ++ ++ int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, target, iblockstate, stack); + if (hook != 0) return hook > 0; + if (iblockstate.func_177230_c() instanceof IGrowable) { IGrowable igrowable = (IGrowable)iblockstate.func_177230_c(); -@@ -132,7 +142,7 @@ - Block block = p_180617_0_.func_180495_p(p_180617_1_).func_177230_c(); +- if (igrowable.func_176473_a(p_179234_1_, p_179234_2_, iblockstate, p_179234_1_.field_72995_K)) ++ if (igrowable.func_176473_a(worldIn, target, iblockstate, worldIn.field_72995_K)) + { +- if (!p_179234_1_.field_72995_K) ++ if (!worldIn.field_72995_K) + { +- if (igrowable.func_180670_a(p_179234_1_, p_179234_1_.field_73012_v, p_179234_2_, iblockstate)) ++ if (igrowable.func_180670_a(worldIn, worldIn.field_73012_v, target, iblockstate)) + { +- igrowable.func_176474_b(p_179234_1_, p_179234_1_.field_73012_v, p_179234_2_, iblockstate); ++ igrowable.func_176474_b(worldIn, worldIn.field_73012_v, target, iblockstate); + } -- if (block.func_149688_o() != Material.field_151579_a) -+ if (block.isAir(p_180617_0_, p_180617_1_)) - { - block.func_180654_a(p_180617_0_, p_180617_1_); +- --p_179234_0_.field_77994_a; ++ --stack.field_77994_a; + } -@@ -144,6 +154,16 @@ - p_180617_0_.func_175688_a(EnumParticleTypes.VILLAGER_HAPPY, (double)((float)p_180617_1_.func_177958_n() + field_77697_d.nextFloat()), (double)p_180617_1_.func_177956_o() + (double)field_77697_d.nextFloat() * block.func_149669_A(), (double)((float)p_180617_1_.func_177952_p() + field_77697_d.nextFloat()), d0, d1, d2, new int[0]); + return true; +@@ -142,6 +152,16 @@ + p_180617_0_.func_175688_a(EnumParticleTypes.VILLAGER_HAPPY, (double)((float)p_180617_1_.func_177958_n() + field_77697_d.nextFloat()), (double)p_180617_1_.func_177956_o() + (double)field_77697_d.nextFloat() * iblockstate.func_185900_c(p_180617_0_, p_180617_1_).field_72337_e, (double)((float)p_180617_1_.func_177952_p() + field_77697_d.nextFloat()), d0, d1, d2, new int[0]); } } + else @@ -53,4 +64,4 @@ + } } - public boolean func_111207_a(ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_) + public boolean func_111207_a(ItemStack p_111207_1_, EntityPlayer p_111207_2_, EntityLivingBase p_111207_3_, EnumHand p_111207_4_) diff --git a/patches/minecraft/net/minecraft/item/ItemEmptyMap.java.patch b/patches/minecraft/net/minecraft/item/ItemEmptyMap.java.patch index aaf05d09de..c38e2ed9f7 100644 --- a/patches/minecraft/net/minecraft/item/ItemEmptyMap.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemEmptyMap.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/item/ItemEmptyMap.java +++ ../src-work/minecraft/net/minecraft/item/ItemEmptyMap.java -@@ -22,7 +22,7 @@ +@@ -25,7 +25,7 @@ p_77659_2_.func_72823_a(s, mapdata); mapdata.field_76197_d = 0; mapdata.func_176054_a(p_77659_3_.field_70165_t, p_77659_3_.field_70161_v, mapdata.field_76197_d); -- mapdata.field_76200_c = (byte)p_77659_2_.field_73011_w.func_177502_q(); -+ mapdata.field_76200_c = p_77659_2_.field_73011_w.func_177502_q(); +- mapdata.field_76200_c = (byte)p_77659_2_.field_73011_w.func_186058_p().func_186068_a(); ++ mapdata.field_76200_c = p_77659_2_.field_73011_w.func_186058_p().func_186068_a(); + mapdata.field_186210_e = true; mapdata.func_76185_a(); --p_77659_1_.field_77994_a; - diff --git a/patches/minecraft/net/minecraft/item/ItemFlintAndSteel.java.patch b/patches/minecraft/net/minecraft/item/ItemFlintAndSteel.java.patch index 624bf5ffcf..9e1f53a17e 100644 --- a/patches/minecraft/net/minecraft/item/ItemFlintAndSteel.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemFlintAndSteel.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/item/ItemFlintAndSteel.java +++ ../src-work/minecraft/net/minecraft/item/ItemFlintAndSteel.java -@@ -27,7 +27,7 @@ +@@ -31,7 +31,7 @@ } else { -- if (p_180614_3_.func_180495_p(p_180614_4_).func_177230_c().func_149688_o() == Material.field_151579_a) +- if (p_180614_3_.func_180495_p(p_180614_4_).func_185904_a() == Material.field_151579_a) + if (p_180614_3_.func_175623_d(p_180614_4_)) { - p_180614_3_.func_72908_a((double)p_180614_4_.func_177958_n() + 0.5D, (double)p_180614_4_.func_177956_o() + 0.5D, (double)p_180614_4_.func_177952_p() + 0.5D, "fire.ignite", 1.0F, field_77697_d.nextFloat() * 0.4F + 0.8F); - p_180614_3_.func_175656_a(p_180614_4_, Blocks.field_150480_ab.func_176223_P()); + p_180614_3_.func_184133_a(p_180614_2_, p_180614_4_, SoundEvents.field_187649_bu, SoundCategory.BLOCKS, 1.0F, field_77697_d.nextFloat() * 0.4F + 0.8F); + p_180614_3_.func_180501_a(p_180614_4_, Blocks.field_150480_ab.func_176223_P(), 11); diff --git a/patches/minecraft/net/minecraft/item/ItemHoe.java.patch b/patches/minecraft/net/minecraft/item/ItemHoe.java.patch index 3d3e201efe..98f3a2028d 100644 --- a/patches/minecraft/net/minecraft/item/ItemHoe.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemHoe.java.patch @@ -1,17 +1,17 @@ --- ../src-base/minecraft/net/minecraft/item/ItemHoe.java +++ ../src-work/minecraft/net/minecraft/item/ItemHoe.java -@@ -34,10 +34,13 @@ +@@ -45,10 +45,13 @@ } else { + int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(p_180614_1_, p_180614_2_, p_180614_3_, p_180614_4_); -+ if (hook != 0) return hook > 0; ++ if (hook != 0) return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; + IBlockState iblockstate = p_180614_3_.func_180495_p(p_180614_4_); Block block = iblockstate.func_177230_c(); -- if (p_180614_5_ != EnumFacing.DOWN && p_180614_3_.func_180495_p(p_180614_4_.func_177984_a()).func_177230_c().func_149688_o() == Material.field_151579_a) -+ if (p_180614_5_ != EnumFacing.DOWN && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) +- if (p_180614_6_ != EnumFacing.DOWN && p_180614_3_.func_180495_p(p_180614_4_.func_177984_a()).func_185904_a() == Material.field_151579_a) ++ if (p_180614_6_ != EnumFacing.DOWN && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) { - if (block == Blocks.field_150349_c) + if (block == Blocks.field_150349_c || block == Blocks.field_185774_da) { diff --git a/patches/minecraft/net/minecraft/item/ItemLilyPad.java.patch b/patches/minecraft/net/minecraft/item/ItemLilyPad.java.patch index e0bd7c80cd..784e8a2963 100644 --- a/patches/minecraft/net/minecraft/item/ItemLilyPad.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemLilyPad.java.patch @@ -1,17 +1,18 @@ --- ../src-base/minecraft/net/minecraft/item/ItemLilyPad.java +++ ../src-work/minecraft/net/minecraft/item/ItemLilyPad.java -@@ -49,7 +49,14 @@ +@@ -47,6 +47,15 @@ - if (iblockstate.func_177230_c().func_149688_o() == Material.field_151586_h && ((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue() == 0 && p_77659_2_.func_175623_d(blockpos1)) + if (iblockstate.func_185904_a() == Material.field_151586_h && ((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue() == 0 && p_77659_2_.func_175623_d(blockpos1)) { + // special case for handling block placement with water lilies + net.minecraftforge.common.util.BlockSnapshot blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(p_77659_2_, blockpos1); - p_77659_2_.func_175656_a(blockpos1, Blocks.field_150392_bi.func_176223_P()); ++ p_77659_2_.func_175656_a(blockpos1, Blocks.field_150392_bi.func_176223_P()); + if (net.minecraftforge.event.ForgeEventFactory.onPlayerBlockPlace(p_77659_3_, blocksnapshot, net.minecraft.util.EnumFacing.UP).isCanceled()) + { + blocksnapshot.restore(true, false); -+ return p_77659_1_; ++ return new ActionResult(EnumActionResult.FAIL, p_77659_1_); + } ++ + p_77659_2_.func_180501_a(blockpos1, Blocks.field_150392_bi.func_176223_P(), 11); if (!p_77659_3_.field_71075_bZ.field_75098_d) - { diff --git a/patches/minecraft/net/minecraft/item/ItemMap.java.patch b/patches/minecraft/net/minecraft/item/ItemMap.java.patch index c8f63dba2a..ed071b6b54 100644 --- a/patches/minecraft/net/minecraft/item/ItemMap.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemMap.java.patch @@ -4,8 +4,8 @@ mapdata = new MapData(s); mapdata.field_76197_d = 3; mapdata.func_176054_a((double)p_77873_2_.func_72912_H().func_76079_c(), (double)p_77873_2_.func_72912_H().func_76074_e(), mapdata.field_76197_d); -- mapdata.field_76200_c = (byte)p_77873_2_.field_73011_w.func_177502_q(); -+ mapdata.field_76200_c = p_77873_2_.field_73011_w.func_177502_q(); +- mapdata.field_76200_c = (byte)p_77873_2_.field_73011_w.func_186058_p().func_186068_a(); ++ mapdata.field_76200_c = p_77873_2_.field_73011_w.func_186058_p().func_186068_a(); mapdata.func_76185_a(); p_77873_2_.func_72823_a(s, mapdata); } diff --git a/patches/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch b/patches/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch index 589f687762..04e7c10df2 100644 --- a/patches/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemMonsterPlacer.java.patch @@ -1,113 +1,30 @@ --- ../src-base/minecraft/net/minecraft/item/ItemMonsterPlacer.java +++ ../src-work/minecraft/net/minecraft/item/ItemMonsterPlacer.java -@@ -36,7 +36,7 @@ - public String func_77653_i(ItemStack p_77653_1_) - { - String s = ("" + StatCollector.func_74838_a(this.func_77658_a() + ".name")).trim(); -- String s1 = EntityList.func_75617_a(p_77653_1_.func_77960_j()); -+ String s1 = ItemMonsterPlacer.getEntityName(p_77653_1_); - - if (s1 != null) - { -@@ -49,7 +49,7 @@ - @SideOnly(Side.CLIENT) - public int func_82790_a(ItemStack p_82790_1_, int p_82790_2_) - { -- EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.field_75627_a.get(Integer.valueOf(p_82790_1_.func_77960_j())); -+ EntityList.EntityEggInfo entitylist$entityegginfo = ItemMonsterPlacer.getEggInfo(p_82790_1_); - return entitylist$entityegginfo != null ? (p_82790_2_ == 0 ? entitylist$entityegginfo.field_75611_b : entitylist$entityegginfo.field_75612_c) : 16777215; - } - -@@ -74,7 +74,7 @@ - if (tileentity instanceof TileEntityMobSpawner) - { - MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).func_145881_a(); -- mobspawnerbaselogic.func_98272_a(EntityList.func_75617_a(p_180614_1_.func_77960_j())); -+ mobspawnerbaselogic.func_98272_a(ItemMonsterPlacer.getEntityName(p_180614_1_)); - tileentity.func_70296_d(); - p_180614_3_.func_175689_h(p_180614_4_); - -@@ -90,12 +90,12 @@ - p_180614_4_ = p_180614_4_.func_177972_a(p_180614_5_); +@@ -88,7 +88,7 @@ + p_180614_4_ = p_180614_4_.func_177972_a(p_180614_6_); double d0 = 0.0D; -- if (p_180614_5_ == EnumFacing.UP && iblockstate instanceof BlockFence) -+ if (p_180614_5_ == EnumFacing.UP && iblockstate.func_177230_c() instanceof BlockFence) //Forge: Fix Vanilla bug comparing state instead of block +- if (p_180614_6_ == EnumFacing.UP && iblockstate instanceof BlockFence) ++ if (p_180614_6_ == EnumFacing.UP && iblockstate.func_177230_c() instanceof BlockFence) //Forge: Fix Vanilla bug comparing state instead of block { d0 = 0.5D; } - -- Entity entity = func_77840_a(p_180614_3_, p_180614_1_.func_77960_j(), (double)p_180614_4_.func_177958_n() + 0.5D, (double)p_180614_4_.func_177956_o() + d0, (double)p_180614_4_.func_177952_p() + 0.5D); -+ Entity entity = spawnCreature(p_180614_3_, ItemMonsterPlacer.getEntityName(p_180614_1_), (double)p_180614_4_.func_177958_n() + 0.5D, (double)p_180614_4_.func_177956_o() + d0, (double)p_180614_4_.func_177952_p() + 0.5D); - - if (entity != null) - { -@@ -146,7 +146,7 @@ - - if (p_77659_2_.func_180495_p(blockpos).func_177230_c() instanceof BlockLiquid) - { -- Entity entity = func_77840_a(p_77659_2_, p_77659_1_.func_77960_j(), (double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.5D, (double)blockpos.func_177952_p() + 0.5D); -+ Entity entity = spawnCreature(p_77659_2_, ItemMonsterPlacer.getEntityName(p_77659_1_), (double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.5D, (double)blockpos.func_177952_p() + 0.5D); - - if (entity != null) - { -@@ -170,19 +170,29 @@ +@@ -195,15 +195,15 @@ } } -+ @Deprecated // Use string version below. - public static Entity func_77840_a(World p_77840_0_, int p_77840_1_, double p_77840_2_, double p_77840_4_, double p_77840_6_) +- public static Entity func_77840_a(World p_77840_0_, String p_77840_1_, double p_77840_2_, double p_77840_4_, double p_77840_6_) ++ public static Entity func_77840_a(World p_77840_0_, String name, double p_77840_2_, double p_77840_4_, double p_77840_6_) { - if (!EntityList.field_75627_a.containsKey(Integer.valueOf(p_77840_1_))) - { - return null; - } -+ return spawnCreature(p_77840_0_, EntityList.func_75617_a(p_77840_1_), p_77840_2_, p_77840_4_, p_77840_6_); -+ } -+ -+ public static Entity spawnCreature(World p_77840_0_, String name, double p_77840_2_, double p_77840_4_, double p_77840_6_) -+ { -+ if (!EntityList.field_75625_b.containsKey(name)) -+ { -+ return null; -+ } - else +- if (p_77840_1_ != null && EntityList.field_75627_a.containsKey(p_77840_1_)) ++ if (name != null && EntityList.field_75627_a.containsKey(name)) { Entity entity = null; for (int i = 0; i < 1; ++i) { -- entity = EntityList.func_75616_a(p_77840_1_, p_77840_0_); -+ entity = EntityList.func_75620_a(name, p_77840_0_); +- entity = EntityList.func_188429_b(p_77840_1_, p_77840_0_); ++ entity = EntityList.func_188429_b(name, p_77840_0_); if (entity instanceof EntityLivingBase) { -@@ -207,5 +217,28 @@ - { - p_150895_3_.add(new ItemStack(p_150895_1_, 1, entitylist$entityegginfo.field_75613_a)); - } -+ -+ for (String name : net.minecraftforge.fml.common.registry.EntityRegistry.getEggs().keySet()) -+ { -+ ItemStack stack = new ItemStack(p_150895_1_); -+ net.minecraft.nbt.NBTTagCompound nbt = new net.minecraft.nbt.NBTTagCompound(); -+ nbt.func_74778_a("entity_name", name); -+ stack.func_77982_d(nbt); -+ p_150895_3_.add(stack); -+ } - } -+ -+ public static String getEntityName(ItemStack stack) -+ { -+ if (stack.func_77942_o() && stack.func_77978_p().func_150297_b("entity_name", 8)) -+ return stack.func_77978_p().func_74779_i("entity_name"); -+ return EntityList.func_75617_a(stack.func_77960_j()); -+ } -+ -+ private static EntityList.EntityEggInfo getEggInfo(ItemStack stack) -+ { -+ if (stack.func_77942_o() && stack.func_77978_p().func_150297_b("entity_name", 8)) -+ return net.minecraftforge.fml.common.registry.EntityRegistry.getEggs().get(stack.func_77978_p().func_74779_i("entity_name")); -+ return (EntityList.EntityEggInfo)EntityList.field_75627_a.get(stack.func_77960_j()); -+ } - } diff --git a/patches/minecraft/net/minecraft/item/ItemRecord.java.patch b/patches/minecraft/net/minecraft/item/ItemRecord.java.patch index dcafa7df78..16e050b5be 100644 --- a/patches/minecraft/net/minecraft/item/ItemRecord.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemRecord.java.patch @@ -1,10 +1,9 @@ --- ../src-base/minecraft/net/minecraft/item/ItemRecord.java +++ ../src-work/minecraft/net/minecraft/item/ItemRecord.java -@@ -76,4 +76,15 @@ - { - return (ItemRecord)field_150928_b.get(p_150926_0_); +@@ -73,6 +73,17 @@ + return EnumRarity.RARE; } -+ + + /** + * Retrieves the resource location of the sound to play for this record. + * @@ -15,4 +14,7 @@ + { + return new net.minecraft.util.ResourceLocation(name); + } - } ++ + @SideOnly(Side.CLIENT) + public static ItemRecord func_185074_a(SoundEvent p_185074_0_) + { diff --git a/patches/minecraft/net/minecraft/item/ItemSeedFood.java.patch b/patches/minecraft/net/minecraft/item/ItemSeedFood.java.patch index 1d41825289..4625623628 100644 --- a/patches/minecraft/net/minecraft/item/ItemSeedFood.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemSeedFood.java.patch @@ -1,7 +1,7 @@ --- ../src-base/minecraft/net/minecraft/item/ItemSeedFood.java +++ ../src-work/minecraft/net/minecraft/item/ItemSeedFood.java -@@ -6,7 +6,7 @@ - import net.minecraft.util.EnumFacing; +@@ -8,7 +8,7 @@ + import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class ItemSeedFood extends ItemFood @@ -9,17 +9,18 @@ { private Block field_150908_b; private Block field_82809_c; -@@ -28,7 +28,7 @@ +@@ -22,7 +22,8 @@ + + public EnumActionResult func_180614_a(ItemStack p_180614_1_, EntityPlayer p_180614_2_, World p_180614_3_, BlockPos p_180614_4_, EnumHand p_180614_5_, EnumFacing p_180614_6_, float p_180614_7_, float p_180614_8_, float p_180614_9_) + { +- if (p_180614_6_ == EnumFacing.UP && p_180614_2_.func_175151_a(p_180614_4_.func_177972_a(p_180614_6_), p_180614_6_, p_180614_1_) && p_180614_3_.func_180495_p(p_180614_4_).func_177230_c() == this.field_82809_c && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) ++ net.minecraft.block.state.IBlockState state = p_180614_3_.func_180495_p(p_180614_4_); ++ if (p_180614_6_ == EnumFacing.UP && p_180614_2_.func_175151_a(p_180614_4_.func_177972_a(p_180614_6_), p_180614_6_, p_180614_1_) && state.func_177230_c().canSustainPlant(state, p_180614_3_, p_180614_4_, EnumFacing.UP, this) && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) { - return false; - } -- else if (p_180614_3_.func_180495_p(p_180614_4_).func_177230_c() == this.field_82809_c && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) -+ else if (p_180614_3_.func_180495_p(p_180614_4_).func_177230_c().canSustainPlant(p_180614_3_, p_180614_4_, EnumFacing.UP, this) && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) - { - p_180614_3_.func_175656_a(p_180614_4_.func_177984_a(), this.field_150908_b.func_176223_P()); + p_180614_3_.func_180501_a(p_180614_4_.func_177984_a(), this.field_150908_b.func_176223_P(), 11); --p_180614_1_.field_77994_a; -@@ -39,4 +39,16 @@ - return false; +@@ -33,4 +34,16 @@ + return EnumActionResult.FAIL; } } + diff --git a/patches/minecraft/net/minecraft/item/ItemSeeds.java.patch b/patches/minecraft/net/minecraft/item/ItemSeeds.java.patch index 08fd7261b1..c433dc17c9 100644 --- a/patches/minecraft/net/minecraft/item/ItemSeeds.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemSeeds.java.patch @@ -1,7 +1,7 @@ --- ../src-base/minecraft/net/minecraft/item/ItemSeeds.java +++ ../src-work/minecraft/net/minecraft/item/ItemSeeds.java -@@ -7,7 +7,7 @@ - import net.minecraft.util.EnumFacing; +@@ -9,7 +9,7 @@ + import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public class ItemSeeds extends Item @@ -9,17 +9,18 @@ { private Block field_150925_a; private Block field_77838_b; -@@ -29,7 +29,7 @@ - { - return false; - } -- else if (p_180614_3_.func_180495_p(p_180614_4_).func_177230_c() == this.field_77838_b && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) -+ else if (p_180614_3_.func_180495_p(p_180614_4_).func_177230_c().canSustainPlant(p_180614_3_, p_180614_4_, EnumFacing.UP, this) && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) +@@ -23,7 +23,8 @@ + + public EnumActionResult func_180614_a(ItemStack p_180614_1_, EntityPlayer p_180614_2_, World p_180614_3_, BlockPos p_180614_4_, EnumHand p_180614_5_, EnumFacing p_180614_6_, float p_180614_7_, float p_180614_8_, float p_180614_9_) + { +- if (p_180614_6_ == EnumFacing.UP && p_180614_2_.func_175151_a(p_180614_4_.func_177972_a(p_180614_6_), p_180614_6_, p_180614_1_) && p_180614_3_.func_180495_p(p_180614_4_).func_177230_c() == this.field_77838_b && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) ++ net.minecraft.block.state.IBlockState state = p_180614_3_.func_180495_p(p_180614_4_); ++ if (p_180614_6_ == EnumFacing.UP && p_180614_2_.func_175151_a(p_180614_4_.func_177972_a(p_180614_6_), p_180614_6_, p_180614_1_) && state.func_177230_c().canSustainPlant(state, p_180614_3_, p_180614_4_, EnumFacing.UP, this) && p_180614_3_.func_175623_d(p_180614_4_.func_177984_a())) { p_180614_3_.func_175656_a(p_180614_4_.func_177984_a(), this.field_150925_a.func_176223_P()); --p_180614_1_.field_77994_a; -@@ -40,4 +40,16 @@ - return false; +@@ -34,4 +35,16 @@ + return EnumActionResult.FAIL; } } + diff --git a/patches/minecraft/net/minecraft/item/ItemShears.java.patch b/patches/minecraft/net/minecraft/item/ItemShears.java.patch index 3f6119ca84..3746b62ab7 100644 --- a/patches/minecraft/net/minecraft/item/ItemShears.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemShears.java.patch @@ -1,28 +1,22 @@ --- ../src-base/minecraft/net/minecraft/item/ItemShears.java +++ ../src-work/minecraft/net/minecraft/item/ItemShears.java -@@ -19,13 +19,12 @@ - - public boolean func_179218_a(ItemStack p_179218_1_, World p_179218_2_, Block p_179218_3_, BlockPos p_179218_4_, EntityLivingBase p_179218_5_) +@@ -22,7 +22,7 @@ { -- if (p_179218_3_.func_149688_o() != Material.field_151584_j && p_179218_3_ != Blocks.field_150321_G && p_179218_3_ != Blocks.field_150329_H && p_179218_3_ != Blocks.field_150395_bd && p_179218_3_ != Blocks.field_150473_bD && p_179218_3_ != Blocks.field_150325_L) -+ if (p_179218_3_.func_149688_o() != Material.field_151584_j && p_179218_3_ != Blocks.field_150321_G && p_179218_3_ != Blocks.field_150329_H && p_179218_3_ != Blocks.field_150395_bd && p_179218_3_ != Blocks.field_150473_bD && p_179218_3_ != Blocks.field_150325_L && !(p_179218_3_ instanceof net.minecraftforge.common.IShearable)) - { - return super.func_179218_a(p_179218_1_, p_179218_2_, p_179218_3_, p_179218_4_, p_179218_5_); - } - else - { -- p_179218_1_.func_77972_a(1, p_179218_5_); - return true; - } + p_179218_1_.func_77972_a(1, p_179218_5_); + Block block = p_179218_3_.func_177230_c(); +- return p_179218_3_.func_185904_a() != Material.field_151584_j && block != Blocks.field_150321_G && block != Blocks.field_150329_H && block != Blocks.field_150395_bd && block != Blocks.field_150473_bD && block != Blocks.field_150325_L ? super.func_179218_a(p_179218_1_, p_179218_2_, p_179218_3_, p_179218_4_, p_179218_5_) : true; ++ return p_179218_3_.func_185904_a() != Material.field_151584_j && block != Blocks.field_150321_G && block != Blocks.field_150329_H && block != Blocks.field_150395_bd && block != Blocks.field_150473_bD && block != Blocks.field_150325_L && !(p_179218_3_ instanceof net.minecraftforge.common.IShearable) ? super.func_179218_a(p_179218_1_, p_179218_2_, p_179218_3_, p_179218_4_, p_179218_5_) : true; } -@@ -39,4 +38,71 @@ - { - return p_150893_2_ != Blocks.field_150321_G && p_150893_2_.func_149688_o() != Material.field_151584_j ? (p_150893_2_ == Blocks.field_150325_L ? 5.0F : super.func_150893_a(p_150893_1_, p_150893_2_)) : 15.0F; + + public boolean func_150897_b(IBlockState p_150897_1_) +@@ -36,4 +36,71 @@ + Block block = p_150893_2_.func_177230_c(); + return block != Blocks.field_150321_G && p_150893_2_.func_185904_a() != Material.field_151584_j ? (block == Blocks.field_150325_L ? 5.0F : super.func_150893_a(p_150893_1_, p_150893_2_)) : 15.0F; } + + + @Override -+ public boolean func_111207_a(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity) ++ public boolean func_111207_a(ItemStack itemstack, net.minecraft.entity.player.EntityPlayer player, EntityLivingBase entity, net.minecraft.util.EnumHand hand) + { + if (entity.field_70170_p.field_72995_K) + { @@ -35,7 +29,7 @@ + if (target.isShearable(itemstack, entity.field_70170_p, pos)) + { + java.util.List drops = target.onSheared(itemstack, entity.field_70170_p, pos, -+ net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.enchantment.Enchantment.field_77346_s.field_77352_x, itemstack)); ++ net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.init.Enchantments.field_185308_t, itemstack)); + + java.util.Random rand = new java.util.Random(); + for(ItemStack stack : drops) @@ -66,7 +60,7 @@ + if (target.isShearable(itemstack, player.field_70170_p, pos)) + { + java.util.List drops = target.onSheared(itemstack, player.field_70170_p, pos, -+ net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.enchantment.Enchantment.field_77346_s.field_77352_x, itemstack)); ++ net.minecraft.enchantment.EnchantmentHelper.func_77506_a(net.minecraft.init.Enchantments.field_185308_t, itemstack)); + java.util.Random rand = new java.util.Random(); + + for(ItemStack stack : drops) @@ -81,7 +75,7 @@ + } + + itemstack.func_77972_a(1, player); -+ player.func_71064_a(net.minecraft.stats.StatList.field_75934_C[Block.func_149682_b(block)], 1); ++ player.func_71029_a(net.minecraft.stats.StatList.func_188055_a(block)); + } + } + return false; diff --git a/patches/minecraft/net/minecraft/item/ItemSkull.java.patch b/patches/minecraft/net/minecraft/item/ItemSkull.java.patch index 0e97068ef6..ac5e803293 100644 --- a/patches/minecraft/net/minecraft/item/ItemSkull.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemSkull.java.patch @@ -1,31 +1,22 @@ --- ../src-base/minecraft/net/minecraft/item/ItemSkull.java +++ ../src-work/minecraft/net/minecraft/item/ItemSkull.java -@@ -34,6 +34,11 @@ - - public boolean func_180614_a(ItemStack p_180614_1_, EntityPlayer p_180614_2_, World p_180614_3_, BlockPos p_180614_4_, EnumFacing p_180614_5_, float p_180614_6_, float p_180614_7_, float p_180614_8_) - { -+ if (p_180614_3_.func_180495_p(p_180614_4_).func_177230_c().func_176200_f(p_180614_3_, p_180614_4_) && p_180614_5_ != EnumFacing.DOWN) -+ { -+ p_180614_5_ = EnumFacing.UP; -+ p_180614_4_ = p_180614_4_.func_177977_b(); -+ } - if (p_180614_5_ == EnumFacing.DOWN) +@@ -42,13 +42,18 @@ + } + else { - return false; -@@ -46,7 +51,7 @@ ++ if (p_180614_3_.func_180495_p(p_180614_4_).func_177230_c().func_176200_f(p_180614_3_, p_180614_4_)) ++ { ++ p_180614_6_ = EnumFacing.UP; ++ p_180614_4_ = p_180614_4_.func_177977_b(); ++ } + IBlockState iblockstate = p_180614_3_.func_180495_p(p_180614_4_); + Block block = iblockstate.func_177230_c(); + boolean flag = block.func_176200_f(p_180614_3_, p_180614_4_); if (!flag) { -- if (!p_180614_3_.func_180495_p(p_180614_4_).func_177230_c().func_149688_o().func_76220_a()) -+ if (!p_180614_3_.func_180495_p(p_180614_4_).func_177230_c().func_149688_o().func_76220_a() && !p_180614_3_.isSideSolid(p_180614_4_, p_180614_5_, true)) +- if (!p_180614_3_.func_180495_p(p_180614_4_).func_185904_a().func_76220_a()) ++ if (!p_180614_3_.func_180495_p(p_180614_4_).func_185904_a().func_76220_a() && !p_180614_3_.isSideSolid(p_180614_4_, p_180614_6_, true)) { - return false; + return EnumActionResult.FAIL; } -@@ -66,6 +71,7 @@ - { - if (!p_180614_3_.field_72995_K) - { -+ if (!Blocks.field_150465_bP.func_176198_a(p_180614_3_, p_180614_4_, p_180614_5_)) return false; - p_180614_3_.func_180501_a(p_180614_4_, Blocks.field_150465_bP.func_176223_P().func_177226_a(BlockSkull.field_176418_a, p_180614_5_), 3); - int i = 0; - diff --git a/patches/minecraft/net/minecraft/item/ItemSnow.java.patch b/patches/minecraft/net/minecraft/item/ItemSnow.java.patch index 984fba4edb..3f3cea17a4 100644 --- a/patches/minecraft/net/minecraft/item/ItemSnow.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemSnow.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/item/ItemSnow.java +++ ../src-work/minecraft/net/minecraft/item/ItemSnow.java -@@ -67,4 +67,10 @@ +@@ -68,4 +68,10 @@ { return p_77647_1_; } diff --git a/patches/minecraft/net/minecraft/item/ItemStack.java.patch b/patches/minecraft/net/minecraft/item/ItemStack.java.patch index 7d0836f32b..f7f888960b 100644 --- a/patches/minecraft/net/minecraft/item/ItemStack.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemStack.java.patch @@ -1,15 +1,15 @@ --- ../src-base/minecraft/net/minecraft/item/ItemStack.java +++ ../src-work/minecraft/net/minecraft/item/ItemStack.java -@@ -35,7 +35,7 @@ +@@ -41,7 +41,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public final class ItemStack +public final class ItemStack implements net.minecraftforge.common.capabilities.ICapabilitySerializable { - public static final DecimalFormat field_111284_a = new DecimalFormat("#.###"); + public static final DecimalFormat field_111284_a = new DecimalFormat("#.##"); public int field_77994_a; -@@ -49,6 +49,10 @@ +@@ -55,6 +55,10 @@ private Block field_179550_j; private boolean field_179551_k; @@ -20,7 +20,7 @@ public ItemStack(Block p_i1876_1_) { this((Block)p_i1876_1_, 1); -@@ -74,13 +78,15 @@ +@@ -80,13 +84,15 @@ this((Item)p_i1880_1_, p_i1880_2_, 0); } @@ -38,16 +38,16 @@ this.field_77994_a = p_i1881_2_; this.field_77991_e = p_i1881_3_; -@@ -107,7 +113,7 @@ - +@@ -114,7 +120,7 @@ public ItemStack func_77979_a(int p_77979_1_) { + p_77979_1_ = Math.min(p_77979_1_, this.field_77994_a); - ItemStack itemstack = new ItemStack(this.field_151002_e, p_77979_1_, this.field_77991_e); + ItemStack itemstack = new ItemStack(this.field_151002_e, p_77979_1_, this.field_77991_e, this.capabilities != null ? this.capabilities.serializeNBT() : null); if (this.field_77990_d != null) { -@@ -120,11 +126,12 @@ +@@ -127,11 +133,12 @@ public Item func_77973_b() { @@ -55,13 +55,13 @@ + return this.delegate != null ? this.delegate.get() : null; } - public boolean func_179546_a(EntityPlayer p_179546_1_, World p_179546_2_, BlockPos p_179546_3_, EnumFacing p_179546_4_, float p_179546_5_, float p_179546_6_, float p_179546_7_) + public EnumActionResult func_179546_a(EntityPlayer p_179546_1_, World p_179546_2_, BlockPos p_179546_3_, EnumHand p_179546_4_, EnumFacing p_179546_5_, float p_179546_6_, float p_179546_7_, float p_179546_8_) { -+ if (!p_179546_2_.field_72995_K) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(this, p_179546_1_, p_179546_2_, p_179546_3_, p_179546_4_, p_179546_5_, p_179546_6_, p_179546_7_); - boolean flag = this.func_77973_b().func_180614_a(this, p_179546_1_, p_179546_2_, p_179546_3_, p_179546_4_, p_179546_5_, p_179546_6_, p_179546_7_); ++ if (!p_179546_2_.field_72995_K) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(this, p_179546_1_, p_179546_2_, p_179546_3_, p_179546_5_, p_179546_6_, p_179546_7_, p_179546_8_, p_179546_4_); + EnumActionResult enumactionresult = this.func_77973_b().func_180614_a(this, p_179546_1_, p_179546_2_, p_179546_3_, p_179546_4_, p_179546_5_, p_179546_6_, p_179546_7_, p_179546_8_); - if (flag) -@@ -162,19 +169,23 @@ + if (enumactionresult == EnumActionResult.SUCCESS) +@@ -169,12 +176,16 @@ p_77955_1_.func_74782_a("tag", this.field_77990_d); } @@ -72,22 +72,14 @@ public void func_77963_c(NBTTagCompound p_77963_1_) { +- this.field_151002_e = Item.func_111206_d(p_77963_1_.func_74779_i("id")); + this.capNBT = p_77963_1_.func_74764_b("ForgeCaps") ? p_77963_1_.func_74775_l("ForgeCaps") : null; - if (p_77963_1_.func_150297_b("id", 8)) - { -- this.field_151002_e = Item.func_111206_d(p_77963_1_.func_74779_i("id")); -+ this.func_150996_a(Item.func_111206_d(p_77963_1_.func_74779_i("id"))); - } - else - { -- this.field_151002_e = Item.func_150899_d(p_77963_1_.func_74765_d("id")); -+ this.func_150996_a(Item.func_150899_d(p_77963_1_.func_74765_d("id"))); - } ++ this.func_150996_a(Item.func_111206_d(p_77963_1_.func_74779_i("id"))); + this.capNBT = null; - this.field_77994_a = p_77963_1_.func_74771_c("Count"); this.field_77991_e = p_77963_1_.func_74765_d("Damage"); -@@ -197,7 +208,7 @@ + +@@ -196,7 +207,7 @@ public int func_77976_d() { @@ -96,7 +88,7 @@ } public boolean func_77985_e() -@@ -207,7 +218,7 @@ +@@ -206,7 +217,7 @@ public boolean func_77984_f() { @@ -105,7 +97,7 @@ } public boolean func_77981_g() -@@ -217,32 +228,27 @@ +@@ -216,32 +227,27 @@ public boolean func_77951_h() { @@ -138,12 +130,12 @@ public int func_77958_k() { -- return this.field_151002_e.func_77612_l(); -+ return this.field_151002_e.getMaxDamage(this); +- return this.field_151002_e == null ? 0 : this.field_151002_e.func_77612_l(); ++ return this.field_151002_e == null ? 0 : this.field_151002_e.getMaxDamage(this); } public boolean func_96631_a(int p_96631_1_, Random p_96631_2_) -@@ -274,8 +280,8 @@ +@@ -273,8 +279,8 @@ } } @@ -154,16 +146,16 @@ } } -@@ -334,7 +340,7 @@ +@@ -328,7 +334,7 @@ - public boolean func_150998_b(Block p_150998_1_) + public boolean func_150998_b(IBlockState p_150998_1_) { - return this.field_151002_e.func_150897_b(p_150998_1_); + return func_77973_b().canHarvestBlock(p_150998_1_, this); } - public boolean func_111282_a(EntityPlayer p_111282_1_, EntityLivingBase p_111282_2_) -@@ -344,7 +350,7 @@ + public boolean func_111282_a(EntityPlayer p_111282_1_, EntityLivingBase p_111282_2_, EnumHand p_111282_3_) +@@ -338,7 +344,7 @@ public ItemStack func_77946_l() { @@ -172,7 +164,7 @@ if (this.field_77990_d != null) { -@@ -742,6 +748,7 @@ +@@ -759,6 +765,7 @@ } } @@ -180,16 +172,16 @@ return list; } -@@ -852,7 +859,7 @@ +@@ -869,7 +876,7 @@ } else { -- multimap = this.func_77973_b().func_111205_h(); -+ multimap = this.func_77973_b().getAttributeModifiers(this); +- multimap = this.func_77973_b().func_111205_h(p_111283_1_); ++ multimap = this.func_77973_b().getAttributeModifiers(p_111283_1_, this); } return multimap; -@@ -860,6 +867,18 @@ +@@ -901,6 +908,18 @@ public void func_150996_a(Item p_150996_1_) { @@ -208,7 +200,7 @@ this.field_151002_e = p_150996_1_; } -@@ -946,4 +965,26 @@ +@@ -987,4 +1006,26 @@ return false; } } diff --git a/patches/minecraft/net/minecraft/item/ItemSword.java.patch b/patches/minecraft/net/minecraft/item/ItemSword.java.patch index 2b99d22f15..cd88c33771 100644 --- a/patches/minecraft/net/minecraft/item/ItemSword.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemSword.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/item/ItemSword.java +++ ../src-work/minecraft/net/minecraft/item/ItemSword.java -@@ -101,7 +101,9 @@ +@@ -88,7 +88,9 @@ public boolean func_82789_a(ItemStack p_82789_1_, ItemStack p_82789_2_) { @@ -10,4 +10,4 @@ + return super.func_82789_a(p_82789_1_, p_82789_2_); } - public Multimap func_111205_h() + public Multimap func_111205_h(EntityEquipmentSlot p_111205_1_) diff --git a/patches/minecraft/net/minecraft/item/ItemTool.java.patch b/patches/minecraft/net/minecraft/item/ItemTool.java.patch index 2a0e7450b2..efb12b0b58 100644 --- a/patches/minecraft/net/minecraft/item/ItemTool.java.patch +++ b/patches/minecraft/net/minecraft/item/ItemTool.java.patch @@ -1,8 +1,8 @@ --- ../src-base/minecraft/net/minecraft/item/ItemTool.java +++ ../src-work/minecraft/net/minecraft/item/ItemTool.java -@@ -28,6 +28,18 @@ - this.field_77864_a = p_i45333_2_.func_77998_b(); - this.field_77865_bY = p_i45333_1_ + p_i45333_2_.func_78000_c(); +@@ -33,6 +33,18 @@ + this.field_77865_bY = p_i46745_1_ + p_i46745_3_.func_78000_c(); + this.field_185065_c = p_i46745_2_; this.func_77637_a(CreativeTabs.field_78040_i); + if (this instanceof ItemPickaxe) + { @@ -18,8 +18,20 @@ + } } - public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_) -@@ -74,7 +86,9 @@ + protected ItemTool(Item.ToolMaterial p_i46746_1_, Set p_i46746_2_) +@@ -42,6 +54,11 @@ + + public float func_150893_a(ItemStack p_150893_1_, IBlockState p_150893_2_) + { ++ for (String type : getToolClasses(p_150893_1_)) ++ { ++ if (p_150893_2_.func_177230_c().isToolEffective(type, p_150893_2_)) ++ return field_77864_a; ++ } + return this.field_150914_c.contains(p_150893_2_.func_177230_c()) ? this.field_77864_a : 1.0F; + } + +@@ -84,7 +101,9 @@ public boolean func_82789_a(ItemStack p_82789_1_, ItemStack p_82789_2_) { @@ -29,9 +41,9 @@ + return super.func_82789_a(p_82789_1_, p_82789_2_); } - public Multimap func_111205_h() -@@ -83,4 +97,38 @@ - multimap.put(SharedMonsterAttributes.field_111264_e.func_111108_a(), new AttributeModifier(field_111210_e, "Tool modifier", (double)this.field_77865_bY, 0)); + public Multimap func_111205_h(EntityEquipmentSlot p_111205_1_) +@@ -99,4 +118,27 @@ + return multimap; } + @@ -56,16 +68,5 @@ + { + return toolClass != null ? com.google.common.collect.ImmutableSet.of(toolClass) : super.getToolClasses(stack); + } -+ -+ @Override -+ public float getDigSpeed(ItemStack stack, net.minecraft.block.state.IBlockState state) -+ { -+ for (String type : getToolClasses(stack)) -+ { -+ if (state.func_177230_c().isToolEffective(type, state)) -+ return field_77864_a; -+ } -+ return super.getDigSpeed(stack, state); -+ } + /*===================================== FORGE END =================================*/ } diff --git a/patches/minecraft/net/minecraft/item/crafting/FurnaceRecipes.java.patch b/patches/minecraft/net/minecraft/item/crafting/FurnaceRecipes.java.patch index cd73ea934e..0d6a291aab 100644 --- a/patches/minecraft/net/minecraft/item/crafting/FurnaceRecipes.java.patch +++ b/patches/minecraft/net/minecraft/item/crafting/FurnaceRecipes.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/item/crafting/FurnaceRecipes.java +++ ../src-work/minecraft/net/minecraft/item/crafting/FurnaceRecipes.java -@@ -72,6 +72,7 @@ +@@ -73,6 +73,7 @@ public void func_151394_a(ItemStack p_151394_1_, ItemStack p_151394_2_, float p_151394_3_) { @@ -8,7 +8,7 @@ this.field_77604_b.put(p_151394_1_, p_151394_2_); this.field_77605_c.put(p_151394_2_, Float.valueOf(p_151394_3_)); } -@@ -101,6 +102,9 @@ +@@ -102,6 +103,9 @@ public float func_151398_b(ItemStack p_151398_1_) { diff --git a/patches/minecraft/net/minecraft/item/crafting/RecipesBanners.java.patch b/patches/minecraft/net/minecraft/item/crafting/RecipesBanners.java.patch index bddf21f35e..d5afab9c37 100644 --- a/patches/minecraft/net/minecraft/item/crafting/RecipesBanners.java.patch +++ b/patches/minecraft/net/minecraft/item/crafting/RecipesBanners.java.patch @@ -1,6 +1,19 @@ --- ../src-base/minecraft/net/minecraft/item/crafting/RecipesBanners.java +++ ../src-work/minecraft/net/minecraft/item/crafting/RecipesBanners.java -@@ -135,11 +135,7 @@ +@@ -89,9 +89,10 @@ + { + ItemStack itemstack2 = p_77572_1_.func_70301_a(j); + +- if (itemstack2 != null && itemstack2.func_77973_b() == Items.field_151100_aR) ++ int color = getColor(itemstack2); ++ if (color != -1) + { +- k = itemstack2.func_77960_j(); ++ k = color; + break; + } + } +@@ -135,11 +136,7 @@ for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack = p_179532_1_.func_70301_a(i); @@ -13,7 +26,64 @@ } return aitemstack; -@@ -356,9 +352,9 @@ +@@ -164,7 +161,7 @@ + + if (itemstack != null && itemstack.func_77973_b() != Items.field_179564_cE) + { +- if (itemstack.func_77973_b() == Items.field_151100_aR) ++ if (isDye(itemstack)) + { + if (flag2) + { +@@ -204,7 +201,7 @@ + + if (itemstack1 != null && itemstack1.func_77973_b() != Items.field_179564_cE) + { +- if (itemstack1.func_77973_b() != Items.field_151100_aR) ++ if (!isDye(itemstack1)) + { + flag = false; + break; +@@ -245,6 +242,38 @@ + + return null; + } ++ ++ private static String[] colors = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White" }; ++ @SuppressWarnings("unchecked") //Why java... ++ private static java.util.List[] colored = new java.util.List[colors.length]; ++ private static java.util.List dyes; ++ private static boolean hasInit = false; ++ private static void init() ++ { ++ if (hasInit) return; ++ for (int x = 0; x < colors.length; x++) ++ colored[x] = net.minecraftforge.oredict.OreDictionary.getOres("dye" + colors[x]); ++ dyes = net.minecraftforge.oredict.OreDictionary.getOres("dye"); ++ hasInit = true; ++ } ++ private boolean isDye(ItemStack stack) ++ { ++ init(); ++ for (ItemStack ore : dyes) ++ if (net.minecraftforge.oredict.OreDictionary.itemMatches(ore, stack, false)) ++ return true; ++ return false; ++ } ++ private int getColor(ItemStack stack) ++ { ++ init(); ++ if (stack == null) return -1; ++ for (int x = 0; x < colored.length; x++) ++ for (ItemStack ore : colored[x]) ++ if (net.minecraftforge.oredict.OreDictionary.itemMatches(ore, stack, true)) ++ return x; ++ return -1; ++ } + } + + public static class RecipeDuplicatePattern implements IRecipe +@@ -356,9 +385,9 @@ if (itemstack != null) { diff --git a/patches/minecraft/net/minecraft/nbt/NBTTagCompound.java.patch b/patches/minecraft/net/minecraft/nbt/NBTTagCompound.java.patch index 8a494fdfb5..c626278f8a 100644 --- a/patches/minecraft/net/minecraft/nbt/NBTTagCompound.java.patch +++ b/patches/minecraft/net/minecraft/nbt/NBTTagCompound.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/nbt/NBTTagCompound.java +++ ../src-work/minecraft/net/minecraft/nbt/NBTTagCompound.java -@@ -395,6 +395,7 @@ +@@ -454,6 +454,7 @@ private static byte func_152447_a(DataInput p_152447_0_, NBTSizeTracker p_152447_1_) throws IOException { @@ -8,7 +8,7 @@ return p_152447_0_.readByte(); } -@@ -405,6 +406,7 @@ +@@ -464,6 +465,7 @@ static NBTBase func_152449_a(byte p_152449_0_, String p_152449_1_, DataInput p_152449_2_, int p_152449_3_, NBTSizeTracker p_152449_4_) throws IOException { diff --git a/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch b/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch index dfe8c66c5d..df2660338f 100644 --- a/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch +++ b/patches/minecraft/net/minecraft/network/NetHandlerPlayServer.java.patch @@ -1,51 +1,6 @@ --- ../src-base/minecraft/net/minecraft/network/NetHandlerPlayServer.java +++ ../src-work/minecraft/net/minecraft/network/NetHandlerPlayServer.java -@@ -254,6 +254,8 @@ - this.field_147369_b.field_70154_o.func_70043_V(); - } - -+ if (!this.field_147380_r) return; //Fixes teleportation kick while riding entities -+ - this.field_147367_d.func_71203_ab().func_72358_d(this.field_147369_b); - - if (this.field_147369_b.field_70154_o != null) -@@ -350,6 +352,8 @@ - this.field_147369_b.func_70664_aZ(); - } - -+ if (!this.field_147380_r) return; //Fixes "Moved Too Fast" kick when being teleported while moving -+ - this.field_147369_b.func_70091_d(d11, d12, d13); - this.field_147369_b.field_70122_E = p_147347_1_.func_149465_i(); - d11 = d8 - this.field_147369_b.field_70165_t; -@@ -370,6 +374,8 @@ - field_147370_c.warn(this.field_147369_b.func_70005_c_() + " moved wrongly!"); - } - -+ if (!this.field_147380_r) return; //Fixes "Moved Too Fast" kick when being teleported while moving -+ - this.field_147369_b.func_70080_a(d8, d9, d10, f1, f2); - this.field_147369_b.func_71000_j(this.field_147369_b.field_70165_t - d0, this.field_147369_b.field_70163_u - d1, this.field_147369_b.field_70161_v - d2); - -@@ -377,7 +383,7 @@ - { - boolean flag2 = worldserver.func_72945_a(this.field_147369_b, this.field_147369_b.func_174813_aQ().func_72331_e((double)f3, (double)f3, (double)f3)).isEmpty(); - -- if (flag && (flag1 || !flag2) && !this.field_147369_b.func_70608_bn()) -+ if (flag && (flag1 || !flag2) && !this.field_147369_b.func_70608_bn() && !this.field_147369_b.field_70145_X) - { - this.func_147364_a(this.field_147373_o, this.field_147382_p, this.field_147381_q, f1, f2); - return; -@@ -405,6 +411,8 @@ - this.field_147365_f = 0; - } - -+ if (!this.field_147380_r) return; //Fixes "Moved Too Fast" kick when being teleported while moving -+ - this.field_147369_b.field_70122_E = p_147347_1_.func_149465_i(); - this.field_147367_d.func_71203_ab().func_72358_d(this.field_147369_b); - this.field_147369_b.func_71122_b(this.field_147369_b.field_70163_u - d7, p_147347_1_.func_149465_i()); -@@ -497,7 +505,10 @@ +@@ -612,7 +612,10 @@ double d2 = this.field_147369_b.field_70161_v - ((double)blockpos.func_177952_p() + 0.5D); double d3 = d0 * d0 + d1 * d1 + d2 * d2; @@ -57,77 +12,58 @@ { return; } -@@ -549,6 +560,7 @@ - WorldServer worldserver = this.field_147367_d.func_71218_a(this.field_147369_b.field_71093_bK); - ItemStack itemstack = this.field_147369_b.field_71071_by.func_70448_g(); - boolean flag = false; -+ boolean placeResult = true; - BlockPos blockpos = p_147346_1_.func_179724_a(); - EnumFacing enumfacing = EnumFacing.func_82600_a(p_147346_1_.func_149568_f()); - this.field_147369_b.func_143004_u(); -@@ -560,13 +572,20 @@ - return; - } +@@ -670,7 +673,9 @@ -+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_147369_b, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_AIR, worldserver, new BlockPos(0, 0, 0), null, new net.minecraft.util.Vec3(p_147346_1_.func_149573_h(), p_147346_1_.func_149569_i(), p_147346_1_.func_149575_j())); -+ if (event.useItem != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) -+ { - this.field_147369_b.field_71134_c.func_73085_a(this.field_147369_b, worldserver, itemstack); -+ } - } - else if (blockpos.func_177956_o() < this.field_147367_d.func_71207_Z() - 1 || enumfacing != EnumFacing.UP && blockpos.func_177956_o() < this.field_147367_d.func_71207_Z()) + if (blockpos.func_177956_o() < this.field_147367_d.func_71207_Z() - 1 || enumfacing != EnumFacing.UP && blockpos.func_177956_o() < this.field_147367_d.func_71207_Z()) { -- if (this.field_147380_r && this.field_147369_b.func_70092_e((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.5D, (double)blockpos.func_177952_p() + 0.5D) < 64.0D && !this.field_147367_d.func_175579_a(worldserver, blockpos, this.field_147369_b) && worldserver.func_175723_af().func_177746_a(blockpos)) +- if (this.field_184362_y == null && this.field_147369_b.func_70092_e((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.5D, (double)blockpos.func_177952_p() + 0.5D) < 64.0D && !this.field_147367_d.func_175579_a(worldserver, blockpos, this.field_147369_b) && worldserver.func_175723_af().func_177746_a(blockpos)) + double dist = field_147369_b.field_71134_c.getBlockReachDistance() + 3; + dist *= dist; -+ if (this.field_147380_r && this.field_147369_b.func_70092_e((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.5D, (double)blockpos.func_177952_p() + 0.5D) < dist && !this.field_147367_d.func_175579_a(worldserver, blockpos, this.field_147369_b) && worldserver.func_175723_af().func_177746_a(blockpos)) ++ if (this.field_184362_y == null && this.field_147369_b.func_70092_e((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.5D, (double)blockpos.func_177952_p() + 0.5D) < dist && !this.field_147367_d.func_175579_a(worldserver, blockpos, this.field_147369_b) && worldserver.func_175723_af().func_177746_a(blockpos)) { -- this.field_147369_b.field_71134_c.func_180236_a(this.field_147369_b, worldserver, itemstack, blockpos, enumfacing, p_147346_1_.func_149573_h(), p_147346_1_.func_149569_i(), p_147346_1_.func_149575_j()); -+ // record block place result so we can update client itemstack size if place event was cancelled. -+ placeResult = this.field_147369_b.field_71134_c.func_180236_a(this.field_147369_b, worldserver, itemstack, blockpos, enumfacing, p_147346_1_.func_149573_h(), p_147346_1_.func_149569_i(), p_147346_1_.func_149575_j()); - } - - flag = true; -@@ -598,12 +617,18 @@ - this.field_147369_b.field_71137_h = true; - this.field_147369_b.field_71071_by.field_70462_a[this.field_147369_b.field_71071_by.field_70461_c] = ItemStack.func_77944_b(this.field_147369_b.field_71071_by.field_70462_a[this.field_147369_b.field_71071_by.field_70461_c]); - Slot slot = this.field_147369_b.field_71070_bA.func_75147_a(this.field_147369_b.field_71071_by, this.field_147369_b.field_71071_by.field_70461_c); -+ int windowId = this.field_147369_b.field_71070_bA.field_75152_c; -+ if (slot == null) // Forge: Fix 'slotless' inventories not selecting a valid slot to update -+ { -+ slot = this.field_147369_b.field_71069_bz.func_75147_a(this.field_147369_b.field_71071_by, this.field_147369_b.field_71071_by.field_70461_c); -+ windowId = this.field_147369_b.field_71069_bz.field_75152_c; -+ } - this.field_147369_b.field_71070_bA.func_75142_b(); - this.field_147369_b.field_71137_h = false; - -- if (!ItemStack.func_77989_b(this.field_147369_b.field_71071_by.func_70448_g(), p_147346_1_.func_149574_g())) -+ if (!ItemStack.func_77989_b(this.field_147369_b.field_71071_by.func_70448_g(), p_147346_1_.func_149574_g()) || !placeResult) // force client itemstack update if place event was cancelled - { -- this.func_147359_a(new S2FPacketSetSlot(this.field_147369_b.field_71070_bA.field_75152_c, slot.field_75222_d, this.field_147369_b.field_71071_by.func_70448_g())); -+ this.func_147359_a(new S2FPacketSetSlot(windowId, slot.field_75222_d, this.field_147369_b.field_71071_by.func_70448_g())); + this.field_147369_b.field_71134_c.func_187251_a(this.field_147369_b, worldserver, itemstack, enumhand, blockpos, enumfacing, p_184337_1_.func_187026_d(), p_184337_1_.func_187025_e(), p_184337_1_.func_187020_f()); } +@@ -689,6 +694,7 @@ + if (itemstack != null && itemstack.field_77994_a == 0) + { + this.field_147369_b.func_184611_a(enumhand, (ItemStack)null); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.field_147369_b, itemstack, enumhand); + itemstack = null; } } -@@ -770,8 +795,10 @@ +@@ -709,6 +715,7 @@ + if (itemstack != null && itemstack.field_77994_a == 0) + { + this.field_147369_b.func_184611_a(enumhand, (ItemStack)null); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.field_147369_b, itemstack, enumhand); + itemstack = null; + } + } +@@ -888,7 +895,9 @@ } else { -- IChatComponent ichatcomponent = new ChatComponentTranslation("chat.type.text", new Object[] {this.field_147369_b.func_145748_c_(), s}); -- this.field_147367_d.func_71203_ab().func_148544_a(ichatcomponent, false); -+ ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", this.field_147369_b.func_145748_c_(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(s)); -+ IChatComponent chat = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1); -+ if (chat == null) return; -+ this.field_147367_d.func_71203_ab().func_148544_a(chat, false); +- ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", new Object[] {this.field_147369_b.func_145748_c_(), s}); ++ ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", this.field_147369_b.func_145748_c_(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(s)); ++ itextcomponent = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, itextcomponent); ++ if (itextcomponent == null) return; + this.field_147367_d.func_184103_al().func_148544_a(itextcomponent, false); } - this.field_147374_l += 20; -@@ -916,7 +943,7 @@ +@@ -1018,6 +1027,7 @@ + { + EnumHand enumhand1 = p_147340_1_.func_186994_b(); + ItemStack itemstack1 = this.field_147369_b.func_184586_b(enumhand1); ++ if(net.minecraftforge.common.ForgeHooks.onInteractEntityAt(field_147369_b, entity, p_147340_1_.func_179712_b(), itemstack1, enumhand1)) return; + entity.func_184199_a(this.field_147369_b, p_147340_1_.func_179712_b(), itemstack1, enumhand1); + } + else if (p_147340_1_.func_149565_c() == CPacketUseEntity.Action.ATTACK) +@@ -1057,7 +1067,7 @@ return; } -- this.field_147369_b = this.field_147367_d.func_71203_ab().func_72368_a(this.field_147369_b, 0, false); -+ this.field_147369_b = this.field_147367_d.func_71203_ab().func_72368_a(this.field_147369_b, field_147369_b.field_71093_bK, false); - } +- this.field_147369_b = this.field_147367_d.func_184103_al().func_72368_a(this.field_147369_b, 0, false); ++ this.field_147369_b = this.field_147367_d.func_184103_al().func_72368_a(this.field_147369_b, field_147369_b.field_71093_bK, false); - break; + if (this.field_147367_d.func_71199_h()) + { diff --git a/patches/minecraft/net/minecraft/network/NetworkManager.java.patch b/patches/minecraft/net/minecraft/network/NetworkManager.java.patch index d865286089..e2a7a2c035 100644 --- a/patches/minecraft/net/minecraft/network/NetworkManager.java.patch +++ b/patches/minecraft/net/minecraft/network/NetworkManager.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/network/NetworkManager.java +++ ../src-work/minecraft/net/minecraft/network/NetworkManager.java -@@ -93,6 +93,11 @@ +@@ -89,6 +89,11 @@ this.field_179294_g = p_i46004_1_; } @@ -12,7 +12,7 @@ public void channelActive(ChannelHandlerContext p_channelActive_1_) throws Exception { super.channelActive(p_channelActive_1_); -@@ -208,7 +213,7 @@ +@@ -205,7 +210,7 @@ final EnumConnectionState enumconnectionstate = EnumConnectionState.func_150752_a(p_150732_1_); final EnumConnectionState enumconnectionstate1 = (EnumConnectionState)this.field_150746_k.attr(field_150739_c).get(); @@ -21,7 +21,7 @@ { field_150735_g.debug("Disabled auto read"); this.field_150746_k.config().setAutoRead(false); -@@ -216,7 +221,7 @@ +@@ -213,7 +218,7 @@ if (this.field_150746_k.eventLoop().inEventLoop()) { @@ -30,7 +30,7 @@ { this.func_150723_a(enumconnectionstate); } -@@ -236,7 +241,7 @@ +@@ -233,7 +238,7 @@ { public void run() { @@ -39,7 +39,7 @@ { NetworkManager.this.func_150723_a(enumconnectionstate); } -@@ -455,6 +460,11 @@ +@@ -452,6 +457,11 @@ } } @@ -50,4 +50,4 @@ + static class InboundHandlerTuplePacketListener { - private final Packet field_150774_a; + private final Packet field_150774_a; diff --git a/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch b/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch index e31f320e9b..76ca4cff80 100644 --- a/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch +++ b/patches/minecraft/net/minecraft/network/NetworkSystem.java.patch @@ -1,11 +1,11 @@ --- ../src-base/minecraft/net/minecraft/network/NetworkSystem.java +++ ../src-work/minecraft/net/minecraft/network/NetworkSystem.java -@@ -115,7 +115,7 @@ +@@ -111,7 +111,7 @@ ; } -- p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"legacy_query", (ChannelHandler)(new PingResponseHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2())).addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2())).addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.CLIENTBOUND))); -+ p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.READ_TIMEOUT))).addLast((String)"legacy_query", (ChannelHandler)(new PingResponseHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new MessageDeserializer2())).addLast((String)"decoder", (ChannelHandler)(new MessageDeserializer(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new MessageSerializer2())).addLast((String)"encoder", (ChannelHandler)(new MessageSerializer(EnumPacketDirection.CLIENTBOUND))); +- p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(30))).addLast((String)"legacy_query", (ChannelHandler)(new LegacyPingHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new NettyVarint21FrameDecoder())).addLast((String)"decoder", (ChannelHandler)(new NettyPacketDecoder(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new NettyVarint21FrameEncoder())).addLast((String)"encoder", (ChannelHandler)(new NettyPacketEncoder(EnumPacketDirection.CLIENTBOUND))); ++ p_initChannel_1_.pipeline().addLast((String)"timeout", (ChannelHandler)(new ReadTimeoutHandler(net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.READ_TIMEOUT))).addLast((String)"legacy_query", (ChannelHandler)(new LegacyPingHandler(NetworkSystem.this))).addLast((String)"splitter", (ChannelHandler)(new NettyVarint21FrameDecoder())).addLast((String)"decoder", (ChannelHandler)(new NettyPacketDecoder(EnumPacketDirection.SERVERBOUND))).addLast((String)"prepender", (ChannelHandler)(new NettyVarint21FrameEncoder())).addLast((String)"encoder", (ChannelHandler)(new NettyPacketEncoder(EnumPacketDirection.CLIENTBOUND))); NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND); NetworkSystem.this.field_151272_f.add(networkmanager); p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager); diff --git a/patches/minecraft/net/minecraft/network/ServerStatusResponse.java.patch b/patches/minecraft/net/minecraft/network/ServerStatusResponse.java.patch index 856c5c869f..388c5ef4b9 100644 --- a/patches/minecraft/net/minecraft/network/ServerStatusResponse.java.patch +++ b/patches/minecraft/net/minecraft/network/ServerStatusResponse.java.patch @@ -1,23 +1,23 @@ --- ../src-base/minecraft/net/minecraft/network/ServerStatusResponse.java +++ ../src-work/minecraft/net/minecraft/network/ServerStatusResponse.java @@ -29,6 +29,7 @@ - public void func_151315_a(IChatComponent p_151315_1_) + public void func_151315_a(ITextComponent p_151315_1_) { this.field_151326_a = p_151315_1_; + invalidateJson(); } - public ServerStatusResponse.PlayerCountData func_151318_b() + public ServerStatusResponse.Players func_151318_b() @@ -39,6 +40,7 @@ - public void func_151319_a(ServerStatusResponse.PlayerCountData p_151319_1_) + public void func_151319_a(ServerStatusResponse.Players p_151319_1_) { this.field_151324_b = p_151319_1_; + invalidateJson(); } - public ServerStatusResponse.MinecraftProtocolVersionIdentifier func_151322_c() + public ServerStatusResponse.Version func_151322_c() @@ -49,11 +51,13 @@ - public void func_151321_a(ServerStatusResponse.MinecraftProtocolVersionIdentifier p_151321_1_) + public void func_151321_a(ServerStatusResponse.Version p_151321_1_) { this.field_151325_c = p_151321_1_; + invalidateJson(); @@ -30,7 +30,7 @@ } public String func_151316_d() -@@ -215,6 +219,7 @@ +@@ -176,6 +180,7 @@ serverstatusresponse.func_151320_a(JsonUtils.func_151200_h(jsonobject, "favicon")); } @@ -38,7 +38,7 @@ return serverstatusresponse; } -@@ -242,7 +247,47 @@ +@@ -203,10 +208,50 @@ jsonobject.addProperty("favicon", p_serialize_1_.func_151316_d()); } @@ -46,7 +46,7 @@ return jsonobject; } } -+ + + private java.util.concurrent.Semaphore mutex = new java.util.concurrent.Semaphore(1); + private String json = null; + /** @@ -69,7 +69,7 @@ + ret = this.json; + if (ret == null) + { -+ ret = net.minecraft.network.status.server.S00PacketServerInfo.field_149297_a.toJson(this); ++ ret = net.minecraft.network.status.server.SPacketServerInfo.field_149297_a.toJson(this); + this.json = ret; + } + mutex.release(); @@ -85,4 +85,7 @@ + { + this.json = null; + } - } ++ + public static class Version + { + private final String field_151306_a; diff --git a/patches/minecraft/net/minecraft/network/play/client/C17PacketCustomPayload.java.patch b/patches/minecraft/net/minecraft/network/play/client/CPacketCustomPayload.java.patch similarity index 74% rename from patches/minecraft/net/minecraft/network/play/client/C17PacketCustomPayload.java.patch rename to patches/minecraft/net/minecraft/network/play/client/CPacketCustomPayload.java.patch index 1345ee1259..b0ba904952 100644 --- a/patches/minecraft/net/minecraft/network/play/client/C17PacketCustomPayload.java.patch +++ b/patches/minecraft/net/minecraft/network/play/client/CPacketCustomPayload.java.patch @@ -1,5 +1,5 @@ ---- ../src-base/minecraft/net/minecraft/network/play/client/C17PacketCustomPayload.java -+++ ../src-work/minecraft/net/minecraft/network/play/client/C17PacketCustomPayload.java +--- ../src-base/minecraft/net/minecraft/network/play/client/CPacketCustomPayload.java ++++ ../src-work/minecraft/net/minecraft/network/play/client/CPacketCustomPayload.java @@ -47,7 +47,11 @@ public void func_148840_b(PacketBuffer p_148840_1_) throws IOException { diff --git a/patches/minecraft/net/minecraft/network/play/server/S3FPacketCustomPayload.java.patch b/patches/minecraft/net/minecraft/network/play/server/SPacketCustomPayload.java.patch similarity index 74% rename from patches/minecraft/net/minecraft/network/play/server/S3FPacketCustomPayload.java.patch rename to patches/minecraft/net/minecraft/network/play/server/SPacketCustomPayload.java.patch index 9604b555aa..01ef581c1f 100644 --- a/patches/minecraft/net/minecraft/network/play/server/S3FPacketCustomPayload.java.patch +++ b/patches/minecraft/net/minecraft/network/play/server/SPacketCustomPayload.java.patch @@ -1,5 +1,5 @@ ---- ../src-base/minecraft/net/minecraft/network/play/server/S3FPacketCustomPayload.java -+++ ../src-work/minecraft/net/minecraft/network/play/server/S3FPacketCustomPayload.java +--- ../src-base/minecraft/net/minecraft/network/play/server/SPacketCustomPayload.java ++++ ../src-work/minecraft/net/minecraft/network/play/server/SPacketCustomPayload.java @@ -46,7 +46,11 @@ public void func_148840_b(PacketBuffer p_148840_1_) throws IOException { diff --git a/patches/minecraft/net/minecraft/network/status/server/S00PacketServerInfo.java.patch b/patches/minecraft/net/minecraft/network/status/server/S00PacketServerInfo.java.patch deleted file mode 100644 index 6e9d12a151..0000000000 --- a/patches/minecraft/net/minecraft/network/status/server/S00PacketServerInfo.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/network/status/server/S00PacketServerInfo.java -+++ ../src-work/minecraft/net/minecraft/network/status/server/S00PacketServerInfo.java -@@ -34,7 +34,7 @@ - - public void func_148840_b(PacketBuffer p_148840_1_) throws IOException - { -- p_148840_1_.func_180714_a(field_149297_a.toJson((Object)this.field_149296_b)); -+ p_148840_1_.func_180714_a(this.field_149296_b.getJson()); - } - - public void func_148833_a(INetHandlerStatusClient p_148833_1_) diff --git a/patches/minecraft/net/minecraft/potion/Potion.java.patch b/patches/minecraft/net/minecraft/potion/Potion.java.patch index 1ee629dcc2..438c3e5d6e 100644 --- a/patches/minecraft/net/minecraft/potion/Potion.java.patch +++ b/patches/minecraft/net/minecraft/potion/Potion.java.patch @@ -1,49 +1,18 @@ --- ../src-base/minecraft/net/minecraft/potion/Potion.java +++ ../src-work/minecraft/net/minecraft/potion/Potion.java -@@ -21,7 +21,7 @@ +@@ -21,9 +21,9 @@ + import net.minecraftforge.fml.relauncher.Side; + import net.minecraftforge.fml.relauncher.SideOnly; - public class Potion +-public class Potion ++public class Potion extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl { -- public static final Potion[] field_76425_a = new Potion[32]; -+ public static final Potion[] field_76425_a = new Potion[256]; - private static final Map field_180150_I = Maps.newHashMap(); - public static final Potion field_180151_b = null; - public static final Potion field_76424_c = (new Potion(1, new ResourceLocation("speed"), false, 8171462)).func_76390_b("potion.moveSpeed").func_76399_b(0, 0).func_111184_a(SharedMonsterAttributes.field_111263_d, "91AEAA56-376B-4498-935B-2F7F68070635", 0.20000000298023224D, 2); -@@ -64,10 +64,10 @@ - private double field_76412_L; - private boolean field_76413_M; - -+ @Deprecated // use the Constructor without potion ID or everything will explode. - protected Potion(int p_i45897_1_, ResourceLocation p_i45897_2_, boolean p_i45897_3_, int p_i45897_4_) - { -- this.field_76415_H = p_i45897_1_; -- field_76425_a[p_i45897_1_] = this; -+ net.minecraftforge.fml.common.registry.GameData.getPotionRegistry().func_177775_a(p_i45897_1_, p_i45897_2_, this); - field_180150_I.put(p_i45897_2_, this); - this.field_76418_K = p_i45897_3_; - -@@ -83,14 +83,18 @@ - this.field_76414_N = p_i45897_4_; - } - -+ protected Potion(ResourceLocation location, boolean badEffect, int potionColor) { -+ this(-1, location, badEffect, potionColor); -+ } -+ - public static Potion func_180142_b(String p_180142_0_) - { -- return (Potion)field_180150_I.get(new ResourceLocation(p_180142_0_)); -+ return net.minecraftforge.fml.common.registry.GameData.getPotionRegistry().func_82594_a(new ResourceLocation(p_180142_0_)); - } - - public static Set func_181168_c() - { -- return field_180150_I.keySet(); -+ return net.minecraftforge.fml.common.registry.GameData.getPotionRegistry().func_148742_b(); - } - - protected Potion func_76399_b(int p_76399_1_, int p_76399_2_) -@@ -230,7 +234,6 @@ +- public static final RegistryNamespaced field_188414_b = new RegistryNamespaced(); ++ public static final RegistryNamespaced field_188414_b = net.minecraftforge.fml.common.registry.GameData.getPotionRegistry(); + private final Map field_111188_I = Maps.newHashMap(); + private final boolean field_76418_K; + private final int field_76414_N; +@@ -195,7 +195,6 @@ return this.field_76417_J; } @@ -51,11 +20,10 @@ public boolean func_76398_f() { return this.field_76418_K; -@@ -310,4 +313,34 @@ - { +@@ -266,7 +265,61 @@ return p_111183_2_.func_111164_d() * (double)(p_111183_1_ + 1); } -+ + + /* ======================================== FORGE START =====================================*/ + + /** @@ -76,6 +44,16 @@ + } + + /** ++ * If the Potion effect should be displayed in the player's ingame HUD ++ * @param effect the active PotionEffect ++ * @return true to display it (default), false to hide it. ++ */ ++ public boolean shouldRenderHUD(PotionEffect effect) ++ { ++ return true; ++ } ++ ++ /** + * Called to draw the this Potion onto the player's inventory when it's active. + * This can be used to e.g. render Potion icons from your own texture. + * @param x the x coordinate @@ -83,6 +61,24 @@ + * @param effect the active PotionEffect + * @param mc the Minecraft instance, for convenience + */ -+ @SideOnly(Side.CLIENT) + @SideOnly(Side.CLIENT) + public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc) { } - } ++ ++ /** ++ * Called to draw the this Potion onto the player's ingame HUD when it's active. ++ * This can be used to e.g. render Potion icons from your own texture. ++ * @param x the x coordinate ++ * @param y the y coordinate ++ * @param effect the active PotionEffect ++ * @param mc the Minecraft instance, for convenience ++ * @param alpha the alpha value, blinks when the potion is about to run out ++ */ ++ @SideOnly(Side.CLIENT) ++ public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha) { } ++ ++ /* ======================================== FORGE END =====================================*/ ++ ++ @SideOnly(Side.CLIENT) + public boolean func_188408_i() + { + return this.field_188415_h; diff --git a/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch b/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch index 8b588f66a6..b68c6378c2 100644 --- a/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch +++ b/patches/minecraft/net/minecraft/potion/PotionEffect.java.patch @@ -1,41 +1,32 @@ --- ../src-base/minecraft/net/minecraft/potion/PotionEffect.java +++ ../src-work/minecraft/net/minecraft/potion/PotionEffect.java -@@ -18,6 +18,8 @@ +@@ -19,6 +19,8 @@ @SideOnly(Side.CLIENT) private boolean field_100013_f; - private boolean field_180156_h; + private boolean field_188421_h; + /** List of ItemStack that can cure the potion effect **/ + private java.util.List curativeItems; - public PotionEffect(int p_i1574_1_, int p_i1574_2_) + public PotionEffect(Potion p_i46811_1_) { -@@ -36,6 +38,8 @@ - this.field_76461_c = p_i45896_3_; - this.field_82724_e = p_i45896_4_; - this.field_180156_h = p_i45896_5_; -+ this.curativeItems = new java.util.ArrayList(); -+ this.curativeItems.add(new net.minecraft.item.ItemStack(net.minecraft.init.Items.field_151117_aB)); - } - - public PotionEffect(PotionEffect p_i1577_1_) -@@ -45,6 +49,7 @@ +@@ -51,6 +53,7 @@ this.field_76461_c = p_i1577_1_.field_76461_c; this.field_82724_e = p_i1577_1_.field_82724_e; - this.field_180156_h = p_i1577_1_.field_180156_h; + this.field_188421_h = p_i1577_1_.field_188421_h; + this.curativeItems = p_i1577_1_.curativeItems; } public void func_76452_a(PotionEffect p_76452_1_) -@@ -190,7 +195,7 @@ +@@ -200,7 +203,7 @@ public static PotionEffect func_82722_b(NBTTagCompound p_82722_0_) { - int i = p_82722_0_.func_74771_c("Id"); -+ int i = p_82722_0_.func_74771_c("Id") & 0xff; ++ int i = p_82722_0_.func_74771_c("Id") & 0xFF; + Potion potion = Potion.func_188412_a(i); - if (i >= 0 && i < Potion.field_76425_a.length && Potion.field_76425_a[i] != null) - { -@@ -223,4 +228,53 @@ + if (potion == null) +@@ -240,4 +243,58 @@ { return this.field_100013_f; } @@ -47,6 +38,11 @@ + */ + public java.util.List getCurativeItems() + { ++ if (this.curativeItems == null) //Lazy load this so that we don't create a circular dep on Items. ++ { ++ this.curativeItems = new java.util.ArrayList(); ++ this.curativeItems.add(new net.minecraft.item.ItemStack(net.minecraft.init.Items.field_151117_aB)); ++ } + return this.curativeItems; + } + @@ -57,7 +53,7 @@ + */ + public boolean isCurativeItem(net.minecraft.item.ItemStack stack) + { -+ for (net.minecraft.item.ItemStack curativeItem : this.curativeItems) ++ for (net.minecraft.item.ItemStack curativeItem : this.getCurativeItems()) + { + if (curativeItem.func_77969_a(stack)) + { @@ -85,7 +81,7 @@ + { + if (!this.isCurativeItem(stack)) + { -+ this.curativeItems.add(stack); ++ this.getCurativeItems().add(stack); + } + } } diff --git a/patches/minecraft/net/minecraft/potion/PotionType.java.patch b/patches/minecraft/net/minecraft/potion/PotionType.java.patch new file mode 100644 index 0000000000..43c7e4b7d1 --- /dev/null +++ b/patches/minecraft/net/minecraft/potion/PotionType.java.patch @@ -0,0 +1,16 @@ +--- ../src-base/minecraft/net/minecraft/potion/PotionType.java ++++ ../src-work/minecraft/net/minecraft/potion/PotionType.java +@@ -8,10 +8,11 @@ + import net.minecraftforge.fml.relauncher.Side; + import net.minecraftforge.fml.relauncher.SideOnly; + +-public class PotionType ++public class PotionType extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl + { ++ @Deprecated // unused + private static final ResourceLocation field_185177_b = new ResourceLocation("water"); +- public static final RegistryNamespacedDefaultedByKey field_185176_a = new RegistryNamespacedDefaultedByKey(field_185177_b); ++ public static final RegistryNamespacedDefaultedByKey field_185176_a = net.minecraftforge.fml.common.registry.GameData.getPotionTypesRegistry(); + private static int field_185178_c; + private final String field_185179_d; + private final ImmutableList field_185180_e; diff --git a/patches/minecraft/net/minecraft/realms/RealmsConnect.java.patch b/patches/minecraft/net/minecraft/realms/RealmsConnect.java.patch index 485a416d0c..cc68754548 100644 --- a/patches/minecraft/net/minecraft/realms/RealmsConnect.java.patch +++ b/patches/minecraft/net/minecraft/realms/RealmsConnect.java.patch @@ -12,8 +12,8 @@ return; } -- RealmsConnect.this.connection.func_179290_a(new C00Handshake(47, p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN)); -+ RealmsConnect.this.connection.func_179290_a(new C00Handshake(47, p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN, true)); +- RealmsConnect.this.connection.func_179290_a(new C00Handshake(107, p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN)); ++ RealmsConnect.this.connection.func_179290_a(new C00Handshake(107, p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN, true)); if (RealmsConnect.this.aborted) { diff --git a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index c8298d70a1..a104654274 100644 --- a/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -1,15 +1,15 @@ --- ../src-base/minecraft/net/minecraft/server/MinecraftServer.java +++ ../src-work/minecraft/net/minecraft/server/MinecraftServer.java -@@ -98,7 +98,7 @@ +@@ -100,7 +100,7 @@ @SideOnly(Side.SERVER) private String field_71320_r; private int field_71319_s = -1; - public WorldServer[] field_71305_c; + public WorldServer[] field_71305_c = new WorldServer[0]; - private ServerConfigurationManager field_71318_t; + private PlayerList field_71318_t; private boolean field_71317_u = true; private boolean field_71316_v; -@@ -115,7 +115,8 @@ +@@ -117,7 +117,8 @@ private int field_71280_D; private int field_143008_E = 0; public final long[] field_71311_j = new long[100]; @@ -19,7 +19,7 @@ private KeyPair field_71292_I; private String field_71293_J; private String field_71294_K; -@@ -227,8 +228,6 @@ +@@ -215,8 +216,6 @@ { this.func_71237_c(p_71247_1_); this.func_71192_d("menu.loadingLevel"); @@ -28,7 +28,7 @@ ISaveHandler isavehandler = this.field_71310_m.func_75804_a(p_71247_1_, true); this.func_175584_a(this.func_71270_I(), isavehandler); WorldInfo worldinfo = isavehandler.func_75757_d(); -@@ -259,47 +258,21 @@ +@@ -247,47 +246,21 @@ worldsettings = new WorldSettings(worldinfo); } @@ -84,7 +84,7 @@ this.func_147139_a(this.func_147135_j()); this.func_71222_d(); } -@@ -314,7 +287,7 @@ +@@ -302,7 +275,7 @@ this.func_71192_d("menu.generatingTerrain"); int j1 = 0; field_147145_h.info("Preparing start region for level " + j1); @@ -93,40 +93,32 @@ BlockPos blockpos = worldserver.func_175694_M(); long k1 = func_130071_aq(); -@@ -403,7 +376,7 @@ - - public void func_71260_j() - { -- if (!this.field_71290_O) -+ if (!this.field_71290_O && net.minecraftforge.fml.common.Loader.instance().hasReachedState(net.minecraftforge.fml.common.LoaderState.SERVER_STARTED) && !field_71316_v) // make sure the save is valid and we don't save twice - { - field_147145_h.info("Stopping server"); - -@@ -427,8 +400,15 @@ - for (int i = 0; i < this.field_71305_c.length; ++i) +@@ -420,9 +393,15 @@ + { + if (this.field_71305_c[j] != null) { - WorldServer worldserver = this.field_71305_c[i]; -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(worldserver)); - worldserver.func_73041_k(); - } -+ -+ WorldServer[] tmp = field_71305_c; -+ for (WorldServer world : tmp) -+ { -+ net.minecraftforge.common.DimensionManager.setWorld(world.field_73011_w.func_177502_q(), null); -+ } ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(this.field_71305_c[j])); } + this.field_71305_c[j].func_73041_k(); +- } } ++ ++ WorldServer[] tmp = field_71305_c; ++ for (WorldServer world : tmp) ++ { ++ net.minecraftforge.common.DimensionManager.setWorld(world.field_73011_w.getDimension(), null, this); ++ } + } - if (this.field_71307_n.func_76468_d()) -@@ -460,6 +440,7 @@ + if (this.field_71307_n.func_76468_d()) +@@ -447,6 +426,7 @@ { if (this.func_71197_b()) { + net.minecraftforge.fml.common.FMLCommonHandler.instance().handleServerStarted(); this.field_175591_ab = func_130071_aq(); long i = 0L; - this.field_147147_p.func_151315_a(new ChatComponentText(this.field_71286_C)); -@@ -504,12 +485,20 @@ + this.field_147147_p.func_151315_a(new TextComponentString(this.field_71286_C)); +@@ -491,12 +471,20 @@ Thread.sleep(Math.max(1L, 50L - i)); this.field_71296_Q = true; } @@ -147,7 +139,7 @@ catch (Throwable throwable1) { field_147145_h.error("Encountered an unexpected exception", throwable1); -@@ -535,14 +524,15 @@ +@@ -522,14 +510,15 @@ field_147145_h.error("We were unable to save this crash report to disk."); } @@ -164,7 +156,7 @@ } catch (Throwable throwable) { -@@ -550,6 +540,8 @@ +@@ -537,6 +526,8 @@ } finally { @@ -173,7 +165,7 @@ this.func_71240_o(); } } -@@ -599,6 +591,7 @@ +@@ -604,6 +595,7 @@ public void func_71217_p() { long i = System.nanoTime(); @@ -181,7 +173,7 @@ ++this.field_71315_w; if (this.field_71295_T) -@@ -625,6 +618,7 @@ +@@ -630,6 +622,7 @@ Collections.shuffle(Arrays.asList(agameprofile)); this.field_147147_p.func_151318_b().func_151330_a(agameprofile); @@ -189,7 +181,7 @@ } if (this.field_71315_w % 900 == 0) -@@ -652,6 +646,7 @@ +@@ -657,6 +650,7 @@ this.field_71304_b.func_76319_b(); this.field_71304_b.func_76319_b(); @@ -197,7 +189,7 @@ } public void func_71190_q() -@@ -667,14 +662,17 @@ +@@ -672,14 +666,17 @@ } this.field_71304_b.func_76318_c("levels"); @@ -218,7 +210,7 @@ this.field_71304_b.func_76320_a(worldserver.func_72912_H().func_76065_j()); if (this.field_71315_w % 20 == 0) -@@ -685,6 +683,7 @@ +@@ -690,6 +687,7 @@ } this.field_71304_b.func_76320_a("tick"); @@ -226,7 +218,7 @@ try { -@@ -708,6 +707,7 @@ +@@ -713,6 +711,7 @@ throw new ReportedException(crashreport1); } @@ -234,7 +226,7 @@ this.field_71304_b.func_76319_b(); this.field_71304_b.func_76320_a("tracker"); worldserver.func_73039_n().func_72788_a(); -@@ -715,9 +715,11 @@ +@@ -720,9 +719,11 @@ this.field_71304_b.func_76319_b(); } @@ -247,7 +239,7 @@ this.field_71304_b.func_76318_c("connection"); this.func_147137_ag().func_151269_c(); this.field_71304_b.func_76318_c("players"); -@@ -739,6 +741,7 @@ +@@ -744,6 +745,7 @@ public void func_71256_s() { @@ -255,7 +247,7 @@ this.field_175590_aa = new Thread(this, "Server thread"); this.field_175590_aa.start(); } -@@ -755,7 +758,13 @@ +@@ -760,7 +762,13 @@ public WorldServer func_71218_a(int p_71218_1_) { @@ -270,7 +262,7 @@ } public String func_71249_w() -@@ -785,7 +794,7 @@ +@@ -790,7 +798,7 @@ public String getServerModName() { @@ -279,11 +271,3 @@ } public CrashReport func_71230_b(CrashReport p_71230_1_) -@@ -996,6 +1005,7 @@ - - if (worldserver != null) - { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(worldserver)); - worldserver.func_73041_k(); - } - } diff --git a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch index c0eff5da96..d750cdb466 100644 --- a/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -1,14 +1,14 @@ --- ../src-base/minecraft/net/minecraft/server/dedicated/DedicatedServer.java +++ ../src-work/minecraft/net/minecraft/server/dedicated/DedicatedServer.java -@@ -49,6 +49,7 @@ +@@ -56,6 +56,7 @@ private boolean field_71338_p; private WorldSettings.GameType field_71337_q; private boolean field_71335_s; + public static boolean allowPlayerLogins = false; - public DedicatedServer(File p_i1508_1_) + public DedicatedServer(File p_i47086_1_, DataFixer p_i47086_2_, YggdrasilAuthenticationService p_i47086_3_, MinecraftSessionService p_i47086_4_, GameProfileRepository p_i47086_5_, PlayerProfileCache p_i47086_6_) { -@@ -82,6 +83,7 @@ +@@ -89,6 +90,7 @@ { public void run() { @@ -16,7 +16,7 @@ BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in)); String s4; -@@ -107,6 +109,8 @@ +@@ -114,6 +116,8 @@ field_155771_h.warn("To start the server with more ram, launch it as \"java -Xmx1024M -Xms1024M -jar minecraft_server.jar\""); } @@ -25,23 +25,23 @@ field_155771_h.info("Loading properties"); this.field_71340_o = new PropertyManager(new File("server.properties")); this.field_154332_n = new ServerEula(new File("eula.txt")); -@@ -198,6 +202,7 @@ +@@ -205,6 +209,7 @@ } else { + net.minecraftforge.fml.common.FMLCommonHandler.instance().onServerStarted(); - this.func_152361_a(new DedicatedPlayerList(this)); + this.func_184105_a(new DedicatedPlayerList(this)); long j = System.nanoTime(); -@@ -244,6 +249,7 @@ - this.func_71191_d((this.func_71207_Z() + 8) / 16 * 16); - this.func_71191_d(MathHelper.func_76125_a(this.func_71207_Z(), 64, 256)); - this.field_71340_o.func_73667_a("max-build-height", Integer.valueOf(this.func_71207_Z())); +@@ -254,6 +259,7 @@ + TileEntitySkull.func_184293_a(this.func_152358_ax()); + TileEntitySkull.func_184294_a(this.func_147130_as()); + PlayerProfileCache.func_187320_a(this.func_71266_T()); + if (!net.minecraftforge.fml.common.FMLCommonHandler.instance().handleServerAboutToStart(this)) return false; field_155771_h.info("Preparing level \"" + this.func_71270_I() + "\""); this.func_71247_a(this.func_71270_I(), this.func_71270_I(), k, worldtype, s2); long i1 = System.nanoTime() - j; -@@ -272,7 +278,7 @@ +@@ -282,7 +288,7 @@ thread1.start(); } @@ -50,11 +50,13 @@ } } } -@@ -621,4 +627,7 @@ - this.field_71321_q.func_71556_a(RConConsoleSource.func_175570_h(), p_71252_1_); - return RConConsoleSource.func_175570_h().func_70008_c(); +@@ -580,6 +586,9 @@ + return this.field_71340_o.func_73669_a("network-compression-threshold", super.func_175577_aI()); } -+ + + //Forge: Enable formated text for colors in console. -+ @Override public void func_145747_a(net.minecraft.util.IChatComponent message) { field_155771_h.info(message.func_150254_d()); } - } ++ @Override public void func_145747_a(net.minecraft.util.text.ITextComponent message) { field_155771_h.info(message.func_150254_d()); } ++ + protected boolean func_152368_aE() throws IOException + { + boolean flag = false; diff --git a/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch b/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch index 06a26df6ee..8b9416cb1f 100644 --- a/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch +++ b/patches/minecraft/net/minecraft/server/gui/MinecraftServerGui.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/server/gui/MinecraftServerGui.java +++ ../src-work/minecraft/net/minecraft/server/gui/MinecraftServerGui.java -@@ -78,6 +78,7 @@ +@@ -77,6 +77,7 @@ System.exit(0); } }); @@ -8,7 +8,7 @@ } public MinecraftServerGui(DedicatedServer p_i2362_1_) -@@ -162,8 +163,13 @@ +@@ -161,8 +162,13 @@ return jpanel; } diff --git a/patches/minecraft/net/minecraft/server/integrated/IntegratedServer.java.patch b/patches/minecraft/net/minecraft/server/integrated/IntegratedServer.java.patch index 7962cb7aca..473fa124d4 100644 --- a/patches/minecraft/net/minecraft/server/integrated/IntegratedServer.java.patch +++ b/patches/minecraft/net/minecraft/server/integrated/IntegratedServer.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/server/integrated/IntegratedServer.java +++ ../src-work/minecraft/net/minecraft/server/integrated/IntegratedServer.java -@@ -71,8 +71,6 @@ +@@ -68,8 +68,6 @@ protected void func_71247_a(String p_71247_1_, String p_71247_2_, long p_71247_3_, WorldType p_71247_5_, String p_71247_6_) { this.func_71237_c(p_71247_1_); @@ -9,20 +9,19 @@ ISaveHandler isavehandler = this.func_71254_M().func_75804_a(p_71247_1_, true); this.func_175584_a(this.func_71270_I(), isavehandler); WorldInfo worldinfo = isavehandler.func_75757_d(); -@@ -86,44 +84,24 @@ +@@ -83,44 +81,23 @@ worldinfo.func_76062_a(p_71247_2_); } - for (int i = 0; i < this.field_71305_c.length; ++i) -- { -- int j = 0; + WorldServer overWorld = (func_71242_L() ? (WorldServer)(new DemoWorldServer(this, isavehandler, worldinfo, 0, this.field_71304_b)).func_175643_b() : + (WorldServer)(new WorldServer(this, isavehandler, worldinfo, 0, this.field_71304_b)).func_175643_b()); + overWorld.func_72963_a(this.field_71350_m); - -- if (i == 1) + for (int dim : net.minecraftforge.common.DimensionManager.getStaticDimensionIDs()) -+ { + { +- int j = 0; +- +- if (i == 1) + WorldServer world = (dim == 0 ? overWorld : (WorldServer)(new WorldServerMulti(this, isavehandler, dim, overWorld, this.field_71304_b)).func_175643_b()); + world.func_72954_a(new WorldManager(this, world)); + if (!this.func_71264_H()) @@ -58,15 +57,15 @@ + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(world)); } -- this.func_71203_ab().func_72364_a(this.field_71305_c); -+ this.func_71203_ab().func_72364_a(new WorldServer[]{ overWorld }); +- this.func_184103_al().func_72364_a(this.field_71305_c); ++ this.func_184103_al().func_72364_a(new WorldServer[]{ overWorld }); - if (this.field_71305_c[0].func_72912_H().func_176130_y() == null) + if (overWorld.func_72912_H().func_176130_y() == null) { this.func_147139_a(this.field_71349_l.field_71474_y.field_74318_M); } -@@ -141,9 +119,10 @@ +@@ -138,9 +115,10 @@ this.func_71245_h(true); field_147148_h.info("Generating keypair"); this.func_71253_a(CryptManager.func_75891_b()); @@ -78,7 +77,7 @@ } public void func_71217_p() -@@ -216,6 +195,7 @@ +@@ -213,6 +191,7 @@ public EnumDifficulty func_147135_j() { diff --git a/patches/minecraft/net/minecraft/server/management/ItemInWorldManager.java.patch b/patches/minecraft/net/minecraft/server/management/ItemInWorldManager.java.patch deleted file mode 100644 index 3114e1a6a9..0000000000 --- a/patches/minecraft/net/minecraft/server/management/ItemInWorldManager.java.patch +++ /dev/null @@ -1,266 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/server/management/ItemInWorldManager.java -+++ ../src-work/minecraft/net/minecraft/server/management/ItemInWorldManager.java -@@ -22,6 +22,8 @@ - - public class ItemInWorldManager - { -+ /** Forge reach distance */ -+ private double blockReachDistance = 5.0d; - public World field_73092_a; - public EntityPlayerMP field_73090_b; - private WorldSettings.GameType field_73091_c = WorldSettings.GameType.NOT_SET; -@@ -116,7 +118,7 @@ - else - { - int k = this.field_73100_i - this.field_73089_e; -- float f1 = block1.func_180647_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180241_i) * (float)(k + 1); -+ float f1 = block1.func_180647_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180240_f) * (float)(k + 1); //Forge: Fix network break progress using wrong position - int l = (int)(f1 * 10.0F); - - if (l != this.field_73094_o) -@@ -130,6 +132,14 @@ - - public void func_180784_a(BlockPos p_180784_1_, EnumFacing p_180784_2_) - { -+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_73090_b, -+ net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, field_73092_a, p_180784_1_, p_180784_2_, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(field_73090_b, getBlockReachDistance() + 1)); -+ if (event.isCanceled()) -+ { -+ field_73090_b.field_71135_a.func_147359_a(new S23PacketBlockChange(field_73092_a, p_180784_1_)); -+ return; -+ } -+ - if (this.func_73083_d()) - { - if (!this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_)) -@@ -164,18 +174,35 @@ - } - } - -- this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_); -+ // - this.field_73089_e = this.field_73100_i; - float f = 1.0F; - -- if (block.func_149688_o() != Material.field_151579_a) -+ if (!block.isAir(field_73092_a, p_180784_1_)) - { -- block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b); -+ if (event.useBlock != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) -+ { -+ block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b); -+ this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_); -+ } -+ else -+ { -+ field_73090_b.field_71135_a.func_147359_a(new S23PacketBlockChange(field_73092_a, p_180784_1_)); -+ } - f = block.func_180647_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_180784_1_); - } - -- if (block.func_149688_o() != Material.field_151579_a && f >= 1.0F) -+ if (event.useItem == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) - { -+ if (f >= 1.0F) -+ { -+ field_73090_b.field_71135_a.func_147359_a(new S23PacketBlockChange(field_73092_a, p_180784_1_)); -+ } -+ return; -+ } -+ -+ if (!block.isAir(field_73092_a, p_180784_1_) && f >= 1.0F) -+ { - this.func_180237_b(p_180784_1_); - } - else -@@ -196,7 +223,7 @@ - int i = this.field_73100_i - this.field_73089_e; - Block block = this.field_73092_a.func_180495_p(p_180785_1_).func_177230_c(); - -- if (block.func_149688_o() != Material.field_151579_a) -+ if (!block.isAir(field_73092_a, p_180785_1_)) - { - float f = block.func_180647_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_180785_1_) * (float)(i + 1); - -@@ -225,9 +252,13 @@ - - private boolean func_180235_c(BlockPos p_180235_1_) - { -+ return removeBlock(p_180235_1_, false); -+ } -+ private boolean removeBlock(BlockPos p_180235_1_, boolean canHarvest) -+ { - IBlockState iblockstate = this.field_73092_a.func_180495_p(p_180235_1_); - iblockstate.func_177230_c().func_176208_a(this.field_73092_a, p_180235_1_, iblockstate, this.field_73090_b); -- boolean flag = this.field_73092_a.func_175698_g(p_180235_1_); -+ boolean flag = iblockstate.func_177230_c().removedByPlayer(field_73092_a, p_180235_1_, field_73090_b, canHarvest); - - if (flag) - { -@@ -239,7 +270,8 @@ - - public boolean func_180237_b(BlockPos p_180237_1_) - { -- if (this.field_73091_c.func_77145_d() && this.field_73090_b.func_70694_bm() != null && this.field_73090_b.func_70694_bm().func_77973_b() instanceof ItemSword) -+ int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(field_73092_a, field_73091_c, field_73090_b, p_180237_1_); -+ if (exp == -1) - { - return false; - } -@@ -248,40 +280,21 @@ - IBlockState iblockstate = this.field_73092_a.func_180495_p(p_180237_1_); - TileEntity tileentity = this.field_73092_a.func_175625_s(p_180237_1_); - -- if (this.field_73091_c.func_82752_c()) -- { -- if (this.field_73091_c == WorldSettings.GameType.SPECTATOR) -- { -- return false; -- } -+ ItemStack stack = field_73090_b.func_71045_bC(); -+ if (stack != null && stack.func_77973_b().onBlockStartBreak(stack, p_180237_1_, field_73090_b)) return false; - -- if (!this.field_73090_b.func_175142_cm()) -- { -- ItemStack itemstack = this.field_73090_b.func_71045_bC(); -- -- if (itemstack == null) -- { -- return false; -- } -- -- if (!itemstack.func_179544_c(iblockstate.func_177230_c())) -- { -- return false; -- } -- } -- } -- - this.field_73092_a.func_180498_a(this.field_73090_b, 2001, p_180237_1_, Block.func_176210_f(iblockstate)); -- boolean flag1 = this.func_180235_c(p_180237_1_); -+ boolean flag1 = false; - - if (this.func_73083_d()) - { -+ flag1 = this.func_180235_c(p_180237_1_); - this.field_73090_b.field_71135_a.func_147359_a(new S23PacketBlockChange(this.field_73092_a, p_180237_1_)); - } - else - { - ItemStack itemstack1 = this.field_73090_b.func_71045_bC(); -- boolean flag = this.field_73090_b.func_146099_a(iblockstate.func_177230_c()); -+ boolean flag = iblockstate.func_177230_c().canHarvestBlock(field_73092_a, p_180237_1_, field_73090_b); - - if (itemstack1 != null) - { -@@ -293,12 +306,18 @@ - } - } - -+ flag1 = this.removeBlock(p_180237_1_, flag); - if (flag1 && flag) - { - iblockstate.func_177230_c().func_180657_a(this.field_73092_a, this.field_73090_b, p_180237_1_, iblockstate, tileentity); - } - } - -+ // Drop experiance -+ if (!this.func_73083_d() && flag1 && exp > 0) -+ { -+ iblockstate.func_177230_c().func_180637_b(field_73092_a, p_180237_1_, exp); -+ } - return flag1; - } - } -@@ -332,6 +351,7 @@ - if (itemstack.field_77994_a == 0) - { - p_73085_1_.field_71071_by.field_70462_a[p_73085_1_.field_71071_by.field_70461_c] = null; -+ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_73085_1_, itemstack); - } - - if (!p_73085_1_.func_71039_bw()) -@@ -380,33 +400,51 @@ - } - else - { -- if (!p_180236_1_.func_70093_af() || p_180236_1_.func_70694_bm() == null) -+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(p_180236_1_, -+ net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, p_180236_2_, p_180236_4_, p_180236_5_, new net.minecraft.util.Vec3(p_180236_6_, p_180236_7_, p_180236_8_)); -+ if (event.isCanceled()) - { -- IBlockState iblockstate = p_180236_2_.func_180495_p(p_180236_4_); -- -- if (iblockstate.func_177230_c().func_180639_a(p_180236_2_, p_180236_4_, iblockstate, p_180236_1_, p_180236_5_, p_180236_6_, p_180236_7_, p_180236_8_)) -- { -- return true; -- } -+ field_73090_b.field_71135_a.func_147359_a(new S23PacketBlockChange(field_73092_a, p_180236_4_)); -+ return false; - } - -- if (p_180236_3_ == null) -+ if (p_180236_3_ != null && p_180236_3_.func_77973_b().onItemUseFirst(p_180236_3_, p_180236_1_, p_180236_2_, p_180236_4_, p_180236_5_, p_180236_6_, p_180236_7_, p_180236_8_)) - { -- return false; -+ if (p_180236_3_.field_77994_a <= 0) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(field_73090_b, p_180236_3_); -+ return true; - } -- else if (this.func_73083_d()) -+ -+ IBlockState iblockstate = p_180236_2_.func_180495_p(p_180236_4_); -+ boolean isAir = p_180236_2_.func_175623_d(p_180236_4_); -+ boolean useBlock = !p_180236_1_.func_70093_af() || p_180236_1_.func_70694_bm() == null; -+ if (!useBlock) useBlock = p_180236_1_.func_70694_bm().func_77973_b().doesSneakBypassUse(p_180236_2_, p_180236_4_, p_180236_1_); -+ boolean result = false; -+ -+ if (useBlock) - { -- int j = p_180236_3_.func_77960_j(); -- int i = p_180236_3_.field_77994_a; -- boolean flag = p_180236_3_.func_179546_a(p_180236_1_, p_180236_2_, p_180236_4_, p_180236_5_, p_180236_6_, p_180236_7_, p_180236_8_); -- p_180236_3_.func_77964_b(j); -- p_180236_3_.field_77994_a = i; -- return flag; -+ if (event.useBlock != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) -+ { -+ result = iblockstate.func_177230_c().func_180639_a(p_180236_2_, p_180236_4_, iblockstate, p_180236_1_, p_180236_5_, p_180236_6_, p_180236_7_, p_180236_8_); -+ } -+ else -+ { -+ field_73090_b.field_71135_a.func_147359_a(new S23PacketBlockChange(field_73092_a, p_180236_4_)); -+ result = event.useItem != net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW; -+ } - } -- else -+ if (p_180236_3_ != null && !result && event.useItem != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) - { -- return p_180236_3_.func_179546_a(p_180236_1_, p_180236_2_, p_180236_4_, p_180236_5_, p_180236_6_, p_180236_7_, p_180236_8_); -+ int meta = p_180236_3_.func_77960_j(); -+ int size = p_180236_3_.field_77994_a; -+ result = p_180236_3_.func_179546_a(p_180236_1_, p_180236_2_, p_180236_4_, p_180236_5_, p_180236_6_, p_180236_7_, p_180236_8_); -+ if (func_73083_d()) -+ { -+ p_180236_3_.func_77964_b(meta); -+ p_180236_3_.field_77994_a = size; -+ } -+ if (p_180236_3_.field_77994_a <= 0) net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(field_73090_b, p_180236_3_); - } -+ return result; - } - } - -@@ -414,4 +452,13 @@ - { - this.field_73092_a = p_73080_1_; - } -+ -+ public double getBlockReachDistance() -+ { -+ return blockReachDistance; -+ } -+ public void setBlockReachDistance(double distance) -+ { -+ blockReachDistance = distance; -+ } - } diff --git a/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch b/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch new file mode 100644 index 0000000000..623e191d2f --- /dev/null +++ b/patches/minecraft/net/minecraft/server/management/PlayerInteractionManager.java.patch @@ -0,0 +1,284 @@ +--- ../src-base/minecraft/net/minecraft/server/management/PlayerInteractionManager.java ++++ ../src-work/minecraft/net/minecraft/server/management/PlayerInteractionManager.java +@@ -27,6 +27,8 @@ + + public class PlayerInteractionManager + { ++ /** Forge reach distance */ ++ private double blockReachDistance = 5.0d; + public World field_73092_a; + public EntityPlayerMP field_73090_b; + private WorldSettings.GameType field_73091_c = WorldSettings.GameType.NOT_SET; +@@ -88,7 +90,7 @@ + IBlockState iblockstate = this.field_73092_a.func_180495_p(this.field_180241_i); + Block block = iblockstate.func_177230_c(); + +- if (iblockstate.func_185904_a() == Material.field_151579_a) ++ if (block.isAir(iblockstate, field_73092_a, field_180241_i)) + { + this.field_73097_j = false; + } +@@ -115,7 +117,7 @@ + IBlockState iblockstate1 = this.field_73092_a.func_180495_p(this.field_180240_f); + Block block1 = iblockstate1.func_177230_c(); + +- if (iblockstate1.func_185904_a() == Material.field_151579_a) ++ if (block1.isAir(iblockstate1, field_73092_a, field_180240_f)) + { + this.field_73092_a.func_175715_c(this.field_73090_b.func_145782_y(), this.field_180240_f, -1); + this.field_73094_o = -1; +@@ -124,7 +126,7 @@ + else + { + int k = this.field_73100_i - this.field_73089_e; +- float f1 = iblockstate1.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180241_i) * (float)(k + 1); ++ float f1 = iblockstate1.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180240_f) * (float)(k + 1); // Forge: Fix network break progress using wrong position + int l = (int)(f1 * 10.0F); + + if (l != this.field_73094_o) +@@ -138,6 +140,15 @@ + + public void func_180784_a(BlockPos p_180784_1_, EnumFacing p_180784_2_) + { ++ net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock event = net.minecraftforge.common.ForgeHooks.onLeftClickBlock(field_73090_b, p_180784_1_, p_180784_2_, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(field_73090_b, getBlockReachDistance() + 1)); ++ if (event.isCanceled()) ++ { ++ // Restore block and te data ++ field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(field_73092_a, p_180784_1_)); ++ field_73092_a.func_184138_a(p_180784_1_, field_73092_a.func_180495_p(p_180784_1_), field_73092_a.func_180495_p(p_180784_1_), 3); ++ return; ++ } ++ + if (this.func_73083_d()) + { + if (!this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_)) +@@ -173,17 +184,36 @@ + } + } + +- this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_); + this.field_73089_e = this.field_73100_i; + float f = 1.0F; + +- if (iblockstate.func_185904_a() != Material.field_151579_a) ++ if (!iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180784_1_)) + { +- block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b); ++ if (event.getUseBlock() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) ++ { ++ block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b); ++ this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_); ++ } ++ else ++ { ++ // Restore block and te data ++ field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(field_73092_a, p_180784_1_)); ++ field_73092_a.func_184138_a(p_180784_1_, field_73092_a.func_180495_p(p_180784_1_), field_73092_a.func_180495_p(p_180784_1_), 3); ++ } + f = iblockstate.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_180784_1_); + } ++ if (event.getUseItem() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) ++ { ++ if (f >= 1.0F) ++ { ++ // Restore block and te data ++ field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(field_73092_a, p_180784_1_)); ++ field_73092_a.func_184138_a(p_180784_1_, field_73092_a.func_180495_p(p_180784_1_), field_73092_a.func_180495_p(p_180784_1_), 3); ++ } ++ return; ++ } + +- if (iblockstate.func_185904_a() != Material.field_151579_a && f >= 1.0F) ++ if (!iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180784_1_) && f >= 1.0F) + { + this.func_180237_b(p_180784_1_); + } +@@ -205,7 +235,7 @@ + int i = this.field_73100_i - this.field_73089_e; + IBlockState iblockstate = this.field_73092_a.func_180495_p(p_180785_1_); + +- if (iblockstate.func_185904_a() != Material.field_151579_a) ++ if (!iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180785_1_)) + { + float f = iblockstate.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_180785_1_) * (float)(i + 1); + +@@ -234,13 +264,17 @@ + + private boolean func_180235_c(BlockPos p_180235_1_) + { +- IBlockState iblockstate = this.field_73092_a.func_180495_p(p_180235_1_); +- iblockstate.func_177230_c().func_176208_a(this.field_73092_a, p_180235_1_, iblockstate, this.field_73090_b); +- boolean flag = this.field_73092_a.func_175698_g(p_180235_1_); ++ return removeBlock(p_180235_1_, false); ++ } + ++ private boolean removeBlock(BlockPos pos, boolean canHarvest) ++ { ++ IBlockState iblockstate = this.field_73092_a.func_180495_p(pos); ++ boolean flag = iblockstate.func_177230_c().removedByPlayer(iblockstate, field_73092_a, pos, field_73090_b, canHarvest); ++ + if (flag) + { +- iblockstate.func_177230_c().func_176206_d(this.field_73092_a, p_180235_1_, iblockstate); ++ iblockstate.func_177230_c().func_176206_d(this.field_73092_a, pos, iblockstate); + } + + return flag; +@@ -248,7 +282,8 @@ + + public boolean func_180237_b(BlockPos p_180237_1_) + { +- if (this.field_73091_c.func_77145_d() && this.field_73090_b.func_184614_ca() != null && this.field_73090_b.func_184614_ca().func_77973_b() instanceof ItemSword) ++ int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(field_73092_a, field_73091_c, field_73090_b, p_180237_1_); ++ if (exp == -1) + { + return false; + } +@@ -264,41 +299,22 @@ + } + else + { +- if (this.field_73091_c.func_82752_c()) +- { +- if (this.field_73091_c == WorldSettings.GameType.SPECTATOR) +- { +- return false; +- } ++ ItemStack stack = field_73090_b.func_184614_ca(); ++ if (stack != null && stack.func_77973_b().onBlockStartBreak(stack, p_180237_1_, field_73090_b)) return false; + +- if (!this.field_73090_b.func_175142_cm()) +- { +- ItemStack itemstack = this.field_73090_b.func_184614_ca(); +- +- if (itemstack == null) +- { +- return false; +- } +- +- if (!itemstack.func_179544_c(iblockstate.func_177230_c())) +- { +- return false; +- } +- } +- } +- + this.field_73092_a.func_180498_a(this.field_73090_b, 2001, p_180237_1_, Block.func_176210_f(iblockstate)); +- boolean flag1 = this.func_180235_c(p_180237_1_); ++ boolean flag1 = false; + + if (this.func_73083_d()) + { ++ flag1 = this.func_180235_c(p_180237_1_); + this.field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(this.field_73092_a, p_180237_1_)); + } + else + { + ItemStack itemstack1 = this.field_73090_b.func_184614_ca(); + ItemStack itemstack2 = itemstack1 == null ? null : itemstack1.func_77946_l(); +- boolean flag = this.field_73090_b.func_184823_b(iblockstate); ++ boolean flag = iblockstate.func_177230_c().canHarvestBlock(field_73092_a, p_180237_1_, field_73090_b); + + if (itemstack1 != null) + { +@@ -310,12 +326,18 @@ + } + } + ++ flag1 = this.removeBlock(p_180237_1_, flag); + if (flag1 && flag) + { + iblockstate.func_177230_c().func_180657_a(this.field_73092_a, this.field_73090_b, p_180237_1_, iblockstate, tileentity, itemstack2); + } + } + ++ // Drop experience ++ if (!this.func_73083_d() && flag1 && exp > 0) ++ { ++ iblockstate.func_177230_c().func_180637_b(field_73092_a, p_180237_1_, exp); ++ } + return flag1; + } + } +@@ -333,6 +355,7 @@ + } + else + { ++ if (net.minecraftforge.common.ForgeHooks.onItemRightClick(p_187250_1_, p_187250_4_, p_187250_3_)) return net.minecraft.util.EnumActionResult.PASS; + int i = p_187250_3_.field_77994_a; + int j = p_187250_3_.func_77960_j(); + ActionResult actionresult = p_187250_3_.func_77957_a(p_187250_2_, p_187250_1_, p_187250_4_); +@@ -359,6 +382,7 @@ + if (itemstack.field_77994_a == 0) + { + p_187250_1_.func_184611_a(p_187250_4_, (ItemStack)null); ++ net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(p_187250_1_, itemstack, p_187250_4_); + } + + if (!p_187250_1_.func_184587_cr()) +@@ -403,13 +427,26 @@ + } + else + { +- if (!p_187251_1_.func_70093_af() || p_187251_1_.func_184614_ca() == null && p_187251_1_.func_184592_cb() == null) ++ net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock event = net.minecraftforge.common.ForgeHooks ++ .onRightClickBlock(p_187251_1_, p_187251_4_, p_187251_3_, p_187251_5_, p_187251_6_, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(field_73090_b, getBlockReachDistance() + 1)); ++ if (event.isCanceled()) return EnumActionResult.PASS; ++ ++ net.minecraft.item.Item item = p_187251_3_ == null ? null : p_187251_3_.func_77973_b(); ++ EnumActionResult ret = item == null ? EnumActionResult.PASS : item.onItemUseFirst(p_187251_3_, p_187251_1_, p_187251_2_, p_187251_5_, p_187251_6_, p_187251_7_, p_187251_8_, p_187251_9_, p_187251_4_); ++ if (ret != EnumActionResult.PASS) return ret; ++ ++ boolean bypass = true; ++ for (ItemStack s : new ItemStack[]{p_187251_1_.func_184614_ca(), p_187251_1_.func_184592_cb()}) //TODO: Expand to more hands? player.inv.getHands()? ++ bypass = bypass && (s == null || s.func_77973_b().doesSneakBypassUse(s, p_187251_2_, p_187251_5_, p_187251_1_)); ++ EnumActionResult result = EnumActionResult.PASS; ++ ++ if (!p_187251_1_.func_70093_af() || bypass || event.getUseBlock() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW) + { + IBlockState iblockstate = p_187251_2_.func_180495_p(p_187251_5_); +- ++ if(event.getUseBlock() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) + if (iblockstate.func_177230_c().func_180639_a(p_187251_2_, p_187251_5_, iblockstate, p_187251_1_, p_187251_4_, p_187251_3_, p_187251_6_, p_187251_7_, p_187251_8_, p_187251_9_)) + { +- return EnumActionResult.SUCCESS; ++ result = EnumActionResult.SUCCESS; + } + } + +@@ -429,14 +466,21 @@ + { + int j = p_187251_3_.func_77960_j(); + int i = p_187251_3_.field_77994_a; ++ if (result != EnumActionResult.SUCCESS && event.getUseItem() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY ++ || result == EnumActionResult.SUCCESS && event.getUseItem() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW) { + EnumActionResult enumactionresult = p_187251_3_.func_179546_a(p_187251_1_, p_187251_2_, p_187251_5_, p_187251_4_, p_187251_6_, p_187251_7_, p_187251_8_, p_187251_9_); + p_187251_3_.func_77964_b(j); + p_187251_3_.field_77994_a = i; + return enumactionresult; ++ } else return result; ++ + } + else + { ++ if (result != EnumActionResult.SUCCESS && event.getUseItem() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY ++ || result == EnumActionResult.SUCCESS && event.getUseItem() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW) + return p_187251_3_.func_179546_a(p_187251_1_, p_187251_2_, p_187251_5_, p_187251_4_, p_187251_6_, p_187251_7_, p_187251_8_, p_187251_9_); ++ else return result; + } + } + } +@@ -445,4 +489,13 @@ + { + this.field_73092_a = p_73080_1_; + } ++ ++ public double getBlockReachDistance() ++ { ++ return blockReachDistance; ++ } ++ public void setBlockReachDistance(double distance) ++ { ++ blockReachDistance = distance; ++ } + } diff --git a/patches/minecraft/net/minecraft/server/management/ServerConfigurationManager.java.patch b/patches/minecraft/net/minecraft/server/management/PlayerList.java.patch similarity index 64% rename from patches/minecraft/net/minecraft/server/management/ServerConfigurationManager.java.patch rename to patches/minecraft/net/minecraft/server/management/PlayerList.java.patch index 2f7ace96d3..467fe98f6d 100644 --- a/patches/minecraft/net/minecraft/server/management/ServerConfigurationManager.java.patch +++ b/patches/minecraft/net/minecraft/server/management/PlayerList.java.patch @@ -1,15 +1,15 @@ ---- ../src-base/minecraft/net/minecraft/server/management/ServerConfigurationManager.java -+++ ../src-work/minecraft/net/minecraft/server/management/ServerConfigurationManager.java -@@ -99,7 +99,7 @@ +--- ../src-base/minecraft/net/minecraft/server/management/PlayerList.java ++++ ../src-work/minecraft/net/minecraft/server/management/PlayerList.java +@@ -101,7 +101,7 @@ this.field_72405_c = 8; } - public void func_72355_a(NetworkManager p_72355_1_, EntityPlayerMP p_72355_2_) -+ public void func_72355_a(NetworkManager p_72355_1_, EntityPlayerMP p_72355_2_, NetHandlerPlayServer nethandlerplayserver) ++ public void initializeConnectionToPlayer(NetworkManager p_72355_1_, EntityPlayerMP p_72355_2_, NetHandlerPlayServer nethandlerplayserver) { GameProfile gameprofile = p_72355_2_.func_146103_bH(); PlayerProfileCache playerprofilecache = this.field_72400_f.func_152358_ax(); -@@ -108,6 +108,17 @@ +@@ -110,6 +110,17 @@ playerprofilecache.func_152649_a(gameprofile); NBTTagCompound nbttagcompound = this.func_72380_a(p_72355_2_); p_72355_2_.func_70029_a(this.field_72400_f.func_71218_a(p_72355_2_.field_71093_bK)); @@ -17,8 +17,8 @@ + World playerWorld = this.field_72400_f.func_71218_a(p_72355_2_.field_71093_bK); + if (playerWorld == null) + { -+ p_72355_2_.field_71093_bK=0; -+ playerWorld=this.field_72400_f.func_71218_a(0); ++ p_72355_2_.field_71093_bK = 0; ++ playerWorld = this.field_72400_f.func_71218_a(0); + BlockPos spawnPoint = playerWorld.field_73011_w.getRandomizedSpawnPoint(); + p_72355_2_.func_70107_b(spawnPoint.func_177958_n(), spawnPoint.func_177956_o(), spawnPoint.func_177952_p()); + } @@ -27,32 +27,32 @@ p_72355_2_.field_71134_c.func_73080_a((WorldServer)p_72355_2_.field_70170_p); String s1 = "local"; -@@ -121,7 +132,7 @@ +@@ -123,7 +134,7 @@ WorldInfo worldinfo = worldserver.func_72912_H(); BlockPos blockpos = worldserver.func_175694_M(); this.func_72381_a(p_72355_2_, (EntityPlayerMP)null, worldserver); - NetHandlerPlayServer nethandlerplayserver = new NetHandlerPlayServer(this.field_72400_f, p_72355_1_, p_72355_2_); + p_72355_2_.field_71135_a = nethandlerplayserver; - nethandlerplayserver.func_147359_a(new S01PacketJoinGame(p_72355_2_.func_145782_y(), p_72355_2_.field_71134_c.func_73081_b(), worldinfo.func_76093_s(), worldserver.field_73011_w.func_177502_q(), worldserver.func_175659_aa(), this.func_72352_l(), worldinfo.func_76067_t(), worldserver.func_82736_K().func_82766_b("reducedDebugInfo"))); - nethandlerplayserver.func_147359_a(new S3FPacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).func_180714_a(this.func_72365_p().getServerModName()))); - nethandlerplayserver.func_147359_a(new S41PacketServerDifficulty(worldinfo.func_176130_y(), worldinfo.func_176123_z())); -@@ -161,6 +172,7 @@ + nethandlerplayserver.func_147359_a(new SPacketJoinGame(p_72355_2_.func_145782_y(), p_72355_2_.field_71134_c.func_73081_b(), worldinfo.func_76093_s(), worldserver.field_73011_w.func_186058_p().func_186068_a(), worldserver.func_175659_aa(), this.func_72352_l(), worldinfo.func_76067_t(), worldserver.func_82736_K().func_82766_b("reducedDebugInfo"))); + nethandlerplayserver.func_147359_a(new SPacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).func_180714_a(this.func_72365_p().getServerModName()))); + nethandlerplayserver.func_147359_a(new SPacketServerDifficulty(worldinfo.func_176130_y(), worldinfo.func_176123_z())); +@@ -213,6 +224,7 @@ + } p_72355_2_.func_71116_b(); - + net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerLoggedIn(p_72355_2_); - if (nbttagcompound != null && nbttagcompound.func_150297_b("Riding", 10)) - { - Entity entity = EntityList.func_75615_a(nbttagcompound.func_74775_l("Riding"), worldserver); -@@ -262,6 +274,7 @@ - p_72380_1_.func_70020_e(nbttagcompound); - nbttagcompound1 = nbttagcompound; + } + + protected void func_96456_a(ServerScoreboard p_96456_1_, EntityPlayerMP p_96456_2_) +@@ -302,6 +314,7 @@ + nbttagcompound1 = this.field_72400_f.func_184110_aI().func_188257_a(FixTypes.PLAYER, nbttagcompound); + p_72380_1_.func_70020_e(nbttagcompound1); field_148546_d.debug("loading single player"); + net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_72380_1_, this.field_72412_k, p_72380_1_.func_110124_au().toString()); } else { -@@ -271,8 +284,23 @@ +@@ -311,8 +324,24 @@ return nbttagcompound1; } @@ -69,6 +69,7 @@ + return ((net.minecraft.world.storage.SaveHandler)this.field_72412_k).getPlayerNBT(player); + } + } ++ protected void func_72391_b(EntityPlayerMP p_72391_1_) { + if (p_72391_1_.field_71135_a == null) return; @@ -76,31 +77,31 @@ this.field_72412_k.func_75753_a(p_72391_1_); StatisticsFile statisticsfile = (StatisticsFile)this.field_148547_k.get(p_72391_1_.func_110124_au()); -@@ -288,6 +316,7 @@ - this.field_177454_f.put(p_72377_1_.func_110124_au(), p_72377_1_); - this.func_148540_a(new S38PacketPlayerListItem(S38PacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {p_72377_1_})); - WorldServer worldserver = this.field_72400_f.func_71218_a(p_72377_1_.field_71093_bK); +@@ -334,6 +363,7 @@ + p_72377_1_.field_71135_a.func_147359_a(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {(EntityPlayerMP)this.field_72404_b.get(i)})); + } + + net.minecraftforge.common.chunkio.ChunkIOExecutor.adjustPoolSize(this.func_72394_k()); worldserver.func_72838_d(p_72377_1_); this.func_72375_a(p_72377_1_, (WorldServer)null); - -@@ -305,6 +334,7 @@ + } +@@ -345,6 +375,7 @@ public void func_72367_e(EntityPlayerMP p_72367_1_) { + net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerLoggedOut(p_72367_1_); + WorldServer worldserver = p_72367_1_.func_71121_q(); p_72367_1_.func_71029_a(StatList.field_75947_j); this.func_72391_b(p_72367_1_); - WorldServer worldserver = p_72367_1_.func_71121_q(); -@@ -326,6 +356,7 @@ +@@ -379,6 +410,7 @@ this.field_177454_f.remove(uuid); this.field_148547_k.remove(uuid); } + net.minecraftforge.common.chunkio.ChunkIOExecutor.adjustPoolSize(this.func_72394_k()); - this.func_148540_a(new S38PacketPlayerListItem(S38PacketPlayerListItem.Action.REMOVE_PLAYER, new EntityPlayerMP[] {p_72367_1_})); + this.func_148540_a(new SPacketPlayerListItem(SPacketPlayerListItem.Action.REMOVE_PLAYER, new EntityPlayerMP[] {p_72367_1_})); } -@@ -409,13 +440,23 @@ +@@ -462,13 +494,23 @@ public EntityPlayerMP func_72368_a(EntityPlayerMP p_72368_1_, int p_72368_2_, boolean p_72368_3_) { @@ -116,7 +117,7 @@ + p_72368_1_.func_71121_q().func_73039_n().func_72787_a(p_72368_1_); p_72368_1_.func_71121_q().func_73039_n().func_72790_b(p_72368_1_); - p_72368_1_.func_71121_q().func_73040_p().func_72695_c(p_72368_1_); + p_72368_1_.func_71121_q().func_184164_w().func_72695_c(p_72368_1_); this.field_72404_b.remove(p_72368_1_); this.field_72400_f.func_71218_a(p_72368_1_.field_71093_bK).func_72973_f(p_72368_1_); - BlockPos blockpos = p_72368_1_.func_180470_cg(); @@ -124,17 +125,19 @@ + BlockPos blockpos = p_72368_1_.getBedLocation(p_72368_2_); + boolean flag = p_72368_1_.isSpawnForced(p_72368_2_); p_72368_1_.field_71093_bK = p_72368_2_; - ItemInWorldManager iteminworldmanager; + PlayerInteractionManager playerinteractionmanager; -@@ -431,6 +472,7 @@ - EntityPlayerMP entityplayermp = new EntityPlayerMP(this.field_72400_f, this.field_72400_f.func_71218_a(p_72368_1_.field_71093_bK), p_72368_1_.func_146103_bH(), iteminworldmanager); +@@ -484,7 +526,8 @@ + EntityPlayerMP entityplayermp = new EntityPlayerMP(this.field_72400_f, this.field_72400_f.func_71218_a(p_72368_1_.field_71093_bK), p_72368_1_.func_146103_bH(), playerinteractionmanager); entityplayermp.field_71135_a = p_72368_1_.field_71135_a; entityplayermp.func_71049_a(p_72368_1_, p_72368_3_); +- entityplayermp.func_145769_d(p_72368_1_.func_145782_y()); + entityplayermp.field_71093_bK = p_72368_2_; - entityplayermp.func_145769_d(p_72368_1_.func_145782_y()); ++ entityplayermp.func_145769_d(p_72368_1_.func_145782_y()); entityplayermp.func_174817_o(p_72368_1_); - WorldServer worldserver = this.field_72400_f.func_71218_a(p_72368_1_.field_71093_bK); -@@ -470,19 +512,25 @@ + entityplayermp.func_184819_a(p_72368_1_.func_184591_cq()); + +@@ -531,6 +574,7 @@ this.field_177454_f.put(entityplayermp.func_110124_au(), entityplayermp); entityplayermp.func_71116_b(); entityplayermp.func_70606_j(entityplayermp.func_110143_aJ()); @@ -142,31 +145,34 @@ return entityplayermp; } - public void func_72356_a(EntityPlayerMP p_72356_1_, int p_72356_2_) +@@ -545,15 +589,20 @@ + + public void func_187242_a(EntityPlayerMP p_187242_1_, int p_187242_2_) { -+ transferPlayerToDimension(p_72356_1_, p_72356_2_, field_72400_f.func_71218_a(p_72356_2_).func_85176_s()); ++ transferPlayerToDimension(p_187242_1_, p_187242_2_, field_72400_f.func_71218_a(p_187242_2_).func_85176_s()); + } + -+ public void transferPlayerToDimension(EntityPlayerMP p_72356_1_, int p_72356_2_, net.minecraft.world.Teleporter teleporter) ++ public void transferPlayerToDimension(EntityPlayerMP p_187242_1_, int p_187242_2_, net.minecraft.world.Teleporter teleporter) + { - int i = p_72356_1_.field_71093_bK; - WorldServer worldserver = this.field_72400_f.func_71218_a(p_72356_1_.field_71093_bK); - p_72356_1_.field_71093_bK = p_72356_2_; - WorldServer worldserver1 = this.field_72400_f.func_71218_a(p_72356_1_.field_71093_bK); -- p_72356_1_.field_71135_a.func_147359_a(new S07PacketRespawn(p_72356_1_.field_71093_bK, p_72356_1_.field_70170_p.func_175659_aa(), p_72356_1_.field_70170_p.func_72912_H().func_76067_t(), p_72356_1_.field_71134_c.func_73081_b())); -+ p_72356_1_.field_71135_a.func_147359_a(new S07PacketRespawn(p_72356_1_.field_71093_bK, worldserver1.func_175659_aa(), worldserver1.func_72912_H().func_76067_t(), p_72356_1_.field_71134_c.func_73081_b())); - worldserver.func_72973_f(p_72356_1_); - p_72356_1_.field_70128_L = false; -- this.func_82448_a(p_72356_1_, i, worldserver, worldserver1); -+ this.transferEntityToWorld(p_72356_1_, i, worldserver, worldserver1, teleporter); - this.func_72375_a(p_72356_1_, worldserver); - p_72356_1_.field_71135_a.func_147364_a(p_72356_1_.field_70165_t, p_72356_1_.field_70163_u, p_72356_1_.field_70161_v, p_72356_1_.field_70177_z, p_72356_1_.field_70125_A); - p_72356_1_.field_71134_c.func_73080_a(worldserver1); -@@ -493,17 +541,27 @@ + int i = p_187242_1_.field_71093_bK; + WorldServer worldserver = this.field_72400_f.func_71218_a(p_187242_1_.field_71093_bK); + p_187242_1_.field_71093_bK = p_187242_2_; + WorldServer worldserver1 = this.field_72400_f.func_71218_a(p_187242_1_.field_71093_bK); +- p_187242_1_.field_71135_a.func_147359_a(new SPacketRespawn(p_187242_1_.field_71093_bK, p_187242_1_.field_70170_p.func_175659_aa(), p_187242_1_.field_70170_p.func_72912_H().func_76067_t(), p_187242_1_.field_71134_c.func_73081_b())); ++ p_187242_1_.field_71135_a.func_147359_a(new SPacketRespawn(p_187242_1_.field_71093_bK, worldserver1.func_175659_aa(), worldserver1.func_72912_H().func_76067_t(), p_187242_1_.field_71134_c.func_73081_b())); + this.func_187243_f(p_187242_1_); + worldserver.func_72973_f(p_187242_1_); + p_187242_1_.field_70128_L = false; +- this.func_82448_a(p_187242_1_, i, worldserver, worldserver1); ++ this.transferEntityToWorld(p_187242_1_, i, worldserver, worldserver1, teleporter); + this.func_72375_a(p_187242_1_, worldserver); + p_187242_1_.field_71135_a.func_147364_a(p_187242_1_.field_70165_t, p_187242_1_.field_70163_u, p_187242_1_.field_70161_v, p_187242_1_.field_70177_z, p_187242_1_.field_70125_A); + p_187242_1_.field_71134_c.func_73080_a(worldserver1); +@@ -565,17 +614,27 @@ { - p_72356_1_.field_71135_a.func_147359_a(new S1DPacketEntityEffect(p_72356_1_.func_145782_y(), potioneffect)); + p_187242_1_.field_71135_a.func_147359_a(new SPacketEntityEffect(p_187242_1_.func_145782_y(), potioneffect)); } -+ net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(p_72356_1_, i, p_72356_2_); ++ net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerChangedDimensionEvent(p_187242_1_, i, p_187242_2_); } public void func_82448_a(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_) @@ -189,20 +195,20 @@ p_82448_3_.field_72984_F.func_76320_a("moving"); - if (p_82448_1_.field_71093_bK == -1) -+ if (false && p_82448_1_.field_71093_bK == -1) //Forge Kill it but dont comment out so we can rename it. ++ if (false && p_82448_1_.field_71093_bK == -1) { d0 = MathHelper.func_151237_a(d0 / d2, p_82448_4_.func_175723_af().func_177726_b() + 16.0D, p_82448_4_.func_175723_af().func_177728_d() - 16.0D); d1 = MathHelper.func_151237_a(d1 / d2, p_82448_4_.func_175723_af().func_177736_c() + 16.0D, p_82448_4_.func_175723_af().func_177733_e() - 16.0D); -@@ -514,7 +572,7 @@ +@@ -586,7 +645,7 @@ p_82448_3_.func_72866_a(p_82448_1_, false); } } - else if (p_82448_1_.field_71093_bK == 0) -+ else if (false && p_82448_1_.field_71093_bK == 0) //Forge Kill it but dont comment out so we can rename it. ++ else if (false && p_82448_1_.field_71093_bK == 0) { d0 = MathHelper.func_151237_a(d0 * d2, p_82448_4_.func_175723_af().func_177726_b() + 16.0D, p_82448_4_.func_175723_af().func_177728_d() - 16.0D); d1 = MathHelper.func_151237_a(d1 * d2, p_82448_4_.func_175723_af().func_177736_c() + 16.0D, p_82448_4_.func_175723_af().func_177733_e() - 16.0D); -@@ -525,7 +583,8 @@ +@@ -597,7 +656,8 @@ p_82448_3_.func_72866_a(p_82448_1_, false); } } @@ -212,7 +218,7 @@ { BlockPos blockpos; -@@ -560,7 +619,7 @@ +@@ -632,7 +692,7 @@ if (p_82448_1_.func_70089_S()) { p_82448_1_.func_70012_b(d0, p_82448_1_.field_70163_u, d1, p_82448_1_.field_70177_z, p_82448_1_.field_70125_A); diff --git a/patches/minecraft/net/minecraft/server/management/PlayerManager.java.patch b/patches/minecraft/net/minecraft/server/management/PlayerManager.java.patch index e0c026df7d..7340a0b5a5 100644 --- a/patches/minecraft/net/minecraft/server/management/PlayerManager.java.patch +++ b/patches/minecraft/net/minecraft/server/management/PlayerManager.java.patch @@ -1,220 +1,121 @@ --- ../src-base/minecraft/net/minecraft/server/management/PlayerManager.java +++ ../src-work/minecraft/net/minecraft/server/management/PlayerManager.java -@@ -117,15 +117,24 @@ - int j = (int)p_72683_1_.field_70161_v >> 4; - p_72683_1_.field_71131_d = p_72683_1_.field_70165_t; - p_72683_1_.field_71132_e = p_72683_1_.field_70161_v; -+ // Load nearby chunks first -+ List chunkList = Lists.newArrayList(); - - for (int k = i - this.field_72698_e; k <= i + this.field_72698_e; ++k) - { - for (int l = j - this.field_72698_e; l <= j + this.field_72698_e; ++l) - { -- this.func_72690_a(k, l, true).func_73255_a(p_72683_1_); -+ chunkList.add(new ChunkCoordIntPair(k, l)); - } - } - -+ java.util.Collections.sort(chunkList, new net.minecraftforge.common.util.ChunkCoordComparator(p_72683_1_)); -+ -+ for (ChunkCoordIntPair pair : chunkList) -+ { -+ this.func_72690_a(pair.field_77276_a, pair.field_77275_b, true).func_73255_a(p_72683_1_); -+ } -+ - this.field_72699_b.add(p_72683_1_); - this.func_72691_b(p_72683_1_); - } -@@ -225,6 +234,7 @@ - int i1 = this.field_72698_e; - int j1 = i - k; - int k1 = j - l; -+ List chunksToLoad = Lists.newArrayList(); - - if (j1 != 0 || k1 != 0) - { -@@ -234,7 +244,7 @@ - { - if (!this.func_72684_a(l1, i2, k, l, i1)) - { -- this.func_72690_a(l1, i2, true).func_73255_a(p_72685_1_); -+ chunksToLoad.add(new ChunkCoordIntPair(l1, i2)); - } - - if (!this.func_72684_a(l1 - j1, i2 - k1, i, j, i1)) -@@ -252,6 +262,18 @@ - this.func_72691_b(p_72685_1_); - p_72685_1_.field_71131_d = p_72685_1_.field_70165_t; - p_72685_1_.field_71132_e = p_72685_1_.field_70161_v; -+ // send nearest chunks first -+ java.util.Collections.sort(chunksToLoad, new net.minecraftforge.common.util.ChunkCoordComparator(p_72685_1_)); -+ -+ for (ChunkCoordIntPair pair : chunksToLoad) -+ { -+ this.func_72690_a(pair.field_77276_a, pair.field_77275_b, true).func_73255_a(p_72685_1_); -+ } -+ -+ if (i1 > 1 || i1 < -1 || j1 > 1 || j1 < -1) -+ { -+ java.util.Collections.sort(p_72685_1_.field_71129_f, new net.minecraftforge.common.util.ChunkCoordComparator(p_72685_1_)); -+ } - } - } - } -@@ -322,11 +344,20 @@ - private int field_73262_e; - private int field_73260_f; - private long field_111198_g; -+ private final java.util.HashMap players = new java.util.HashMap(); -+ private boolean loaded = false; +@@ -468,11 +468,18 @@ + private int field_187288_h; + private long field_187289_i; + private boolean field_187290_j; + private Runnable loadedRunnable = new Runnable() + { + public void run() + { -+ PlayerInstance.this.loaded = true; ++ PlayerInstance.this.field_187286_f = PlayerManager.this.func_72688_a().func_72863_F().func_186028_c(PlayerInstance.this.field_187284_d.field_77276_a, PlayerInstance.this.field_187284_d.field_77275_b); + } + }; public PlayerInstance(int p_i1518_2_, int p_i1518_3_) { - this.field_73264_c = new ChunkCoordIntPair(p_i1518_2_, p_i1518_3_); -- PlayerManager.this.func_72688_a().field_73059_b.func_73158_c(p_i1518_2_, p_i1518_3_); -+ PlayerManager.this.func_72688_a().field_73059_b.loadChunk(p_i1518_2_, p_i1518_3_, this.loadedRunnable); + this.field_187284_d = new ChunkCoordIntPair(p_i1518_2_, p_i1518_3_); +- this.field_187286_f = PlayerManager.this.func_72688_a().func_72863_F().func_186028_c(p_i1518_2_, p_i1518_3_); ++ PlayerManager.this.func_72688_a().func_72863_F().loadChunk(p_i1518_2_, p_i1518_3_, this.loadedRunnable); } - public void func_73255_a(EntityPlayerMP p_73255_1_) -@@ -343,7 +374,24 @@ - } - - this.field_73263_b.add(p_73255_1_); -+ Runnable playerRunnable = null; -+ if (this.loaded) -+ { - p_73255_1_.field_71129_f.add(this.field_73264_c); -+ } -+ else -+ { -+ final EntityPlayerMP tmp = p_73255_1_; -+ playerRunnable = new Runnable() -+ { -+ public void run() -+ { -+ tmp.field_71129_f.add(PlayerInstance.this.field_73264_c); -+ } -+ }; -+ PlayerManager.this.func_72688_a().field_73059_b.loadChunk(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b, playerRunnable); -+ } -+ this.players.put(p_73255_1_, playerRunnable); - } - } - -@@ -351,6 +399,24 @@ + public ChunkCoordIntPair func_187264_a() +@@ -506,6 +513,20 @@ { - if (this.field_73263_b.contains(p_73252_1_)) + if (this.field_187283_c.contains(p_187277_1_)) { + // If we haven't loaded yet don't load the chunk just so we can clean it up -+ if (!this.loaded) ++ if (this.field_187286_f == null) + { -+ net.minecraftforge.common.chunkio.ChunkIOExecutor.dropQueuedChunkLoad(PlayerManager.this.func_72688_a(), this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b, this.players.get(p_73252_1_)); -+ this.field_73263_b.remove(p_73252_1_); -+ this.players.remove(p_73252_1_); ++ this.field_187283_c.remove(p_187277_1_); + -+ if (this.field_73263_b.isEmpty()) ++ if (this.field_187283_c.isEmpty()) + { -+ net.minecraftforge.common.chunkio.ChunkIOExecutor.dropQueuedChunkLoad(PlayerManager.this.func_72688_a(), this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b, this.loadedRunnable); -+ long i = (long) this.field_73264_c.field_77276_a + 2147483647L | (long) this.field_73264_c.field_77275_b + 2147483647L << 32; -+ PlayerManager.this.field_72700_c.func_76159_d(i); -+ PlayerManager.this.field_111193_e.remove(this); ++ net.minecraftforge.common.chunkio.ChunkIOExecutor.dropQueuedChunkLoad(PlayerManager.this.func_72688_a(), this.field_187284_d.field_77276_a, this.field_187284_d.field_77275_b, this.loadedRunnable); ++ PlayerManager.this.func_187305_b(this); + } + + return; + } + - Chunk chunk = PlayerManager.this.field_72701_a.func_72964_e(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b); - - if (chunk.func_150802_k()) -@@ -358,9 +424,12 @@ - p_73252_1_.field_71135_a.func_147359_a(new S21PacketChunkData(chunk, true, 0)); - } - -+ this.players.remove(p_73252_1_); - this.field_73263_b.remove(p_73252_1_); - p_73252_1_.field_71129_f.remove(this.field_73264_c); - -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkWatchEvent.UnWatch(field_73264_c, p_73252_1_)); -+ - if (this.field_73263_b.isEmpty()) + if (this.field_187290_j) { - long i = (long)this.field_73264_c.field_77276_a + 2147483647L | (long)this.field_73264_c.field_77275_b + 2147483647L << 32; -@@ -398,7 +467,7 @@ + p_187277_1_.field_71135_a.func_147359_a(new SPacketUnloadChunk(this.field_187284_d.field_77276_a, this.field_187284_d.field_77275_b)); +@@ -513,6 +534,8 @@ - this.field_73260_f |= 1 << (p_151253_2_ >> 4); + this.field_187283_c.remove(p_187277_1_); -- if (this.field_73262_e < 64) -+ //Forge; Cache everything, so always run - { - short short1 = (short)(p_151253_1_ << 12 | p_151253_3_ << 8 | p_151253_2_); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkWatchEvent.UnWatch(this.field_187284_d, p_187277_1_)); ++ + if (this.field_187283_c.isEmpty()) + { + PlayerManager.this.func_187305_b(this); +@@ -625,7 +648,7 @@ -@@ -410,6 +479,10 @@ + this.field_187288_h |= 1 << (p_187265_2_ >> 4); + +- if (this.field_187287_g < 64) ++ //Forge; Cache everything, so always run + { + short short1 = (short)(p_187265_1_ << 12 | p_187265_3_ << 8 | p_187265_2_); + +@@ -637,6 +660,8 @@ + } } - } -+ if (field_73262_e == field_151254_d.length) -+ { -+ field_151254_d = java.util.Arrays.copyOf(field_151254_d, field_151254_d.length << 1); -+ } - this.field_151254_d[this.field_73262_e++] = short1; ++ if (this.field_187287_g == this.field_187285_e.length) ++ this.field_187285_e = java.util.Arrays.copyOf(this.field_187285_e, this.field_187285_e.length << 1); + this.field_187285_e[this.field_187287_g++] = short1; + } } - } -@@ -427,6 +500,7 @@ +@@ -653,6 +678,7 @@ } } + @SuppressWarnings("unused") - public void func_73254_a() + public void func_187280_d() { - if (this.field_73262_e != 0) -@@ -439,18 +513,19 @@ - BlockPos blockpos = new BlockPos(i, j, k); - this.func_151251_a(new S23PacketBlockChange(PlayerManager.this.field_72701_a, blockpos)); + if (this.field_187290_j && this.field_187286_f != null) +@@ -666,18 +692,20 @@ + int k = (this.field_187285_e[0] >> 8 & 15) + this.field_187284_d.field_77275_b * 16; + BlockPos blockpos = new BlockPos(i, j, k); + this.func_187267_a(new SPacketBlockChange(PlayerManager.this.func_72688_a(), blockpos)); ++ net.minecraft.block.state.IBlockState state = PlayerManager.this.func_72688_a().func_180495_p(blockpos); -- if (PlayerManager.this.field_72701_a.func_180495_p(blockpos).func_177230_c().func_149716_u()) -+ if (PlayerManager.this.field_72701_a.func_180495_p(blockpos).func_177230_c().hasTileEntity(PlayerManager.this.field_72701_a.func_180495_p(blockpos))) - { - this.func_151252_a(PlayerManager.this.field_72701_a.func_175625_s(blockpos)); - } - } -- else if (this.field_73262_e == 64) -+ else if (this.field_73262_e >= net.minecraftforge.common.ForgeModContainer.clumpingThreshold) - { - int i1 = this.field_73264_c.field_77276_a * 16; - int k1 = this.field_73264_c.field_77275_b * 16; - this.func_151251_a(new S21PacketChunkData(PlayerManager.this.field_72701_a.func_72964_e(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b), false, this.field_73260_f)); - -- for (int i2 = 0; i2 < 16; ++i2) -+ // Forge: Grabs ALL tile entities is costly on a modded server, only send needed ones -+ for (int i2 = 0; false && i2 < 16; ++i2) - { - if ((this.field_73260_f & 1 << i2) != 0) +- if (PlayerManager.this.func_72688_a().func_180495_p(blockpos).func_177230_c().func_149716_u()) ++ if (state.func_177230_c().hasTileEntity(state)) { -@@ -467,7 +542,9 @@ - else - { - this.func_151251_a(new S22PacketMultiBlockChange(this.field_73262_e, this.field_151254_d, PlayerManager.this.field_72701_a.func_72964_e(this.field_73264_c.field_77276_a, this.field_73264_c.field_77275_b))); -- -+ } -+ { // Forge: Send only the tile entities that are updated, Adding this brace lets us keep the indent and the patch small -+ WorldServer world = PlayerManager.this.field_72701_a; - for (int j1 = 0; j1 < this.field_73262_e; ++j1) - { - int l1 = (this.field_151254_d[j1] >> 12 & 15) + this.field_73264_c.field_77276_a * 16; -@@ -475,7 +552,7 @@ - int l2 = (this.field_151254_d[j1] >> 8 & 15) + this.field_73264_c.field_77275_b * 16; - BlockPos blockpos1 = new BlockPos(l1, j2, l2); - -- if (PlayerManager.this.field_72701_a.func_180495_p(blockpos1).func_177230_c().func_149716_u()) -+ if (world.func_180495_p(blockpos1).func_177230_c().hasTileEntity(world.func_180495_p(blockpos1))) - { - this.func_151252_a(PlayerManager.this.field_72701_a.func_175625_s(blockpos1)); + this.func_187273_a(PlayerManager.this.func_72688_a().func_175625_s(blockpos)); } + } +- else if (this.field_187287_g == 64) ++ else if (this.field_187287_g >= net.minecraftforge.common.ForgeModContainer.clumpingThreshold) + { + int i1 = this.field_187284_d.field_77276_a * 16; + int k1 = this.field_187284_d.field_77275_b * 16; + this.func_187267_a(new SPacketChunkData(this.field_187286_f, false, this.field_187288_h)); + ++ if (false) // Forge: Grabs ALL the tile entities, costly on a modded server, only send needed ones + for (int i2 = 0; i2 < 16; ++i2) + { + if ((this.field_187288_h & 1 << i2) != 0) +@@ -695,15 +723,17 @@ + else + { + this.func_187267_a(new SPacketMultiBlockChange(this.field_187287_g, this.field_187285_e, this.field_187286_f)); +- ++ } ++ { // Forge: Send only the tile entities that are updated, Adding this brace lets us keep the indent and the patch small + for (int j1 = 0; j1 < this.field_187287_g; ++j1) + { + int l1 = (this.field_187285_e[j1] >> 12 & 15) + this.field_187284_d.field_77276_a * 16; + int j2 = this.field_187285_e[j1] & 255; + int l2 = (this.field_187285_e[j1] >> 8 & 15) + this.field_187284_d.field_77275_b * 16; + BlockPos blockpos1 = new BlockPos(l1, j2, l2); ++ net.minecraft.block.state.IBlockState state = PlayerManager.this.func_72688_a().func_180495_p(blockpos1); + +- if (PlayerManager.this.func_72688_a().func_180495_p(blockpos1).func_177230_c().func_149716_u()) ++ if (state.func_177230_c().hasTileEntity(state)) + { + this.func_187273_a(PlayerManager.this.func_72688_a().func_175625_s(blockpos1)); + } diff --git a/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch b/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch index ad1cf30059..624eebff65 100644 --- a/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch +++ b/patches/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java.patch @@ -1,26 +1,20 @@ --- ../src-base/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java +++ ../src-work/minecraft/net/minecraft/server/network/NetHandlerLoginServer.java -@@ -66,12 +66,12 @@ +@@ -66,7 +66,7 @@ if (entityplayermp == null) { this.field_147328_g = NetHandlerLoginServer.LoginState.READY_TO_ACCEPT; -- this.field_147327_f.func_71203_ab().func_72355_a(this.field_147333_a, this.field_181025_l); -+ net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.fmlServerHandshake(this.field_147327_f.func_71203_ab(), this.field_147333_a, this.field_181025_l); +- this.field_147327_f.func_184103_al().func_72355_a(this.field_147333_a, this.field_181025_l); ++ net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.fmlServerHandshake(this.field_147327_f.func_184103_al(), this.field_147333_a, this.field_181025_l); this.field_181025_l = null; } } - -- if (this.field_147336_h++ == 600) -+ if (this.field_147336_h++ == net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.LOGIN_TIMEOUT) - { - this.func_147322_a("Took too long to log in"); - } @@ -130,7 +130,7 @@ } else { -- this.field_147327_f.func_71203_ab().func_72355_a(this.field_147333_a, this.field_147327_f.func_71203_ab().func_148545_a(this.field_147337_i)); -+ net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.fmlServerHandshake(this.field_147327_f.func_71203_ab(), this.field_147333_a, this.field_147327_f.func_71203_ab().func_148545_a(this.field_147337_i)); +- this.field_147327_f.func_184103_al().func_72355_a(this.field_147333_a, this.field_147327_f.func_184103_al().func_148545_a(this.field_147337_i)); ++ net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.fmlServerHandshake(this.field_147327_f.func_184103_al(), this.field_147333_a, this.field_147327_f.func_184103_al().func_148545_a(this.field_147337_i)); } } } diff --git a/patches/minecraft/net/minecraft/stats/StatList.java.patch b/patches/minecraft/net/minecraft/stats/StatList.java.patch index 61bd2d01fa..8eca044945 100644 --- a/patches/minecraft/net/minecraft/stats/StatList.java.patch +++ b/patches/minecraft/net/minecraft/stats/StatList.java.patch @@ -1,24 +1,24 @@ --- ../src-base/minecraft/net/minecraft/stats/StatList.java +++ ../src-work/minecraft/net/minecraft/stats/StatList.java -@@ -119,7 +119,7 @@ +@@ -155,7 +155,7 @@ } } -- func_75924_a(field_75928_D); -+ replaceAllSimilarBlocks(field_75928_D, true); +- func_75924_a(field_188066_af); ++ replaceAllSimilarBlocks(field_188066_af, true); } private static void func_151181_c() -@@ -141,7 +141,7 @@ +@@ -177,7 +177,7 @@ } } -- func_75924_a(field_75934_C); -+ replaceAllSimilarBlocks(field_75934_C, false); +- func_75924_a(field_188065_ae); ++ replaceAllSimilarBlocks(field_188065_ae, false); } private static void func_75925_c() -@@ -165,7 +165,7 @@ +@@ -201,7 +201,7 @@ } } @@ -27,7 +27,16 @@ } private static void func_151179_e() -@@ -184,7 +184,7 @@ +@@ -220,7 +220,7 @@ + } + } + +- func_75924_a(field_75930_F); ++ replaceAllSimilarBlocks(field_75930_F, true); + } + + private static void func_188054_f() +@@ -240,7 +240,7 @@ } } @@ -36,7 +45,7 @@ } private static String func_180204_a(Item p_180204_0_) -@@ -193,28 +193,35 @@ +@@ -249,28 +249,35 @@ return resourcelocation != null ? resourcelocation.toString().replace(':', '.') : null; } diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch index d9070581c7..8e771c7091 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntity.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntity.java -@@ -17,7 +17,7 @@ +@@ -18,7 +18,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -9,7 +9,7 @@ { private static final Logger field_145852_a = LogManager.getLogger(); private static Map < String, Class > field_145855_i = Maps. < String, Class > newHashMap(); -@@ -59,6 +59,8 @@ +@@ -60,6 +60,8 @@ public void func_145839_a(NBTTagCompound p_145839_1_) { this.field_174879_c = new BlockPos(p_145839_1_.func_74762_e("x"), p_145839_1_.func_74762_e("y"), p_145839_1_.func_74762_e("z")); @@ -18,7 +18,7 @@ } public void func_145841_b(NBTTagCompound p_145841_1_) -@@ -75,6 +77,8 @@ +@@ -76,6 +78,8 @@ p_145841_1_.func_74768_a("x", this.field_174879_c.func_177958_n()); p_145841_1_.func_74768_a("y", this.field_174879_c.func_177956_o()); p_145841_1_.func_74768_a("z", this.field_174879_c.func_177952_p()); @@ -27,37 +27,40 @@ } } -@@ -82,9 +86,10 @@ +@@ -83,10 +87,11 @@ { TileEntity tileentity = null; - + String s = p_184246_1_.func_74779_i("id"); + Class oclass = null; + try { -- Class oclass = (Class)field_145855_i.get(p_145827_0_.func_74779_i("id")); -+ oclass = (Class)field_145855_i.get(p_145827_0_.func_74779_i("id")); +- Class oclass = (Class)field_145855_i.get(s); ++ oclass = (Class)field_145855_i.get(s); if (oclass != null) { -@@ -102,7 +107,17 @@ - } - else +@@ -96,6 +101,9 @@ + catch (Throwable throwable1) { -+ try -+ { - field_145852_a.warn("Skipping BlockEntity with id " + p_145827_0_.func_74779_i("id")); -+ } -+ catch (Exception ex) -+ { -+ net.minecraftforge.fml.common.FMLLog.log(org.apache.logging.log4j.Level.ERROR, ex, -+ "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", -+ p_145827_0_.func_74779_i("id"), oclass.getName()); -+ tileentity = null; -+ } + field_145852_a.error("Failed to create block entity " + s, throwable1); ++ net.minecraftforge.fml.common.FMLLog.log(org.apache.logging.log4j.Level.ERROR, throwable1, ++ "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", ++ s, oclass.getName()); } - return tileentity; -@@ -134,7 +149,6 @@ + if (tileentity != null) +@@ -107,6 +115,9 @@ + catch (Throwable throwable) + { + field_145852_a.error("Failed to load data for block entity " + s, throwable); ++ net.minecraftforge.fml.common.FMLLog.log(org.apache.logging.log4j.Level.ERROR, throwable, ++ "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", ++ s, oclass.getName()); + tileentity = null; + } + } +@@ -144,7 +155,6 @@ } } @@ -65,11 +68,10 @@ public double func_145835_a(double p_145835_1_, double p_145835_3_, double p_145835_5_) { double d0 = (double)this.field_174879_c.func_177958_n() + 0.5D - p_145835_1_; -@@ -279,4 +293,183 @@ - func_145826_a(TileEntityFlowerPot.class, "FlowerPot"); - func_145826_a(TileEntityBanner.class, "Banner"); +@@ -271,6 +281,186 @@ + return false; } -+ + + // -- BEGIN FORGE PATCHES -- + /** + * Called when you receive a TileEntityData packet for the location this @@ -80,7 +82,7 @@ + * @param net The NetworkManager the packet originated from + * @param pkt The data packet + */ -+ public void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.S35PacketUpdateTileEntity pkt) ++ public void onDataPacket(net.minecraft.network.NetworkManager net, net.minecraft.network.play.server.SPacketUpdateTileEntity pkt) + { + } + @@ -115,7 +117,7 @@ + /** + * Sometimes default render bounding box: infinite in scope. Used to control rendering on {@link TileEntitySpecialRenderer}. + */ -+ public static final net.minecraft.util.AxisAlignedBB INFINITE_EXTENT_AABB = new net.minecraft.util.AxisAlignedBB(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); ++ public static final net.minecraft.util.math.AxisAlignedBB INFINITE_EXTENT_AABB = new net.minecraft.util.math.AxisAlignedBB(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); + /** + * Return an {@link AxisAlignedBB} that controls the visible scope of a {@link TileEntitySpecialRenderer} associated with this {@link TileEntity} + * Defaults to the collision bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated with the block @@ -124,24 +126,25 @@ + * @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity} + */ + @SideOnly(Side.CLIENT) -+ public net.minecraft.util.AxisAlignedBB getRenderBoundingBox() ++ public net.minecraft.util.math.AxisAlignedBB getRenderBoundingBox() + { -+ net.minecraft.util.AxisAlignedBB bb = INFINITE_EXTENT_AABB; ++ net.minecraft.util.math.AxisAlignedBB bb = INFINITE_EXTENT_AABB; + Block type = func_145838_q(); ++ BlockPos pos = func_174877_v(); + if (type == Blocks.field_150381_bn) + { -+ bb = new net.minecraft.util.AxisAlignedBB(func_174877_v(), func_174877_v().func_177982_a(1, 1, 1)); ++ bb = new net.minecraft.util.math.AxisAlignedBB(pos, pos.func_177982_a(1, 1, 1)); + } + else if (type == Blocks.field_150486_ae || type == Blocks.field_150447_bR) + { -+ bb = new net.minecraft.util.AxisAlignedBB(func_174877_v().func_177982_a(-1, 0, -1), func_174877_v().func_177982_a(2, 2, 2)); ++ bb = new net.minecraft.util.math.AxisAlignedBB(pos.func_177982_a(-1, 0, -1), pos.func_177982_a(2, 2, 2)); + } + else if (type != null && type != Blocks.field_150461_bJ) + { -+ net.minecraft.util.AxisAlignedBB cbb = null; ++ net.minecraft.util.math.AxisAlignedBB cbb = null; + try + { -+ cbb = type.func_180640_a(field_145850_b, func_174877_v(), field_145850_b.func_180495_p(func_174877_v())); ++ cbb = field_145850_b.func_180495_p(func_174877_v()).func_185890_d(field_145850_b, pos).func_72321_a(pos.func_177958_n(), pos.func_177956_o(), pos.func_177952_p()); + } + catch (Exception e) + { @@ -151,7 +154,7 @@ + // So, once again in the long line of US having to accommodate BUKKIT breaking things, + // here it is, assume that the TE is only 1 cubic block. Problem with this is that it may + // cause the TileEntity renderer to error further down the line! But alas, nothing we can do. -+ cbb = new net.minecraft.util.AxisAlignedBB(func_174877_v().func_177982_a(-1, 0, -1), func_174877_v().func_177982_a(1, 1, 1)); ++ cbb = new net.minecraft.util.math.AxisAlignedBB(func_174877_v().func_177982_a(-1, 0, -1), func_174877_v().func_177982_a(1, 1, 1)); + } + if (cbb != null) bb = cbb; + } @@ -248,4 +251,7 @@ + this.func_145841_b(ret); + return ret; + } - } ++ + static + { + func_145826_a(TileEntityFurnace.class, "Furnace"); diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityBeacon.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityBeacon.java.patch index acb9425af2..6ba50bb6ff 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityBeacon.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityBeacon.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntityBeacon.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityBeacon.java -@@ -169,7 +169,7 @@ +@@ -179,7 +179,7 @@ { Block block = this.field_145850_b.func_180495_p(new BlockPos(j1, i2, k1)).func_177230_c(); @@ -9,7 +9,7 @@ { flag1 = false; break; -@@ -368,7 +368,7 @@ +@@ -371,7 +371,7 @@ public boolean func_94041_b(int p_94041_1_, ItemStack p_94041_2_) { diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch index b061d4b423..bba76fd606 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityBrewingStand.java -@@ -104,7 +104,7 @@ +@@ -140,7 +140,7 @@ private boolean func_145934_k() { @@ -9,16 +9,7 @@ { ItemStack itemstack = this.field_145945_j[3]; -@@ -118,7 +118,7 @@ - - for (int i = 0; i < 3; ++i) - { -- if (this.field_145945_j[i] != null && this.field_145945_j[i].func_77973_b() == Items.field_151068_bn) -+ if (this.field_145945_j[i] != null && this.field_145945_j[i].func_77973_b() instanceof ItemPotion) - { - int j = this.field_145945_j[i].func_77960_j(); - int k = this.func_145936_c(j, itemstack); -@@ -145,19 +145,22 @@ +@@ -165,25 +165,23 @@ } else { @@ -29,61 +20,57 @@ private void func_145940_l() { -+ if (net.minecraftforge.event.ForgeEventFactory.onPotionAttemptBreaw(field_145945_j)) return; - if (this.func_145934_k()) ++ if (net.minecraftforge.event.ForgeEventFactory.onPotionAttemptBrew(field_145945_j)) return; + ItemStack itemstack = this.field_145945_j[3]; + +- for (int i = 0; i < 3; ++i) +- { +- this.field_145945_j[i] = PotionHelper.func_185212_d(itemstack, this.field_145945_j[i]); +- } ++ net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(field_145945_j, field_145945_j[3], field_145947_i); + + --itemstack.field_77994_a; + BlockPos blockpos = this.func_174877_v(); + +- if (itemstack.func_77973_b().func_77634_r()) ++ if (itemstack.func_77973_b().hasContainerItem(itemstack)) { -+ net.minecraftforge.common.brewing.BrewingRecipeRegistry.brewPotions(field_145945_j, field_145945_j[3], field_145947_i); - ItemStack itemstack = this.field_145945_j[3]; +- ItemStack itemstack1 = new ItemStack(itemstack.func_77973_b().func_77668_q()); ++ ItemStack itemstack1 = itemstack.func_77973_b().getContainerItem(itemstack); -+ if (false) { // Code moved to net.minecraftforge.common.brewing.VanillaBrewingRecipe - for (int i = 0; i < 3; ++i) + if (itemstack.field_77994_a <= 0) { -- if (this.field_145945_j[i] != null && this.field_145945_j[i].func_77973_b() == Items.field_151068_bn) -+ if (this.field_145945_j[i] != null && this.field_145945_j[i].func_77973_b() instanceof ItemPotion) - { - int j = this.field_145945_j[i].func_77960_j(); - int k = this.func_145936_c(j, itemstack); -@@ -177,10 +180,11 @@ - } - } - } -+ } +@@ -202,6 +200,7 @@ -- if (itemstack.func_77973_b().func_77634_r()) -+ if (itemstack.func_77973_b().hasContainerItem(itemstack)) - { -- this.field_145945_j[3] = new ItemStack(itemstack.func_77973_b().func_77668_q()); -+ this.field_145945_j[3] = itemstack.func_77973_b().getContainerItem(itemstack); - } - else - { -@@ -191,6 +195,7 @@ - this.field_145945_j[3] = null; - } - } -+ net.minecraftforge.event.ForgeEventFactory.onPotionBrewed(field_145945_j); - } + this.field_145945_j[3] = itemstack; + this.field_145850_b.func_175718_b(1035, blockpos, 0); ++ net.minecraftforge.event.ForgeEventFactory.onPotionBrewed(field_145945_j); } -@@ -310,7 +315,9 @@ - - public boolean func_94041_b(int p_94041_1_, ItemStack p_94041_2_) + public void func_145839_a(NBTTagCompound p_145839_1_) +@@ -303,12 +302,12 @@ { -- return p_94041_1_ == 3 ? p_94041_2_.func_77973_b().func_150892_m(p_94041_2_) : p_94041_2_.func_77973_b() == Items.field_151068_bn || p_94041_2_.func_77973_b() == Items.field_151069_bo; -+ if (p_94041_1_ == 3 && net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_94041_2_)) return true; -+ else if (p_94041_1_ != 3 && net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_94041_2_)) return true; -+ return false; - } - - public boolean[] func_174902_m() -@@ -386,4 +393,18 @@ - this.field_145945_j[i] = null; + if (p_94041_1_ == 3) + { +- return PotionHelper.func_185205_a(p_94041_2_); ++ return net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidIngredient(p_94041_2_); + } + else + { + Item item = p_94041_2_.func_77973_b(); +- return p_94041_1_ == 4 ? item == Items.field_151065_br : item == Items.field_151068_bn || item == Items.field_185155_bH || item == Items.field_185156_bI || item == Items.field_151069_bo; ++ return p_94041_1_ == 4 ? item == Items.field_151065_br : net.minecraftforge.common.brewing.BrewingRecipeRegistry.isValidInput(p_94041_2_); } } -+ + +@@ -362,6 +361,21 @@ + } + } + + net.minecraftforge.items.IItemHandler handlerInput = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP); + net.minecraftforge.items.IItemHandler handlerOutput = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN); + ++ @SuppressWarnings("unchecked") + @Override + public T getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) + { @@ -94,4 +81,7 @@ + return (T) handlerOutput; + return super.getCapability(capability, facing); + } - } ++ + public int func_174890_g() + { + return 2; diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityChest.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityChest.java.patch index 1c77e9b787..d7766de5e6 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityChest.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityChest.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntityChest.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityChest.java -@@ -186,6 +186,7 @@ +@@ -171,6 +171,7 @@ { super.func_145836_u(); this.field_145984_a = false; @@ -8,13 +8,13 @@ } @SuppressWarnings("incomplete-switch") -@@ -468,4 +469,24 @@ - this.field_145985_p[i] = null; +@@ -457,6 +458,27 @@ } } -+ + + public net.minecraftforge.items.VanillaDoubleChestItemHandler doubleChestHandler; + ++ @SuppressWarnings("unchecked") + @Override + public T getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) + { @@ -32,4 +32,7 @@ + { + return super.getCapability(net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); + } - } ++ + public void func_184287_a(ResourceLocation p_184287_1_, long p_184287_2_) + { + this.field_184284_m = p_184287_1_; diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityFurnace.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityFurnace.java.patch index 44e66c1e42..41e782be4f 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityFurnace.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityFurnace.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntityFurnace.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityFurnace.java -@@ -141,9 +141,9 @@ +@@ -110,9 +110,9 @@ } } @@ -13,7 +13,7 @@ this.field_145963_i = func_145952_a(this.field_145957_n[1]); if (p_145839_1_.func_150297_b("CustomName", 8)) -@@ -155,9 +155,9 @@ +@@ -124,9 +124,9 @@ public void func_145841_b(NBTTagCompound p_145841_1_) { super.func_145841_b(p_145841_1_); @@ -26,7 +26,7 @@ NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.field_145957_n.length; ++i) -@@ -223,8 +223,7 @@ +@@ -192,8 +192,7 @@ if (this.field_145957_n[1].field_77994_a == 0) { @@ -36,7 +36,7 @@ } } } -@@ -279,7 +278,11 @@ +@@ -248,7 +247,11 @@ else { ItemStack itemstack = FurnaceRecipes.func_77602_a().func_151395_a(this.field_145957_n[0]); @@ -49,7 +49,7 @@ } } -@@ -295,7 +298,7 @@ +@@ -264,7 +267,7 @@ } else if (this.field_145957_n[2].func_77973_b() == itemstack.func_77973_b()) { @@ -58,7 +58,7 @@ } if (this.field_145957_n[0].func_77973_b() == Item.func_150898_a(Blocks.field_150360_v) && this.field_145957_n[0].func_77960_j() == 1 && this.field_145957_n[1] != null && this.field_145957_n[1].func_77973_b() == Items.field_151133_ar) -@@ -342,7 +345,15 @@ +@@ -311,7 +314,15 @@ } } @@ -75,7 +75,7 @@ } } -@@ -451,4 +462,21 @@ +@@ -432,4 +443,22 @@ this.field_145957_n[i] = null; } } @@ -84,6 +84,7 @@ + net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN); + net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.WEST); + ++ @SuppressWarnings("unchecked") + @Override + public T getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) + { diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityHopper.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityHopper.java.patch index a03e41ceb3..d55f5e0a4a 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityHopper.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityHopper.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntityHopper.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityHopper.java -@@ -260,6 +260,7 @@ +@@ -237,6 +237,7 @@ private boolean func_145883_k() { @@ -8,7 +8,7 @@ IInventory iinventory = this.func_145895_l(); if (iinventory == null) -@@ -366,6 +367,7 @@ +@@ -343,6 +344,7 @@ public static boolean func_145891_a(IHopper p_145891_0_) { @@ -16,7 +16,7 @@ IInventory iinventory = func_145884_b(p_145891_0_); if (iinventory != null) -@@ -515,17 +517,31 @@ +@@ -492,17 +494,31 @@ if (itemstack == null) { @@ -49,7 +49,7 @@ } if (flag) -@@ -668,4 +684,10 @@ +@@ -648,4 +664,10 @@ this.field_145900_a[i] = null; } } diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityLockable.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityLockable.java.patch index 5059fc2d06..6c31d0dcdd 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityLockable.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityLockable.java.patch @@ -1,8 +1,8 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntityLockable.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityLockable.java -@@ -47,4 +47,25 @@ +@@ -47,4 +47,26 @@ { - return (IChatComponent)(this.func_145818_k_() ? new ChatComponentText(this.func_70005_c_()) : new ChatComponentTranslation(this.func_70005_c_(), new Object[0])); + return (ITextComponent)(this.func_145818_k_() ? new TextComponentString(this.func_70005_c_()) : new TextComponentTranslation(this.func_70005_c_(), new Object[0])); } + + private net.minecraftforge.items.IItemHandler itemHandler; @@ -12,6 +12,7 @@ + return new net.minecraftforge.items.wrapper.InvWrapper(this); + } + ++ @SuppressWarnings("unchecked") + @Override + public T getCapability(net.minecraftforge.common.capabilities.Capability capability, net.minecraft.util.EnumFacing facing) + { diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityNote.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityNote.java.patch index e3fef4d685..a47e343929 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityNote.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityNote.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntityNote.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityNote.java -@@ -27,7 +27,9 @@ +@@ -29,7 +29,9 @@ public void func_145877_a() { diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntityPiston.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntityPiston.java.patch index a1d1cc237c..9a9ead7609 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntityPiston.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntityPiston.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntityPiston.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityPiston.java -@@ -148,7 +148,8 @@ +@@ -201,7 +201,8 @@ if (this.field_145850_b.func_180495_p(this.field_174879_c).func_177230_c() == Blocks.field_180384_M) { this.field_145850_b.func_180501_a(this.field_174879_c, this.field_174932_a, 3); @@ -10,7 +10,7 @@ } } } -@@ -166,7 +167,8 @@ +@@ -219,7 +220,8 @@ if (this.field_145850_b.func_180495_p(this.field_174879_c).func_177230_c() == Blocks.field_180384_M) { this.field_145850_b.func_180501_a(this.field_174879_c, this.field_174932_a, 3); diff --git a/patches/minecraft/net/minecraft/tileentity/TileEntitySign.java.patch b/patches/minecraft/net/minecraft/tileentity/TileEntitySign.java.patch index 6b66af8ce5..0919e78045 100644 --- a/patches/minecraft/net/minecraft/tileentity/TileEntitySign.java.patch +++ b/patches/minecraft/net/minecraft/tileentity/TileEntitySign.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntitySign.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntitySign.java -@@ -61,7 +61,7 @@ +@@ -60,7 +60,7 @@ } public boolean func_70003_b(int p_70003_1_, String p_70003_2_) { diff --git a/patches/minecraft/net/minecraft/util/ActionResult.java.patch b/patches/minecraft/net/minecraft/util/ActionResult.java.patch new file mode 100644 index 0000000000..28c5a82cff --- /dev/null +++ b/patches/minecraft/net/minecraft/util/ActionResult.java.patch @@ -0,0 +1,13 @@ +--- ../src-base/minecraft/net/minecraft/util/ActionResult.java ++++ ../src-work/minecraft/net/minecraft/util/ActionResult.java +@@ -20,4 +20,10 @@ + { + return this.field_188400_b; + } ++ ++ //Just a generic helper function to make typecasing easier... ++ public static ActionResult newResult(EnumActionResult result, T value) ++ { ++ return new ActionResult(result, value); ++ } + } diff --git a/patches/minecraft/net/minecraft/util/BlockPos.java.patch b/patches/minecraft/net/minecraft/util/BlockPos.java.patch deleted file mode 100644 index bb5ccf3d65..0000000000 --- a/patches/minecraft/net/minecraft/util/BlockPos.java.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/util/BlockPos.java -+++ ../src-work/minecraft/net/minecraft/util/BlockPos.java -@@ -257,6 +257,21 @@ - }; - } - -+ /** -+ * Returns a version of this BlockPos that is guaranteed to be Immutable. -+ * In most cases this will return 'this', but if 'this' is an instance of -+ * MutableBlockPos it will return a new instance of BlockPos with the same values. -+ * -+ * When storing a parameter given to you for an extended period of time, make sure you -+ * use this in case the value is changed internally. -+ * -+ * @return An immutable BlockPos. -+ */ -+ public BlockPos getImmutable() -+ { -+ return this; -+ } -+ - public static final class MutableBlockPos extends BlockPos - { - private int field_177997_b; -@@ -298,5 +313,7 @@ - this.field_177996_d = p_181079_3_; - return this; - } -+ -+ @Override public BlockPos getImmutable() { return new BlockPos(this); } - } - } diff --git a/patches/minecraft/net/minecraft/util/EnumWorldBlockLayer.java.patch b/patches/minecraft/net/minecraft/util/BlockRenderLayer.java.patch similarity index 53% rename from patches/minecraft/net/minecraft/util/EnumWorldBlockLayer.java.patch rename to patches/minecraft/net/minecraft/util/BlockRenderLayer.java.patch index 7bb192c6d1..80055839ac 100644 --- a/patches/minecraft/net/minecraft/util/EnumWorldBlockLayer.java.patch +++ b/patches/minecraft/net/minecraft/util/BlockRenderLayer.java.patch @@ -1,5 +1,5 @@ ---- ../src-base/minecraft/net/minecraft/util/EnumWorldBlockLayer.java -+++ ../src-work/minecraft/net/minecraft/util/EnumWorldBlockLayer.java +--- ../src-base/minecraft/net/minecraft/util/BlockRenderLayer.java ++++ ../src-work/minecraft/net/minecraft/util/BlockRenderLayer.java @@ -1,9 +1,5 @@ package net.minecraft.util; @@ -7,6 +7,6 @@ -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) - public enum EnumWorldBlockLayer + public enum BlockRenderLayer { SOLID("Solid"), diff --git a/patches/minecraft/net/minecraft/util/EnumFacing.java.patch b/patches/minecraft/net/minecraft/util/EnumFacing.java.patch index a0fbc640d1..241b4620f5 100644 --- a/patches/minecraft/net/minecraft/util/EnumFacing.java.patch +++ b/patches/minecraft/net/minecraft/util/EnumFacing.java.patch @@ -1,15 +1,15 @@ --- ../src-base/minecraft/net/minecraft/util/EnumFacing.java +++ ../src-work/minecraft/net/minecraft/util/EnumFacing.java -@@ -6,8 +6,6 @@ - import java.util.Iterator; - import java.util.Map; +@@ -8,8 +8,6 @@ import java.util.Random; + import net.minecraft.util.math.MathHelper; + import net.minecraft.util.math.Vec3i; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; public enum EnumFacing implements IStringSerializable { -@@ -60,7 +58,6 @@ +@@ -62,7 +60,6 @@ return func_82600_a(this.field_176759_h); } @@ -17,7 +17,7 @@ public EnumFacing func_176732_a(EnumFacing.Axis p_176732_1_) { switch (p_176732_1_) -@@ -111,7 +108,6 @@ +@@ -113,7 +110,6 @@ } } @@ -25,7 +25,7 @@ private EnumFacing func_176744_n() { switch (this) -@@ -131,7 +127,6 @@ +@@ -133,7 +129,6 @@ } } @@ -33,7 +33,7 @@ private EnumFacing func_176738_p() { switch (this) -@@ -192,7 +187,6 @@ +@@ -194,7 +189,6 @@ return this.field_176758_k; } @@ -41,7 +41,7 @@ public static EnumFacing func_176739_a(String p_176739_0_) { return p_176739_0_ == null ? null : (EnumFacing)field_176761_p.get(p_176739_0_.toLowerCase()); -@@ -218,7 +212,6 @@ +@@ -225,7 +219,6 @@ return values()[p_176741_0_.nextInt(values().length)]; } @@ -49,7 +49,7 @@ public static EnumFacing func_176737_a(float p_176737_0_, float p_176737_1_, float p_176737_2_) { EnumFacing enumfacing = NORTH; -@@ -261,7 +254,6 @@ +@@ -268,7 +261,6 @@ throw new IllegalArgumentException("No such direction: " + p_181076_0_ + " " + p_181076_1_); } @@ -57,7 +57,7 @@ public Vec3i func_176730_m() { return this.field_176756_m; -@@ -297,7 +289,6 @@ +@@ -304,7 +296,6 @@ this.field_176723_f = p_i46015_4_; } diff --git a/patches/minecraft/net/minecraft/util/IChatComponent.java.patch b/patches/minecraft/net/minecraft/util/IChatComponent.java.patch deleted file mode 100644 index 2f0530ce4c..0000000000 --- a/patches/minecraft/net/minecraft/util/IChatComponent.java.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/util/IChatComponent.java -+++ ../src-work/minecraft/net/minecraft/util/IChatComponent.java -@@ -31,7 +31,6 @@ - - String func_150260_c(); - -- @SideOnly(Side.CLIENT) - String func_150254_d(); - - List func_150253_a(); diff --git a/patches/minecraft/net/minecraft/util/IntIdentityHashBiMap.java.patch b/patches/minecraft/net/minecraft/util/IntIdentityHashBiMap.java.patch new file mode 100644 index 0000000000..2b9932be97 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/IntIdentityHashBiMap.java.patch @@ -0,0 +1,10 @@ +--- ../src-base/minecraft/net/minecraft/util/IntIdentityHashBiMap.java ++++ ../src-work/minecraft/net/minecraft/util/IntIdentityHashBiMap.java +@@ -166,7 +166,6 @@ + return Iterators.filter(Iterators.forArray(this.field_186820_d), Predicates.notNull()); + } + +- @SideOnly(Side.CLIENT) + public void func_186812_a() + { + Arrays.fill(this.field_186818_b, (Object)null); diff --git a/patches/minecraft/net/minecraft/util/MovingObjectPosition.java.patch b/patches/minecraft/net/minecraft/util/MovingObjectPosition.java.patch deleted file mode 100644 index f717cac15c..0000000000 --- a/patches/minecraft/net/minecraft/util/MovingObjectPosition.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/util/MovingObjectPosition.java -+++ ../src-work/minecraft/net/minecraft/util/MovingObjectPosition.java -@@ -10,6 +10,12 @@ - public Vec3 field_72307_f; - public Entity field_72308_g; - -+ /** Used to determine what sub-segment is hit */ -+ public int subHit = -1; -+ -+ /** Used to add extra hit info */ -+ public Object hitInfo = null; -+ - public MovingObjectPosition(Vec3 p_i45551_1_, EnumFacing p_i45551_2_, BlockPos p_i45551_3_) - { - this(MovingObjectPosition.MovingObjectType.BLOCK, p_i45551_1_, p_i45551_2_, p_i45551_3_); diff --git a/patches/minecraft/net/minecraft/util/ResourceLocation.java.patch b/patches/minecraft/net/minecraft/util/ResourceLocation.java.patch deleted file mode 100644 index bef0586ad9..0000000000 --- a/patches/minecraft/net/minecraft/util/ResourceLocation.java.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/util/ResourceLocation.java -+++ ../src-work/minecraft/net/minecraft/util/ResourceLocation.java -@@ -1,7 +1,5 @@ - package net.minecraft.util; - --import net.minecraftforge.fml.relauncher.Side; --import net.minecraftforge.fml.relauncher.SideOnly; - import org.apache.commons.lang3.Validate; - - public class ResourceLocation -@@ -21,7 +19,6 @@ - this(0, func_177516_a(p_i1293_1_)); - } - -- @SideOnly(Side.CLIENT) - public ResourceLocation(String p_i1292_1_, String p_i1292_2_) - { - this(0, new String[] {p_i1292_1_, p_i1292_2_}); -@@ -50,7 +47,6 @@ - return this.field_110625_b; - } - -- @SideOnly(Side.CLIENT) - public String func_110624_b() - { - return this.field_110626_a; diff --git a/patches/minecraft/net/minecraft/util/Session.java.patch b/patches/minecraft/net/minecraft/util/Session.java.patch index 19d55db7eb..db649de70e 100644 --- a/patches/minecraft/net/minecraft/util/Session.java.patch +++ b/patches/minecraft/net/minecraft/util/Session.java.patch @@ -1,15 +1,6 @@ --- ../src-base/minecraft/net/minecraft/util/Session.java +++ ../src-work/minecraft/net/minecraft/util/Session.java -@@ -5,6 +5,8 @@ - import com.mojang.util.UUIDTypeAdapter; - import java.util.Map; - import java.util.UUID; -+ -+import net.minecraftforge.fml.common.FMLLog; - import net.minecraftforge.fml.relauncher.Side; - import net.minecraftforge.fml.relauncher.SideOnly; - -@@ -15,9 +17,24 @@ +@@ -15,9 +15,25 @@ private final String field_148257_b; private final String field_148258_c; private final Session.Type field_152429_d; @@ -22,19 +13,20 @@ + { + p_i1098_1_ = "MissingName"; + p_i1098_2_ = p_i1098_3_ = "NotValid"; -+ FMLLog.getLogger().log(org.apache.logging.log4j.Level.WARN, "========================================================="); -+ FMLLog.getLogger().log(org.apache.logging.log4j.Level.WARN, "WARNING!! the username was not set for this session, typically"); -+ FMLLog.getLogger().log(org.apache.logging.log4j.Level.WARN, "this means you installed Forge incorrectly. We have set your"); -+ FMLLog.getLogger().log(org.apache.logging.log4j.Level.WARN, "name to \"MissingName\" and your session to nothing. Please"); -+ FMLLog.getLogger().log(org.apache.logging.log4j.Level.WARN, "check your installation and post a console log from the launcher"); -+ FMLLog.getLogger().log(org.apache.logging.log4j.Level.WARN, "when asking for help!"); -+ FMLLog.getLogger().log(org.apache.logging.log4j.Level.WARN, "========================================================="); ++ org.apache.logging.log4j.Logger logger = net.minecraftforge.fml.common.FMLLog.getLogger(); ++ logger.log(org.apache.logging.log4j.Level.WARN, "========================================================="); ++ logger.log(org.apache.logging.log4j.Level.WARN, "WARNING!! the username was not set for this session, typically"); ++ logger.log(org.apache.logging.log4j.Level.WARN, "this means you installed Forge incorrectly. We have set your"); ++ logger.log(org.apache.logging.log4j.Level.WARN, "name to \"MissingName\" and your session to nothing. Please"); ++ logger.log(org.apache.logging.log4j.Level.WARN, "check your installation and post a console log from the launcher"); ++ logger.log(org.apache.logging.log4j.Level.WARN, "when asking for help!"); ++ logger.log(org.apache.logging.log4j.Level.WARN, "========================================================="); + } + this.field_74286_b = p_i1098_1_; this.field_148257_b = p_i1098_2_; this.field_148258_c = p_i1098_3_; -@@ -49,11 +66,13 @@ +@@ -49,14 +65,29 @@ try { UUID uuid = UUIDTypeAdapter.fromString(this.func_148255_b()); @@ -50,10 +42,6 @@ } } -@@ -62,6 +81,19 @@ - return this.field_152429_d; - } - + /* ======================================== FORGE START ===================================== */ + //For internal use only. Modders should never need to use this. + public void setProperties(com.mojang.authlib.properties.PropertyMap properties) diff --git a/patches/minecraft/net/minecraft/util/SoundEvent.java.patch b/patches/minecraft/net/minecraft/util/SoundEvent.java.patch new file mode 100644 index 0000000000..26b5a580d3 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/SoundEvent.java.patch @@ -0,0 +1,14 @@ +--- ../src-base/minecraft/net/minecraft/util/SoundEvent.java ++++ ../src-work/minecraft/net/minecraft/util/SoundEvent.java +@@ -4,9 +4,9 @@ + import net.minecraftforge.fml.relauncher.Side; + import net.minecraftforge.fml.relauncher.SideOnly; + +-public class SoundEvent ++public class SoundEvent extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl + { +- public static final RegistryNamespaced field_187505_a = new RegistryNamespaced(); ++ public static final RegistryNamespaced field_187505_a = net.minecraftforge.fml.common.registry.GameData.getSoundEventRegistry(); + private final ResourceLocation field_187506_b; + private static int field_187507_c = 0; + diff --git a/patches/minecraft/net/minecraft/util/TabCompleter.java.patch b/patches/minecraft/net/minecraft/util/TabCompleter.java.patch new file mode 100644 index 0000000000..5fe77be006 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/TabCompleter.java.patch @@ -0,0 +1,39 @@ +--- ../src-base/minecraft/net/minecraft/util/TabCompleter.java ++++ ../src-work/minecraft/net/minecraft/util/TabCompleter.java +@@ -53,13 +53,14 @@ + this.field_186844_a.func_146175_b(i - this.field_186844_a.func_146198_h()); + } + +- this.field_186844_a.func_146191_b((String)this.field_186849_f.get(this.field_186848_e++)); ++ this.field_186844_a.func_146191_b(net.minecraft.util.text.TextFormatting.func_110646_a(this.field_186849_f.get(this.field_186848_e++))); + } + + private void func_186838_a(String p_186838_1_) + { + if (p_186838_1_.length() >= 1) + { ++ net.minecraftforge.client.ClientCommandHandler.instance.autoComplete(p_186838_1_); + Minecraft.func_71410_x().field_71439_g.field_71174_a.func_147297_a(new CPacketTabComplete(p_186838_1_, this.func_186839_b(), this.field_186845_b)); + this.field_186847_d = true; + } +@@ -74,6 +75,12 @@ + this.field_186846_c = false; + this.field_186849_f.clear(); + ++ String[] complete = net.minecraftforge.client.ClientCommandHandler.instance.latestAutoComplete; ++ if (complete != null) ++ { ++ p_186840_1_ = com.google.common.collect.ObjectArrays.concat(complete, p_186840_1_, String.class); ++ } ++ + for (String s : p_186840_1_) + { + if (!s.isEmpty()) +@@ -84,6 +91,7 @@ + + String s1 = this.field_186844_a.func_146179_b().substring(this.field_186844_a.func_146197_a(-1, this.field_186844_a.func_146198_h(), false)); + String s2 = org.apache.commons.lang3.StringUtils.getCommonPrefix(p_186840_1_); ++ s2 = net.minecraft.util.text.TextFormatting.func_110646_a(s2); + + if (!s2.isEmpty() && !s1.equalsIgnoreCase(s2)) + { diff --git a/patches/minecraft/net/minecraft/util/Vec3.java.patch b/patches/minecraft/net/minecraft/util/Vec3.java.patch deleted file mode 100644 index 2cc1ac5181..0000000000 --- a/patches/minecraft/net/minecraft/util/Vec3.java.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/util/Vec3.java -+++ ../src-work/minecraft/net/minecraft/util/Vec3.java -@@ -1,8 +1,5 @@ - package net.minecraft.util; - --import net.minecraftforge.fml.relauncher.Side; --import net.minecraftforge.fml.relauncher.SideOnly; -- - public class Vec3 - { - public final double field_72450_a; -@@ -36,7 +33,6 @@ - this((double)p_i46377_1_.func_177958_n(), (double)p_i46377_1_.func_177956_o(), (double)p_i46377_1_.func_177952_p()); - } - -- @SideOnly(Side.CLIENT) - public Vec3 func_72444_a(Vec3 p_72444_1_) - { - return new Vec3(p_72444_1_.field_72450_a - this.field_72450_a, p_72444_1_.field_72448_b - this.field_72448_b, p_72444_1_.field_72449_c - this.field_72449_c); -@@ -53,7 +49,6 @@ - return this.field_72450_a * p_72430_1_.field_72450_a + this.field_72448_b * p_72430_1_.field_72448_b + this.field_72449_c * p_72430_1_.field_72449_c; - } - -- @SideOnly(Side.CLIENT) - public Vec3 func_72431_c(Vec3 p_72431_1_) - { - return new Vec3(this.field_72448_b * p_72431_1_.field_72449_c - this.field_72449_c * p_72431_1_.field_72448_b, this.field_72449_c * p_72431_1_.field_72450_a - this.field_72450_a * p_72431_1_.field_72449_c, this.field_72450_a * p_72431_1_.field_72448_b - this.field_72448_b * p_72431_1_.field_72450_a); -@@ -79,7 +74,6 @@ - return new Vec3(this.field_72450_a + p_72441_1_, this.field_72448_b + p_72441_3_, this.field_72449_c + p_72441_5_); - } - -- @SideOnly(Side.CLIENT) - public double func_72438_d(Vec3 p_72438_1_) - { - double d0 = p_72438_1_.field_72450_a - this.field_72450_a; diff --git a/patches/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch b/patches/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch deleted file mode 100644 index b8f7e3aa4e..0000000000 --- a/patches/minecraft/net/minecraft/util/WeightedRandomChestContent.java.patch +++ /dev/null @@ -1,68 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/util/WeightedRandomChestContent.java -+++ ../src-work/minecraft/net/minecraft/util/WeightedRandomChestContent.java -@@ -36,48 +36,39 @@ - for (int i = 0; i < p_177630_3_; ++i) - { - WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.func_76271_a(p_177630_0_, p_177630_1_); -- int j = weightedrandomchestcontent.field_76295_d + p_177630_0_.nextInt(weightedrandomchestcontent.field_76296_e - weightedrandomchestcontent.field_76295_d + 1); -+ ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(p_177630_0_, p_177630_2_); - -- if (weightedrandomchestcontent.field_76297_b.func_77976_d() >= j) -+ for (ItemStack itemstack1 : stacks) - { -- ItemStack itemstack1 = weightedrandomchestcontent.field_76297_b.func_77946_l(); -- itemstack1.field_77994_a = j; - p_177630_2_.func_70299_a(p_177630_0_.nextInt(p_177630_2_.func_70302_i_()), itemstack1); - } -- else -- { -- for (int k = 0; k < j; ++k) -- { -- ItemStack itemstack = weightedrandomchestcontent.field_76297_b.func_77946_l(); -- itemstack.field_77994_a = 1; -- p_177630_2_.func_70299_a(p_177630_0_.nextInt(p_177630_2_.func_70302_i_()), itemstack); -- } -- } - } - } - -+ // -- Forge hooks -+ /** -+ * Allow a mod to submit a custom implementation that can delegate item stack generation beyond simple stack lookup -+ * -+ * @param random The current random for generation -+ * @param newInventory The inventory being generated (do not populate it, but you can refer to it) -+ * @return An array of {@link ItemStack} to put into the chest -+ */ -+ protected ItemStack[] generateChestContent(Random random, IInventory newInventory) -+ { -+ return net.minecraftforge.common.ChestGenHooks.generateStacks(random, field_76297_b, field_76295_d, field_76296_e); -+ } -+ - public static void func_177631_a(Random p_177631_0_, List p_177631_1_, TileEntityDispenser p_177631_2_, int p_177631_3_) - { - for (int i = 0; i < p_177631_3_; ++i) - { - WeightedRandomChestContent weightedrandomchestcontent = (WeightedRandomChestContent)WeightedRandom.func_76271_a(p_177631_0_, p_177631_1_); -- int j = weightedrandomchestcontent.field_76295_d + p_177631_0_.nextInt(weightedrandomchestcontent.field_76296_e - weightedrandomchestcontent.field_76295_d + 1); -+ ItemStack[] stacks = weightedrandomchestcontent.generateChestContent(p_177631_0_, p_177631_2_); - -- if (weightedrandomchestcontent.field_76297_b.func_77976_d() >= j) -+ for (ItemStack itemstack1 : stacks) - { -- ItemStack itemstack1 = weightedrandomchestcontent.field_76297_b.func_77946_l(); -- itemstack1.field_77994_a = j; - p_177631_2_.func_70299_a(p_177631_0_.nextInt(p_177631_2_.func_70302_i_()), itemstack1); - } -- else -- { -- for (int k = 0; k < j; ++k) -- { -- ItemStack itemstack = weightedrandomchestcontent.field_76297_b.func_77946_l(); -- itemstack.field_77994_a = 1; -- p_177631_2_.func_70299_a(p_177631_0_.nextInt(p_177631_2_.func_70302_i_()), itemstack); -- } -- } - } - } - diff --git a/patches/minecraft/net/minecraft/util/math/BlockPos.java.patch b/patches/minecraft/net/minecraft/util/math/BlockPos.java.patch new file mode 100644 index 0000000000..33fca8b2b9 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/math/BlockPos.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/net/minecraft/util/math/BlockPos.java ++++ ../src-work/minecraft/net/minecraft/util/math/BlockPos.java +@@ -443,5 +443,8 @@ + { + return this.func_185343_d(this.field_185347_c + p_185341_1_.func_82601_c(), this.field_185348_d + p_185341_1_.func_96559_d(), this.field_185349_e + p_185341_1_.func_82599_e()); + } ++ ++ // This method can safely be removed once vanilla adds it - MC-100165 ++ @Override public BlockPos func_185334_h() { return new BlockPos(this); } + } + } diff --git a/patches/minecraft/net/minecraft/util/math/RayTraceResult.java.patch b/patches/minecraft/net/minecraft/util/math/RayTraceResult.java.patch new file mode 100644 index 0000000000..9072515469 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/math/RayTraceResult.java.patch @@ -0,0 +1,15 @@ +--- ../src-base/minecraft/net/minecraft/util/math/RayTraceResult.java ++++ ../src-work/minecraft/net/minecraft/util/math/RayTraceResult.java +@@ -5,6 +5,12 @@ + + public class RayTraceResult + { ++ /** Used to determine what sub-segment is hit */ ++ public int subHit = -1; ++ ++ /** Used to add extra hit info */ ++ public Object hitInfo = null; ++ + private BlockPos field_178783_e; + public RayTraceResult.Type field_72313_a; + public EnumFacing field_178784_b; diff --git a/patches/minecraft/net/minecraft/util/math/Vec3d.java.patch b/patches/minecraft/net/minecraft/util/math/Vec3d.java.patch new file mode 100644 index 0000000000..662335a594 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/math/Vec3d.java.patch @@ -0,0 +1,19 @@ +--- ../src-base/minecraft/net/minecraft/util/math/Vec3d.java ++++ ../src-work/minecraft/net/minecraft/util/math/Vec3d.java +@@ -1,8 +1,5 @@ + package net.minecraft.util.math; + +-import net.minecraftforge.fml.relauncher.Side; +-import net.minecraftforge.fml.relauncher.SideOnly; +- + public class Vec3d + { + public static final Vec3d field_186680_a = new Vec3d(0.0D, 0.0D, 0.0D); +@@ -53,7 +50,6 @@ + return this.field_72450_a * p_72430_1_.field_72450_a + this.field_72448_b * p_72430_1_.field_72448_b + this.field_72449_c * p_72430_1_.field_72449_c; + } + +- @SideOnly(Side.CLIENT) + public Vec3d func_72431_c(Vec3d p_72431_1_) + { + return new Vec3d(this.field_72448_b * p_72431_1_.field_72449_c - this.field_72449_c * p_72431_1_.field_72448_b, this.field_72449_c * p_72431_1_.field_72450_a - this.field_72450_a * p_72431_1_.field_72449_c, this.field_72450_a * p_72431_1_.field_72448_b - this.field_72448_b * p_72431_1_.field_72450_a); diff --git a/patches/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java.patch b/patches/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java.patch new file mode 100644 index 0000000000..ae4a01c842 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java.patch @@ -0,0 +1,14 @@ +--- ../src-base/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java ++++ ../src-work/minecraft/net/minecraft/util/registry/RegistryNamespacedDefaultedByKey.java +@@ -57,4 +57,11 @@ + V v = super.func_186801_a(p_186801_1_); + return (V)(v == null ? this.field_148761_e : v); + } ++ ++ //Bypass functions to allow querying this registry WITHOUT getting the defaulted value. ++ // MODDERS DO NOT USE THIS IS FOR FORGE INTERNAL CHECKS ++ public int getIDForObjectBypass(V bypass) { return super.func_148757_b(bypass); } ++ public K getNameForObjectBypass(V value) { return super.func_177774_c(value); } ++ public V getObjectBypass(K name) { return super.func_82594_a(name); } ++ public V getObjectByIdBypass(int id){ return super.func_148754_a(id); } + } diff --git a/patches/minecraft/net/minecraft/util/text/ITextComponent.java.patch b/patches/minecraft/net/minecraft/util/text/ITextComponent.java.patch new file mode 100644 index 0000000000..d7c43cfc4c --- /dev/null +++ b/patches/minecraft/net/minecraft/util/text/ITextComponent.java.patch @@ -0,0 +1,10 @@ +--- ../src-base/minecraft/net/minecraft/util/text/ITextComponent.java ++++ ../src-work/minecraft/net/minecraft/util/text/ITextComponent.java +@@ -33,7 +33,6 @@ + + String func_150260_c(); + +- @SideOnly(Side.CLIENT) + String func_150254_d(); + + List func_150253_a(); diff --git a/patches/minecraft/net/minecraft/util/ChatStyle.java.patch b/patches/minecraft/net/minecraft/util/text/Style.java.patch similarity index 56% rename from patches/minecraft/net/minecraft/util/ChatStyle.java.patch rename to patches/minecraft/net/minecraft/util/text/Style.java.patch index 55efa51da1..93a20c90a4 100644 --- a/patches/minecraft/net/minecraft/util/ChatStyle.java.patch +++ b/patches/minecraft/net/minecraft/util/text/Style.java.patch @@ -1,5 +1,5 @@ ---- ../src-base/minecraft/net/minecraft/util/ChatStyle.java -+++ ../src-work/minecraft/net/minecraft/util/ChatStyle.java +--- ../src-base/minecraft/net/minecraft/util/text/Style.java ++++ ../src-work/minecraft/net/minecraft/util/text/Style.java @@ -229,7 +229,6 @@ return this; } diff --git a/patches/minecraft/net/minecraft/util/ChatComponentStyle.java.patch b/patches/minecraft/net/minecraft/util/text/TextComponentBase.java.patch similarity index 58% rename from patches/minecraft/net/minecraft/util/ChatComponentStyle.java.patch rename to patches/minecraft/net/minecraft/util/text/TextComponentBase.java.patch index fd4f0534d1..4307987cc3 100644 --- a/patches/minecraft/net/minecraft/util/ChatComponentStyle.java.patch +++ b/patches/minecraft/net/minecraft/util/text/TextComponentBase.java.patch @@ -1,5 +1,5 @@ ---- ../src-base/minecraft/net/minecraft/util/ChatComponentStyle.java -+++ ../src-work/minecraft/net/minecraft/util/ChatComponentStyle.java +--- ../src-base/minecraft/net/minecraft/util/text/TextComponentBase.java ++++ ../src-work/minecraft/net/minecraft/util/text/TextComponentBase.java @@ -74,7 +74,6 @@ return stringbuilder.toString(); } diff --git a/patches/minecraft/net/minecraft/util/StringTranslate.java.patch b/patches/minecraft/net/minecraft/util/text/translation/LanguageMap.java.patch similarity index 58% rename from patches/minecraft/net/minecraft/util/StringTranslate.java.patch rename to patches/minecraft/net/minecraft/util/text/translation/LanguageMap.java.patch index be6f428274..b6e9a122fb 100644 --- a/patches/minecraft/net/minecraft/util/StringTranslate.java.patch +++ b/patches/minecraft/net/minecraft/util/text/translation/LanguageMap.java.patch @@ -1,10 +1,10 @@ ---- ../src-base/minecraft/net/minecraft/util/StringTranslate.java -+++ ../src-work/minecraft/net/minecraft/util/StringTranslate.java +--- ../src-base/minecraft/net/minecraft/util/text/translation/LanguageMap.java ++++ ../src-work/minecraft/net/minecraft/util/text/translation/LanguageMap.java @@ -23,9 +23,29 @@ - public StringTranslate() + public LanguageMap() { -+ InputStream inputstream = StringTranslate.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang"); ++ InputStream inputstream = LanguageMap.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang"); + inject(this, inputstream); + } + @@ -13,25 +13,25 @@ + inject(field_74817_a, inputstream); + } + -+ private static void inject(StringTranslate inst, InputStream inputstream) ++ private static void inject(LanguageMap inst, InputStream inputstream) + { -+ java.util.HashMap map = parseLangFile(inputstream); ++ Map map = parseLangFile(inputstream); + inst.field_74816_c.putAll(map); + inst.field_150511_e = System.currentTimeMillis(); + } + -+ public static java.util.HashMap parseLangFile(InputStream inputstream) ++ public static Map parseLangFile(InputStream inputstream) + { -+ java.util.HashMap table = Maps.newHashMap(); ++ Map table = Maps.newHashMap(); try { -- InputStream inputstream = StringTranslate.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang"); +- InputStream inputstream = LanguageMap.class.getResourceAsStream("/assets/minecraft/lang/en_US.lang"); + inputstream = net.minecraftforge.fml.common.FMLCommonHandler.instance().loadLanguage(table, inputstream); + if (inputstream == null) return table; for (String s : IOUtils.readLines(inputstream, Charsets.UTF_8)) { -@@ -37,17 +57,17 @@ +@@ -37,17 +57,18 @@ { String s1 = astring[0]; String s2 = field_111053_a.matcher(astring[1]).replaceAll("%$1s"); @@ -43,12 +43,12 @@ - this.field_150511_e = System.currentTimeMillis(); } -- catch (IOException var7) -+ catch (Exception var7) + catch (IOException var7) { ; } ++ catch (Exception ex) {} + return table; } - static StringTranslate func_74808_a() + static LanguageMap func_74808_a() diff --git a/patches/minecraft/net/minecraft/world/BossInfo.java.patch b/patches/minecraft/net/minecraft/world/BossInfo.java.patch new file mode 100644 index 0000000000..c5bb266f34 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/BossInfo.java.patch @@ -0,0 +1,35 @@ +--- ../src-base/minecraft/net/minecraft/world/BossInfo.java ++++ ../src-work/minecraft/net/minecraft/world/BossInfo.java +@@ -2,8 +2,6 @@ + + import java.util.UUID; + import net.minecraft.util.text.ITextComponent; +-import net.minecraftforge.fml.relauncher.Side; +-import net.minecraftforge.fml.relauncher.SideOnly; + + public abstract class BossInfo + { +@@ -35,7 +33,6 @@ + return this.field_186749_a; + } + +- @SideOnly(Side.CLIENT) + public void func_186739_a(ITextComponent p_186739_1_) + { + this.field_186749_a = p_186739_1_; +@@ -56,7 +53,6 @@ + return this.field_186751_c; + } + +- @SideOnly(Side.CLIENT) + public void func_186745_a(BossInfo.Color p_186745_1_) + { + this.field_186751_c = p_186745_1_; +@@ -67,7 +63,6 @@ + return this.field_186752_d; + } + +- @SideOnly(Side.CLIENT) + public void func_186746_a(BossInfo.Overlay p_186746_1_) + { + this.field_186752_d = p_186746_1_; diff --git a/patches/minecraft/net/minecraft/world/BossInfoServer.java.patch b/patches/minecraft/net/minecraft/world/BossInfoServer.java.patch new file mode 100644 index 0000000000..a10f0ab75e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/BossInfoServer.java.patch @@ -0,0 +1,35 @@ +--- ../src-base/minecraft/net/minecraft/world/BossInfoServer.java ++++ ../src-work/minecraft/net/minecraft/world/BossInfoServer.java +@@ -9,8 +9,6 @@ + import net.minecraft.network.play.server.SPacketUpdateEntityNBT; + import net.minecraft.util.math.MathHelper; + import net.minecraft.util.text.ITextComponent; +-import net.minecraftforge.fml.relauncher.Side; +-import net.minecraftforge.fml.relauncher.SideOnly; + + public class BossInfoServer extends BossInfo + { +@@ -34,7 +32,6 @@ + } + } + +- @SideOnly(Side.CLIENT) + public void func_186745_a(BossInfo.Color p_186745_1_) + { + if (p_186745_1_ != this.field_186751_c) +@@ -44,7 +41,6 @@ + } + } + +- @SideOnly(Side.CLIENT) + public void func_186746_a(BossInfo.Overlay p_186746_1_) + { + if (p_186746_1_ != this.field_186752_d) +@@ -87,7 +83,6 @@ + return this; + } + +- @SideOnly(Side.CLIENT) + public void func_186739_a(ITextComponent p_186739_1_) + { + if (!Objects.equal(p_186739_1_, this.field_186749_a)) diff --git a/patches/minecraft/net/minecraft/world/ChunkCache.java.patch b/patches/minecraft/net/minecraft/world/ChunkCache.java.patch index 4bb2bf0d9d..7c90984810 100644 --- a/patches/minecraft/net/minecraft/world/ChunkCache.java.patch +++ b/patches/minecraft/net/minecraft/world/ChunkCache.java.patch @@ -18,16 +18,17 @@ return this.field_72817_c[i][j].func_177413_a(p_175629_1_, p_175629_2_); } } -@@ -150,7 +154,7 @@ +@@ -150,7 +154,8 @@ public boolean func_175623_d(BlockPos p_175623_1_) { -- return this.func_180495_p(p_175623_1_).func_177230_c().func_149688_o() == Material.field_151579_a; -+ return this.func_180495_p(p_175623_1_).func_177230_c().isAir(this, p_175623_1_); +- return this.func_180495_p(p_175623_1_).func_185904_a() == Material.field_151579_a; ++ IBlockState state = this.func_180495_p(p_175623_1_); ++ return state.func_177230_c().isAir(state, this, p_175623_1_); } @SideOnly(Side.CLIENT) -@@ -160,6 +164,7 @@ +@@ -160,6 +165,7 @@ { int i = (p_175628_2_.func_177958_n() >> 4) - this.field_72818_a; int j = (p_175628_2_.func_177952_p() >> 4) - this.field_72816_b; @@ -35,7 +36,7 @@ return this.field_72817_c[i][j].func_177413_a(p_175628_1_, p_175628_2_); } else -@@ -179,4 +184,16 @@ +@@ -178,4 +184,17 @@ { return this.field_72815_e.func_175624_G(); } @@ -49,6 +50,7 @@ + if (x < 0 || x >= field_72817_c.length || z < 0 || z >= field_72817_c[x].length) return _default; + if (field_72817_c[x][z] == null) return _default; + -+ return func_180495_p(pos).func_177230_c().isSideSolid(this, pos, side); ++ IBlockState state = func_180495_p(pos); ++ return state.func_177230_c().isSideSolid(state, this, pos, side); + } } diff --git a/patches/minecraft/net/minecraft/world/DimensionType.java.patch b/patches/minecraft/net/minecraft/world/DimensionType.java.patch new file mode 100644 index 0000000000..b7c257354a --- /dev/null +++ b/patches/minecraft/net/minecraft/world/DimensionType.java.patch @@ -0,0 +1,37 @@ +--- ../src-base/minecraft/net/minecraft/world/DimensionType.java ++++ ../src-work/minecraft/net/minecraft/world/DimensionType.java +@@ -13,6 +13,7 @@ + private final String field_186075_e; + private final String field_186076_f; + private final Class field_186077_g; ++ private boolean shouldLoadSpawn = false; + + private DimensionType(int p_i46672_3_, String p_i46672_4_, String p_i46672_5_, Class p_i46672_6_) + { +@@ -20,6 +21,7 @@ + this.field_186075_e = p_i46672_4_; + this.field_186076_f = p_i46672_5_; + this.field_186077_g = p_i46672_6_; ++ this.shouldLoadSpawn = p_i46672_3_ == 0; + } + + public int func_186068_a() +@@ -74,4 +76,18 @@ + + throw new IllegalArgumentException("Invalid dimension id " + p_186069_0_); + } ++ ++ public boolean shouldLoadSpawn(){ return this.shouldLoadSpawn; } ++ public DimensionType setLoadSpawn(boolean value) { this.shouldLoadSpawn = value; return this; } ++ ++ private static Class[] ENUM_ARGS = {int.class, String.class, String.class, Class.class}; ++ static { net.minecraftforge.common.util.EnumHelper.testEnum(DimensionType.class, ENUM_ARGS); } ++ public static DimensionType register(String name, String suffix, int id, Class provider, boolean keepLoaded) ++ { ++ String enum_name = name.replace(" ", "_").toLowerCase(); ++ DimensionType ret = net.minecraftforge.common.util.EnumHelper.addEnum(DimensionType.class, enum_name, ENUM_ARGS, ++ id, name, suffix, provider); ++ return ret.setLoadSpawn(keepLoaded); ++ } ++ //TODO: Unregister? There is no way to really delete a enum value... + } diff --git a/patches/minecraft/net/minecraft/world/Explosion.java.patch b/patches/minecraft/net/minecraft/world/Explosion.java.patch index a7cbd02cf7..73813f3694 100644 --- a/patches/minecraft/net/minecraft/world/Explosion.java.patch +++ b/patches/minecraft/net/minecraft/world/Explosion.java.patch @@ -1,39 +1,39 @@ --- ../src-base/minecraft/net/minecraft/world/Explosion.java +++ ../src-work/minecraft/net/minecraft/world/Explosion.java -@@ -38,6 +38,7 @@ +@@ -40,6 +40,7 @@ private final float field_77280_f; private final List field_77281_g; - private final Map field_77288_k; -+ private final Vec3 position; + private final Map field_77288_k; ++ private final Vec3d position; @SideOnly(Side.CLIENT) public Explosion(World p_i45752_1_, Entity p_i45752_2_, double p_i45752_3_, double p_i45752_5_, double p_i45752_7_, float p_i45752_9_, List p_i45752_10_) -@@ -65,6 +66,7 @@ +@@ -67,6 +68,7 @@ this.field_77282_d = p_i45754_7_; this.field_77286_a = p_i45754_10_; this.field_82755_b = p_i45754_11_; -+ this.position = new Vec3(field_77284_b, field_77285_c, field_77282_d); ++ this.position = new Vec3d(field_77284_b, field_77285_c, field_77282_d); } public void func_77278_a() -@@ -99,7 +101,7 @@ +@@ -101,7 +103,7 @@ - if (iblockstate.func_177230_c().func_149688_o() != Material.field_151579_a) + if (iblockstate.func_185904_a() != Material.field_151579_a) { - float f2 = this.field_77283_e != null ? this.field_77283_e.func_180428_a(this, this.field_77287_j, blockpos, iblockstate) : iblockstate.func_177230_c().func_149638_a((Entity)null); + float f2 = this.field_77283_e != null ? this.field_77283_e.func_180428_a(this, this.field_77287_j, blockpos, iblockstate) : iblockstate.func_177230_c().getExplosionResistance(field_77287_j, blockpos, (Entity)null, this); f -= (f2 + 0.3F) * 0.3F; } -@@ -126,6 +128,7 @@ +@@ -128,6 +130,7 @@ int j2 = MathHelper.func_76128_c(this.field_77282_d - (double)f3 - 1.0D); int j1 = MathHelper.func_76128_c(this.field_77282_d + (double)f3 + 1.0D); List list = this.field_77287_j.func_72839_b(this.field_77283_e, new AxisAlignedBB((double)k1, (double)i2, (double)j2, (double)l1, (double)i1, (double)j1)); + net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.field_77287_j, this, list, f3); - Vec3 vec3 = new Vec3(this.field_77284_b, this.field_77285_c, this.field_77282_d); + Vec3d vec3d = new Vec3d(this.field_77284_b, this.field_77285_c, this.field_77282_d); for (int k2 = 0; k2 < list.size(); ++k2) -@@ -213,8 +216,7 @@ +@@ -227,8 +230,7 @@ block.func_180653_a(this.field_77287_j, blockpos, this.field_77287_j.func_180495_p(blockpos), 1.0F / this.field_77280_f, 0); } @@ -43,10 +43,10 @@ } } } -@@ -250,4 +252,6 @@ +@@ -264,4 +266,6 @@ { return this.field_77281_g; } + -+ public Vec3 getPosition(){ return this.position; } ++ public Vec3d getPosition(){ return this.position; } } diff --git a/patches/minecraft/net/minecraft/world/World.java.patch b/patches/minecraft/net/minecraft/world/World.java.patch index c4358f475c..5e1530d23e 100644 --- a/patches/minecraft/net/minecraft/world/World.java.patch +++ b/patches/minecraft/net/minecraft/world/World.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/World.java +++ ../src-work/minecraft/net/minecraft/world/World.java -@@ -57,6 +57,13 @@ +@@ -60,6 +60,13 @@ public abstract class World implements IBlockAccess { @@ -14,7 +14,7 @@ private int field_181546_a = 63; protected boolean field_72999_e; public final List field_72996_f = Lists.newArrayList(); -@@ -98,6 +105,10 @@ +@@ -101,6 +108,10 @@ private final WorldBorder field_175728_M; int[] field_72994_J; @@ -24,8 +24,8 @@ + protected World(ISaveHandler p_i45749_1_, WorldInfo p_i45749_2_, WorldProvider p_i45749_3_, Profiler p_i45749_4_, boolean p_i45749_5_) { - this.field_72990_M = this.field_73012_v.nextInt(12000); -@@ -110,6 +121,7 @@ + this.field_73021_x = Lists.newArrayList(new IWorldEventListener[] {this.field_184152_t}); +@@ -115,6 +126,7 @@ this.field_73011_w = p_i45749_3_; this.field_72995_K = p_i45749_5_; this.field_175728_M = p_i45749_3_.func_177501_r(); @@ -33,7 +33,7 @@ } public World func_175643_b() -@@ -119,13 +131,18 @@ +@@ -124,13 +136,18 @@ public BiomeGenBase func_180494_b(final BlockPos p_180494_1_) { @@ -55,7 +55,7 @@ } catch (Throwable throwable) { -@@ -135,7 +152,7 @@ +@@ -140,7 +157,7 @@ { public String call() throws Exception { @@ -64,25 +64,25 @@ } }); throw new ReportedException(crashreport); -@@ -143,7 +160,7 @@ +@@ -148,7 +165,7 @@ } else { -- return this.field_73011_w.func_177499_m().func_180300_a(p_180494_1_, BiomeGenBase.field_76772_c); -+ return this.field_73011_w.func_177499_m().func_180300_a(pos, BiomeGenBase.field_76772_c); +- return this.field_73011_w.func_177499_m().func_180300_a(p_180494_1_, Biomes.field_76772_c); ++ return this.field_73011_w.func_177499_m().func_180300_a(pos, Biomes.field_76772_c); } } -@@ -184,7 +201,7 @@ +@@ -194,7 +211,7 @@ public boolean func_175623_d(BlockPos p_175623_1_) { -- return this.func_180495_p(p_175623_1_).func_177230_c().func_149688_o() == Material.field_151579_a; -+ return this.func_180495_p(p_175623_1_).func_177230_c().isAir(this, p_175623_1_); +- return this.func_180495_p(p_175623_1_).func_185904_a() == Material.field_151579_a; ++ return this.func_180495_p(p_175623_1_).func_177230_c().isAir(this.func_180495_p(p_175623_1_), this, p_175623_1_); } public boolean func_175667_e(BlockPos p_175667_1_) -@@ -284,39 +301,63 @@ +@@ -291,37 +308,61 @@ { Chunk chunk = this.func_175726_f(p_180501_1_); Block block = p_180501_2_.func_177230_c(); @@ -93,9 +93,9 @@ + blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(this, p_180501_1_, p_180501_3_); + this.capturedBlockSnapshots.add(blockSnapshot); + } -+ Block oldBlock = func_180495_p(p_180501_1_).func_177230_c(); -+ int oldLight = oldBlock.getLightValue(this, p_180501_1_); -+ int oldOpacity = oldBlock.getLightOpacity(this, p_180501_1_); ++ IBlockState oldState = func_180495_p(p_180501_1_); ++ int oldLight = oldState.getLightValue(this, p_180501_1_); ++ int oldOpacity = oldState.getLightOpacity(this, p_180501_1_); + IBlockState iblockstate = chunk.func_177436_a(p_180501_1_, p_180501_2_); @@ -106,10 +106,8 @@ } else { - Block block1 = iblockstate.func_177230_c(); - -- if (block.func_149717_k() != block1.func_149717_k() || block.func_149750_m() != block1.func_149750_m()) -+ if (block.getLightOpacity(this, p_180501_1_) != oldOpacity || block.getLightValue(this, p_180501_1_) != oldLight) +- if (p_180501_2_.func_185891_c() != iblockstate.func_185891_c() || p_180501_2_.func_185906_d() != iblockstate.func_185906_d()) ++ if (p_180501_2_.getLightOpacity(this, p_180501_1_) != oldOpacity || p_180501_2_.getLightValue(this, p_180501_1_) != oldLight) { this.field_72984_F.func_76320_a("checkLight"); this.func_175664_x(p_180501_1_); @@ -119,35 +117,35 @@ - if ((p_180501_3_ & 2) != 0 && (!this.field_72995_K || (p_180501_3_ & 4) == 0) && chunk.func_150802_k()) + if (blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates { -- this.func_175689_h(p_180501_1_); -+ this.markAndNotifyBlock(p_180501_1_, chunk, iblockstate, p_180501_2_, p_180501_3_); // Modularize client and physic updates +- this.func_184138_a(p_180501_1_, iblockstate, p_180501_2_, p_180501_3_); ++ this.markAndNotifyBlock(p_180501_1_, chunk, iblockstate, p_180501_2_, p_180501_3_); } - -- if (!this.field_72995_K && (p_180501_3_ & 1) != 0) + return true; + } + } + } -+ -+ // Split off from original setBlockState(BlockPos, IBlockState Block p_147465_4_, int) method in order to directly send client and physic updates -+ public void markAndNotifyBlock(BlockPos pos, Chunk chunk, IBlockState old, IBlockState new_, int flags) + +- if (!this.field_72995_K && (p_180501_3_ & 1) != 0) ++ // Split off from original setBlockState(BlockPos, IBlockState, int) method in order to directly send client and physic updates ++ public void markAndNotifyBlock(BlockPos pos, Chunk chunk, IBlockState iblockstate, IBlockState newState, int flags) + { -+ if ((flags & 2) != 0 && (!this.field_72995_K || (flags & 4) == 0) && (chunk == null || chunk.func_150802_k())) -+ { -+ this.func_175689_h(pos); -+ } + { + { -+ if (!this.field_72995_K && (flags & 1) != 0) ++ if ((flags & 2) != 0 && (!this.field_72995_K || (flags & 4) == 0) && (chunk == null || chunk.func_150802_k())) { - this.func_175722_b(p_180501_1_, iblockstate.func_177230_c()); -+ this.func_175722_b(pos, old.func_177230_c()); ++ this.func_184138_a(pos, iblockstate, newState, flags); ++ } -- if (block.func_149740_M()) -+ if (new_.func_177230_c().func_149740_M()) +- if (p_180501_2_.func_185912_n()) ++ if (!this.field_72995_K && (flags & 1) != 0) ++ { ++ this.func_175722_b(pos, iblockstate.func_177230_c()); ++ ++ if (newState.func_185912_n()) { - this.func_175666_e(p_180501_1_, block); -+ this.func_175666_e(pos, new_.func_177230_c()); ++ this.func_175666_e(pos, newState.func_177230_c()); } } - @@ -155,7 +153,16 @@ } } } -@@ -404,6 +445,9 @@ +@@ -336,7 +377,7 @@ + IBlockState iblockstate = this.func_180495_p(p_175655_1_); + Block block = iblockstate.func_177230_c(); + +- if (iblockstate.func_185904_a() == Material.field_151579_a) ++ if (block.isAir(iblockstate, this, p_175655_1_)) + { + return false; + } +@@ -409,6 +450,9 @@ public void func_175685_c(BlockPos p_175685_1_, Block p_175685_2_) { @@ -165,7 +172,7 @@ this.func_180496_d(p_175685_1_.func_177976_e(), p_175685_2_); this.func_180496_d(p_175685_1_.func_177974_f(), p_175685_2_); this.func_180496_d(p_175685_1_.func_177977_b(), p_175685_2_); -@@ -414,6 +458,11 @@ +@@ -419,6 +463,11 @@ public void func_175695_a(BlockPos p_175695_1_, Block p_175695_2_, EnumFacing p_175695_3_) { @@ -177,7 +184,16 @@ if (p_175695_3_ != EnumFacing.WEST) { this.func_180496_d(p_175695_1_.func_177976_e(), p_175695_2_); -@@ -777,7 +826,7 @@ +@@ -514,7 +563,7 @@ + { + IBlockState iblockstate = this.func_180495_p(blockpos); + +- if (iblockstate.func_185891_c() > 0 && !iblockstate.func_185904_a().func_76224_d()) ++ if (iblockstate.func_177230_c().getLightOpacity(iblockstate, this, blockpos) > 0 && !iblockstate.func_185904_a().func_76224_d()) + { + return false; + } +@@ -782,7 +831,7 @@ public boolean func_72935_r() { @@ -185,34 +201,22 @@ + return this.field_73011_w.isDaytime(); } - public MovingObjectPosition func_72933_a(Vec3 p_72933_1_, Vec3 p_72933_2_) -@@ -972,6 +1021,12 @@ + public RayTraceResult func_72933_a(Vec3d p_72933_1_, Vec3d p_72933_2_) +@@ -982,6 +1031,13 @@ - public void func_72956_a(Entity p_72956_1_, String p_72956_2_, float p_72956_3_, float p_72956_4_) + public void func_184148_a(EntityPlayer p_184148_1_, double p_184148_2_, double p_184148_4_, double p_184148_6_, SoundEvent p_184148_8_, SoundCategory p_184148_9_, float p_184148_10_, float p_184148_11_) { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_72956_1_, p_72956_2_, p_72956_3_, p_72956_4_); -+ if (event.isCanceled() || event.name == null) return; -+ p_72956_2_ = event.name; -+ p_72956_3_ = event.newVolume; -+ p_72956_4_ = event.newPitch; ++ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_184148_1_, p_184148_8_, p_184148_9_, p_184148_10_, p_184148_11_); ++ if (event.isCanceled() || event.getSound() == null) return; ++ p_184148_8_ = event.getSound(); ++ p_184148_9_ = event.getCategory(); ++ p_184148_10_ = event.getVolume(); ++ p_184148_11_ = event.getPitch(); + for (int i = 0; i < this.field_73021_x.size(); ++i) { - ((IWorldAccess)this.field_73021_x.get(i)).func_72704_a(p_72956_2_, p_72956_1_.field_70165_t, p_72956_1_.field_70163_u, p_72956_1_.field_70161_v, p_72956_3_, p_72956_4_); -@@ -980,6 +1035,12 @@ - - public void func_85173_a(EntityPlayer p_85173_1_, String p_85173_2_, float p_85173_3_, float p_85173_4_) - { -+ net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(p_85173_1_, p_85173_2_, p_85173_3_, p_85173_4_); -+ if (event.isCanceled() || event.name == null) return; -+ p_85173_2_ = event.name; -+ p_85173_3_ = event.newVolume; -+ p_85173_4_ = event.newPitch; -+ - for (int i = 0; i < this.field_73021_x.size(); ++i) - { - ((IWorldAccess)this.field_73021_x.get(i)).func_85102_a(p_85173_1_, p_85173_2_, p_85173_1_.field_70165_t, p_85173_1_.field_70163_u, p_85173_1_.field_70161_v, p_85173_3_, p_85173_4_); -@@ -1033,6 +1094,9 @@ + ((IWorldEventListener)this.field_73021_x.get(i)).func_184375_a(p_184148_1_, p_184148_8_, p_184148_9_, p_184148_2_, p_184148_4_, p_184148_6_, p_184148_10_, p_184148_11_); +@@ -1027,6 +1083,9 @@ public boolean func_72838_d(Entity p_72838_1_) { @@ -222,7 +226,7 @@ int i = MathHelper.func_76128_c(p_72838_1_.field_70165_t / 16.0D); int j = MathHelper.func_76128_c(p_72838_1_.field_70161_v / 16.0D); boolean flag = p_72838_1_.field_98038_p; -@@ -1055,6 +1119,8 @@ +@@ -1049,6 +1108,8 @@ this.func_72854_c(); } @@ -231,7 +235,15 @@ this.func_72964_e(i, j).func_76612_a(p_72838_1_); this.field_72996_f.add(p_72838_1_); this.func_72923_a(p_72838_1_); -@@ -1267,17 +1333,29 @@ +@@ -1285,7 +1346,6 @@ + return list; + } + +- @SideOnly(Side.CLIENT) + public void func_72848_b(IWorldEventListener p_72848_1_) + { + this.field_73021_x.remove(p_72848_1_); +@@ -1348,19 +1408,38 @@ public int func_72967_a(float p_72967_1_) { @@ -250,7 +262,7 @@ + public float getSunBrightnessFactor(float p_72967_1_) + { float f = this.func_72826_c(p_72967_1_); - float f1 = 1.0F - (MathHelper.func_76134_b(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F); + float f1 = 1.0F - (MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.5F); f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F); f1 = 1.0F - f1; f1 = (float)((double)f1 * (1.0D - (double)(this.func_72867_j(p_72967_1_) * 5.0F) / 16.0D)); @@ -260,11 +272,6 @@ + return f1; } -- @SideOnly(Side.CLIENT) - public void func_72848_b(IWorldAccess p_72848_1_) - { - this.field_73021_x.remove(p_72848_1_); -@@ -1286,6 +1364,12 @@ @SideOnly(Side.CLIENT) public float func_72971_b(float p_72971_1_) { @@ -275,24 +282,28 @@ + public float getSunBrightnessBody(float p_72971_1_) + { float f = this.func_72826_c(p_72971_1_); - float f1 = 1.0F - (MathHelper.func_76134_b(f * (float)Math.PI * 2.0F) * 2.0F + 0.2F); + float f1 = 1.0F - (MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.2F); f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F); -@@ -1298,6 +1382,12 @@ +@@ -1373,23 +1452,27 @@ @SideOnly(Side.CLIENT) - public Vec3 func_72833_a(Entity p_72833_1_, float p_72833_2_) + public Vec3d func_72833_a(Entity p_72833_1_, float p_72833_2_) { +- float f = this.func_72826_c(p_72833_2_); + return this.field_73011_w.getSkyColor(p_72833_1_, p_72833_2_); + } + + @SideOnly(Side.CLIENT) -+ public Vec3 getSkyColorBody(Entity p_72833_1_, float p_72833_2_) ++ public Vec3d getSkyColorBody(Entity entityIn, float partialTicks) + { - float f = this.func_72826_c(p_72833_2_); - float f1 = MathHelper.func_76134_b(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F; ++ float f = this.func_72826_c(partialTicks); + float f1 = MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.5F; f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F); -@@ -1305,9 +1395,7 @@ - int j = MathHelper.func_76128_c(p_72833_1_.field_70163_u); - int k = MathHelper.func_76128_c(p_72833_1_.field_70161_v); +- int i = MathHelper.func_76128_c(p_72833_1_.field_70165_t); +- int j = MathHelper.func_76128_c(p_72833_1_.field_70163_u); +- int k = MathHelper.func_76128_c(p_72833_1_.field_70161_v); ++ int i = MathHelper.func_76128_c(entityIn.field_70165_t); ++ int j = MathHelper.func_76128_c(entityIn.field_70163_u); ++ int k = MathHelper.func_76128_c(entityIn.field_70161_v); BlockPos blockpos = new BlockPos(i, j, k); - BiomeGenBase biomegenbase = this.func_180494_b(blockpos); - float f2 = biomegenbase.func_180626_a(blockpos); @@ -301,7 +312,33 @@ float f3 = (float)(l >> 16 & 255) / 255.0F; float f4 = (float)(l >> 8 & 255) / 255.0F; float f5 = (float)(l & 255) / 255.0F; -@@ -1367,6 +1455,11 @@ + f3 = f3 * f1; + f4 = f4 * f1; + f5 = f5 * f1; +- float f6 = this.func_72867_j(p_72833_2_); ++ float f6 = this.func_72867_j(partialTicks); + + if (f6 > 0.0F) + { +@@ -1400,7 +1483,7 @@ + f5 = f5 * f8 + f7 * (1.0F - f8); + } + +- float f10 = this.func_72819_i(p_72833_2_); ++ float f10 = this.func_72819_i(partialTicks); + + if (f10 > 0.0F) + { +@@ -1413,7 +1496,7 @@ + + if (this.field_73016_r > 0) + { +- float f12 = (float)this.field_73016_r - p_72833_2_; ++ float f12 = (float)this.field_73016_r - partialTicks; + + if (f12 > 1.0F) + { +@@ -1442,6 +1525,11 @@ public float func_130001_d() { @@ -313,32 +350,50 @@ return WorldProvider.field_111203_a[this.field_73011_w.func_76559_b(this.field_72986_A.func_76073_f())]; } -@@ -1379,6 +1472,12 @@ +@@ -1454,13 +1542,19 @@ @SideOnly(Side.CLIENT) - public Vec3 func_72824_f(float p_72824_1_) + public Vec3d func_72824_f(float p_72824_1_) { -+ return this.field_73011_w.drawClouds(p_72824_1_); +- float f = this.func_72826_c(p_72824_1_); ++ return this.field_73011_w.getCloudColor(p_72824_1_); + } + + @SideOnly(Side.CLIENT) -+ public Vec3 drawCloudsBody(float p_72824_1_) ++ public Vec3d getCloudColorBody(float partialTicks) + { - float f = this.func_72826_c(p_72824_1_); - float f1 = MathHelper.func_76134_b(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F; ++ float f = this.func_72826_c(partialTicks); + float f1 = MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.5F; f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F); -@@ -1434,9 +1533,9 @@ + float f2 = (float)(this.field_73001_c >> 16 & 255L) / 255.0F; + float f3 = (float)(this.field_73001_c >> 8 & 255L) / 255.0F; + float f4 = (float)(this.field_73001_c & 255L) / 255.0F; +- float f5 = this.func_72867_j(p_72824_1_); ++ float f5 = this.func_72867_j(partialTicks); + + if (f5 > 0.0F) + { +@@ -1474,7 +1568,7 @@ + f2 = f2 * (f1 * 0.9F + 0.1F); + f3 = f3 * (f1 * 0.9F + 0.1F); + f4 = f4 * (f1 * 0.85F + 0.15F); +- float f9 = this.func_72819_i(p_72824_1_); ++ float f9 = this.func_72819_i(partialTicks); + + if (f9 > 0.0F) + { +@@ -1509,9 +1603,9 @@ for (blockpos = new BlockPos(p_175672_1_.func_177958_n(), chunk.func_76625_h() + 16, p_175672_1_.func_177952_p()); blockpos.func_177956_o() >= 0; blockpos = blockpos1) { blockpos1 = blockpos.func_177977_b(); -- Material material = chunk.func_177428_a(blockpos1).func_149688_o(); -+ Block block = chunk.func_177428_a(blockpos1); +- Material material = chunk.func_177435_g(blockpos1).func_185904_a(); ++ IBlockState state = chunk.func_177435_g(blockpos1); - if (material.func_76230_c() && material != Material.field_151584_j) -+ if (block.func_149688_o().func_76230_c() && !block.isLeaves(this, blockpos1) && !block.isFoliage(this, blockpos1)) ++ if (state.func_185904_a().func_76230_c() && !state.func_177230_c().isLeaves(state, this, blockpos1) && !state.func_177230_c().isFoliage(this, blockpos1)) { break; } -@@ -1448,6 +1547,12 @@ +@@ -1523,6 +1617,12 @@ @SideOnly(Side.CLIENT) public float func_72880_h(float p_72880_1_) { @@ -349,47 +404,38 @@ + public float getStarBrightnessBody(float p_72880_1_) + { float f = this.func_72826_c(p_72880_1_); - float f1 = 1.0F - (MathHelper.func_76134_b(f * (float)Math.PI * 2.0F) * 2.0F + 0.25F); + float f1 = 1.0F - (MathHelper.func_76134_b(f * ((float)Math.PI * 2F)) * 2.0F + 0.25F); f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F); -@@ -1494,7 +1599,15 @@ +@@ -1574,6 +1674,12 @@ entity.func_85029_a(crashreportcategory); } -- throw new ReportedException(crashreport); + if (net.minecraftforge.common.ForgeModContainer.removeErroringEntities) + { + net.minecraftforge.fml.common.FMLLog.severe(crashreport.func_71502_e()); + func_72900_e(entity); + } + else -+ { -+ throw new ReportedException(crashreport); -+ } + throw new ReportedException(crashreport); } - if (entity.field_70128_L) -@@ -1554,7 +1667,15 @@ +@@ -1635,6 +1741,12 @@ CrashReport crashreport1 = CrashReport.func_85055_a(throwable1, "Ticking entity"); - CrashReportCategory crashreportcategory2 = crashreport1.func_85058_a("Entity being ticked"); - entity2.func_85029_a(crashreportcategory2); -- throw new ReportedException(crashreport1); + CrashReportCategory crashreportcategory1 = crashreport1.func_85058_a("Entity being ticked"); + entity2.func_85029_a(crashreportcategory1); + if (net.minecraftforge.common.ForgeModContainer.removeErroringEntities) + { + net.minecraftforge.fml.common.FMLLog.severe(crashreport1.func_71502_e()); + func_72900_e(entity2); + } + else -+ { -+ throw new ReportedException(crashreport1); -+ } + throw new ReportedException(crashreport1); } } - -@@ -1601,7 +1722,16 @@ +@@ -1684,6 +1796,13 @@ CrashReport crashreport2 = CrashReport.func_85055_a(throwable, "Ticking block entity"); - CrashReportCategory crashreportcategory1 = crashreport2.func_85058_a("Block entity being ticked"); - tileentity.func_145828_a(crashreportcategory1); -- throw new ReportedException(crashreport2); + CrashReportCategory crashreportcategory2 = crashreport2.func_85058_a("Block entity being ticked"); + tileentity.func_145828_a(crashreportcategory2); + if (net.minecraftforge.common.ForgeModContainer.removeErroringTileEntities) + { + net.minecraftforge.fml.common.FMLLog.severe(crashreport2.func_71502_e()); @@ -397,13 +443,10 @@ + this.func_175713_t(tileentity.func_174877_v()); + } + else -+ { -+ throw new ReportedException(crashreport2); -+ } + throw new ReportedException(crashreport2); } } - } -@@ -1618,15 +1748,20 @@ +@@ -1701,15 +1820,20 @@ } } @@ -426,7 +469,7 @@ this.field_72984_F.func_76318_c("pendingBlockEntities"); if (!this.field_147484_a.isEmpty()) -@@ -1660,7 +1795,8 @@ +@@ -1748,7 +1872,8 @@ public boolean func_175700_a(TileEntity p_175700_1_) { @@ -436,7 +479,7 @@ if (flag && p_175700_1_ instanceof ITickable) { -@@ -1699,9 +1835,13 @@ +@@ -1782,9 +1907,13 @@ { int i = MathHelper.func_76128_c(p_72866_1_.field_70165_t); int j = MathHelper.func_76128_c(p_72866_1_.field_70161_v); @@ -452,17 +495,17 @@ { p_72866_1_.field_70142_S = p_72866_1_.field_70165_t; p_72866_1_.field_70137_T = p_72866_1_.field_70163_u; -@@ -1829,7 +1969,7 @@ +@@ -1913,7 +2042,7 @@ { - Block block = this.func_180495_p(blockpos$mutableblockpos.func_181079_c(k1, l1, i2)).func_177230_c(); + IBlockState iblockstate = this.func_180495_p(blockpos$pooledmutableblockpos.func_185343_d(k1, l1, i2)); -- if (block.func_149688_o() != Material.field_151579_a) -+ if (!block.isAir(this, new BlockPos(k1, l1, i2))) +- if (iblockstate.func_185904_a() != Material.field_151579_a) ++ if (!iblockstate.func_177230_c().isAir(iblockstate, this, new BlockPos(k1, l1, i2))) { + blockpos$pooledmutableblockpos.func_185344_t(); return true; - } -@@ -1894,6 +2034,10 @@ - { +@@ -1983,6 +2112,10 @@ + blockpos$pooledmutableblockpos.func_185344_t(); return true; } + else if (block.isBurning(this, new BlockPos(k1, l1, i2))) @@ -472,34 +515,34 @@ } } } -@@ -1930,6 +2074,16 @@ - blockpos$mutableblockpos.func_181079_c(k1, l1, i2); - IBlockState iblockstate = this.func_180495_p(blockpos$mutableblockpos); +@@ -2022,6 +2155,16 @@ + IBlockState iblockstate = this.func_180495_p(blockpos$pooledmutableblockpos); Block block = iblockstate.func_177230_c(); -+ -+ Boolean result = block.isEntityInsideMaterial(this, blockpos$mutableblockpos, iblockstate, p_72918_3_, (double)l, p_72918_2_, false); + ++ Boolean result = block.isEntityInsideMaterial(this, blockpos$pooledmutableblockpos, iblockstate, p_72918_3_, (double)l, p_72918_2_, false); + if (result != null && result == true) + { + // Forge: When requested call blocks modifyAcceleration method, and more importantly cause this method to return true, which results in an entity being "inWater" + flag = true; -+ vec3 = block.func_176197_a(this, blockpos$mutableblockpos, p_72918_3_, vec3); ++ vec3d = block.func_176197_a(this, blockpos$pooledmutableblockpos, p_72918_3_, vec3d); + continue; + } + else if (result != null && result == false) continue; - - if (block.func_149688_o() == p_72918_2_) ++ + if (iblockstate.func_185904_a() == p_72918_2_) { -@@ -2004,6 +2158,9 @@ - IBlockState iblockstate = this.func_180495_p(blockpos$mutableblockpos.func_181079_c(k1, l1, i2)); - Block block = iblockstate.func_177230_c(); + double d0 = (double)((float)(l1 + 1) - BlockLiquid.func_149801_b(((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue())); +@@ -2098,6 +2241,9 @@ + { + IBlockState iblockstate = this.func_180495_p(blockpos$pooledmutableblockpos.func_185343_d(k1, l1, i2)); -+ Boolean result = block.isAABBInsideMaterial(this, blockpos$mutableblockpos, p_72830_1_, p_72830_2_); ++ Boolean result = iblockstate.func_177230_c().isAABBInsideMaterial(this, blockpos$pooledmutableblockpos, p_72830_1_, p_72830_2_); + if (result != null) return result; + - if (block.func_149688_o() == p_72830_2_) + if (iblockstate.func_185904_a() == p_72830_2_) { int j2 = ((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue(); -@@ -2034,6 +2191,7 @@ +@@ -2130,6 +2276,7 @@ public Explosion func_72885_a(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_) { Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_, p_72885_9_, p_72885_10_); @@ -507,7 +550,15 @@ explosion.func_77278_a(); explosion.func_77279_a(true); return explosion; -@@ -2180,19 +2338,27 @@ +@@ -2253,6 +2400,7 @@ + + public void func_175690_a(BlockPos p_175690_1_, TileEntity p_175690_2_) + { ++ p_175690_1_ = p_175690_1_.func_185334_h(); // Forge - prevent mutable BlockPos leaks + if (p_175690_2_ != null && !p_175690_2_.func_145837_r()) + { + if (this.field_147481_N) +@@ -2276,19 +2424,27 @@ else { this.func_175700_a(p_175690_2_); @@ -536,7 +587,7 @@ } else { -@@ -2205,6 +2371,7 @@ +@@ -2301,6 +2457,7 @@ this.func_175726_f(p_175713_1_).func_177425_e(p_175713_1_); } @@ -544,25 +595,16 @@ } public void func_147457_a(TileEntity p_147457_1_) -@@ -2223,7 +2390,7 @@ - { - IBlockState iblockstate = p_175683_0_.func_180495_p(p_175683_1_); - Block block = iblockstate.func_177230_c(); -- return block.func_149688_o().func_76218_k() && block.func_149686_d() ? true : (block instanceof BlockStairs ? iblockstate.func_177229_b(BlockStairs.field_176308_b) == BlockStairs.EnumHalf.TOP : (block instanceof BlockSlab ? iblockstate.func_177229_b(BlockSlab.field_176554_a) == BlockSlab.EnumBlockHalf.TOP : (block instanceof BlockHopper ? true : (block instanceof BlockSnow ? ((Integer)iblockstate.func_177229_b(BlockSnow.field_176315_a)).intValue() == 7 : false)))); -+ return block.isSideSolid(p_175683_0_, p_175683_1_, EnumFacing.UP); - } - - public boolean func_175677_d(BlockPos p_175677_1_, boolean p_175677_2_) -@@ -2243,7 +2410,7 @@ +@@ -2327,7 +2484,7 @@ + if (chunk != null && !chunk.func_76621_g()) + { + IBlockState iblockstate = this.func_180495_p(p_175677_1_); +- return iblockstate.func_185904_a().func_76218_k() && iblockstate.func_185917_h(); ++ return iblockstate.func_177230_c().isNormalCube(iblockstate, this, p_175677_1_); + } else { - Block block = this.func_180495_p(p_175677_1_).func_177230_c(); -- return block.func_149688_o().func_76218_k() && block.func_149686_d(); -+ return block.isNormalCube(this, p_175677_1_); - } - } - } -@@ -2262,6 +2429,7 @@ +@@ -2350,6 +2507,7 @@ { this.field_72985_G = p_72891_1_; this.field_72992_H = p_72891_2_; @@ -570,7 +612,7 @@ } public void func_72835_b() -@@ -2271,6 +2439,11 @@ +@@ -2359,6 +2517,11 @@ protected void func_72947_a() { @@ -582,7 +624,7 @@ if (this.field_72986_A.func_76059_o()) { this.field_73004_o = 1.0F; -@@ -2284,6 +2457,11 @@ +@@ -2372,6 +2535,11 @@ protected void func_72979_l() { @@ -594,74 +636,107 @@ if (!this.field_73011_w.func_177495_o()) { if (!this.field_72995_K) -@@ -2378,6 +2556,7 @@ - { - this.field_72993_I.clear(); - this.field_72984_F.func_76320_a("buildList"); -+ this.field_72993_I.addAll(getPersistentChunks().keySet()); - - for (int i = 0; i < this.field_73010_i.size(); ++i) - { -@@ -2434,8 +2613,9 @@ - Block block = p_147467_3_.func_177428_a(blockpos); - j = j + p_147467_1_; - k = k + p_147467_2_; -+ BlockPos worldpos = blockpos.func_177982_a(p_147467_1_, 0, p_147467_2_); - -- if (block.func_149688_o() == Material.field_151579_a && this.func_175699_k(blockpos) <= this.field_73012_v.nextInt(8) && this.func_175642_b(EnumSkyBlock.SKY, blockpos) <= 0) -+ if (block.isAir(this, worldpos) && this.func_175699_k(worldpos) <= this.field_73012_v.nextInt(8) && this.func_175642_b(EnumSkyBlock.SKY, worldpos) <= 0) //Forge: isAir, and fix arguments to world positions instead of chunk position - { - EntityPlayer entityplayer = this.func_72977_a((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, 8.0D); - -@@ -2475,6 +2655,11 @@ +@@ -2491,28 +2659,33 @@ public boolean func_175670_e(BlockPos p_175670_1_, boolean p_175670_2_) { +- BiomeGenBase biomegenbase = this.func_180494_b(p_175670_1_); +- float f = biomegenbase.func_180626_a(p_175670_1_); + return this.field_73011_w.canBlockFreeze(p_175670_1_, p_175670_2_); + } -+ -+ public boolean canBlockFreezeBody(BlockPos p_175670_1_, boolean p_175670_2_) -+ { - BiomeGenBase biomegenbase = this.func_180494_b(p_175670_1_); - float f = biomegenbase.func_180626_a(p_175670_1_); -@@ -2516,6 +2701,11 @@ ++ public boolean canBlockFreezeBody(BlockPos pos, boolean noWaterAdj) ++ { ++ BiomeGenBase biomegenbase = this.func_180494_b(pos); ++ float f = biomegenbase.func_180626_a(pos); ++ + if (f > 0.15F) + { + return false; + } + else + { +- if (p_175670_1_.func_177956_o() >= 0 && p_175670_1_.func_177956_o() < 256 && this.func_175642_b(EnumSkyBlock.BLOCK, p_175670_1_) < 10) ++ if (pos.func_177956_o() >= 0 && pos.func_177956_o() < 256 && this.func_175642_b(EnumSkyBlock.BLOCK, pos) < 10) + { +- IBlockState iblockstate = this.func_180495_p(p_175670_1_); ++ IBlockState iblockstate = this.func_180495_p(pos); + Block block = iblockstate.func_177230_c(); + + if ((block == Blocks.field_150355_j || block == Blocks.field_150358_i) && ((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue() == 0) + { +- if (!p_175670_2_) ++ if (!noWaterAdj) + { + return true; + } + +- boolean flag = this.func_175696_F(p_175670_1_.func_177976_e()) && this.func_175696_F(p_175670_1_.func_177974_f()) && this.func_175696_F(p_175670_1_.func_177978_c()) && this.func_175696_F(p_175670_1_.func_177968_d()); ++ boolean flag = this.func_175696_F(pos.func_177976_e()) && this.func_175696_F(pos.func_177974_f()) && this.func_175696_F(pos.func_177978_c()) && this.func_175696_F(pos.func_177968_d()); + + if (!flag) + { +@@ -2532,24 +2705,29 @@ public boolean func_175708_f(BlockPos p_175708_1_, boolean p_175708_2_) { +- BiomeGenBase biomegenbase = this.func_180494_b(p_175708_1_); +- float f = biomegenbase.func_180626_a(p_175708_1_); + return this.field_73011_w.canSnowAt(p_175708_1_, p_175708_2_); + } -+ -+ public boolean canSnowAtBody(BlockPos p_175708_1_, boolean p_175708_2_) + ++ public boolean canSnowAtBody(BlockPos pos, boolean checkLight) + { - BiomeGenBase biomegenbase = this.func_180494_b(p_175708_1_); - float f = biomegenbase.func_180626_a(p_175708_1_); - -@@ -2533,7 +2723,7 @@ ++ BiomeGenBase biomegenbase = this.func_180494_b(pos); ++ float f = biomegenbase.func_180626_a(pos); ++ + if (f > 0.15F) + { + return false; + } +- else if (!p_175708_2_) ++ else if (!checkLight) + { + return true; + } + else + { +- if (p_175708_1_.func_177956_o() >= 0 && p_175708_1_.func_177956_o() < 256 && this.func_175642_b(EnumSkyBlock.BLOCK, p_175708_1_) < 10) ++ if (pos.func_177956_o() >= 0 && pos.func_177956_o() < 256 && this.func_175642_b(EnumSkyBlock.BLOCK, pos) < 10) { - Block block = this.func_180495_p(p_175708_1_).func_177230_c(); +- IBlockState iblockstate = this.func_180495_p(p_175708_1_); ++ IBlockState iblockstate = this.func_180495_p(pos); -- if (block.func_149688_o() == Material.field_151579_a && Blocks.field_150431_aC.func_176196_c(this, p_175708_1_)) -+ if (block.isAir(this, p_175708_1_) && Blocks.field_150431_aC.func_176196_c(this, p_175708_1_)) +- if (iblockstate.func_185904_a() == Material.field_151579_a && Blocks.field_150431_aC.func_176196_c(this, p_175708_1_)) ++ if (iblockstate.func_177230_c().isAir(iblockstate, this, pos) && Blocks.field_150431_aC.func_176196_c(this, pos)) { return true; } -@@ -2565,10 +2755,11 @@ +@@ -2581,10 +2759,11 @@ else { - Block block = this.func_180495_p(p_175638_1_).func_177230_c(); -- int i = p_175638_2_ == EnumSkyBlock.SKY ? 0 : block.func_149750_m(); -- int j = block.func_149717_k(); -+ int blockLight = block.getLightValue(this, p_175638_1_); + IBlockState iblockstate = this.func_180495_p(p_175638_1_); +- int i = p_175638_2_ == EnumSkyBlock.SKY ? 0 : iblockstate.func_185906_d(); +- int j = iblockstate.func_185891_c(); ++ int blockLight = iblockstate.func_177230_c().getLightValue(iblockstate, this, p_175638_1_); + int i = p_175638_2_ == EnumSkyBlock.SKY ? 0 : blockLight; -+ int j = block.getLightOpacity(this, p_175638_1_); ++ int j = iblockstate.func_177230_c().getLightOpacity(iblockstate, this, p_175638_1_); -- if (j >= 15 && block.func_149750_m() > 0) +- if (j >= 15 && iblockstate.func_185906_d() > 0) + if (j >= 15 && blockLight > 0) { j = 1; } -@@ -2768,10 +2959,10 @@ +@@ -2683,7 +2862,7 @@ + int j4 = j2 + enumfacing.func_96559_d(); + int k4 = k2 + enumfacing.func_82599_e(); + blockpos$pooledmutableblockpos.func_185343_d(i4, j4, k4); +- int l4 = Math.max(1, this.func_180495_p(blockpos$pooledmutableblockpos).func_185891_c()); ++ int l4 = Math.max(1, this.func_180495_p(blockpos$pooledmutableblockpos).func_177230_c().getLightOpacity(this.func_180495_p(blockpos$pooledmutableblockpos), this, blockpos$pooledmutableblockpos)); + i3 = this.func_175642_b(p_180500_1_, blockpos$pooledmutableblockpos); + + if (i3 == l2 - l4 && j < this.field_72994_J.length) +@@ -2789,10 +2968,10 @@ public List func_175674_a(Entity p_175674_1_, AxisAlignedBB p_175674_2_, Predicate p_175674_3_) { List list = Lists.newArrayList(); @@ -676,22 +751,22 @@ for (int i1 = i; i1 <= j; ++i1) { -@@ -2824,10 +3015,10 @@ +@@ -2845,10 +3024,10 @@ public List func_175647_a(Class p_175647_1_, AxisAlignedBB p_175647_2_, Predicate p_175647_3_) { - int i = MathHelper.func_76128_c((p_175647_2_.field_72340_a - 2.0D) / 16.0D); -- int j = MathHelper.func_76128_c((p_175647_2_.field_72336_d + 2.0D) / 16.0D); +- int j = MathHelper.func_76143_f((p_175647_2_.field_72336_d + 2.0D) / 16.0D); - int k = MathHelper.func_76128_c((p_175647_2_.field_72339_c - 2.0D) / 16.0D); -- int l = MathHelper.func_76128_c((p_175647_2_.field_72334_f + 2.0D) / 16.0D); +- int l = MathHelper.func_76143_f((p_175647_2_.field_72334_f + 2.0D) / 16.0D); + int i = MathHelper.func_76128_c((p_175647_2_.field_72340_a - MAX_ENTITY_RADIUS) / 16.0D); -+ int j = MathHelper.func_76128_c((p_175647_2_.field_72336_d + MAX_ENTITY_RADIUS) / 16.0D); ++ int j = MathHelper.func_76143_f((p_175647_2_.field_72336_d + MAX_ENTITY_RADIUS) / 16.0D); + int k = MathHelper.func_76128_c((p_175647_2_.field_72339_c - MAX_ENTITY_RADIUS) / 16.0D); -+ int l = MathHelper.func_76128_c((p_175647_2_.field_72334_f + MAX_ENTITY_RADIUS) / 16.0D); ++ int l = MathHelper.func_76143_f((p_175647_2_.field_72334_f + MAX_ENTITY_RADIUS) / 16.0D); List list = Lists.newArrayList(); - for (int i1 = i; i1 <= j; ++i1) -@@ -2905,11 +3096,13 @@ + for (int i1 = i; i1 < j; ++i1) +@@ -2926,11 +3105,13 @@ public void func_175650_b(Collection p_175650_1_) { @@ -708,27 +783,25 @@ } } -@@ -2922,7 +3115,9 @@ +@@ -2943,7 +3124,7 @@ { - Block block = this.func_180495_p(p_175716_2_).func_177230_c(); - AxisAlignedBB axisalignedbb = p_175716_3_ ? null : p_175716_1_.func_180640_a(this, p_175716_2_, p_175716_1_.func_176223_P()); -- return axisalignedbb != null && !this.func_72917_a(axisalignedbb, p_175716_5_) ? false : (block.func_149688_o() == Material.field_151594_q && p_175716_1_ == Blocks.field_150467_bQ ? true : block.func_149688_o().func_76222_j() && p_175716_1_.func_176193_a(this, p_175716_2_, p_175716_4_, p_175716_6_)); -+ if (axisalignedbb != null && !this.func_72917_a(axisalignedbb, p_175716_5_)) return false; -+ if (block.func_149688_o() == Material.field_151594_q && p_175716_1_ == Blocks.field_150467_bQ) return true; -+ return block.func_176200_f(this, p_175716_2_) && p_175716_1_.func_176193_a(this, p_175716_2_, p_175716_4_, p_175716_6_); + IBlockState iblockstate = this.func_180495_p(p_175716_2_); + AxisAlignedBB axisalignedbb = p_175716_3_ ? null : p_175716_1_.func_176223_P().func_185890_d(this, p_175716_2_); +- return axisalignedbb != Block.field_185506_k && !this.func_72917_a(axisalignedbb.func_186670_a(p_175716_2_), p_175716_5_) ? false : (iblockstate.func_185904_a() == Material.field_151594_q && p_175716_1_ == Blocks.field_150467_bQ ? true : iblockstate.func_185904_a().func_76222_j() && p_175716_1_.func_176193_a(this, p_175716_2_, p_175716_4_, p_175716_6_)); ++ return axisalignedbb != Block.field_185506_k && !this.func_72917_a(axisalignedbb.func_186670_a(p_175716_2_), p_175716_5_) ? false : (iblockstate.func_185904_a() == Material.field_151594_q && p_175716_1_ == Blocks.field_150467_bQ ? true : iblockstate.func_177230_c().func_176200_f(this, p_175716_2_) && p_175716_1_.func_176193_a(this, p_175716_2_, p_175716_4_, p_175716_6_)); } public int func_181545_F() -@@ -3007,7 +3202,7 @@ +@@ -3026,7 +3207,7 @@ + public int func_175651_c(BlockPos p_175651_1_, EnumFacing p_175651_2_) { IBlockState iblockstate = this.func_180495_p(p_175651_1_); - Block block = iblockstate.func_177230_c(); -- return block.func_149721_r() ? this.func_175676_y(p_175651_1_) : block.func_180656_a(this, p_175651_1_, iblockstate, p_175651_2_); -+ return block.shouldCheckWeakPower(this, p_175651_1_, p_175651_2_) ? this.func_175676_y(p_175651_1_) : block.func_180656_a(this, p_175651_1_, iblockstate, p_175651_2_); +- return iblockstate.func_185915_l() ? this.func_175676_y(p_175651_1_) : iblockstate.func_185911_a(this, p_175651_1_, p_175651_2_); ++ return iblockstate.func_177230_c().shouldCheckWeakPower(iblockstate, this, p_175651_1_, p_175651_2_) ? this.func_175676_y(p_175651_1_) : iblockstate.func_185911_a(this, p_175651_1_, p_175651_2_); } public boolean func_175640_z(BlockPos p_175640_1_) -@@ -3134,7 +3329,7 @@ +@@ -3215,7 +3396,7 @@ public long func_72905_C() { @@ -737,7 +810,7 @@ } public long func_82737_E() -@@ -3144,17 +3339,17 @@ +@@ -3225,17 +3406,17 @@ public long func_72820_D() { @@ -758,7 +831,7 @@ if (!this.func_175723_af().func_177746_a(blockpos)) { -@@ -3166,7 +3361,7 @@ +@@ -3247,7 +3428,7 @@ public void func_175652_B(BlockPos p_175652_1_) { @@ -767,7 +840,7 @@ } @SideOnly(Side.CLIENT) -@@ -3186,12 +3381,18 @@ +@@ -3267,12 +3448,18 @@ if (!this.field_72996_f.contains(p_72897_1_)) { @@ -781,12 +854,12 @@ + return this.field_73011_w.canMineBlock(p_175660_1_, p_175660_2_); + } + -+ public boolean canMineBlockBody(EntityPlayer p_175660_1_, BlockPos p_175660_2_) ++ public boolean canMineBlockBody(EntityPlayer player, BlockPos pos) + { return true; } -@@ -3285,8 +3486,7 @@ +@@ -3366,8 +3553,7 @@ public boolean func_180502_D(BlockPos p_180502_1_) { @@ -796,7 +869,7 @@ } public MapStorage func_175693_T() -@@ -3345,12 +3545,12 @@ +@@ -3426,12 +3612,12 @@ public int func_72800_K() { @@ -811,7 +884,7 @@ } public Random func_72843_D(int p_72843_1_, int p_72843_2_, int p_72843_3_) -@@ -3405,7 +3605,7 @@ +@@ -3481,7 +3667,7 @@ @SideOnly(Side.CLIENT) public double func_72919_O() { @@ -820,7 +893,7 @@ } public void func_175715_c(int p_175715_1_, BlockPos p_175715_2_, int p_175715_3_) -@@ -3439,7 +3639,7 @@ +@@ -3515,7 +3701,7 @@ public void func_175666_e(BlockPos p_175666_1_, Block p_175666_2_) { @@ -829,36 +902,33 @@ { BlockPos blockpos = p_175666_1_.func_177972_a(enumfacing); -@@ -3447,18 +3647,14 @@ +@@ -3523,18 +3709,14 @@ { IBlockState iblockstate = this.func_180495_p(blockpos); -- if (Blocks.field_150441_bU.func_149907_e(iblockstate.func_177230_c())) +- if (Blocks.field_150441_bU.func_185547_C(iblockstate)) + iblockstate.func_177230_c().onNeighborChange(this, blockpos, p_175666_1_); -+ if (iblockstate.func_177230_c().isNormalCube(this, blockpos)) ++ if (iblockstate.func_177230_c().isNormalCube(iblockstate, this, blockpos)) { - iblockstate.func_177230_c().func_176204_a(this, blockpos, iblockstate, p_175666_2_); - } -- else if (iblockstate.func_177230_c().func_149721_r()) +- else if (iblockstate.func_185915_l()) - { -- blockpos = blockpos.func_177972_a(enumfacing); -- iblockstate = this.func_180495_p(blockpos); + blockpos = blockpos.func_177972_a(enumfacing); + iblockstate = this.func_180495_p(blockpos); - -- if (Blocks.field_150441_bU.func_149907_e(iblockstate.func_177230_c())) -+ BlockPos posOther = blockpos.func_177972_a(enumfacing); -+ Block other = func_180495_p(posOther).func_177230_c(); -+ if (other.getWeakChanges(this, posOther)) +- if (Blocks.field_150441_bU.func_185547_C(iblockstate)) ++ if (iblockstate.func_177230_c().getWeakChanges(this, blockpos)) { - iblockstate.func_177230_c().func_176204_a(this, blockpos, iblockstate, p_175666_2_); -+ other.onNeighborChange(this, posOther, p_175666_1_); ++ iblockstate.func_177230_c().onNeighborChange(this, blockpos, p_175666_1_); } } } -@@ -3528,4 +3724,81 @@ - int k = 128; +@@ -3600,6 +3782,87 @@ return i >= -k && i <= k && j >= -k && j <= k; } -+ + + /* ======================================== FORGE START =====================================*/ + /** + * Determine if the given block is considered solid on the @@ -889,7 +959,7 @@ + + Chunk chunk = func_175726_f(pos); + if (chunk == null || chunk.func_76621_g()) return _default; -+ return func_180495_p(pos).func_177230_c().isSideSolid(this, pos, side); ++ return func_180495_p(pos).isSideSolid(this, pos, side); + } + + /** @@ -902,6 +972,10 @@ + return net.minecraftforge.common.ForgeChunkManager.getPersistentChunksFor(this); + } + ++ public Iterator getPersistentChunkIterable(Iterator chunkIterator) ++ { ++ return net.minecraftforge.common.ForgeChunkManager.getPersistentChunksIterableFor(this, chunkIterator); ++ } + /** + * Readded as it was removed, very useful helper function + * @@ -935,4 +1009,7 @@ + { + return perWorldStorage; + } - } ++ + public void func_184135_a(Packet p_184135_1_) + { + throw new UnsupportedOperationException("Can\'t send packets to server unless you\'re on the client."); diff --git a/patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch b/patches/minecraft/net/minecraft/world/WorldEntitySpawner.java.patch similarity index 74% rename from patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch rename to patches/minecraft/net/minecraft/world/WorldEntitySpawner.java.patch index 6a68367cca..b8d9d1052a 100644 --- a/patches/minecraft/net/minecraft/world/SpawnerAnimals.java.patch +++ b/patches/minecraft/net/minecraft/world/WorldEntitySpawner.java.patch @@ -1,25 +1,26 @@ ---- ../src-base/minecraft/net/minecraft/world/SpawnerAnimals.java -+++ ../src-work/minecraft/net/minecraft/world/SpawnerAnimals.java -@@ -69,14 +69,15 @@ +--- ../src-base/minecraft/net/minecraft/world/WorldEntitySpawner.java ++++ ../src-work/minecraft/net/minecraft/world/WorldEntitySpawner.java +@@ -77,15 +77,17 @@ { if ((!enumcreaturetype.func_75599_d() || p_77192_3_) && (enumcreaturetype.func_75599_d() || p_77192_2_) && (!enumcreaturetype.func_82705_e() || p_77192_4_)) { -- int j4 = p_77192_1_.func_72907_a(enumcreaturetype.func_75598_a()); -+ int j4 = p_77192_1_.countEntities(enumcreaturetype, true); - int k4 = enumcreaturetype.func_75601_b() * i / field_180268_a; +- int k4 = p_77192_1_.func_72907_a(enumcreaturetype.func_75598_a()); ++ int k4 = p_77192_1_.countEntities(enumcreaturetype, true); + int l4 = enumcreaturetype.func_75601_b() * i / field_180268_a; - if (j4 <= k4) + if (k4 <= l4) { + java.util.ArrayList shuffled = com.google.common.collect.Lists.newArrayList(this.field_77193_b); + java.util.Collections.shuffle(shuffled); - label374: -- + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + label415: + - for (ChunkCoordIntPair chunkcoordintpair1 : this.field_77193_b) + for (ChunkCoordIntPair chunkcoordintpair1 : shuffled) { BlockPos blockpos = func_180621_a(p_77192_1_, chunkcoordintpair1.field_77276_a, chunkcoordintpair1.field_77275_b); int k1 = blockpos.func_177958_n(); -@@ -134,8 +135,10 @@ +@@ -144,8 +146,10 @@ entityliving.func_70012_b((double)f, (double)i3, (double)f1, p_77192_1_.field_73012_v.nextFloat() * 360.0F, 0.0F); @@ -31,21 +32,23 @@ ientitylivingdata = entityliving.func_180482_a(p_77192_1_.func_175649_E(new BlockPos(entityliving)), ientitylivingdata); if (entityliving.func_70058_J()) -@@ -144,7 +147,7 @@ - p_77192_1_.func_72838_d(entityliving); +@@ -158,7 +162,7 @@ + entityliving.func_70106_y(); } - if (j2 >= entityliving.func_70641_bl()) + if (i2 >= net.minecraftforge.event.ForgeEventFactory.getMaxSpawnPackSize(entityliving)) { - continue label374; + continue label415; } -@@ -193,7 +196,7 @@ +@@ -211,8 +215,9 @@ + else { BlockPos blockpos = p_180267_2_.func_177977_b(); ++ IBlockState state = p_180267_1_.func_180495_p(blockpos); -- if (!World.func_175683_a(p_180267_1_, blockpos)) -+ if (!p_180267_1_.func_180495_p(blockpos).func_177230_c().canCreatureSpawn(p_180267_1_, blockpos, p_180267_0_)) +- if (!p_180267_1_.func_180495_p(blockpos).func_185896_q()) ++ if (!state.func_177230_c().canCreatureSpawn(state, p_180267_1_, blockpos, p_180267_0_)) { return false; } diff --git a/patches/minecraft/net/minecraft/world/WorldProvider.java.patch b/patches/minecraft/net/minecraft/world/WorldProvider.java.patch index 1bfabc7e51..e5de49716f 100644 --- a/patches/minecraft/net/minecraft/world/WorldProvider.java.patch +++ b/patches/minecraft/net/minecraft/world/WorldProvider.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/WorldProvider.java +++ ../src-work/minecraft/net/minecraft/world/WorldProvider.java -@@ -51,26 +51,12 @@ +@@ -52,26 +52,12 @@ protected void func_76572_b() { @@ -9,34 +9,27 @@ - if (worldtype == WorldType.field_77138_c) - { - FlatGeneratorInfo flatgeneratorinfo = FlatGeneratorInfo.func_82651_a(this.field_76579_a.func_72912_H().func_82571_y()); -- this.field_76578_c = new WorldChunkManagerHell(BiomeGenBase.func_180276_a(flatgeneratorinfo.func_82648_a(), BiomeGenBase.field_180279_ad), 0.5F); +- this.field_76578_c = new BiomeProviderSingle(BiomeGenBase.func_180276_a(flatgeneratorinfo.func_82648_a(), Biomes.field_180279_ad)); - } - else if (worldtype == WorldType.field_180272_g) - { -- this.field_76578_c = new WorldChunkManagerHell(BiomeGenBase.field_76772_c, 0.0F); +- this.field_76578_c = new BiomeProviderSingle(Biomes.field_76772_c); - } - else - { -- this.field_76578_c = new WorldChunkManager(this.field_76579_a); +- this.field_76578_c = new BiomeProvider(this.field_76579_a.func_72912_H()); - } -+ this.field_76578_c = field_76577_b.getChunkManager(field_76579_a); ++ this.field_76578_c = field_76577_b.getBiomeProvider(field_76579_a); } - public IChunkProvider func_76555_c() + public IChunkGenerator func_186060_c() { -- return (IChunkProvider)(this.field_76577_b == WorldType.field_77138_c ? new ChunkProviderFlat(this.field_76579_a, this.field_76579_a.func_72905_C(), this.field_76579_a.func_72912_H().func_76089_r(), this.field_82913_c) : (this.field_76577_b == WorldType.field_180272_g ? new ChunkProviderDebug(this.field_76579_a) : (this.field_76577_b == WorldType.field_180271_f ? new ChunkProviderGenerate(this.field_76579_a, this.field_76579_a.func_72905_C(), this.field_76579_a.func_72912_H().func_76089_r(), this.field_82913_c) : new ChunkProviderGenerate(this.field_76579_a, this.field_76579_a.func_72905_C(), this.field_76579_a.func_72912_H().func_76089_r(), this.field_82913_c)))); +- return (IChunkGenerator)(this.field_76577_b == WorldType.field_77138_c ? new ChunkProviderFlat(this.field_76579_a, this.field_76579_a.func_72905_C(), this.field_76579_a.func_72912_H().func_76089_r(), this.field_82913_c) : (this.field_76577_b == WorldType.field_180272_g ? new ChunkProviderDebug(this.field_76579_a) : (this.field_76577_b == WorldType.field_180271_f ? new ChunkProviderOverworld(this.field_76579_a, this.field_76579_a.func_72905_C(), this.field_76579_a.func_72912_H().func_76089_r(), this.field_82913_c) : new ChunkProviderOverworld(this.field_76579_a, this.field_76579_a.func_72905_C(), this.field_76579_a.func_72912_H().func_76089_r(), this.field_82913_c)))); + return field_76577_b.getChunkGenerator(field_76579_a, field_82913_c); } public boolean func_76566_a(int p_76566_1_, int p_76566_2_) -@@ -153,13 +139,13 @@ - - public static WorldProvider func_76570_a(int p_76570_0_) - { -- return (WorldProvider)(p_76570_0_ == -1 ? new WorldProviderHell() : (p_76570_0_ == 0 ? new WorldProviderSurface() : (p_76570_0_ == 1 ? new WorldProviderEnd() : null))); -+ return net.minecraftforge.common.DimensionManager.createProviderFor(p_76570_0_); - } - +@@ -156,7 +142,7 @@ @SideOnly(Side.CLIENT) public float func_76571_f() { @@ -45,7 +38,7 @@ } @SideOnly(Side.CLIENT) -@@ -175,13 +161,13 @@ +@@ -172,13 +158,13 @@ public int func_76557_i() { @@ -61,25 +54,30 @@ } @SideOnly(Side.CLIENT) -@@ -223,4 +209,319 @@ - { +@@ -212,6 +198,327 @@ return new WorldBorder(); } -+ + + /*======================================= Forge Start =========================================*/ + private net.minecraftforge.client.IRenderHandler skyRenderer = null; + private net.minecraftforge.client.IRenderHandler cloudRenderer = null; + private net.minecraftforge.client.IRenderHandler weatherRenderer = null; ++ private int dimensionId; + + /** + * Sets the providers current dimension ID, used in default getSaveFolder() + * Added to allow default providers to be registered for multiple dimensions. ++ * This is to denote the exact dimension ID opposed to the 'type' in WorldType + * + * @param dim Dimension ID + */ + public void setDimension(int dim) + { -+ this.field_76574_g = dim; ++ this.dimensionId = dim; ++ } ++ public int getDimension() ++ { ++ return this.dimensionId; + } + + /** @@ -89,7 +87,7 @@ + */ + public String getSaveFolder() + { -+ return (field_76574_g == 0 ? null : "DIM" + field_76574_g); ++ return (dimensionId == 0 ? null : "DIM" + dimensionId); + } + + /** @@ -184,14 +182,14 @@ + BlockPos ret = this.field_76579_a.func_175694_M(); + + boolean isAdventure = field_76579_a.func_72912_H().func_76077_q() == WorldSettings.GameType.ADVENTURE; -+ int spawnFuzz = field_76577_b.getSpawnFuzz(); ++ int spawnFuzz = this.field_76579_a instanceof WorldServer ? field_76577_b.getSpawnFuzz((WorldServer)this.field_76579_a, this.field_76579_a.func_73046_m()) : 1; + int border = MathHelper.func_76128_c(field_76579_a.func_175723_af().func_177729_b(ret.func_177958_n(), ret.func_177952_p())); + if (border < spawnFuzz) spawnFuzz = border; -+ if (spawnFuzz < 1) spawnFuzz = 1; -+ int spawnFuzzHalf = spawnFuzz / 2; + -+ if (!func_177495_o() && !isAdventure) ++ if (!func_177495_o() && !isAdventure && spawnFuzz != 0) + { ++ if (spawnFuzz < 2) spawnFuzz = 2; ++ int spawnFuzzHalf = spawnFuzz / 2; + ret = field_76579_a.func_175672_r(ret.func_177982_a(field_76579_a.field_73012_v.nextInt(spawnFuzzHalf) - spawnFuzz, 0, field_76579_a.field_73012_v.nextInt(spawnFuzzHalf) - spawnFuzz)); + } + @@ -208,7 +206,7 @@ + */ + public boolean shouldMapSpin(String entity, double x, double y, double z) + { -+ return field_76574_g < 0; ++ return dimensionId < 0; + } + + /** @@ -258,15 +256,15 @@ + } + + @SideOnly(Side.CLIENT) -+ public Vec3 getSkyColor(net.minecraft.entity.Entity cameraEntity, float partialTicks) ++ public Vec3d getSkyColor(net.minecraft.entity.Entity cameraEntity, float partialTicks) + { + return field_76579_a.getSkyColorBody(cameraEntity, partialTicks); + } + + @SideOnly(Side.CLIENT) -+ public Vec3 drawClouds(float partialTicks) ++ public Vec3d getCloudColor(float partialTicks) + { -+ return field_76579_a.drawCloudsBody(partialTicks); ++ return field_76579_a.getCloudColorBody(partialTicks); + } + + /** @@ -380,4 +378,7 @@ + { + return true; + } - } ++ + public void func_186061_a(EntityPlayerMP p_186061_1_) + { + } diff --git a/patches/minecraft/net/minecraft/world/WorldProviderSurface.java.patch b/patches/minecraft/net/minecraft/world/WorldProviderSurface.java.patch new file mode 100644 index 0000000000..1b588e11e8 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/WorldProviderSurface.java.patch @@ -0,0 +1,10 @@ +--- ../src-base/minecraft/net/minecraft/world/WorldProviderSurface.java ++++ ../src-work/minecraft/net/minecraft/world/WorldProviderSurface.java +@@ -9,6 +9,6 @@ + + public boolean func_186056_c(int p_186056_1_, int p_186056_2_) + { +- return !this.field_76579_a.func_72916_c(p_186056_1_, p_186056_2_); ++ return !this.field_76579_a.func_72916_c(p_186056_1_, p_186056_2_) || !this.field_76579_a.field_73011_w.func_186058_p().shouldLoadSpawn(); + } + } diff --git a/patches/minecraft/net/minecraft/world/WorldSavedData.java.patch b/patches/minecraft/net/minecraft/world/WorldSavedData.java.patch new file mode 100644 index 0000000000..6e33e0f03f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/WorldSavedData.java.patch @@ -0,0 +1,28 @@ +--- ../src-base/minecraft/net/minecraft/world/WorldSavedData.java ++++ ../src-work/minecraft/net/minecraft/world/WorldSavedData.java +@@ -2,7 +2,7 @@ + + import net.minecraft.nbt.NBTTagCompound; + +-public abstract class WorldSavedData ++public abstract class WorldSavedData implements net.minecraftforge.common.util.INBTSerializable + { + public final String field_76190_i; + private boolean field_76189_a; +@@ -30,4 +30,16 @@ + { + return this.field_76189_a; + } ++ ++ public void deserializeNBT(NBTTagCompound nbt) ++ { ++ this.func_76184_a(nbt); ++ } ++ ++ public NBTTagCompound serializeNBT() ++ { ++ NBTTagCompound ret = new NBTTagCompound(); ++ this.func_76187_b(ret); ++ return ret; ++ } + } diff --git a/patches/minecraft/net/minecraft/world/WorldServer.java.patch b/patches/minecraft/net/minecraft/world/WorldServer.java.patch index 08b38c2ab5..2349e325ab 100644 --- a/patches/minecraft/net/minecraft/world/WorldServer.java.patch +++ b/patches/minecraft/net/minecraft/world/WorldServer.java.patch @@ -1,37 +1,31 @@ --- ../src-base/minecraft/net/minecraft/world/WorldServer.java +++ ../src-work/minecraft/net/minecraft/world/WorldServer.java -@@ -94,30 +94,46 @@ - private static final List field_73069_S = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.field_151055_y, 0, 1, 3, 10), new WeightedRandomChestContent(Item.func_150898_a(Blocks.field_150344_f), 0, 1, 3, 10), new WeightedRandomChestContent(Item.func_150898_a(Blocks.field_150364_r), 0, 1, 3, 10), new WeightedRandomChestContent(Items.field_151049_t, 0, 1, 1, 3), new WeightedRandomChestContent(Items.field_151053_p, 0, 1, 1, 5), new WeightedRandomChestContent(Items.field_151050_s, 0, 1, 1, 3), new WeightedRandomChestContent(Items.field_151039_o, 0, 1, 1, 5), new WeightedRandomChestContent(Items.field_151034_e, 0, 2, 3, 5), new WeightedRandomChestContent(Items.field_151025_P, 0, 2, 3, 3), new WeightedRandomChestContent(Item.func_150898_a(Blocks.field_150363_s), 0, 1, 3, 10)}); +@@ -97,30 +97,39 @@ + private int field_147489_T; private List field_94579_S = Lists.newArrayList(); + /** Stores the recently processed (lighting) chunks */ + protected Set doneChunks = new java.util.HashSet(); + public List customTeleporters = new ArrayList(); -+ private static boolean initChest = false; -+ public static void fillChestHook() -+ { -+ if (!initChest) -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.BONUS_CHEST, field_73069_S, 10, 10); -+ initChest = true; -+ } + public WorldServer(MinecraftServer p_i45921_1_, ISaveHandler p_i45921_2_, WorldInfo p_i45921_3_, int p_i45921_4_, Profiler p_i45921_5_) { - super(p_i45921_2_, p_i45921_3_, WorldProvider.func_76570_a(p_i45921_4_), p_i45921_5_, false); +- super(p_i45921_2_, p_i45921_3_, DimensionType.func_186069_a(p_i45921_4_).func_186070_d(), p_i45921_5_, false); ++ super(p_i45921_2_, p_i45921_3_, net.minecraftforge.common.DimensionManager.createProviderFor(p_i45921_4_), p_i45921_5_, false); this.field_73061_a = p_i45921_1_; this.field_73062_L = new EntityTracker(this); this.field_73063_M = new PlayerManager(this); + // Guarantee the dimension ID was not reset by the provider -+ int providerDim = this.field_73011_w.field_76574_g; ++ int providerDim = this.field_73011_w.getDimension(); this.field_73011_w.func_76558_a(this); -+ this.field_73011_w.field_76574_g = providerDim; ++ this.field_73011_w.setDimension(providerDim); this.field_73020_y = this.func_72970_h(); + perWorldStorage = new MapStorage(new net.minecraftforge.common.WorldSpecificSaveHandler((WorldServer)this, p_i45921_2_)); this.field_85177_Q = new Teleporter(this); this.func_72966_v(); this.func_72947_a(); this.func_175723_af().func_177725_a(p_i45921_1_.func_175580_aG()); -+ net.minecraftforge.common.DimensionManager.setWorld(p_i45921_4_, this); ++ net.minecraftforge.common.DimensionManager.setWorld(p_i45921_4_, this, field_73061_a); } public World func_175643_b() @@ -49,7 +43,7 @@ } else { -@@ -210,6 +226,10 @@ +@@ -214,6 +223,10 @@ this.field_175740_d.func_75528_a(); this.field_72984_F.func_76318_c("portalForcer"); this.field_85177_Q.func_85189_a(this.func_82737_E()); @@ -60,7 +54,7 @@ this.field_72984_F.func_76319_b(); this.func_147488_Z(); } -@@ -217,12 +237,14 @@ +@@ -221,12 +234,14 @@ public BiomeGenBase.SpawnListEntry func_175734_a(EnumCreatureType p_175734_1_, BlockPos p_175734_2_) { List list = this.func_72863_F().func_177458_a(p_175734_1_, p_175734_2_); @@ -75,7 +69,7 @@ return list != null && !list.isEmpty() ? list.contains(p_175732_2_) : false; } -@@ -268,10 +290,7 @@ +@@ -272,10 +287,7 @@ private void func_73051_P() { @@ -87,16 +81,25 @@ } public boolean func_73056_e() -@@ -349,7 +367,7 @@ +@@ -368,7 +380,7 @@ + boolean flag1 = this.func_72911_I(); + this.field_72984_F.func_76320_a("pollingChunks"); + +- for (Iterator iterator = this.field_73063_M.func_187300_b(); iterator.hasNext(); this.field_72984_F.func_76319_b()) ++ for (Iterator iterator = getPersistentChunkIterable(this.field_73063_M.func_187300_b()); iterator.hasNext(); this.field_72984_F.func_76319_b()) + { + this.field_72984_F.func_76320_a("getChunk"); + Chunk chunk = (Chunk)iterator.next(); +@@ -380,7 +392,7 @@ chunk.func_150804_b(false); this.field_72984_F.func_76318_c("thunder"); -- if (this.field_73012_v.nextInt(100000) == 0 && this.func_72896_J() && this.func_72911_I()) -+ if (this.field_73011_w.canDoLightning(chunk) && this.field_73012_v.nextInt(100000) == 0 && this.func_72896_J() && this.func_72911_I()) +- if (flag && flag1 && this.field_73012_v.nextInt(100000) == 0) ++ if (this.field_73011_w.canDoLightning(chunk) && flag && flag1 && this.field_73012_v.nextInt(100000) == 0) { this.field_73005_l = this.field_73005_l * 3 + 1013904223; - int i1 = this.field_73005_l >> 2; -@@ -363,7 +381,7 @@ + int l = this.field_73005_l >> 2; +@@ -409,7 +421,7 @@ this.field_72984_F.func_76318_c("iceandsnow"); @@ -104,27 +107,27 @@ + if (this.field_73011_w.canDoRainSnowIce(chunk) && this.field_73012_v.nextInt(16) == 0) { this.field_73005_l = this.field_73005_l * 3 + 1013904223; - int k2 = this.field_73005_l >> 2; -@@ -456,6 +474,9 @@ + int j2 = this.field_73005_l >> 2; +@@ -527,6 +539,9 @@ if (p_175654_2_.func_149698_L()) { i = 8; + //Keeping here as a note for future when it may be restored. -+ boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(nextticklistentry.field_180282_a.func_177958_n() >> 4, nextticklistentry.field_180282_a.func_177952_p() >> 4)); ++ boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(p_175654_1_.func_177958_n() >> 4, p_175654_1_.func_177952_p() >> 4)); + i = isForced ? 0 : 8; - if (this.func_175707_a(nextticklistentry.field_180282_a.func_177982_a(-i, -i, -i), nextticklistentry.field_180282_a.func_177982_a(i, i, i))) + if (this.func_175707_a(p_175654_1_.func_177982_a(-i, -i, -i), p_175654_1_.func_177982_a(i, i, i))) { -@@ -508,7 +529,7 @@ +@@ -588,7 +603,7 @@ public void func_72939_s() { - if (this.field_73010_i.isEmpty()) + if (this.field_73010_i.isEmpty() && getPersistentChunks().isEmpty()) { - if (this.field_80004_Q++ >= 1200) + if (this.field_80004_Q++ >= 300) { -@@ -573,6 +594,9 @@ +@@ -712,6 +727,9 @@ { NextTickListEntry nextticklistentry1 = (NextTickListEntry)iterator.next(); iterator.remove(); @@ -134,7 +137,7 @@ int k = 0; if (this.func_175707_a(nextticklistentry1.field_180282_a.func_177982_a(-k, -k, -k), nextticklistentry1.field_180282_a.func_177982_a(k, k, k))) -@@ -696,22 +720,40 @@ +@@ -838,24 +856,42 @@ { List list = Lists.newArrayList(); @@ -175,47 +178,50 @@ public boolean func_175660_a(EntityPlayer p_175660_1_, BlockPos p_175660_2_) { +- return !this.field_73061_a.func_175579_a(this, p_175660_2_, p_175660_1_) && this.func_175723_af().func_177746_a(p_175660_2_); + return super.func_175660_a(p_175660_1_, p_175660_2_); -+ } -+ public boolean canMineBlockBody(EntityPlayer p_175660_1_, BlockPos p_175660_2_) -+ { - return !this.field_73061_a.func_175579_a(this, p_175660_2_, p_175660_1_) && this.func_175723_af().func_177746_a(p_175660_2_); } ++ public boolean canMineBlockBody(EntityPlayer player, BlockPos pos) ++ { ++ return !this.field_73061_a.func_175579_a(this, pos, player) && this.func_175723_af().func_177746_a(pos); ++ } -@@ -777,6 +819,7 @@ + public void func_72963_a(WorldSettings p_72963_1_) + { +@@ -919,6 +955,7 @@ } else { + if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(this, p_73052_1_)) return; this.field_72987_B = true; - WorldChunkManager worldchunkmanager = this.field_73011_w.func_177499_m(); - List list = worldchunkmanager.func_76932_a(); -@@ -822,7 +865,7 @@ - - protected void func_73047_i() - { -- WorldGeneratorBonusChest worldgeneratorbonuschest = new WorldGeneratorBonusChest(field_73069_S, 10); -+ WorldGeneratorBonusChest worldgeneratorbonuschest = net.minecraftforge.common.ForgeHooks.getBonusChest(field_73012_v); - - for (int i = 0; i < 10; ++i) - { -@@ -859,6 +902,7 @@ + BiomeProvider biomeprovider = this.field_73011_w.func_177499_m(); + List list = biomeprovider.func_76932_a(); +@@ -1003,6 +1040,7 @@ } - this.field_73020_y.func_73151_a(p_73044_1_, p_73044_2_); + chunkproviderserver.func_186027_a(p_73044_1_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Save(this)); - for (Chunk chunk : Lists.newArrayList(this.field_73059_b.func_152380_a())) + for (Chunk chunk : Lists.newArrayList(chunkproviderserver.func_152380_a())) { -@@ -892,6 +936,7 @@ +@@ -1047,6 +1085,7 @@ this.field_72986_A.func_176135_e(this.func_175723_af().func_177732_i()); - this.field_73019_z.func_75755_a(this.field_72986_A, this.field_73061_a.func_71203_ab().func_72378_q()); + this.field_73019_z.func_75755_a(this.field_72986_A, this.field_73061_a.func_184103_al().func_72378_q()); this.field_72988_C.func_75744_a(); + this.perWorldStorage.func_75744_a(); } - public void func_72923_a(Entity p_72923_1_) -@@ -947,6 +992,7 @@ + public boolean func_72838_d(Entity p_72838_1_) +@@ -1058,7 +1097,7 @@ + { + for (Entity entity : Lists.newArrayList(p_175650_1_)) + { +- if (this.func_184165_i(entity)) ++ if (this.func_184165_i(entity) && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(entity, this))) + { + this.field_72996_f.add(entity); + this.func_72923_a(entity); +@@ -1161,6 +1200,7 @@ public Explosion func_72885_a(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_) { Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_, p_72885_9_, p_72885_10_); @@ -223,8 +229,8 @@ explosion.func_77278_a(); explosion.func_77279_a(false); -@@ -1026,19 +1072,23 @@ - this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.func_177502_q()); +@@ -1240,19 +1280,23 @@ + this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.func_186058_p().func_186068_a()); } + /* The function in use here has been replaced in order to only send the weather info to players in the correct dimension, @@ -235,29 +241,29 @@ { if (flag) { -- this.field_73061_a.func_71203_ab().func_148540_a(new S2BPacketChangeGameState(2, 0.0F)); -+ this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(2, 0.0F), this.field_73011_w.field_76574_g); +- this.field_73061_a.func_184103_al().func_148540_a(new SPacketChangeGameState(2, 0.0F)); ++ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(2, 0.0F), this.field_73011_w.getDimension()); } else { -- this.field_73061_a.func_71203_ab().func_148540_a(new S2BPacketChangeGameState(1, 0.0F)); -+ this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(1, 0.0F), this.field_73011_w.field_76574_g); +- this.field_73061_a.func_184103_al().func_148540_a(new SPacketChangeGameState(1, 0.0F)); ++ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(1, 0.0F), this.field_73011_w.getDimension()); } -- this.field_73061_a.func_71203_ab().func_148540_a(new S2BPacketChangeGameState(7, this.field_73004_o)); -- this.field_73061_a.func_71203_ab().func_148540_a(new S2BPacketChangeGameState(8, this.field_73017_q)); -+ this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(7, this.field_73004_o), this.field_73011_w.field_76574_g); -+ this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.field_76574_g); +- this.field_73061_a.func_184103_al().func_148540_a(new SPacketChangeGameState(7, this.field_73004_o)); +- this.field_73061_a.func_184103_al().func_148540_a(new SPacketChangeGameState(8, this.field_73017_q)); ++ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(7, this.field_73004_o), this.field_73011_w.getDimension()); ++ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.getDimension()); } } -@@ -1104,6 +1154,11 @@ +@@ -1329,6 +1373,11 @@ return this.field_73061_a.func_152345_ab(); } + public java.io.File getChunkSaveLocation() + { -+ return ((net.minecraft.world.chunk.storage.AnvilChunkLoader)field_73059_b.field_73247_e).field_75825_d; ++ return ((net.minecraft.world.chunk.storage.AnvilChunkLoader)func_72863_F().field_73247_e).field_75825_d; + } + static class ServerBlockEventList extends ArrayList diff --git a/patches/minecraft/net/minecraft/world/WorldServerMulti.java.patch b/patches/minecraft/net/minecraft/world/WorldServerMulti.java.patch index dc61a1c4df..915671b990 100644 --- a/patches/minecraft/net/minecraft/world/WorldServerMulti.java.patch +++ b/patches/minecraft/net/minecraft/world/WorldServerMulti.java.patch @@ -30,9 +30,9 @@ } public World func_175643_b() -@@ -58,12 +61,12 @@ - this.field_72988_C = this.field_175743_a.func_175693_T(); +@@ -59,12 +62,12 @@ this.field_96442_D = this.field_175743_a.func_96441_U(); + this.field_184151_B = this.field_175743_a.func_184146_ak(); String s = VillageCollection.func_176062_a(this.field_73011_w); - VillageCollection villagecollection = (VillageCollection)this.field_72988_C.func_75742_a(VillageCollection.class, s); + VillageCollection villagecollection = (VillageCollection)this.perWorldStorage.func_75742_a(VillageCollection.class, s); @@ -45,11 +45,10 @@ } else { -@@ -73,4 +76,12 @@ - +@@ -75,6 +78,14 @@ return this; } -+ + + + @Override + public void func_73041_k() @@ -57,4 +56,7 @@ + super.func_73041_k(); + this.field_175743_a.func_175723_af().removeListener(this.borderListener); // Unlink ourselves, to prevent world leak. + } - } ++ + public void func_184166_c() + { + this.field_73011_w.func_186057_q(); diff --git a/patches/minecraft/net/minecraft/world/WorldType.java.patch b/patches/minecraft/net/minecraft/world/WorldType.java.patch index 1f7e26efaa..eeb74f3943 100644 --- a/patches/minecraft/net/minecraft/world/WorldType.java.patch +++ b/patches/minecraft/net/minecraft/world/WorldType.java.patch @@ -8,33 +8,34 @@ this.field_77133_f = p_i1960_2_; this.field_77134_g = p_i1960_3_; this.field_77140_h = true; -@@ -113,4 +114,144 @@ +@@ -113,4 +114,145 @@ this.field_151361_l = true; return this; } + -+ public net.minecraft.world.biome.WorldChunkManager getChunkManager(World world) ++ public net.minecraft.world.biome.BiomeProvider getBiomeProvider(World world) + { + if (this == field_77138_c) + { + net.minecraft.world.gen.FlatGeneratorInfo flatgeneratorinfo = net.minecraft.world.gen.FlatGeneratorInfo.func_82651_a(world.func_72912_H().func_82571_y()); -+ return new net.minecraft.world.biome.WorldChunkManagerHell(net.minecraft.world.biome.BiomeGenBase.func_180276_a(flatgeneratorinfo.func_82648_a(), net.minecraft.world.biome.BiomeGenBase.field_180279_ad), 0.5F); ++ return new net.minecraft.world.biome.BiomeProviderSingle(net.minecraft.world.biome.BiomeGenBase.func_180276_a(flatgeneratorinfo.func_82648_a(), net.minecraft.init.Biomes.field_180279_ad)); + } + else if (this == field_180272_g) + { -+ return new net.minecraft.world.biome.WorldChunkManagerHell(net.minecraft.world.biome.BiomeGenBase.field_76772_c, 0.0F); ++ return new net.minecraft.world.biome.BiomeProviderSingle(net.minecraft.init.Biomes.field_76772_c); + } + else + { -+ return new net.minecraft.world.biome.WorldChunkManager(world); ++ return new net.minecraft.world.biome.BiomeProvider(world.func_72912_H()); + } + } + -+ public net.minecraft.world.chunk.IChunkProvider getChunkGenerator(World world, String generatorOptions) ++ public net.minecraft.world.chunk.IChunkGenerator getChunkGenerator(World world, String generatorOptions) + { + if (this == field_77138_c) return new net.minecraft.world.gen.ChunkProviderFlat(world, world.func_72905_C(), world.func_72912_H().func_76089_r(), generatorOptions); + if (this == field_180272_g) return new net.minecraft.world.gen.ChunkProviderDebug(world); -+ return new net.minecraft.world.gen.ChunkProviderGenerate(world, world.func_72905_C(), world.func_72912_H().func_76089_r(), generatorOptions); ++ if (this == field_180271_f) return new net.minecraft.world.gen.ChunkProviderOverworld(world, world.func_72905_C(), world.func_72912_H().func_76089_r(), generatorOptions); ++ return new net.minecraft.world.gen.ChunkProviderOverworld(world, world.func_72905_C(), world.func_72912_H().func_76089_r(), generatorOptions); + } + + public int getMinimumSpawnHeight(World world) @@ -93,9 +94,9 @@ + * Useful for void world types. + * @return Fuzz for entity initial spawn in blocks. + */ -+ public int getSpawnFuzz() ++ public int getSpawnFuzz(WorldServer world, net.minecraft.server.MinecraftServer server) + { -+ return Math.max(5, net.minecraft.server.MinecraftServer.func_71276_C().func_82357_ak() - 6); ++ return Math.max(0, server.func_184108_a(world)); + } + + /** diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeColorHelper.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeColorHelper.java.patch deleted file mode 100644 index 4c72cae179..0000000000 --- a/patches/minecraft/net/minecraft/world/biome/BiomeColorHelper.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/biome/BiomeColorHelper.java -+++ ../src-work/minecraft/net/minecraft/world/biome/BiomeColorHelper.java -@@ -26,7 +26,7 @@ - { - public int func_180283_a(BiomeGenBase p_180283_1_, BlockPos p_180283_2_) - { -- return p_180283_1_.field_76759_H; -+ return p_180283_1_.getWaterColorMultiplier(); - } - }; - diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeDecorator.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeDecorator.java.patch index c18d05315e..584c76ae86 100644 --- a/patches/minecraft/net/minecraft/world/biome/BiomeDecorator.java.patch +++ b/patches/minecraft/net/minecraft/world/biome/BiomeDecorator.java.patch @@ -1,169 +1,167 @@ --- ../src-base/minecraft/net/minecraft/world/biome/BiomeDecorator.java +++ ../src-work/minecraft/net/minecraft/world/biome/BiomeDecorator.java -@@ -105,8 +105,10 @@ +@@ -91,8 +91,10 @@ - protected void func_150513_a(BiomeGenBase p_150513_1_) + protected void func_150513_a(BiomeGenBase p_150513_1_, World p_150513_2_, Random p_150513_3_) { -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Pre(field_76815_a, field_76813_b, field_180294_c)); - this.func_76797_b(); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Pre(p_150513_2_, p_150513_3_, field_180294_c)); + this.func_76797_b(p_150513_2_, p_150513_3_); -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SAND)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SAND)) for (int i = 0; i < this.field_76805_H; ++i) { - int j = this.field_76813_b.nextInt(16) + 8; -@@ -114,6 +116,7 @@ - this.field_76810_g.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_76815_a.func_175672_r(this.field_180294_c.func_177982_a(j, 0, k))); + int j = p_150513_3_.nextInt(16) + 8; +@@ -100,6 +102,7 @@ + this.field_76810_g.func_180709_b(p_150513_2_, p_150513_3_, p_150513_2_.func_175672_r(this.field_180294_c.func_177982_a(j, 0, k))); } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.CLAY)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.CLAY)) for (int i1 = 0; i1 < this.field_76806_I; ++i1) { - int l1 = this.field_76813_b.nextInt(16) + 8; -@@ -121,6 +124,7 @@ - this.field_76809_f.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_76815_a.func_175672_r(this.field_180294_c.func_177982_a(l1, 0, i6))); + int l1 = p_150513_3_.nextInt(16) + 8; +@@ -107,6 +110,7 @@ + this.field_76809_f.func_180709_b(p_150513_2_, p_150513_3_, p_150513_2_.func_175672_r(this.field_180294_c.func_177982_a(l1, 0, i6))); } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SAND_PASS2)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SAND_PASS2)) for (int j1 = 0; j1 < this.field_76801_G; ++j1) { - int i2 = this.field_76813_b.nextInt(16) + 8; -@@ -135,6 +139,7 @@ + int i2 = p_150513_3_.nextInt(16) + 8; +@@ -121,6 +125,7 @@ ++k1; } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.TREE)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.TREE)) for (int j2 = 0; j2 < k1; ++j2) { - int k6 = this.field_76813_b.nextInt(16) + 8; -@@ -149,6 +154,7 @@ + int k6 = p_150513_3_.nextInt(16) + 8; +@@ -135,6 +140,7 @@ } } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.BIG_SHROOM)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.BIG_SHROOM)) for (int k2 = 0; k2 < this.field_76807_J; ++k2) { - int l6 = this.field_76813_b.nextInt(16) + 8; -@@ -156,6 +162,7 @@ - this.field_76826_u.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_76815_a.func_175645_m(this.field_180294_c.func_177982_a(l6, 0, k10))); + int l6 = p_150513_3_.nextInt(16) + 8; +@@ -142,6 +148,7 @@ + this.field_76826_u.func_180709_b(p_150513_2_, p_150513_3_, p_150513_2_.func_175645_m(this.field_180294_c.func_177982_a(l6, 0, k10))); } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.FLOWERS)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.FLOWERS)) for (int l2 = 0; l2 < this.field_76802_A; ++l2) { - int i7 = this.field_76813_b.nextInt(16) + 8; -@@ -177,6 +184,7 @@ + int i7 = p_150513_3_.nextInt(16) + 8; +@@ -163,6 +170,7 @@ } } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.GRASS)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.GRASS)) for (int i3 = 0; i3 < this.field_76803_B; ++i3) { - int j7 = this.field_76813_b.nextInt(16) + 8; -@@ -190,6 +198,7 @@ + int j7 = p_150513_3_.nextInt(16) + 8; +@@ -176,6 +184,7 @@ } } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.DEAD_BUSH)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.DEAD_BUSH)) for (int j3 = 0; j3 < this.field_76804_C; ++j3) { - int k7 = this.field_76813_b.nextInt(16) + 8; -@@ -203,6 +212,7 @@ + int k7 = p_150513_3_.nextInt(16) + 8; +@@ -189,6 +198,7 @@ } } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LILYPAD)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LILYPAD)) for (int k3 = 0; k3 < this.field_76833_y; ++k3) { - int l7 = this.field_76813_b.nextInt(16) + 8; -@@ -229,6 +239,8 @@ + int l7 = p_150513_3_.nextInt(16) + 8; +@@ -215,6 +225,8 @@ } } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM)) + { for (int l3 = 0; l3 < this.field_76798_D; ++l3) { - if (this.field_76813_b.nextInt(4) == 0) -@@ -279,7 +291,9 @@ - this.field_76827_t.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(j4, l15, l8)); + if (p_150513_3_.nextInt(4) == 0) +@@ -265,7 +277,9 @@ + this.field_76827_t.func_180709_b(p_150513_2_, p_150513_3_, this.field_180294_c.func_177982_a(j4, l15, l8)); } } - + } // End of Mushroom generation -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.REED)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.REED)) + { for (int k4 = 0; k4 < this.field_76799_E; ++k4) { - int i9 = this.field_76813_b.nextInt(16) + 8; -@@ -305,7 +319,8 @@ - this.field_76825_v.func_180709_b(this.field_76815_a, this.field_76813_b, this.field_180294_c.func_177982_a(j9, i19, i13)); + int i9 = p_150513_3_.nextInt(16) + 8; +@@ -291,7 +305,8 @@ + this.field_76825_v.func_180709_b(p_150513_2_, p_150513_3_, this.field_180294_c.func_177982_a(j9, i19, i13)); } } - + } // End of Reed generation -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.PUMPKIN)) - if (this.field_76813_b.nextInt(32) == 0) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.PUMPKIN)) + if (p_150513_3_.nextInt(32) == 0) { - int i5 = this.field_76813_b.nextInt(16) + 8; -@@ -319,6 +334,7 @@ + int i5 = p_150513_3_.nextInt(16) + 8; +@@ -305,6 +320,7 @@ } } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.CACTUS)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.CACTUS)) for (int j5 = 0; j5 < this.field_76800_F; ++j5) { - int l9 = this.field_76813_b.nextInt(16) + 8; -@@ -334,6 +350,7 @@ + int l9 = p_150513_3_.nextInt(16) + 8; +@@ -320,6 +336,7 @@ if (this.field_76808_K) { -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LAKE_WATER)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LAKE_WATER)) for (int k5 = 0; k5 < 50; ++k5) { - int i10 = this.field_76813_b.nextInt(16) + 8; -@@ -348,6 +365,7 @@ + int i10 = p_150513_3_.nextInt(16) + 8; +@@ -334,6 +351,7 @@ } } -+ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(field_76815_a, field_76813_b, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LAKE_LAVA)) ++ if(net.minecraftforge.event.terraingen.TerrainGen.decorate(p_150513_2_, p_150513_3_, field_180294_c, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.LAKE_LAVA)) for (int l5 = 0; l5 < 20; ++l5) { - int j10 = this.field_76813_b.nextInt(16) + 8; -@@ -357,6 +375,7 @@ - (new WorldGenLiquids(Blocks.field_150356_k)).func_180709_b(this.field_76815_a, this.field_76813_b, blockpos3); + int j10 = p_150513_3_.nextInt(16) + 8; +@@ -343,21 +361,35 @@ + (new WorldGenLiquids(Blocks.field_150356_k)).func_180709_b(p_150513_2_, p_150513_3_, blockpos3); } } -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Post(field_76815_a, field_76813_b, field_180294_c)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Post(p_150513_2_, p_150513_3_, field_180294_c)); } - protected void func_76795_a(int p_76795_1_, WorldGenerator p_76795_2_, int p_76795_3_, int p_76795_4_) -@@ -397,16 +416,29 @@ - - protected void func_76797_b() + protected void func_76797_b(World p_76797_1_, Random p_76797_2_) { -+ net.minecraftforge.common.MinecraftForge.ORE_GEN_BUS.post(new net.minecraftforge.event.terraingen.OreGenEvent.Pre(field_76815_a, field_76813_b, field_180294_c)); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_76823_i, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.DIRT)) - this.func_76795_a(this.field_180293_d.field_177790_J, this.field_76823_i, this.field_180293_d.field_177791_K, this.field_180293_d.field_177784_L); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_76820_j, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.GRAVEL)) - this.func_76795_a(this.field_180293_d.field_177786_N, this.field_76820_j, this.field_180293_d.field_177787_O, this.field_180293_d.field_177797_P); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_180297_k, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.DIORITE)) - this.func_76795_a(this.field_180293_d.field_177795_V, this.field_180297_k, this.field_180293_d.field_177794_W, this.field_180293_d.field_177801_X); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_180296_j, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.GRANITE)) - this.func_76795_a(this.field_180293_d.field_177799_R, this.field_180296_j, this.field_180293_d.field_177798_S, this.field_180293_d.field_177793_T); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_180295_l, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.ANDESITE)) - this.func_76795_a(this.field_180293_d.field_177802_Z, this.field_180295_l, this.field_180293_d.field_177846_aa, this.field_180293_d.field_177847_ab); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_76821_k, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.COAL)) - this.func_76795_a(this.field_180293_d.field_177845_ad, this.field_76821_k, this.field_180293_d.field_177851_ae, this.field_180293_d.field_177853_af); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_76818_l, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.IRON)) - this.func_76795_a(this.field_180293_d.field_177849_ah, this.field_76818_l, this.field_180293_d.field_177832_ai, this.field_180293_d.field_177834_aj); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_76819_m, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.GOLD)) - this.func_76795_a(this.field_180293_d.field_177830_al, this.field_76819_m, this.field_180293_d.field_177840_am, this.field_180293_d.field_177842_an); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_180299_p, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.REDSTONE)) - this.func_76795_a(this.field_180293_d.field_177838_ap, this.field_180299_p, this.field_180293_d.field_177818_aq, this.field_180293_d.field_177816_ar); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_180298_q, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.DIAMOND)) - this.func_76795_a(this.field_180293_d.field_177812_at, this.field_180298_q, this.field_180293_d.field_177826_au, this.field_180293_d.field_177824_av); -+ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_76815_a, field_76813_b, field_76831_p, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.LAPIS)) - this.func_76793_b(this.field_180293_d.field_177820_ax, this.field_76831_p, this.field_180293_d.field_177807_ay, this.field_180293_d.field_177805_az); -+ net.minecraftforge.common.MinecraftForge.ORE_GEN_BUS.post(new net.minecraftforge.event.terraingen.OreGenEvent.Post(field_76815_a, field_76813_b, field_180294_c)); ++ net.minecraftforge.common.MinecraftForge.ORE_GEN_BUS.post(new net.minecraftforge.event.terraingen.OreGenEvent.Pre(p_76797_1_, p_76797_2_, field_180294_c)); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_76823_i, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.DIRT)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177790_J, this.field_76823_i, this.field_180293_d.field_177791_K, this.field_180293_d.field_177784_L); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_76820_j, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.GRAVEL)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177786_N, this.field_76820_j, this.field_180293_d.field_177787_O, this.field_180293_d.field_177797_P); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_180297_k, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.DIORITE)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177795_V, this.field_180297_k, this.field_180293_d.field_177794_W, this.field_180293_d.field_177801_X); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_180296_j, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.GRANITE)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177799_R, this.field_180296_j, this.field_180293_d.field_177798_S, this.field_180293_d.field_177793_T); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_180295_l, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.ANDESITE)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177802_Z, this.field_180295_l, this.field_180293_d.field_177846_aa, this.field_180293_d.field_177847_ab); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_76821_k, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.COAL)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177845_ad, this.field_76821_k, this.field_180293_d.field_177851_ae, this.field_180293_d.field_177853_af); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_76818_l, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.IRON)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177849_ah, this.field_76818_l, this.field_180293_d.field_177832_ai, this.field_180293_d.field_177834_aj); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_76819_m, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.GOLD)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177830_al, this.field_76819_m, this.field_180293_d.field_177840_am, this.field_180293_d.field_177842_an); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_180299_p, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.REDSTONE)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177838_ap, this.field_180299_p, this.field_180293_d.field_177818_aq, this.field_180293_d.field_177816_ar); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_180298_q, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.DIAMOND)) + this.func_76795_a(p_76797_1_, p_76797_2_, this.field_180293_d.field_177812_at, this.field_180298_q, this.field_180293_d.field_177826_au, this.field_180293_d.field_177824_av); ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(p_76797_1_, p_76797_2_, field_76831_p, field_180294_c, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.LAPIS)) + this.func_76793_b(p_76797_1_, p_76797_2_, this.field_180293_d.field_177820_ax, this.field_76831_p, this.field_180293_d.field_177807_ay, this.field_180293_d.field_177805_az); ++ net.minecraftforge.common.MinecraftForge.ORE_GEN_BUS.post(new net.minecraftforge.event.terraingen.OreGenEvent.Post(p_76797_1_, p_76797_2_, field_180294_c)); } - } + + protected void func_76795_a(World p_76795_1_, Random p_76795_2_, int p_76795_3_, WorldGenerator p_76795_4_, int p_76795_5_, int p_76795_6_) diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeGenBase.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeGenBase.java.patch index 032589894a..22c125373e 100644 --- a/patches/minecraft/net/minecraft/world/biome/BiomeGenBase.java.patch +++ b/patches/minecraft/net/minecraft/world/biome/BiomeGenBase.java.patch @@ -1,25 +1,24 @@ --- ../src-base/minecraft/net/minecraft/world/biome/BiomeGenBase.java +++ ../src-work/minecraft/net/minecraft/world/biome/BiomeGenBase.java -@@ -138,6 +138,10 @@ +@@ -51,7 +51,7 @@ + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; - public BiomeGenBase(int p_i1971_1_) - { -+ this(p_i1971_1_, true); -+ } -+ public BiomeGenBase(int p_i1971_1_, boolean register) -+ { - this.field_76748_D = field_150596_a.field_150777_a; - this.field_76749_E = field_150596_a.field_150776_b; - this.field_76750_F = 0.5F; -@@ -152,6 +156,7 @@ - this.field_76758_O = new WorldGenBigTree(false); - this.field_76763_Q = new WorldGenSwamp(); - this.field_76756_M = p_i1971_1_; -+ if (register) - field_76773_a[p_i1971_1_] = this; - this.field_76760_I = this.func_76729_a(); - this.field_76762_K.add(new BiomeGenBase.SpawnListEntry(EntitySheep.class, 12, 4, 4)); -@@ -168,11 +173,12 @@ +-public abstract class BiomeGenBase ++public abstract class BiomeGenBase extends net.minecraftforge.fml.common.registry.IForgeRegistryEntry.Impl + { + private static final Logger field_150586_aC = LogManager.getLogger(); + protected static final IBlockState field_185365_a = Blocks.field_150348_b.func_176223_P(); +@@ -70,7 +70,7 @@ + protected static final WorldGenTrees field_76757_N = new WorldGenTrees(false); + protected static final WorldGenBigTree field_76758_O = new WorldGenBigTree(false); + protected static final WorldGenSwamp field_76763_Q = new WorldGenSwamp(); +- public static final RegistryNamespaced field_185377_q = new RegistryNamespaced(); ++ public static final RegistryNamespaced field_185377_q = net.minecraftforge.fml.common.registry.GameData.getBiomeRegistry(); + private final String field_76791_y; + private final float field_76748_D; + private final float field_76749_E; +@@ -128,11 +128,12 @@ this.field_76761_J.add(new BiomeGenBase.SpawnListEntry(EntityWitch.class, 5, 1, 1)); this.field_76755_L.add(new BiomeGenBase.SpawnListEntry(EntitySquid.class, 10, 4, 4)); this.field_82914_M.add(new BiomeGenBase.SpawnListEntry(EntityBat.class, 10, 8, 8)); @@ -32,8 +31,8 @@ + return getModdedBiomeDecorator(new BiomeDecorator()); } - public BiomeGenBase func_76732_a(float p_76732_1_, float p_76732_2_) -@@ -342,7 +348,7 @@ + public boolean func_185363_b() +@@ -228,7 +229,7 @@ { double d0 = (double)MathHelper.func_76131_a(this.func_180626_a(p_180627_1_), 0.0F, 1.0F); double d1 = (double)MathHelper.func_76131_a(this.func_76727_i(), 0.0F, 1.0F); @@ -41,8 +40,8 @@ + return getModdedBiomeGrassColor(ColorizerGrass.func_77480_a(d0, d1)); } - @SideOnly(Side.CLIENT) -@@ -350,7 +356,7 @@ + public final void func_180628_b(World p_180628_1_, Random p_180628_2_, ChunkPrimer p_180628_3_, int p_180628_4_, int p_180628_5_, double p_180628_6_) +@@ -321,7 +322,7 @@ { double d0 = (double)MathHelper.func_76131_a(this.func_180626_a(p_180625_1_), 0.0F, 1.0F); double d1 = (double)MathHelper.func_76131_a(this.func_76727_i(), 0.0F, 1.0F); @@ -50,9 +49,9 @@ + return getModdedBiomeFoliageColor(ColorizerFoliage.func_77470_a(d0, d1)); } - public boolean func_150559_j() -@@ -497,6 +503,84 @@ - } + public Class func_150562_l() +@@ -386,6 +387,83 @@ + return this.field_76766_R; } + /* ========================================= FORGE START ======================================*/ @@ -67,21 +66,21 @@ + { + net.minecraftforge.event.terraingen.BiomeEvent.GetWaterColor event = new net.minecraftforge.event.terraingen.BiomeEvent.GetWaterColor(this, field_76759_H); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ return event.newColor; ++ return event.getNewColor(); + } + + public int getModdedBiomeGrassColor(int original) + { + net.minecraftforge.event.terraingen.BiomeEvent.GetGrassColor event = new net.minecraftforge.event.terraingen.BiomeEvent.GetGrassColor(this, original); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ return event.newColor; ++ return event.getNewColor(); + } + + public int getModdedBiomeFoliageColor(int original) + { + net.minecraftforge.event.terraingen.BiomeEvent.GetFoliageColor event = new net.minecraftforge.event.terraingen.BiomeEvent.GetFoliageColor(this, original); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ return event.newColor; ++ return event.getNewColor(); + } + + /** @@ -130,9 +129,8 @@ + world.func_180501_a(pos, flower.state, 3); + } + -+ + /* ========================================= FORGE END ======================================*/ + - static + public static void func_185358_q() { - field_76772_c.func_150566_k(); + func_185354_a(0, "ocean", new BiomeGenOcean((new BiomeGenBase.BiomeProperties("Ocean")).func_185398_c(-1.0F).func_185400_d(0.1F))); diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeGenForest.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeGenForest.java.patch index 95b4694190..24cfe16201 100644 --- a/patches/minecraft/net/minecraft/world/biome/BiomeGenForest.java.patch +++ b/patches/minecraft/net/minecraft/world/biome/BiomeGenForest.java.patch @@ -1,14 +1,13 @@ --- ../src-base/minecraft/net/minecraft/world/biome/BiomeGenForest.java +++ ../src-work/minecraft/net/minecraft/world/biome/BiomeGenForest.java -@@ -201,4 +201,20 @@ - }; +@@ -147,6 +147,22 @@ } } -+ + + @Override + public void addDefaultFlowers() + { -+ if (field_150632_aF != 1) ++ if (field_150632_aF != BiomeGenForest.Type.FLOWER) + { + super.addDefaultFlowers(); + return; @@ -20,4 +19,7 @@ + addFlower(net.minecraft.init.Blocks.field_150328_O.func_176223_P().func_177226_a(net.minecraft.init.Blocks.field_150328_O.func_176494_l(), type), 10); + } + } - } ++ + public Class func_150562_l() + { + return BiomeGenForest.class; diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeGenHills.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeGenHills.java.patch index 129a16dfc2..7354b7b779 100644 --- a/patches/minecraft/net/minecraft/world/biome/BiomeGenHills.java.patch +++ b/patches/minecraft/net/minecraft/world/biome/BiomeGenHills.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/biome/BiomeGenHills.java +++ ../src-work/minecraft/net/minecraft/world/biome/BiomeGenHills.java -@@ -40,28 +40,20 @@ +@@ -37,28 +37,20 @@ public void func_180624_a(World p_180624_1_, Random p_180624_2_, BlockPos p_180624_3_) { super.func_180624_a(p_180624_1_, p_180624_2_, p_180624_3_); @@ -36,9 +36,9 @@ } public void func_180622_a(World p_180622_1_, Random p_180622_2_, ChunkPrimer p_180622_3_, int p_180622_4_, int p_180622_5_, double p_180622_6_) -@@ -97,4 +89,23 @@ - { - return (new BiomeGenHills(p_180277_1_, false)).func_150633_b(this); +@@ -86,4 +78,24 @@ + EXTRA_TREES, + MUTATED; } + + private static class EmeraldGenerator extends WorldGenerator @@ -51,7 +51,8 @@ + { + BlockPos blockpos = pos.func_177982_a(rand.nextInt(16), rand.nextInt(28) + 4, rand.nextInt(16)); + -+ if (worldIn.func_180495_p(blockpos).func_177230_c().isReplaceableOreGen(worldIn, blockpos, net.minecraft.block.state.pattern.BlockHelper.func_177642_a(Blocks.field_150348_b))) ++ net.minecraft.block.state.IBlockState state = worldIn.func_180495_p(blockpos); ++ if (state.func_177230_c().isReplaceableOreGen(state, worldIn, blockpos, net.minecraft.block.state.pattern.BlockMatcher.func_177642_a(Blocks.field_150348_b))) + { + worldIn.func_180501_a(blockpos, Blocks.field_150412_bA.func_176223_P(), 2); + } diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeGenPlains.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeGenPlains.java.patch index 275d4491a9..a15220f7f6 100644 --- a/patches/minecraft/net/minecraft/world/biome/BiomeGenPlains.java.patch +++ b/patches/minecraft/net/minecraft/world/biome/BiomeGenPlains.java.patch @@ -1,8 +1,8 @@ --- ../src-base/minecraft/net/minecraft/world/biome/BiomeGenPlains.java +++ ../src-work/minecraft/net/minecraft/world/biome/BiomeGenPlains.java -@@ -103,4 +103,19 @@ - biomegenplains.field_150609_ah = 14273354; - return biomegenplains; +@@ -92,4 +92,19 @@ + + super.func_180624_a(p_180624_1_, p_180624_2_, p_180624_3_); } + + @Override diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeGenSwamp.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeGenSwamp.java.patch index 2df3583475..d3c19e2702 100644 --- a/patches/minecraft/net/minecraft/world/biome/BiomeGenSwamp.java.patch +++ b/patches/minecraft/net/minecraft/world/biome/BiomeGenSwamp.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/biome/BiomeGenSwamp.java +++ ../src-work/minecraft/net/minecraft/world/biome/BiomeGenSwamp.java -@@ -84,4 +84,10 @@ +@@ -86,4 +86,10 @@ { return 6975545; } diff --git a/patches/minecraft/net/minecraft/world/biome/BiomeProvider.java.patch b/patches/minecraft/net/minecraft/world/biome/BiomeProvider.java.patch new file mode 100644 index 0000000000..2b6f415c31 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/biome/BiomeProvider.java.patch @@ -0,0 +1,38 @@ +--- ../src-base/minecraft/net/minecraft/world/biome/BiomeProvider.java ++++ ../src-work/minecraft/net/minecraft/world/biome/BiomeProvider.java +@@ -15,6 +15,7 @@ + + public class BiomeProvider + { ++ public static List allowedBiomes = Lists.newArrayList(Biomes.field_76767_f, Biomes.field_76772_c, Biomes.field_76768_g, Biomes.field_76784_u, Biomes.field_76785_t, Biomes.field_76782_w, Biomes.field_76792_x); + private GenLayer field_76944_d; + private GenLayer field_76945_e; + private final BiomeCache field_76942_f; +@@ -23,13 +24,14 @@ + protected BiomeProvider() + { + this.field_76942_f = new BiomeCache(this); +- this.field_76943_g = Lists.newArrayList(new BiomeGenBase[] {Biomes.field_76767_f, Biomes.field_76772_c, Biomes.field_76768_g, Biomes.field_76784_u, Biomes.field_76785_t, Biomes.field_76782_w, Biomes.field_76792_x}); ++ this.field_76943_g = Lists.newArrayList(allowedBiomes); + } + + private BiomeProvider(long p_i45744_1_, WorldType p_i45744_3_, String p_i45744_4_) + { + this(); + GenLayer[] agenlayer = GenLayer.func_180781_a(p_i45744_1_, p_i45744_3_, p_i45744_4_); ++ agenlayer = getModdedBiomeGenerators(p_i45744_3_, p_i45744_1_, agenlayer); + this.field_76944_d = agenlayer[0]; + this.field_76945_e = agenlayer[1]; + } +@@ -196,4 +198,11 @@ + { + this.field_76942_f.func_76838_a(); + } ++ ++ public GenLayer[] getModdedBiomeGenerators(WorldType worldType, long seed, GenLayer[] original) ++ { ++ net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens event = new net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens(worldType, seed, original); ++ net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event); ++ return event.getNewBiomeGens(); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/biome/WorldChunkManager.java.patch b/patches/minecraft/net/minecraft/world/biome/WorldChunkManager.java.patch deleted file mode 100644 index 5378a0e201..0000000000 --- a/patches/minecraft/net/minecraft/world/biome/WorldChunkManager.java.patch +++ /dev/null @@ -1,45 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/biome/WorldChunkManager.java -+++ ../src-work/minecraft/net/minecraft/world/biome/WorldChunkManager.java -@@ -16,6 +16,7 @@ - - public class WorldChunkManager - { -+ public static List allowedBiomes = Lists.newArrayList(BiomeGenBase.field_76767_f, BiomeGenBase.field_76772_c, BiomeGenBase.field_76768_g, BiomeGenBase.field_76784_u, BiomeGenBase.field_76785_t, BiomeGenBase.field_76782_w, BiomeGenBase.field_76792_x); - private GenLayer field_76944_d; - private GenLayer field_76945_e; - private BiomeCache field_76942_f; -@@ -27,13 +28,7 @@ - this.field_76942_f = new BiomeCache(this); - this.field_180301_f = ""; - this.field_76943_g = Lists.newArrayList(); -- this.field_76943_g.add(BiomeGenBase.field_76767_f); -- this.field_76943_g.add(BiomeGenBase.field_76772_c); -- this.field_76943_g.add(BiomeGenBase.field_76768_g); -- this.field_76943_g.add(BiomeGenBase.field_76784_u); -- this.field_76943_g.add(BiomeGenBase.field_76785_t); -- this.field_76943_g.add(BiomeGenBase.field_76782_w); -- this.field_76943_g.add(BiomeGenBase.field_76792_x); -+ this.field_76943_g.addAll(allowedBiomes); - } - - public WorldChunkManager(long p_i45744_1_, WorldType p_i45744_3_, String p_i45744_4_) -@@ -41,6 +36,7 @@ - this(); - this.field_180301_f = p_i45744_4_; - GenLayer[] agenlayer = GenLayer.func_180781_a(p_i45744_1_, p_i45744_3_, p_i45744_4_); -+ agenlayer = getModdedBiomeGenerators(p_i45744_3_, p_i45744_1_, agenlayer); - this.field_76944_d = agenlayer[0]; - this.field_76945_e = agenlayer[1]; - } -@@ -249,4 +245,11 @@ - { - this.field_76942_f.func_76838_a(); - } -+ -+ public GenLayer[] getModdedBiomeGenerators(WorldType worldType, long seed, GenLayer[] original) -+ { -+ net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens event = new net.minecraftforge.event.terraingen.WorldTypeEvent.InitBiomeGens(worldType, seed, original); -+ net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event); -+ return event.newBiomeGens; -+ } - } diff --git a/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch b/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch index adafa6b910..e12fe8fab1 100644 --- a/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch +++ b/patches/minecraft/net/minecraft/world/chunk/Chunk.java.patch @@ -1,38 +1,38 @@ --- ../src-base/minecraft/net/minecraft/world/chunk/Chunk.java +++ ../src-work/minecraft/net/minecraft/world/chunk/Chunk.java -@@ -167,7 +167,7 @@ +@@ -175,7 +175,7 @@ { - Block block = this.func_150810_a(j, l - 1, k); + IBlockState iblockstate = this.func_186032_a(j, l - 1, k); -- if (block.func_149717_k() != 0) -+ if (func_150808_b(j, l - 1, k) != 0) +- if (iblockstate.func_185891_c() != 0) ++ if (iblockstate.getLightOpacity(this.field_76637_e, new BlockPos(j, l - 1, k)) != 0) { this.field_76634_f[k << 4 | j] = l; -@@ -440,12 +440,12 @@ +@@ -448,12 +448,12 @@ public int func_177437_b(BlockPos p_177437_1_) { -- return this.func_177428_a(p_177437_1_).func_149717_k(); -+ return this.func_177428_a(p_177437_1_).getLightOpacity(field_76637_e, p_177437_1_); +- return this.func_177435_g(p_177437_1_).func_185891_c(); ++ return this.func_177435_g(p_177437_1_).getLightOpacity(this.field_76637_e, p_177437_1_); } private int func_150808_b(int p_150808_1_, int p_150808_2_, int p_150808_3_) { -- return this.func_150810_a(p_150808_1_, p_150808_2_, p_150808_3_).func_149717_k(); -+ return func_177437_b(new BlockPos((field_76635_g << 4) + p_150808_1_, p_150808_2_, (field_76647_h << 4) + p_150808_3_)); +- return this.func_186032_a(p_150808_1_, p_150808_2_, p_150808_3_).func_185891_c(); ++ return this.func_186032_a(p_150808_1_, p_150808_2_, p_150808_3_).getLightOpacity(this.field_76637_e, new BlockPos(p_150808_1_, p_150808_2_, p_150808_3_)); } - private Block func_150810_a(int p_150810_1_, int p_150810_2_, int p_150810_3_) -@@ -607,6 +607,7 @@ + public IBlockState func_177435_g(BlockPos p_177435_1_) +@@ -534,6 +534,7 @@ { Block block = p_177436_2_.func_177230_c(); Block block1 = iblockstate.func_177230_c(); -+ int k1 = block1.getLightOpacity(this.field_76637_e, p_177436_1_); // Relocate old light value lookup here, so that it is called before TE is removed. ++ int k1 = iblockstate.getLightOpacity(this.field_76637_e, p_177436_1_); // Relocate old light value lookup here, so that it is called before TE is removed. ExtendedBlockStorage extendedblockstorage = this.field_76652_q[j >> 4]; boolean flag = false; -@@ -623,14 +624,19 @@ +@@ -550,14 +551,19 @@ extendedblockstorage.func_177484_a(i, j & 15, k, p_177436_2_); @@ -54,17 +54,17 @@ this.field_76637_e.func_175713_t(p_177436_1_); } } -@@ -647,8 +653,7 @@ +@@ -574,8 +580,7 @@ } else { -- int j1 = block.func_149717_k(); -- int k1 = block1.func_149717_k(); -+ int j1 = block.getLightOpacity(this.field_76637_e, p_177436_1_); +- int j1 = p_177436_2_.func_185891_c(); +- int k1 = iblockstate.func_185891_c(); ++ int j1 = p_177436_2_.getLightOpacity(this.field_76637_e, p_177436_1_); if (j1 > 0) { -@@ -668,28 +673,19 @@ +@@ -595,28 +600,19 @@ } } @@ -97,7 +97,7 @@ this.field_76637_e.func_175690_a(p_177436_1_, tileentity1); } -@@ -792,6 +788,7 @@ +@@ -719,6 +715,7 @@ k = this.field_76645_j.length - 1; } @@ -105,13 +105,12 @@ p_76612_1_.field_70175_ag = true; p_76612_1_.field_70176_ah = this.field_76635_g; p_76612_1_.field_70162_ai = k; -@@ -830,13 +827,20 @@ - private TileEntity func_177422_i(BlockPos p_177422_1_) +@@ -758,13 +755,19 @@ { - Block block = this.func_177428_a(p_177422_1_); -- return !block.func_149716_u() ? null : ((ITileEntityProvider)block).func_149915_a(this.field_76637_e, this.func_177418_c(p_177422_1_)); -+ IBlockState state = block.func_176203_a(this.func_177418_c(p_177422_1_)); -+ return !block.hasTileEntity(state) ? null : block.createTileEntity(this.field_76637_e, state); + IBlockState iblockstate = this.func_177435_g(p_177422_1_); + Block block = iblockstate.func_177230_c(); +- return !block.func_149716_u() ? null : ((ITileEntityProvider)block).func_149915_a(this.field_76637_e, iblockstate.func_177230_c().func_176201_c(iblockstate)); ++ return !block.hasTileEntity(iblockstate) ? null : block.createTileEntity(this.field_76637_e, iblockstate); } public TileEntity func_177424_a(BlockPos p_177424_1_, Chunk.EnumCreateEntityType p_177424_2_) @@ -127,12 +126,12 @@ if (tileentity == null) { if (p_177424_2_ == Chunk.EnumCreateEntityType.IMMEDIATE) -@@ -846,14 +850,9 @@ +@@ -774,14 +777,9 @@ } else if (p_177424_2_ == Chunk.EnumCreateEntityType.QUEUED) { - this.field_177447_w.add(p_177424_1_); -+ this.field_177447_w.add(p_177424_1_.getImmutable()); ++ this.field_177447_w.add(p_177424_1_.func_185334_h()); } } - else if (tileentity.func_145837_r()) @@ -143,16 +142,16 @@ return tileentity; } -@@ -873,7 +872,7 @@ +@@ -801,7 +799,7 @@ p_177426_2_.func_145834_a(this.field_76637_e); p_177426_2_.func_174878_a(p_177426_1_); -- if (this.func_177428_a(p_177426_1_) instanceof ITileEntityProvider) -+ if (this.func_177428_a(p_177426_1_).hasTileEntity(func_177428_a(p_177426_1_).func_176203_a(this.func_177418_c(p_177426_1_)))) +- if (this.func_177435_g(p_177426_1_).func_177230_c() instanceof ITileEntityProvider) ++ if (this.func_177435_g(p_177426_1_).func_177230_c().hasTileEntity(this.func_177435_g(p_177426_1_))) { if (this.field_150816_i.containsKey(p_177426_1_)) { -@@ -882,6 +881,7 @@ +@@ -810,6 +808,7 @@ p_177426_2_.func_145829_t(); this.field_150816_i.put(p_177426_1_, p_177426_2_); @@ -160,7 +159,7 @@ } } -@@ -910,8 +910,9 @@ +@@ -838,8 +837,9 @@ entity.func_110123_P(); } @@ -171,7 +170,7 @@ } public void func_76623_d() -@@ -927,6 +928,7 @@ +@@ -855,6 +855,7 @@ { this.field_76637_e.func_175681_c(this.field_76645_j[i]); } @@ -179,7 +178,7 @@ } public void func_76630_e() -@@ -936,8 +938,8 @@ +@@ -864,8 +865,8 @@ public void func_177414_a(Entity p_177414_1_, AxisAlignedBB p_177414_2_, List p_177414_3_, Predicate p_177414_4_) { @@ -190,7 +189,7 @@ i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1); j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1); -@@ -976,8 +978,8 @@ +@@ -904,8 +905,8 @@ public void func_177430_a(Class p_177430_1_, AxisAlignedBB p_177430_2_, List p_177430_3_, Predicate p_177430_4_) { @@ -201,21 +200,26 @@ i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1); j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1); -@@ -1137,8 +1139,10 @@ - while (!this.field_177447_w.isEmpty()) +@@ -994,6 +995,7 @@ + { + this.func_150809_p(); + p_186034_1_.func_185931_b(this.field_76635_g, this.field_76647_h); ++ net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(this.field_76635_g, this.field_76647_h, this.field_76637_e, p_186034_1_, this.field_76637_e.func_72863_F()); + this.func_76630_e(); + } + } +@@ -1050,7 +1052,7 @@ { BlockPos blockpos = (BlockPos)this.field_177447_w.poll(); -+ Block block = this.func_177428_a(blockpos); -+ IBlockState state = block.func_176203_a(this.func_177418_c(blockpos)); -- if (this.func_177424_a(blockpos, Chunk.EnumCreateEntityType.CHECK) == null && this.func_177428_a(blockpos).func_149716_u()) -+ if (this.func_177424_a(blockpos, Chunk.EnumCreateEntityType.CHECK) == null && block.hasTileEntity(state)) +- if (this.func_177424_a(blockpos, Chunk.EnumCreateEntityType.CHECK) == null && this.func_177435_g(blockpos).func_177230_c().func_149716_u()) ++ if (this.func_177424_a(blockpos, Chunk.EnumCreateEntityType.CHECK) == null && this.func_177435_g(blockpos).func_177230_c().hasTileEntity(this.func_177435_g(blockpos))) { TileEntity tileentity = this.func_177422_i(blockpos); this.field_76637_e.func_175690_a(blockpos, tileentity); -@@ -1200,6 +1204,13 @@ +@@ -1114,6 +1116,13 @@ @SideOnly(Side.CLIENT) - public void func_177439_a(byte[] p_177439_1_, int p_177439_2_, boolean p_177439_3_) + public void func_186033_a(PacketBuffer p_186033_1_, int p_186033_2_, boolean p_186033_3_) { + for(TileEntity tileEntity : field_150816_i.values()) + { @@ -224,10 +228,10 @@ + tileEntity.func_145838_q(); + } + - int i = 0; boolean flag = !this.field_76637_e.field_73011_w.func_177495_o(); -@@ -1267,10 +1278,16 @@ + for (int i = 0; i < this.field_76652_q.length; ++i) +@@ -1162,10 +1171,16 @@ this.field_76646_k = true; this.func_76590_a(); @@ -243,8 +247,33 @@ + for (TileEntity te : invalidList) te.func_145843_s(); } - public BiomeGenBase func_177411_a(BlockPos p_177411_1_, WorldChunkManager p_177411_2_) -@@ -1583,4 +1600,20 @@ + public BiomeGenBase func_177411_a(BlockPos p_177411_1_, BiomeProvider p_177411_2_) +@@ -1233,13 +1248,13 @@ + BlockPos blockpos1 = blockpos.func_177982_a(k, (j << 4) + i1, l); + boolean flag = i1 == 0 || i1 == 15 || k == 0 || k == 15 || l == 0 || l == 15; + +- if (this.field_76652_q[j] == field_186036_a && flag || this.field_76652_q[j] != field_186036_a && this.field_76652_q[j].func_177485_a(k, i1, l).func_185904_a() == Material.field_151579_a) ++ if (this.field_76652_q[j] == field_186036_a && flag || this.field_76652_q[j] != field_186036_a && this.field_76652_q[j].func_177485_a(k, i1, l).func_177230_c().isAir(this.field_76652_q[j].func_177485_a(k, i1, l), this.field_76637_e, blockpos1)) + { + for (EnumFacing enumfacing : EnumFacing.values()) + { + BlockPos blockpos2 = blockpos1.func_177972_a(enumfacing); + +- if (this.field_76637_e.func_180495_p(blockpos2).func_185906_d() > 0) ++ if (this.field_76637_e.func_180495_p(blockpos2).getLightValue(this.field_76637_e, blockpos2) > 0) + { + this.field_76637_e.func_175664_x(blockpos2); + } +@@ -1370,7 +1385,7 @@ + { + blockpos$mutableblockpos.func_181079_c(blockpos$mutableblockpos.func_177958_n(), l, blockpos$mutableblockpos.func_177952_p()); + +- if (this.func_177435_g(blockpos$mutableblockpos).func_185906_d() > 0) ++ if (this.func_177435_g(blockpos$mutableblockpos).getLightValue(this.field_76637_e, blockpos$mutableblockpos) > 0) + { + this.field_76637_e.func_175664_x(blockpos$mutableblockpos); + } +@@ -1481,4 +1496,20 @@ QUEUED, CHECK; } diff --git a/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch b/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch index cd92eee576..50331158f2 100644 --- a/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch +++ b/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch @@ -1,7 +1,7 @@ --- ../src-base/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java +++ ../src-work/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java -@@ -42,8 +42,41 @@ - this.field_75825_d = p_i2003_1_; +@@ -46,8 +46,41 @@ + this.field_186055_e = p_i46673_2_; } + public boolean chunkExists(World world, int x, int z) @@ -42,8 +42,8 @@ ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(p_75815_2_, p_75815_3_); NBTTagCompound nbttagcompound = (NBTTagCompound)this.field_75828_a.get(chunkcoordintpair); -@@ -59,11 +92,17 @@ - nbttagcompound = CompressedStreamTools.func_74794_a(datainputstream); +@@ -63,11 +96,17 @@ + nbttagcompound = this.field_186055_e.func_188257_a(FixTypes.CHUNK, CompressedStreamTools.func_74794_a(datainputstream)); } - return this.func_75822_a(p_75815_1_, p_75815_2_, p_75815_3_, nbttagcompound); @@ -61,11 +61,11 @@ if (!p_75822_4_.func_150297_b("Level", 10)) { field_151505_a.error("Chunk file at " + p_75822_2_ + "," + p_75822_3_ + " is missing level data, skipping"); -@@ -87,10 +126,29 @@ +@@ -91,10 +130,29 @@ field_151505_a.error("Chunk file at " + p_75822_2_ + "," + p_75822_3_ + " is in the wrong location; relocating. (Expected " + p_75822_2_ + ", " + p_75822_3_ + ", got " + chunk.field_76635_g + ", " + chunk.field_76647_h + ")"); nbttagcompound.func_74768_a("xPos", p_75822_2_); nbttagcompound.func_74768_a("zPos", p_75822_3_); -+ ++ + // Have to move tile entities since we don't load them at this stage + NBTTagList _tileEntities = nbttagcompound.func_150295_c("TileEntities", 10); + @@ -92,43 +92,41 @@ } } } -@@ -105,6 +163,7 @@ - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); +@@ -110,6 +168,7 @@ nbttagcompound.func_74782_a("Level", nbttagcompound1); + nbttagcompound.func_74768_a("DataVersion", 169); this.func_75820_a(p_75816_2_, p_75816_1_, nbttagcompound1); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkDataEvent.Save(p_75816_2_, nbttagcompound)); this.func_75824_a(p_75816_2_.func_76632_l(), nbttagcompound); } catch (Exception exception) -@@ -281,11 +340,20 @@ - { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); +@@ -265,8 +324,17 @@ -+ try -+ { - if (entity.func_70039_c(nbttagcompound1)) + if (entity.func_70039_c(nbttagcompound2)) { ++ try ++ { p_75820_1_.func_177409_g(true); - nbttaglist1.func_74742_a(nbttagcompound1); + nbttaglist1.func_74742_a(nbttagcompound2); ++ } ++ catch (Exception e) ++ { ++ net.minecraftforge.fml.common.FMLLog.log(org.apache.logging.log4j.Level.ERROR, e, ++ "An Entity type %s has thrown an exception trying to write state. It will not persist. Report this to the mod author", ++ entity.getClass().getName()); ++ } } -+ } -+ catch (Exception e) -+ { -+ net.minecraftforge.fml.common.FMLLog.log(org.apache.logging.log4j.Level.ERROR, e, -+ "An Entity type %s has thrown an exception trying to write state. It will not persist. Report this to the mod author", -+ entity.getClass().getName()); -+ } } } +@@ -276,9 +344,18 @@ -@@ -295,8 +363,17 @@ for (TileEntity tileentity : p_75820_1_.func_177434_r().values()) { - NBTTagCompound nbttagcompound2 = new NBTTagCompound(); + try + { - tileentity.func_145841_b(nbttagcompound2); - nbttaglist2.func_74742_a(nbttagcompound2); + NBTTagCompound nbttagcompound3 = new NBTTagCompound(); + tileentity.func_145841_b(nbttagcompound3); + nbttaglist2.func_74742_a(nbttagcompound3); + } + catch (Exception e) + { @@ -139,7 +137,7 @@ } p_75820_3_.func_74782_a("TileEntities", nbttaglist2); -@@ -376,6 +453,12 @@ +@@ -347,6 +424,12 @@ chunk.func_76616_a(p_75823_2_.func_74770_j("Biomes")); } @@ -152,11 +150,12 @@ NBTTagList nbttaglist1 = p_75823_2_.func_150295_c("Entities", 10); if (nbttaglist1 != null) -@@ -447,7 +530,5 @@ +@@ -399,8 +482,6 @@ } } } - - return chunk; } - } + + public static Entity func_186050_a(NBTTagCompound p_186050_0_, World p_186050_1_, Chunk p_186050_2_) diff --git a/patches/minecraft/net/minecraft/world/chunk/storage/AnvilSaveHandler.java.patch b/patches/minecraft/net/minecraft/world/chunk/storage/AnvilSaveHandler.java.patch index 9e563a70be..82936874a8 100644 --- a/patches/minecraft/net/minecraft/world/chunk/storage/AnvilSaveHandler.java.patch +++ b/patches/minecraft/net/minecraft/world/chunk/storage/AnvilSaveHandler.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/chunk/storage/AnvilSaveHandler.java +++ ../src-work/minecraft/net/minecraft/world/chunk/storage/AnvilSaveHandler.java -@@ -20,18 +20,12 @@ +@@ -21,18 +21,12 @@ { File file1 = this.func_75765_b(); @@ -10,14 +10,14 @@ - File file3 = new File(file1, "DIM-1"); + File file3 = new File(file1, p_75763_1_.getSaveFolder()); file3.mkdirs(); - return new AnvilChunkLoader(file3); + return new AnvilChunkLoader(file3, this.field_186341_a); } - else if (p_75763_1_ instanceof WorldProviderEnd) - { - File file2 = new File(file1, "DIM1"); - file2.mkdirs(); -- return new AnvilChunkLoader(file2); +- return new AnvilChunkLoader(file2, this.field_186341_a); - } else { - return new AnvilChunkLoader(file1); + return new AnvilChunkLoader(file1, this.field_186341_a); diff --git a/patches/minecraft/net/minecraft/world/chunk/storage/RegionFile.java.patch b/patches/minecraft/net/minecraft/world/chunk/storage/RegionFile.java.patch index 1992d6dad4..4f7ea64497 100644 --- a/patches/minecraft/net/minecraft/world/chunk/storage/RegionFile.java.patch +++ b/patches/minecraft/net/minecraft/world/chunk/storage/RegionFile.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/chunk/storage/RegionFile.java +++ ../src-work/minecraft/net/minecraft/world/chunk/storage/RegionFile.java -@@ -101,6 +101,39 @@ +@@ -94,6 +94,39 @@ } } diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java.patch index f4cec46a70..27625d41d5 100644 --- a/patches/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java.patch @@ -1,67 +1,72 @@ --- ../src-base/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java +++ ../src-work/minecraft/net/minecraft/world/gen/ChunkProviderEnd.java -@@ -32,6 +32,9 @@ - double[] field_73193_e; - double[] field_73190_f; - double[] field_73191_g; +@@ -39,6 +39,9 @@ + double[] field_185967_f; + double[] field_185968_g; + private final WorldGenEndIsland field_185975_r = new WorldGenEndIsland(); + // temporary variables used during event handling + private int chunkX = 0; + private int chunkZ = 0; - public ChunkProviderEnd(World p_i2007_1_, long p_i2007_2_) + public ChunkProviderEnd(World p_i46667_1_, boolean p_i46667_2_, long p_i46667_3_) { -@@ -42,6 +45,14 @@ - this.field_73199_l = new NoiseGeneratorOctaves(this.field_73204_i, 8); - this.field_73196_a = new NoiseGeneratorOctaves(this.field_73204_i, 10); - this.field_73194_b = new NoiseGeneratorOctaves(this.field_73204_i, 16); +@@ -51,6 +54,16 @@ + this.field_73214_a = new NoiseGeneratorOctaves(this.field_73220_k, 10); + this.field_73212_b = new NoiseGeneratorOctaves(this.field_73220_k, 16); + this.field_185973_o = new NoiseGeneratorSimplex(this.field_73220_k); + -+ NoiseGenerator[] noiseGens = {field_73201_j, field_73202_k, field_73199_l, field_73196_a, field_73194_b}; -+ noiseGens = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i2007_1_, this.field_73204_i, noiseGens); -+ this.field_73201_j = (NoiseGeneratorOctaves)noiseGens[0]; -+ this.field_73202_k = (NoiseGeneratorOctaves)noiseGens[1]; -+ this.field_73199_l = (NoiseGeneratorOctaves)noiseGens[2]; -+ this.field_73196_a = (NoiseGeneratorOctaves)noiseGens[3]; -+ this.field_73194_b = (NoiseGeneratorOctaves)noiseGens[4]; ++ net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextEnd ctx = ++ new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextEnd(field_185969_i, field_185970_j, field_185971_k, field_73214_a, field_73212_b, field_185973_o); ++ ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i46667_1_, this.field_73220_k, ctx); ++ this.field_185969_i = ctx.getLPerlin1(); ++ this.field_185970_j = ctx.getLPerlin2(); ++ this.field_185971_k = ctx.getPerlin(); ++ this.field_73214_a = ctx.getDepth(); ++ this.field_73212_b = ctx.getScale(); ++ this.field_185973_o = ctx.getIsland(); } - public void func_180520_a(int p_180520_1_, int p_180520_2_, ChunkPrimer p_180520_3_) -@@ -114,6 +125,9 @@ + public void func_180518_a(int p_180518_1_, int p_180518_2_, ChunkPrimer p_180518_3_) +@@ -123,6 +136,7 @@ - public void func_180519_a(ChunkPrimer p_180519_1_) + public void func_185962_a(ChunkPrimer p_185962_1_) { -+ net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks(this, chunkX, chunkZ, p_180519_1_, this.field_73200_m); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return; ++ if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, this.chunkX, this.chunkZ, p_185962_1_, this.field_73230_p)) return; for (int i = 0; i < 16; ++i) { for (int j = 0; j < 16; ++j) -@@ -165,6 +179,7 @@ +@@ -174,6 +188,7 @@ - public Chunk func_73154_d(int p_73154_1_, int p_73154_2_) + public Chunk func_185932_a(int p_185932_1_, int p_185932_2_) { -+ chunkX = p_73154_1_; chunkZ = p_73154_2_; - this.field_73204_i.setSeed((long)p_73154_1_ * 341873128712L + (long)p_73154_2_ * 132897987541L); ++ this.chunkX = p_185932_1_; this.chunkZ = p_185932_2_; + this.field_73220_k.setSeed((long)p_185932_1_ * 341873128712L + (long)p_185932_2_ * 132897987541L); ChunkPrimer chunkprimer = new ChunkPrimer(); - this.field_73198_o = this.field_73200_m.func_72959_q().func_76933_b(this.field_73198_o, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16); -@@ -184,6 +199,10 @@ + this.field_73231_z = this.field_73230_p.func_72959_q().func_76933_b(this.field_73231_z, p_185932_1_ * 16, p_185932_2_ * 16, 16, 16); +@@ -255,6 +270,10 @@ - private double[] func_73187_a(double[] p_73187_1_, int p_73187_2_, int p_73187_3_, int p_73187_4_, int p_73187_5_, int p_73187_6_, int p_73187_7_) + private double[] func_185963_a(double[] p_185963_1_, int p_185963_2_, int p_185963_3_, int p_185963_4_, int p_185963_5_, int p_185963_6_, int p_185963_7_) { -+ net.minecraftforge.event.terraingen.ChunkProviderEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.InitNoiseField(this, p_73187_1_, p_73187_2_, p_73187_3_, p_73187_4_, p_73187_5_, p_73187_6_, p_73187_7_); ++ net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, p_185963_1_, p_185963_2_, p_185963_3_, p_185963_4_, p_185963_5_, p_185963_6_, p_185963_7_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.noisefield; ++ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.getNoisefield(); + - if (p_73187_1_ == null) + if (p_185963_1_ == null) { - p_73187_1_ = new double[p_73187_5_ * p_73187_6_ * p_73187_7_]; -@@ -273,8 +292,10 @@ - public void func_73153_a(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) + p_185963_1_ = new double[p_185963_5_ * p_185963_6_ * p_185963_7_]; +@@ -327,6 +346,7 @@ + public void func_185931_b(int p_185931_1_, int p_185931_2_) { BlockFalling.field_149832_M = true; -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Pre(p_73153_1_, field_73200_m, field_73200_m.field_73012_v, p_73153_2_, p_73153_3_, false)); - BlockPos blockpos = new BlockPos(p_73153_2_ * 16, 0, p_73153_3_ * 16); - this.field_73200_m.func_180494_b(blockpos.func_177982_a(16, 0, 16)).func_180624_a(this.field_73200_m, this.field_73200_m.field_73012_v, blockpos); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Post(p_73153_1_, field_73200_m, field_73200_m.field_73012_v, p_73153_2_, p_73153_3_, false)); ++ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.field_73230_p, p_185931_1_, p_185931_2_, false); + BlockPos blockpos = new BlockPos(p_185931_1_ * 16, 0, p_185931_2_ * 16); + + if (this.field_73229_q) +@@ -374,6 +394,7 @@ + } + } + ++ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.field_73230_p, p_185931_1_, p_185931_2_, false); BlockFalling.field_149832_M = false; } diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java.patch deleted file mode 100644 index d8d3ed7df8..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java.patch +++ /dev/null @@ -1,110 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java -+++ ../src-work/minecraft/net/minecraft/world/gen/ChunkProviderGenerate.java -@@ -58,6 +58,15 @@ - - public ChunkProviderGenerate(World p_i45636_1_, long p_i45636_2_, boolean p_i45636_4_, String p_i45636_5_) - { -+ { -+ field_73226_t = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_73226_t, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE); -+ field_73225_u = (MapGenStronghold)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_73225_u, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.STRONGHOLD); -+ field_73224_v = (MapGenVillage)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_73224_v, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.VILLAGE); -+ field_73223_w = (MapGenMineshaft)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_73223_w, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT); -+ field_73233_x = (MapGenScatteredFeature)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_73233_x, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE); -+ field_73232_y = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_73232_y, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE); -+ field_177474_A = (StructureOceanMonument)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_177474_A, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.OCEAN_MONUMENT); -+ } - this.field_73230_p = p_i45636_1_; - this.field_73229_q = p_i45636_4_; - this.field_177475_o = p_i45636_1_.func_72912_H().func_76067_t(); -@@ -87,6 +96,16 @@ - this.field_177476_s = this.field_177477_r.field_177778_E ? Blocks.field_150353_l : Blocks.field_150355_j; - p_i45636_1_.func_181544_b(this.field_177477_r.field_177841_q); - } -+ -+ NoiseGenerator[] noiseGens = {field_147431_j, field_147432_k, field_147429_l, field_147430_m, field_73214_a, field_73212_b, field_73213_c}; -+ noiseGens = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i45636_1_, this.field_73220_k, noiseGens); -+ this.field_147431_j = (NoiseGeneratorOctaves)noiseGens[0]; -+ this.field_147432_k = (NoiseGeneratorOctaves)noiseGens[1]; -+ this.field_147429_l = (NoiseGeneratorOctaves)noiseGens[2]; -+ this.field_147430_m = (NoiseGeneratorPerlin)noiseGens[3]; -+ this.field_73214_a = (NoiseGeneratorOctaves)noiseGens[4]; -+ this.field_73212_b = (NoiseGeneratorOctaves)noiseGens[5]; -+ this.field_73213_c = (NoiseGeneratorOctaves)noiseGens[6]; - } - - public void func_180518_a(int p_180518_1_, int p_180518_2_, ChunkPrimer p_180518_3_) -@@ -160,6 +179,10 @@ - - public void func_180517_a(int p_180517_1_, int p_180517_2_, ChunkPrimer p_180517_3_, BiomeGenBase[] p_180517_4_) - { -+ net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks(this, p_180517_1_, p_180517_2_, p_180517_3_, this.field_73230_p); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return; -+ - double d0 = 0.03125D; - this.field_73227_s = this.field_147430_m.func_151599_a(this.field_73227_s, (double)(p_180517_1_ * 16), (double)(p_180517_2_ * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); - -@@ -366,6 +389,8 @@ - boolean flag = false; - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(p_73153_2_, p_73153_3_); - -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Pre(p_73153_1_, field_73230_p, field_73220_k, p_73153_2_, p_73153_3_, flag)); -+ - if (this.field_177477_r.field_177829_w && this.field_73229_q) - { - this.field_73223_w.func_175794_a(this.field_73230_p, this.field_73220_k, chunkcoordintpair); -@@ -391,7 +416,8 @@ - this.field_177474_A.func_175794_a(this.field_73230_p, this.field_73220_k, chunkcoordintpair); - } - -- if (biomegenbase != BiomeGenBase.field_76769_d && biomegenbase != BiomeGenBase.field_76786_s && this.field_177477_r.field_177781_A && !flag && this.field_73220_k.nextInt(this.field_177477_r.field_177782_B) == 0) -+ if (biomegenbase != BiomeGenBase.field_76769_d && biomegenbase != BiomeGenBase.field_76786_s && this.field_177477_r.field_177781_A && !flag && this.field_73220_k.nextInt(this.field_177477_r.field_177782_B) == 0 -+ && net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, field_73230_p, field_73220_k, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE)) - { - int i1 = this.field_73220_k.nextInt(16) + 8; - int j1 = this.field_73220_k.nextInt(256); -@@ -399,7 +425,8 @@ - (new WorldGenLakes(Blocks.field_150355_j)).func_180709_b(this.field_73230_p, this.field_73220_k, blockpos.func_177982_a(i1, j1, k1)); - } - -- if (!flag && this.field_73220_k.nextInt(this.field_177477_r.field_177777_D / 10) == 0 && this.field_177477_r.field_177783_C) -+ if (!flag && this.field_73220_k.nextInt(this.field_177477_r.field_177777_D / 10) == 0 && this.field_177477_r.field_177783_C && -+ net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, field_73230_p, field_73220_k, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA)) - { - int i2 = this.field_73220_k.nextInt(16) + 8; - int l2 = this.field_73220_k.nextInt(this.field_73220_k.nextInt(248) + 8); -@@ -413,7 +440,8 @@ - - if (this.field_177477_r.field_177837_s) - { -- for (int j2 = 0; j2 < this.field_177477_r.field_177835_t; ++j2) -+ boolean doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, field_73230_p, field_73220_k, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON); -+ for (int j2 = 0; doGen && j2 < this.field_177477_r.field_177835_t; ++j2) - { - int i3 = this.field_73220_k.nextInt(16) + 8; - int l3 = this.field_73220_k.nextInt(256); -@@ -423,10 +451,14 @@ - } - - biomegenbase.func_180624_a(this.field_73230_p, this.field_73220_k, new BlockPos(i, 0, j)); -+ if (net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, field_73230_p, field_73220_k, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS)) -+ { - SpawnerAnimals.func_77191_a(this.field_73230_p, biomegenbase, i + 8, j + 8, 16, 16, this.field_73220_k); -+ } - blockpos = blockpos.func_177982_a(8, 0, 8); - -- for (int k2 = 0; k2 < 16; ++k2) -+ boolean doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, field_73230_p, field_73220_k, p_73153_2_, p_73153_3_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE); -+ for (int k2 = 0; doGen && k2 < 16; ++k2) - { - for (int j3 = 0; j3 < 16; ++j3) - { -@@ -445,6 +477,8 @@ - } - } - -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Post(p_73153_1_, field_73230_p, field_73220_k, p_73153_2_, p_73153_3_, flag)); -+ - BlockFalling.field_149832_M = false; - } - diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkProviderHell.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkProviderHell.java.patch index 216df82678..f4704abe85 100644 --- a/patches/minecraft/net/minecraft/world/gen/ChunkProviderHell.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/ChunkProviderHell.java.patch @@ -1,141 +1,104 @@ --- ../src-base/minecraft/net/minecraft/world/gen/ChunkProviderHell.java +++ ../src-work/minecraft/net/minecraft/world/gen/ChunkProviderHell.java -@@ -49,8 +49,8 @@ - private final WorldGenHellLava field_177472_y = new WorldGenHellLava(Blocks.field_150356_k, false); - private final GeneratorBushFeature field_177471_z = new GeneratorBushFeature(Blocks.field_150338_P); - private final GeneratorBushFeature field_177465_A = new GeneratorBushFeature(Blocks.field_150337_Q); -- private final MapGenNetherBridge field_73172_c = new MapGenNetherBridge(); -- private final MapGenBase field_73182_t = new MapGenCavesHell(); -+ private final MapGenNetherBridge field_73172_c; -+ private final MapGenBase field_73182_t; - double[] field_73169_d; - double[] field_73170_e; - double[] field_73167_f; -@@ -59,16 +59,29 @@ - - public ChunkProviderHell(World p_i45637_1_, boolean p_i45637_2_, long p_i45637_3_) - { -+ this.field_73172_c = (MapGenNetherBridge) net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(new MapGenNetherBridge(), net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_BRIDGE); -+ this.field_73182_t = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(new MapGenCavesHell(), net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_CAVE); - this.field_73175_o = p_i45637_1_; - this.field_177466_i = p_i45637_2_; - this.field_73181_i = new Random(p_i45637_3_); -- this.field_73178_j = new NoiseGeneratorOctaves(this.field_73181_i, 16); -- this.field_73179_k = new NoiseGeneratorOctaves(this.field_73181_i, 16); -- this.field_73176_l = new NoiseGeneratorOctaves(this.field_73181_i, 8); -- this.field_73177_m = new NoiseGeneratorOctaves(this.field_73181_i, 4); -- this.field_73174_n = new NoiseGeneratorOctaves(this.field_73181_i, 4); -- this.field_73173_a = new NoiseGeneratorOctaves(this.field_73181_i, 10); -- this.field_73171_b = new NoiseGeneratorOctaves(this.field_73181_i, 16); -+ NoiseGeneratorOctaves netherNoiseGen1 = new NoiseGeneratorOctaves(this.field_73181_i, 16); -+ NoiseGeneratorOctaves netherNoiseGen2 = new NoiseGeneratorOctaves(this.field_73181_i, 16); -+ NoiseGeneratorOctaves netherNoiseGen3 = new NoiseGeneratorOctaves(this.field_73181_i, 8); -+ NoiseGeneratorOctaves slowsandGravelNoiseGen = new NoiseGeneratorOctaves(this.field_73181_i, 4); -+ NoiseGeneratorOctaves netherrackExculsivityNoiseGen = new NoiseGeneratorOctaves(this.field_73181_i, 4); -+ NoiseGeneratorOctaves netherNoiseGen6 = new NoiseGeneratorOctaves(this.field_73181_i, 10); -+ NoiseGeneratorOctaves netherNoiseGen7 = new NoiseGeneratorOctaves(this.field_73181_i, 16); -+ NoiseGenerator[] noiseGens = new NoiseGenerator[] { -+ netherNoiseGen1, netherNoiseGen2, netherNoiseGen3, slowsandGravelNoiseGen, netherrackExculsivityNoiseGen, netherNoiseGen6, netherNoiseGen7 -+ }; -+ noiseGens = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i45637_1_, this.field_73181_i, noiseGens); -+ this.field_73178_j = (NoiseGeneratorOctaves)noiseGens[0]; -+ this.field_73179_k = (NoiseGeneratorOctaves)noiseGens[1]; -+ this.field_73176_l = (NoiseGeneratorOctaves)noiseGens[2]; -+ this.field_73177_m = (NoiseGeneratorOctaves)noiseGens[3]; -+ this.field_73174_n = (NoiseGeneratorOctaves)noiseGens[4]; -+ this.field_73173_a = (NoiseGeneratorOctaves)noiseGens[5]; -+ this.field_73171_b = (NoiseGeneratorOctaves)noiseGens[6]; +@@ -76,6 +76,19 @@ + this.field_185946_g = new NoiseGeneratorOctaves(this.field_185954_p, 10); + this.field_185947_h = new NoiseGeneratorOctaves(this.field_185954_p, 16); p_i45637_1_.func_181544_b(63); ++ ++ net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell ctx = ++ new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextHell(field_185957_u, field_185958_v, field_185959_w, field_73177_m, field_73174_n, field_185946_g, field_185947_h); ++ ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i45637_1_, this.field_185954_p, ctx); ++ this.field_185957_u = ctx.getLPerlin1(); ++ this.field_185958_v = ctx.getLPerlin2(); ++ this.field_185959_w = ctx.getPerlin(); ++ this.field_73177_m = ctx.getPerlin2(); ++ this.field_73174_n = ctx.getPerlin3(); ++ this.field_185946_g = ctx.getScale(); ++ this.field_185947_h = ctx.getDepth(); ++ this.field_73172_c = (MapGenNetherBridge)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_73172_c, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_BRIDGE); ++ this.field_185939_I = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_185939_I, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.NETHER_CAVE); } -@@ -148,6 +161,10 @@ + public void func_185936_a(int p_185936_1_, int p_185936_2_, ChunkPrimer p_185936_3_) +@@ -154,6 +167,7 @@ - public void func_180516_b(int p_180516_1_, int p_180516_2_, ChunkPrimer p_180516_3_) + public void func_185937_b(int p_185937_1_, int p_185937_2_, ChunkPrimer p_185937_3_) { -+ net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.ReplaceBiomeBlocks(this, p_180516_1_, p_180516_2_, p_180516_3_, this.field_73175_o); -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return; -+ - int i = this.field_73175_o.func_181545_F() + 1; ++ if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_185937_1_, p_185937_2_, p_185937_3_, this.field_185952_n)) return; + int i = this.field_185952_n.func_181545_F() + 1; double d0 = 0.03125D; - this.field_73185_q = this.field_73177_m.func_76304_a(this.field_73185_q, p_180516_1_ * 16, p_180516_2_ * 16, 0, 16, 16, 1, d0, d0, 1.0D); -@@ -265,6 +282,10 @@ + this.field_73185_q = this.field_73177_m.func_76304_a(this.field_73185_q, p_185937_1_ * 16, p_185937_2_ * 16, 0, 16, 16, 1, d0, d0, 1.0D); +@@ -276,6 +290,10 @@ + p_185938_1_ = new double[p_185938_5_ * p_185938_6_ * p_185938_7_]; + } - private double[] func_73164_a(double[] p_73164_1_, int p_73164_2_, int p_73164_3_, int p_73164_4_, int p_73164_5_, int p_73164_6_, int p_73164_7_) - { -+ net.minecraftforge.event.terraingen.ChunkProviderEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkProviderEvent.InitNoiseField(this, p_73164_1_, p_73164_2_, p_73164_3_, p_73164_4_, p_73164_5_, p_73164_6_, p_73164_7_); ++ net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField event = new net.minecraftforge.event.terraingen.ChunkGeneratorEvent.InitNoiseField(this, p_185938_1_, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, p_185938_6_, p_185938_7_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); -+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.noisefield; ++ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.getNoisefield(); + - if (p_73164_1_ == null) - { - p_73164_1_ = new double[p_73164_5_ * p_73164_6_ * p_73164_7_]; -@@ -356,50 +377,60 @@ - public void func_73153_a(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) + double d0 = 684.412D; + double d1 = 2053.236D; + this.field_73168_g = this.field_185946_g.func_76304_a(this.field_73168_g, p_185938_2_, p_185938_3_, p_185938_4_, p_185938_5_, 1, p_185938_7_, 1.0D, 0.0D, 1.0D); +@@ -357,20 +375,25 @@ + public void func_185931_b(int p_185931_1_, int p_185931_2_) { BlockFalling.field_149832_M = true; -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Pre(p_73153_1_, field_73175_o, field_73181_i, p_73153_2_, p_73153_3_, false)); - BlockPos blockpos = new BlockPos(p_73153_2_ * 16, 0, p_73153_3_ * 16); - ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(p_73153_2_, p_73153_3_); - this.field_73172_c.func_175794_a(this.field_73175_o, this.field_73181_i, chunkcoordintpair); ++ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.field_185952_n, p_185931_1_, p_185931_2_, false); + BlockPos blockpos = new BlockPos(p_185931_1_ * 16, 0, p_185931_2_ * 16); + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(p_185931_1_, p_185931_2_); + this.field_73172_c.func_175794_a(this.field_185952_n, this.field_185954_p, chunkcoordintpair); -- for (int i = 0; i < 8; ++i) -+ boolean doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, field_73175_o, field_73181_i, p_73153_2_, p_73153_3_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA); -+ for (int i = 0; doGen && i < 8; ++i) ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA)) + for (int i = 0; i < 8; ++i) { - this.field_177472_y.func_180709_b(this.field_73175_o, this.field_73181_i, blockpos.func_177982_a(this.field_73181_i.nextInt(16) + 8, this.field_73181_i.nextInt(120) + 4, this.field_73181_i.nextInt(16) + 8)); + this.field_177472_y.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(120) + 4, this.field_185954_p.nextInt(16) + 8)); } -- for (int j = 0; j < this.field_73181_i.nextInt(this.field_73181_i.nextInt(10) + 1) + 1; ++j) -+ doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, field_73175_o, field_73181_i, p_73153_2_, p_73153_3_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.FIRE); -+ for (int j = 0; doGen && j < this.field_73181_i.nextInt(this.field_73181_i.nextInt(10) + 1) + 1; ++j) ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.FIRE)) + for (int j = 0; j < this.field_185954_p.nextInt(this.field_185954_p.nextInt(10) + 1) + 1; ++j) { - this.field_177470_t.func_180709_b(this.field_73175_o, this.field_73181_i, blockpos.func_177982_a(this.field_73181_i.nextInt(16) + 8, this.field_73181_i.nextInt(120) + 4, this.field_73181_i.nextInt(16) + 8)); + this.field_177470_t.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(120) + 4, this.field_185954_p.nextInt(16) + 8)); } -- for (int k = 0; k < this.field_73181_i.nextInt(this.field_73181_i.nextInt(10) + 1); ++k) -+ doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, field_73175_o, field_73181_i, p_73153_2_, p_73153_3_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.GLOWSTONE); -+ for (int k = 0; doGen && k < this.field_73181_i.nextInt(this.field_73181_i.nextInt(10) + 1); ++k) ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.GLOWSTONE)) ++ { + for (int k = 0; k < this.field_185954_p.nextInt(this.field_185954_p.nextInt(10) + 1); ++k) { - this.field_177469_u.func_180709_b(this.field_73175_o, this.field_73181_i, blockpos.func_177982_a(this.field_73181_i.nextInt(16) + 8, this.field_73181_i.nextInt(120) + 4, this.field_73181_i.nextInt(16) + 8)); - } - -- for (int l = 0; l < 10; ++l) -+ for (int l = 0; doGen && l < 10; ++l) + this.field_177469_u.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(120) + 4, this.field_185954_p.nextInt(16) + 8)); +@@ -380,7 +403,13 @@ { - this.field_177468_v.func_180709_b(this.field_73175_o, this.field_73181_i, blockpos.func_177982_a(this.field_73181_i.nextInt(16) + 8, this.field_73181_i.nextInt(128), this.field_73181_i.nextInt(16) + 8)); + this.field_177468_v.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(128), this.field_185954_p.nextInt(16) + 8)); } ++ }//Forge: End doGLowstone -- if (this.field_73181_i.nextBoolean()) -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Pre(field_73175_o, field_73181_i, blockpos)); ++ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.field_185952_n, p_185931_1_, p_185931_2_, false); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Pre(this.field_185952_n, this.field_185954_p, blockpos)); + -+ doGen = net.minecraftforge.event.terraingen.TerrainGen.decorate(field_73175_o, field_73181_i, blockpos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM); -+ if (doGen && this.field_73181_i.nextBoolean()) ++ if (net.minecraftforge.event.terraingen.TerrainGen.decorate(this.field_185952_n, this.field_185954_p, blockpos, net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType.SHROOM)) ++ { + if (this.field_185954_p.nextBoolean()) { - this.field_177471_z.func_180709_b(this.field_73175_o, this.field_73181_i, blockpos.func_177982_a(this.field_73181_i.nextInt(16) + 8, this.field_73181_i.nextInt(128), this.field_73181_i.nextInt(16) + 8)); + this.field_177471_z.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(128), this.field_185954_p.nextInt(16) + 8)); +@@ -390,17 +419,22 @@ + { + this.field_177465_A.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16) + 8, this.field_185954_p.nextInt(128), this.field_185954_p.nextInt(16) + 8)); + } ++ } + ++ if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(this.field_185952_n, this.field_185954_p, field_177467_w, blockpos, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.QUARTZ)) + for (int i1 = 0; i1 < 16; ++i1) + { + this.field_177467_w.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16), this.field_185954_p.nextInt(108) + 10, this.field_185954_p.nextInt(16))); } -- if (this.field_73181_i.nextBoolean()) -+ if (doGen && this.field_73181_i.nextBoolean()) ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185952_n, this.field_185954_p, p_185931_1_, p_185931_2_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA2)) + for (int j1 = 0; j1 < 16; ++j1) { - this.field_177465_A.func_180709_b(this.field_73175_o, this.field_73181_i, blockpos.func_177982_a(this.field_73181_i.nextInt(16) + 8, this.field_73181_i.nextInt(128), this.field_73181_i.nextInt(16) + 8)); + this.field_177473_x.func_180709_b(this.field_185952_n, this.field_185954_p, blockpos.func_177982_a(this.field_185954_p.nextInt(16), this.field_185954_p.nextInt(108) + 10, this.field_185954_p.nextInt(16))); } -- for (int i1 = 0; i1 < 16; ++i1) -+ doGen = net.minecraftforge.event.terraingen.TerrainGen.generateOre(field_73175_o, field_73181_i, field_177467_w, blockpos, net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType.QUARTZ); -+ for (int i1 = 0; doGen && i1 < 16; ++i1) - { - this.field_177467_w.func_180709_b(this.field_73175_o, this.field_73181_i, blockpos.func_177982_a(this.field_73181_i.nextInt(16), this.field_73181_i.nextInt(108) + 10, this.field_73181_i.nextInt(16))); - } - -- for (int j1 = 0; j1 < 16; ++j1) -+ doGen = net.minecraftforge.event.terraingen.TerrainGen.populate(p_73153_1_, field_73175_o, field_73181_i, p_73153_2_, p_73153_3_, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.NETHER_LAVA2); -+ for (int j1 = 0; doGen && j1 < 16; ++j1) - { - this.field_177473_x.func_180709_b(this.field_73175_o, this.field_73181_i, blockpos.func_177982_a(this.field_73181_i.nextInt(16), this.field_73181_i.nextInt(108) + 10, this.field_73181_i.nextInt(16))); - } - -+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.PopulateChunkEvent.Post(p_73153_1_, field_73175_o, field_73181_i, p_73153_2_, p_73153_3_, false)); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.terraingen.DecorateBiomeEvent.Post(this.field_185952_n, this.field_185954_p, blockpos)); ++ BlockFalling.field_149832_M = false; } diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkProviderOverworld.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkProviderOverworld.java.patch new file mode 100644 index 0000000000..61da97cbd0 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/ChunkProviderOverworld.java.patch @@ -0,0 +1,101 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/ChunkProviderOverworld.java ++++ ../src-work/minecraft/net/minecraft/world/gen/ChunkProviderOverworld.java +@@ -59,6 +59,15 @@ + + public ChunkProviderOverworld(World p_i46668_1_, long p_i46668_2_, boolean p_i46668_4_, String p_i46668_5_) + { ++ { ++ field_186003_v = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186003_v, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE); ++ field_186004_w = (MapGenStronghold)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186004_w, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.STRONGHOLD); ++ field_186005_x = (MapGenVillage)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186005_x, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.VILLAGE); ++ field_186006_y = (MapGenMineshaft)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186006_y, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT); ++ field_186007_z = (MapGenScatteredFeature)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_186007_z, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE); ++ field_185979_A = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_185979_A, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE); ++ field_185980_B = (StructureOceanMonument)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(field_185980_B, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.OCEAN_MONUMENT); ++ } + this.field_185995_n = p_i46668_1_; + this.field_185996_o = p_i46668_4_; + this.field_185997_p = p_i46668_1_.func_72912_H().func_76067_t(); +@@ -88,6 +97,17 @@ + this.field_186001_t = this.field_186000_s.field_177778_E ? Blocks.field_150353_l.func_176223_P() : Blocks.field_150355_j.func_176223_P(); + p_i46668_1_.func_181544_b(this.field_186000_s.field_177841_q); + } ++ ++ net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld ctx = ++ new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld(field_185991_j, field_185992_k, field_185993_l, field_185994_m, field_185983_b, field_185984_c, field_185985_d); ++ ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(p_i46668_1_, this.field_185990_i, ctx); ++ this.field_185991_j = ctx.getLPerlin1(); ++ this.field_185992_k = ctx.getLPerlin2(); ++ this.field_185993_l = ctx.getPerlin(); ++ this.field_185994_m = ctx.getHeight(); ++ this.field_185983_b = ctx.getScale(); ++ this.field_185984_c = ctx.getDepth(); ++ this.field_185985_d = ctx.getForest(); + } + + public void func_185976_a(int p_185976_1_, int p_185976_2_, ChunkPrimer p_185976_3_) +@@ -161,6 +181,7 @@ + + public void func_185977_a(int p_185977_1_, int p_185977_2_, ChunkPrimer p_185977_3_, BiomeGenBase[] p_185977_4_) + { ++ if (!net.minecraftforge.event.ForgeEventFactory.onReplaceBiomeBlocks(this, p_185977_1_, p_185977_2_, p_185977_3_, this.field_185995_n)) return; + double d0 = 0.03125D; + this.field_186002_u = this.field_185994_m.func_151599_a(this.field_186002_u, (double)(p_185977_1_ * 16), (double)(p_185977_2_ * 16), 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D); + +@@ -365,6 +386,8 @@ + boolean flag = false; + ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(p_185931_1_, p_185931_2_); + ++ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(true, this, this.field_185995_n, p_185931_1_, p_185931_2_, flag); ++ + if (this.field_185996_o) + { + if (this.field_186000_s.field_177829_w) +@@ -394,6 +417,7 @@ + } + + if (biomegenbase != Biomes.field_76769_d && biomegenbase != Biomes.field_76786_s && this.field_186000_s.field_177781_A && !flag && this.field_185990_i.nextInt(this.field_186000_s.field_177782_B) == 0) ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAKE)) + { + int i1 = this.field_185990_i.nextInt(16) + 8; + int j1 = this.field_185990_i.nextInt(256); +@@ -402,6 +426,7 @@ + } + + if (!flag && this.field_185990_i.nextInt(this.field_186000_s.field_177777_D / 10) == 0 && this.field_186000_s.field_177783_C) ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.LAVA)) + { + int i2 = this.field_185990_i.nextInt(16) + 8; + int l2 = this.field_185990_i.nextInt(this.field_185990_i.nextInt(248) + 8); +@@ -414,6 +439,7 @@ + } + + if (this.field_186000_s.field_177837_s) ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.DUNGEON)) + { + for (int j2 = 0; j2 < this.field_186000_s.field_177835_t; ++j2) + { +@@ -425,9 +451,12 @@ + } + + biomegenbase.func_180624_a(this.field_185995_n, this.field_185990_i, new BlockPos(i, 0, j)); ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS)) + WorldEntitySpawner.func_77191_a(this.field_185995_n, biomegenbase, i + 8, j + 8, 16, 16, this.field_185990_i); + blockpos = blockpos.func_177982_a(8, 0, 8); + ++ if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.field_185995_n, this.field_185990_i, p_185931_1_, p_185931_2_, flag, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ICE)) ++ { + for (int k2 = 0; k2 < 16; ++k2) + { + for (int j3 = 0; j3 < 16; ++j3) +@@ -446,7 +475,10 @@ + } + } + } ++ }//Forge: End ICE + ++ net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.field_185995_n, p_185931_1_, p_185931_2_, flag); ++ + BlockFalling.field_149832_M = false; + } + diff --git a/patches/minecraft/net/minecraft/world/gen/ChunkProviderServer.java.patch b/patches/minecraft/net/minecraft/world/gen/ChunkProviderServer.java.patch index cd28c7ec7d..6234904639 100644 --- a/patches/minecraft/net/minecraft/world/gen/ChunkProviderServer.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/ChunkProviderServer.java.patch @@ -1,34 +1,25 @@ --- ../src-base/minecraft/net/minecraft/world/gen/ChunkProviderServer.java +++ ../src-work/minecraft/net/minecraft/world/gen/ChunkProviderServer.java -@@ -36,6 +36,7 @@ - public LongHashMap field_73244_f = new LongHashMap(); - public List field_73245_g = Lists.newArrayList(); - public WorldServer field_73251_h; +@@ -33,6 +33,7 @@ + public final LongHashMap field_73244_f = new LongHashMap(); + public final List field_73245_g = Lists.newArrayList(); + public final WorldServer field_73251_h; + private Set loadingChunks = com.google.common.collect.Sets.newHashSet(); - public ChunkProviderServer(WorldServer p_i1520_1_, IChunkLoader p_i1520_2_, IChunkProvider p_i1520_3_) + public ChunkProviderServer(WorldServer p_i46838_1_, IChunkLoader p_i46838_2_, IChunkGenerator p_i46838_3_) { -@@ -57,7 +58,7 @@ +@@ -92,14 +93,65 @@ - public void func_73241_b(int p_73241_1_, int p_73241_2_) + public Chunk func_186025_d(int p_186025_1_, int p_186025_2_) { -- if (this.field_73251_h.field_73011_w.func_76567_e()) -+ if (this.field_73251_h.field_73011_w.func_76567_e() && net.minecraftforge.common.DimensionManager.shouldLoadSpawn(this.field_73251_h.field_73011_w.func_177502_q())) - { - if (!this.field_73251_h.func_72916_c(p_73241_1_, p_73241_2_)) - { -@@ -80,12 +81,64 @@ - - public Chunk func_73158_c(int p_73158_1_, int p_73158_2_) - { -+ return loadChunk(p_73158_1_, p_73158_2_, null); ++ return loadChunk(p_186025_1_, p_186025_2_, null); + } + -+ public Chunk loadChunk(int par1, int par2, Runnable runnable) ++ public Chunk loadChunk(int X, int Z, Runnable runnable) + { -+ long k = ChunkCoordIntPair.func_77272_a(par1, par2); -+ this.field_73248_b.remove(Long.valueOf(k)); -+ Chunk chunk = (Chunk)this.field_73244_f.func_76164_a(k); ++ long pos = ChunkCoordIntPair.func_77272_a(X, Z); ++ this.field_73248_b.remove(Long.valueOf(pos)); ++ Chunk chunk = this.field_73244_f.func_76164_a(pos); + net.minecraft.world.chunk.storage.AnvilChunkLoader loader = null; + + if (this.field_73247_e instanceof net.minecraft.world.chunk.storage.AnvilChunkLoader) @@ -37,21 +28,21 @@ + } + + // We can only use the queue for already generated chunks -+ if (chunk == null && loader != null && loader.chunkExists(this.field_73251_h, par1, par2)) ++ if (chunk == null && loader != null && loader.chunkExists(this.field_73251_h, X, Z)) + { + if (runnable != null) + { -+ net.minecraftforge.common.chunkio.ChunkIOExecutor.queueChunkLoad(this.field_73251_h, loader, this, par1, par2, runnable); ++ net.minecraftforge.common.chunkio.ChunkIOExecutor.queueChunkLoad(this.field_73251_h, loader, this, X, Z, runnable); + return null; + } + else + { -+ chunk = net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(this.field_73251_h, loader, this, par1, par2); ++ chunk = net.minecraftforge.common.chunkio.ChunkIOExecutor.syncChunkLoad(this.field_73251_h, loader, this, X, Z); + } + } + else if (chunk == null) + { -+ chunk = this.originalLoadChunk(par1, par2); ++ chunk = this.originalLoadChunk(X, Z); + } + + // If we didn't load the chunk async and have a callback run it now @@ -63,42 +54,36 @@ + return chunk; + } + -+ public Chunk originalLoadChunk(int p_73158_1_, int p_73158_2_) ++ public Chunk originalLoadChunk(int p_186025_1_, int p_186025_2_) + { - long i = ChunkCoordIntPair.func_77272_a(p_73158_1_, p_73158_2_); - this.field_73248_b.remove(Long.valueOf(i)); - Chunk chunk = (Chunk)this.field_73244_f.func_76164_a(i); + Chunk chunk = this.func_186028_c(p_186025_1_, p_186025_2_); if (chunk == null) { -+ boolean added = loadingChunks.add(i); -+ if (!added) + long i = ChunkCoordIntPair.func_77272_a(p_186025_1_, p_186025_2_); +- chunk = this.func_73239_e(p_186025_1_, p_186025_2_); ++ if (!loadingChunks.add(i)) + { -+ net.minecraftforge.fml.common.FMLLog.bigWarning("There is an attempt to load a chunk (%d,%d) in di >mension %d that is already being loaded. This will cause weird chunk breakages.", p_73158_1_, p_73158_2_, field_73251_h.field_73011_w.func_177502_q()); ++ net.minecraftforge.fml.common.FMLLog.bigWarning("There is an attempt to load a chunk (%d,%d) in di >mension %d that is already being loaded. This will cause weird chunk breakages.", p_186025_1_, p_186025_2_, field_73251_h.field_73011_w.getDimension()); + } + chunk = net.minecraftforge.common.ForgeChunkManager.fetchDormantChunk(i, this.field_73251_h); -+ -+ if (chunk == null) - chunk = this.func_73239_e(p_73158_1_, p_73158_2_); if (chunk == null) -@@ -114,6 +167,7 @@ ++ chunk = this.func_73239_e(p_186025_1_, p_186025_2_); ++ ++ if (chunk == null) + { + try + { +@@ -118,6 +170,7 @@ this.field_73244_f.func_76163_a(i, chunk); this.field_73245_g.add(chunk); + loadingChunks.remove(i); chunk.func_76631_c(); - chunk.func_76624_a(this, this, p_73158_1_, p_73158_2_); + chunk.func_186030_a(this, this.field_186029_c); } -@@ -205,6 +259,7 @@ - if (this.field_73246_d != null) - { - this.field_73246_d.func_73153_a(p_73153_1_, p_73153_2_, p_73153_3_); -+ net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(p_73153_2_, p_73153_3_, field_73251_h, field_73246_d, p_73153_1_); - chunk.func_76630_e(); - } - } -@@ -266,6 +321,11 @@ +@@ -214,6 +267,11 @@ { if (!this.field_73251_h.field_73058_d) { @@ -110,14 +95,14 @@ for (int i = 0; i < 100; ++i) { if (!this.field_73248_b.isEmpty()) -@@ -280,6 +340,12 @@ +@@ -228,6 +286,12 @@ this.func_73243_a(chunk); this.field_73244_f.func_76159_d(olong.longValue()); this.field_73245_g.remove(chunk); + net.minecraftforge.common.ForgeChunkManager.putDormantChunk(ChunkCoordIntPair.func_77272_a(chunk.field_76635_g, chunk.field_76647_h), chunk); -+ if(field_73245_g.size() == 0 && net.minecraftforge.common.ForgeChunkManager.getPersistentChunksFor(this.field_73251_h).size() == 0 && !net.minecraftforge.common.DimensionManager.shouldLoadSpawn(this.field_73251_h.field_73011_w.func_177502_q())){ -+ net.minecraftforge.common.DimensionManager.unloadWorld(this.field_73251_h.field_73011_w.func_177502_q()); -+ return field_73246_d.func_73156_b(); ++ if(field_73245_g.size() == 0 && net.minecraftforge.common.ForgeChunkManager.getPersistentChunksFor(this.field_73251_h).size() == 0 && !this.field_73251_h.field_73011_w.func_186058_p().shouldLoadSpawn()){ ++ net.minecraftforge.common.DimensionManager.unloadWorld(this.field_73251_h.field_73011_w.getDimension()); ++ return false; + } + } diff --git a/patches/minecraft/net/minecraft/world/gen/MapGenCaves.java.patch b/patches/minecraft/net/minecraft/world/gen/MapGenCaves.java.patch index 63fe3a7bb3..887ba3bfd0 100644 --- a/patches/minecraft/net/minecraft/world/gen/MapGenCaves.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/MapGenCaves.java.patch @@ -1,17 +1,19 @@ --- ../src-base/minecraft/net/minecraft/world/gen/MapGenCaves.java +++ ../src-work/minecraft/net/minecraft/world/gen/MapGenCaves.java -@@ -138,7 +138,7 @@ +@@ -141,9 +141,7 @@ + { + if (l1 >= 0 && l1 < 256) { - IBlockState iblockstate = p_180702_5_.func_177856_a(j1, l1, k1); - +- IBlockState iblockstate = p_180702_5_.func_177856_a(j1, l1, k1); +- - if (iblockstate.func_177230_c() == Blocks.field_150358_i || iblockstate.func_177230_c() == Blocks.field_150355_j) + if (isOceanBlock(p_180702_5_, j1, l1, k1, p_180702_3_, p_180702_4_)) { flag3 = true; } -@@ -176,33 +176,12 @@ +@@ -181,33 +179,12 @@ IBlockState iblockstate1 = p_180702_5_.func_177856_a(j3, j2, i2); - IBlockState iblockstate2 = (IBlockState)Objects.firstNonNull(p_180702_5_.func_177856_a(j3, j2 + 1, i2), Blocks.field_150350_a.func_176223_P()); + IBlockState iblockstate2 = (IBlockState)Objects.firstNonNull(p_180702_5_.func_177856_a(j3, j2 + 1, i2), field_186127_b); - if (iblockstate1.func_177230_c() == Blocks.field_150349_c || iblockstate1.func_177230_c() == Blocks.field_150391_bh) + if (isTopBlock(p_180702_5_, j3, j2, i2, p_180702_3_, p_180702_4_)) @@ -23,15 +25,15 @@ - { - if (j2 - 1 < 10) - { -- p_180702_5_.func_177855_a(j3, j2, i2, Blocks.field_150353_l.func_176223_P()); +- p_180702_5_.func_177855_a(j3, j2, i2, field_186126_a); - } - else - { -- p_180702_5_.func_177855_a(j3, j2, i2, Blocks.field_150350_a.func_176223_P()); +- p_180702_5_.func_177855_a(j3, j2, i2, field_186127_b); - - if (iblockstate2.func_177230_c() == Blocks.field_150354_m) - { -- p_180702_5_.func_177855_a(j3, j2 + 1, i2, iblockstate2.func_177229_b(BlockSand.field_176504_a) == BlockSand.EnumType.RED_SAND ? Blocks.field_180395_cM.func_176223_P() : Blocks.field_150322_A.func_176223_P()); +- p_180702_5_.func_177855_a(j3, j2 + 1, i2, iblockstate2.func_177229_b(BlockSand.field_176504_a) == BlockSand.EnumType.RED_SAND ? field_186129_d : field_186128_c); - } - - if (flag1 && p_180702_5_.func_177856_a(j3, j2 - 1, i2).func_177230_c() == Blocks.field_150346_d) @@ -45,7 +47,7 @@ } } } -@@ -261,4 +240,71 @@ +@@ -266,4 +243,71 @@ } } } @@ -59,8 +61,8 @@ + //Exception biomes to make sure we generate like vanilla + private boolean isExceptionBiome(net.minecraft.world.biome.BiomeGenBase biome) + { -+ if (biome == net.minecraft.world.biome.BiomeGenBase.field_76787_r) return true; -+ if (biome == net.minecraft.world.biome.BiomeGenBase.field_76769_d) return true; ++ if (biome == net.minecraft.init.Biomes.field_76787_r) return true; ++ if (biome == net.minecraft.init.Biomes.field_76769_d) return true; + return false; + } + @@ -96,17 +98,17 @@ + + if (this.func_175793_a(state, up) || state.func_177230_c() == top.func_177230_c() || state.func_177230_c() == filler.func_177230_c()) + { -+ if (y < 10) ++ if (y - 1 < 10) + { -+ data.func_177855_a(x, y, z, Blocks.field_150353_l.func_176223_P()); ++ data.func_177855_a(x, y, z, field_186126_a); + } + else + { -+ data.func_177855_a(x, y, z, Blocks.field_150350_a.func_176223_P()); ++ data.func_177855_a(x, y, z, field_186127_b); + + if (up.func_177230_c() == Blocks.field_150354_m) + { -+ data.func_177855_a(x, y + 1, z, up.func_177229_b(BlockSand.field_176504_a) == BlockSand.EnumType.RED_SAND ? Blocks.field_180395_cM.func_176223_P() : Blocks.field_150322_A.func_176223_P()); ++ data.func_177855_a(x, y + 1, z, up.func_177229_b(BlockSand.field_176504_a) == BlockSand.EnumType.RED_SAND ? field_186129_d : field_186128_c); + } + + if (foundTop && data.func_177856_a(x, y - 1, z).func_177230_c() == filler.func_177230_c()) diff --git a/patches/minecraft/net/minecraft/world/gen/MapGenRavine.java.patch b/patches/minecraft/net/minecraft/world/gen/MapGenRavine.java.patch index b5fc50da70..616b17a9a1 100644 --- a/patches/minecraft/net/minecraft/world/gen/MapGenRavine.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/MapGenRavine.java.patch @@ -1,18 +1,31 @@ --- ../src-base/minecraft/net/minecraft/world/gen/MapGenRavine.java +++ ../src-work/minecraft/net/minecraft/world/gen/MapGenRavine.java -@@ -128,7 +128,7 @@ +@@ -128,9 +128,7 @@ + { + if (l1 >= 0 && l1 < 256) { - IBlockState iblockstate = p_180707_5_.func_177856_a(j1, l1, k1); - +- IBlockState iblockstate = p_180707_5_.func_177856_a(j1, l1, k1); +- - if (iblockstate.func_177230_c() == Blocks.field_150358_i || iblockstate.func_177230_c() == Blocks.field_150355_j) + if (isOceanBlock(p_180707_5_, j1, l1, k1, p_180707_3_, p_180707_4_)) { flag2 = true; } -@@ -165,28 +165,12 @@ - { - IBlockState iblockstate1 = p_180707_5_.func_177856_a(j3, j2, i2); +@@ -146,8 +144,6 @@ + if (!flag2) + { +- BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); +- + for (int j3 = k2; j3 < k; ++j3) + { + double d10 = ((double)(j3 + p_180707_3_ * 16) + 0.5D - p_180707_6_) / d9; +@@ -165,30 +161,12 @@ + + if ((d10 * d10 + d7 * d7) * (double)this.field_75046_d[j2 - 1] + d8 * d8 / 6.0D < 1.0D) + { +- IBlockState iblockstate1 = p_180707_5_.func_177856_a(j3, j2, i2); +- - if (iblockstate1.func_177230_c() == Blocks.field_150349_c) + if (isTopBlock(p_180707_5_, j3, j2, i2, p_180707_3_, p_180707_4_)) { @@ -23,11 +36,11 @@ - { - if (j2 - 1 < 10) - { -- p_180707_5_.func_177855_a(j3, j2, i2, Blocks.field_150356_k.func_176223_P()); +- p_180707_5_.func_177855_a(j3, j2, i2, field_186135_a); - } - else - { -- p_180707_5_.func_177855_a(j3, j2, i2, Blocks.field_150350_a.func_176223_P()); +- p_180707_5_.func_177855_a(j3, j2, i2, field_186136_b); - - if (flag && p_180707_5_.func_177856_a(j3, j2 - 1, i2).func_177230_c() == Blocks.field_150346_d) - { @@ -40,7 +53,7 @@ } } } -@@ -221,4 +205,68 @@ +@@ -223,4 +201,68 @@ } } } @@ -53,10 +66,10 @@ + //Exception biomes to make sure we generate like vanilla + private boolean isExceptionBiome(net.minecraft.world.biome.BiomeGenBase biome) + { -+ if (biome == net.minecraft.world.biome.BiomeGenBase.field_76787_r) return true; -+ if (biome == net.minecraft.world.biome.BiomeGenBase.field_76769_d) return true; -+ if (biome == net.minecraft.world.biome.BiomeGenBase.field_76789_p) return true; -+ if (biome == net.minecraft.world.biome.BiomeGenBase.field_76788_q) return true; ++ if (biome == net.minecraft.init.Biomes.field_76787_r) return true; ++ if (biome == net.minecraft.init.Biomes.field_76769_d) return true; ++ if (biome == net.minecraft.init.Biomes.field_76789_p) return true; ++ if (biome == net.minecraft.init.Biomes.field_76788_q) return true; + return false; + } + @@ -93,13 +106,13 @@ + + if (state.func_177230_c() == Blocks.field_150348_b || state.func_177230_c() == top.func_177230_c() || state.func_177230_c() == filler.func_177230_c()) + { -+ if (y < 10) ++ if (y - 1 < 10) + { -+ data.func_177855_a(x, y, z, Blocks.field_150353_l.func_176223_P()); ++ data.func_177855_a(x, y, z, field_186135_a); + } + else + { -+ data.func_177855_a(x, y, z, Blocks.field_150350_a.func_176223_P()); ++ data.func_177855_a(x, y, z, field_186136_b); + + if (foundTop && data.func_177856_a(x, y - 1, z).func_177230_c() == filler.func_177230_c()) + { diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenAbstractTree.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenAbstractTree.java.patch index f23e6f3182..773fd43edc 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenAbstractTree.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenAbstractTree.java.patch @@ -8,6 +8,6 @@ + public boolean isReplaceable(World world, BlockPos pos) + { + net.minecraft.block.state.IBlockState state = world.func_180495_p(pos); -+ return state.func_177230_c().isAir(world, pos) || state.func_177230_c().isLeaves(world, pos) || state.func_177230_c().isWood(world, pos) || func_150523_a(state.func_177230_c()); ++ return state.func_177230_c().isAir(state, world, pos) || state.func_177230_c().isLeaves(state, world, pos) || state.func_177230_c().isWood(world, pos) || func_150523_a(state.func_177230_c()); + } } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBigMushroom.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBigMushroom.java.patch index 2a98d8c833..2ee32167e7 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBigMushroom.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBigMushroom.java.patch @@ -1,33 +1,34 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenBigMushroom.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenBigMushroom.java -@@ -54,7 +54,7 @@ +@@ -56,9 +56,9 @@ + { + if (j >= 0 && j < 256) { - Block block = p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(l, j, i1)).func_177230_c(); +- Material material = p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(l, j, i1)).func_185904_a(); ++ IBlockState state = p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(l, j, i1)); -- if (block.func_149688_o() != Material.field_151579_a && block.func_149688_o() != Material.field_151584_j) -+ if (!block.isAir(p_180709_1_, blockpos$mutableblockpos) && !block.isLeaves(p_180709_1_, blockpos$mutableblockpos)) +- if (material != Material.field_151579_a && material != Material.field_151584_j) ++ if (!state.func_177230_c().isAir(state, p_180709_1_, blockpos$mutableblockpos) && !state.func_177230_c().isLeaves(state, p_180709_1_, blockpos$mutableblockpos)) { flag = false; } -@@ -190,7 +190,7 @@ +@@ -193,8 +193,9 @@ + if (p_180709_3_.func_177956_o() >= p_180709_3_.func_177956_o() + i - 1 || blockhugemushroom$enumtype != BlockHugeMushroom.EnumType.ALL_INSIDE) { BlockPos blockpos = new BlockPos(l1, l2, i2); ++ IBlockState state = p_180709_1_.func_180495_p(blockpos); -- if (!p_180709_1_.func_180495_p(blockpos).func_177230_c().func_149730_j()) -+ if (p_180709_1_.func_180495_p(blockpos).func_177230_c().canBeReplacedByLeaves(p_180709_1_, blockpos)) +- if (!p_180709_1_.func_180495_p(blockpos).func_185913_b()) ++ if (state.func_177230_c().canBeReplacedByLeaves(state, p_180709_1_, blockpos)) { - this.func_175903_a(p_180709_1_, blockpos, this.field_76523_a.func_176223_P().func_177226_a(BlockHugeMushroom.field_176380_a, blockhugemushroom$enumtype)); + this.func_175903_a(p_180709_1_, blockpos, block.func_176223_P().func_177226_a(BlockHugeMushroom.field_176380_a, blockhugemushroom$enumtype)); } -@@ -201,9 +201,10 @@ - - for (int i3 = 0; i3 < i; ++i3) +@@ -207,7 +208,7 @@ { -- Block block2 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(i3)).func_177230_c(); -+ BlockPos upN = p_180709_3_.func_177981_b(i3); -+ net.minecraft.block.state.IBlockState state = p_180709_1_.func_180495_p(upN); + IBlockState iblockstate = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(i3)); -- if (!block2.func_149730_j()) -+ if (state.func_177230_c().canBeReplacedByLeaves(p_180709_1_, upN)) +- if (!iblockstate.func_185913_b()) ++ if (iblockstate.func_177230_c().canBeReplacedByLeaves(iblockstate, p_180709_1_, p_180709_3_.func_177981_b(i3))) { - this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(i3), this.field_76523_a.func_176223_P().func_177226_a(BlockHugeMushroom.field_176380_a, BlockHugeMushroom.EnumType.STEM)); + this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(i3), block.func_176223_P().func_177226_a(BlockHugeMushroom.field_176380_a, BlockHugeMushroom.EnumType.STEM)); } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBigTree.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBigTree.java.patch index 7fb88e1b7a..9b5ed8239b 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBigTree.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBigTree.java.patch @@ -4,11 +4,11 @@ if (Math.pow((double)Math.abs(j) + 0.5D, 2.0D) + Math.pow((double)Math.abs(k) + 0.5D, 2.0D) <= (double)(p_181631_2_ * p_181631_2_)) { BlockPos blockpos = p_181631_1_.func_177982_a(j, 0, k); -- Material material = this.field_175946_l.func_180495_p(blockpos).func_177230_c().func_149688_o(); -+ net.minecraft.block.state.IBlockState state = this.field_175946_l.func_180495_p(blockpos); +- Material material = this.field_175946_l.func_180495_p(blockpos).func_185904_a(); ++ IBlockState state = this.field_175946_l.func_180495_p(blockpos); - if (material == Material.field_151579_a || material == Material.field_151584_j) -+ if (state.func_177230_c().isAir(this.field_175946_l, blockpos) || state.func_177230_c().isLeaves(this.field_175946_l, blockpos)) ++ if (state.func_177230_c().isAir(state, field_175946_l, blockpos) || state.func_177230_c().isLeaves(state, field_175946_l, blockpos)) { this.func_175903_a(this.field_175946_l, blockpos, p_181631_3_); } @@ -43,7 +43,7 @@ - Block block = this.field_175946_l.func_180495_p(this.field_175947_m.func_177977_b()).func_177230_c(); + BlockPos down = this.field_175947_m.func_177977_b(); + net.minecraft.block.state.IBlockState state = this.field_175946_l.func_180495_p(down); -+ boolean isSoil = state.func_177230_c().canSustainPlant(this.field_175946_l, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); ++ boolean isSoil = state.func_177230_c().canSustainPlant(state, this.field_175946_l, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); - if (block != Blocks.field_150346_d && block != Blocks.field_150349_c && block != Blocks.field_150458_ak) + if (!isSoil) diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBirchTree.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBirchTree.java.patch new file mode 100644 index 0000000000..77d4b839e8 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBirchTree.java.patch @@ -0,0 +1,56 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenBirchTree.java ++++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenBirchTree.java +@@ -56,9 +56,9 @@ + { + for (int i1 = p_180709_3_.func_177952_p() - k; i1 <= p_180709_3_.func_177952_p() + k && flag; ++i1) + { +- if (j >= 0 && j < 256) ++ if (j >= 0 && j < p_180709_1_.func_72800_K()) + { +- if (!this.func_150523_a(p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(l, j, i1)).func_177230_c())) ++ if (!this.isReplaceable(p_180709_1_, blockpos$mutableblockpos.func_181079_c(l, j, i1))) + { + flag = false; + } +@@ -77,11 +77,13 @@ + } + else + { +- Block block = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()).func_177230_c(); ++ BlockPos down = p_180709_3_.func_177977_b(); ++ IBlockState state = p_180709_1_.func_180495_p(down); ++ boolean isSoil = state.func_177230_c().canSustainPlant(state, p_180709_1_, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling)Blocks.field_150345_g); + +- if ((block == Blocks.field_150349_c || block == Blocks.field_150346_d || block == Blocks.field_150458_ak) && p_180709_3_.func_177956_o() < 256 - i - 1) ++ if (isSoil && p_180709_3_.func_177956_o() < p_180709_1_.func_72800_K() - i - 1) + { +- this.func_175921_a(p_180709_1_, p_180709_3_.func_177977_b()); ++ state.func_177230_c().onPlantGrow(state, p_180709_1_, down, p_180709_3_); + + for (int i2 = p_180709_3_.func_177956_o() - 3 + i; i2 <= p_180709_3_.func_177956_o() + i; ++i2) + { +@@ -99,9 +101,9 @@ + if (Math.abs(j1) != l2 || Math.abs(l1) != l2 || p_180709_2_.nextInt(2) != 0 && k2 != 0) + { + BlockPos blockpos = new BlockPos(i3, i2, k1); +- Material material = p_180709_1_.func_180495_p(blockpos).func_185904_a(); ++ IBlockState state2 = p_180709_1_.func_180495_p(blockpos); + +- if (material == Material.field_151579_a || material == Material.field_151584_j) ++ if (state2.func_177230_c().isAir(state2, p_180709_1_, blockpos) || state2.func_177230_c().isAir(state2, p_180709_1_, blockpos)) + { + this.func_175903_a(p_180709_1_, blockpos, field_181630_b); + } +@@ -112,9 +114,10 @@ + + for (int j2 = 0; j2 < i; ++j2) + { +- Material material1 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(j2)).func_185904_a(); ++ BlockPos upN = p_180709_3_.func_177981_b(j2); ++ IBlockState state2 = p_180709_1_.func_180495_p(upN); + +- if (material1 == Material.field_151579_a || material1 == Material.field_151584_j) ++ if (state2.func_177230_c().isAir(state2, p_180709_1_, upN) || state2.func_177230_c().isLeaves(state2, p_180709_1_, upN)) + { + this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(j2), field_181629_a); + } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBush.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBush.java.patch new file mode 100644 index 0000000000..ed54b4718f --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenBush.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenBush.java ++++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenBush.java +@@ -20,7 +20,7 @@ + { + BlockPos blockpos = p_180709_3_.func_177982_a(p_180709_2_.nextInt(8) - p_180709_2_.nextInt(8), p_180709_2_.nextInt(4) - p_180709_2_.nextInt(4), p_180709_2_.nextInt(8) - p_180709_2_.nextInt(8)); + +- if (p_180709_1_.func_175623_d(blockpos) && (!p_180709_1_.field_73011_w.func_177495_o() || blockpos.func_177956_o() < 255) && this.field_175908_a.func_180671_f(p_180709_1_, blockpos, this.field_175908_a.func_176223_P())) ++ if (p_180709_1_.func_175623_d(blockpos) && (!p_180709_1_.field_73011_w.func_177495_o() || blockpos.func_177956_o() < p_180709_1_.func_72800_K() - 1) && this.field_175908_a.func_180671_f(p_180709_1_, blockpos, this.field_175908_a.func_176223_P())) + { + p_180709_1_.func_180501_a(blockpos, this.field_175908_a.func_176223_P(), 2); + } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenCanopyTree.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenCanopyTree.java.patch index 6bc3eb8140..61ebf130cf 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenCanopyTree.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenCanopyTree.java.patch @@ -5,11 +5,11 @@ { BlockPos blockpos = p_180709_3_.func_177977_b(); - Block block = p_180709_1_.func_180495_p(blockpos).func_177230_c(); -+ net.minecraft.block.state.IBlockState state = p_180709_1_.func_180495_p(blockpos); -+ boolean isSoil = state.func_177230_c().canSustainPlant(p_180709_1_, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); ++ IBlockState state = p_180709_1_.func_180495_p(blockpos); ++ boolean isSoil = state.func_177230_c().canSustainPlant(state, p_180709_1_, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); - if (block != Blocks.field_150349_c && block != Blocks.field_150346_d) -+ if (!(isSoil && p_180709_3_.func_177956_o() < 256 - i - 1)) ++ if (!(isSoil && p_180709_3_.func_177956_o() < p_180709_1_.func_72800_K() - i - 1)) { return false; } @@ -32,11 +32,11 @@ int k2 = k + j2; BlockPos blockpos1 = new BlockPos(k1, k2, l1); -- Material material = p_180709_1_.func_180495_p(blockpos1).func_177230_c().func_149688_o(); +- Material material = p_180709_1_.func_180495_p(blockpos1).func_185904_a(); + state = p_180709_1_.func_180495_p(blockpos1); - if (material == Material.field_151579_a || material == Material.field_151584_j) -+ if (state.func_177230_c().isAir(p_180709_1_, blockpos1) || state.func_177230_c().isLeaves(p_180709_1_, blockpos1)) ++ if (state.func_177230_c().isAir(state, p_180709_1_, blockpos1) || state.func_177230_c().isLeaves(state, p_180709_1_, blockpos1)) { this.func_181639_b(p_180709_1_, blockpos1); this.func_181639_b(p_180709_1_, blockpos1.func_177974_f()); @@ -49,15 +49,15 @@ { return false; } -@@ -209,11 +210,17 @@ +@@ -209,11 +210,18 @@ private void func_150526_a(World p_150526_1_, int p_150526_2_, int p_150526_3_, int p_150526_4_) { BlockPos blockpos = new BlockPos(p_150526_2_, p_150526_3_, p_150526_4_); -- Block block = p_150526_1_.func_180495_p(blockpos).func_177230_c(); -+ net.minecraft.block.state.IBlockState state = p_150526_1_.func_180495_p(blockpos); +- Material material = p_150526_1_.func_180495_p(blockpos).func_185904_a(); ++ IBlockState state = p_150526_1_.func_180495_p(blockpos); -- if (block.func_149688_o() == Material.field_151579_a) -+ if (state.func_177230_c().isAir(p_150526_1_, blockpos)) +- if (material == Material.field_151579_a) ++ if (state.func_177230_c().isAir(state, p_150526_1_, blockpos)) { this.func_175903_a(p_150526_1_, blockpos, field_181641_b); } @@ -66,6 +66,7 @@ + //Just a helper macro + private void onPlantGrow(World world, BlockPos pos, BlockPos source) + { -+ world.func_180495_p(pos).func_177230_c().onPlantGrow(world, pos, source); ++ IBlockState state = world.func_180495_p(pos); ++ state.func_177230_c().onPlantGrow(state, world, pos, source); + } } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDeadBush.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDeadBush.java.patch index 61253bc645..6f023be26d 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDeadBush.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDeadBush.java.patch @@ -1,14 +1,16 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenDeadBush.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenDeadBush.java -@@ -13,10 +13,12 @@ +@@ -11,12 +11,12 @@ + { + public boolean func_180709_b(World p_180709_1_, Random p_180709_2_, BlockPos p_180709_3_) { - Block block; - -- while (((block = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c()).func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j) && p_180709_3_.func_177956_o() > 0) +- IBlockState iblockstate; +- +- while (((iblockstate = p_180709_1_.func_180495_p(p_180709_3_)).func_185904_a() == Material.field_151579_a || iblockstate.func_185904_a() == Material.field_151584_j) && p_180709_3_.func_177956_o() > 0) + do { -+ block = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c(); -+ if (!block.isLeaves(p_180709_1_, p_180709_3_) && !block.isLeaves(p_180709_1_, p_180709_3_)) break; ++ IBlockState state = p_180709_1_.func_180495_p(p_180709_3_); ++ if (!state.func_177230_c().isAir(state, p_180709_1_, p_180709_3_) && !state.func_177230_c().isLeaves(state, p_180709_1_, p_180709_3_)) break; p_180709_3_ = p_180709_3_.func_177977_b(); - } + } while (p_180709_3_.func_177956_o() > 0); diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java.patch index dd91af3365..098f8b475f 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java.patch @@ -1,30 +1,10 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenDungeons.java -@@ -123,12 +123,11 @@ - if (j3 == 1) - { - p_180709_1_.func_180501_a(blockpos2, Blocks.field_150486_ae.func_176458_f(p_180709_1_, blockpos2, Blocks.field_150486_ae.func_176223_P()), 2); -- List list = WeightedRandomChestContent.func_177629_a(field_175917_c, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92114_b(p_180709_2_)}); - TileEntity tileentity1 = p_180709_1_.func_175625_s(blockpos2); - - if (tileentity1 instanceof TileEntityChest) - { -- WeightedRandomChestContent.func_177630_a(p_180709_2_, list, (TileEntityChest)tileentity1, 8); -+ WeightedRandomChestContent.func_177630_a(p_180709_2_, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST, p_180709_2_), (TileEntityChest)tileentity1, 8); - } - - break; -@@ -159,6 +158,12 @@ +@@ -154,6 +154,6 @@ private String func_76543_b(Random p_76543_1_) { - return field_175916_b[p_76543_1_.nextInt(field_175916_b.length)]; + return net.minecraftforge.common.DungeonHooks.getRandomDungeonMob(p_76543_1_); } -+ -+ static -+ { -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST, field_175917_c, 8, 8); -+ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.field_151134_bR, 1, 0), 1, 1, 1)); -+ } } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenForest.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenForest.java.patch deleted file mode 100644 index 9eca24df4e..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenForest.java.patch +++ /dev/null @@ -1,50 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenForest.java -+++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenForest.java -@@ -58,7 +58,7 @@ - { - if (j >= 0 && j < 256) - { -- if (!this.func_150523_a(p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(l, j, i1)).func_177230_c())) -+ if (!this.isReplaceable(p_180709_1_, blockpos$mutableblockpos.func_181079_c(l, j, i1))) - { - flag = false; - } -@@ -77,11 +77,13 @@ - } - else - { -- Block block1 = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()).func_177230_c(); -+ BlockPos down = p_180709_3_.func_177977_b(); -+ Block block1 = p_180709_1_.func_180495_p(down).func_177230_c(); -+ boolean isSoil = block1.canSustainPlant(p_180709_1_, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); - -- if ((block1 == Blocks.field_150349_c || block1 == Blocks.field_150346_d || block1 == Blocks.field_150458_ak) && p_180709_3_.func_177956_o() < 256 - i - 1) -+ if (isSoil && p_180709_3_.func_177956_o() < 256 - i - 1) - { -- this.func_175921_a(p_180709_1_, p_180709_3_.func_177977_b()); -+ block1.onPlantGrow(p_180709_1_, down, p_180709_3_); - - for (int i2 = p_180709_3_.func_177956_o() - 3 + i; i2 <= p_180709_3_.func_177956_o() + i; ++i2) - { -@@ -101,7 +103,7 @@ - BlockPos blockpos = new BlockPos(i3, i2, k1); - Block block = p_180709_1_.func_180495_p(blockpos).func_177230_c(); - -- if (block.func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j) -+ if (block.isAir(p_180709_1_, blockpos) || block.isLeaves(p_180709_1_, blockpos)) - { - this.func_175903_a(p_180709_1_, blockpos, field_181630_b); - } -@@ -112,9 +114,9 @@ - - for (int j2 = 0; j2 < i; ++j2) - { -- Block block2 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(j2)).func_177230_c(); -- -- if (block2.func_149688_o() == Material.field_151579_a || block2.func_149688_o() == Material.field_151584_j) -+ BlockPos upN = p_180709_3_.func_177981_b(j2); -+ Block block2 = p_180709_1_.func_180495_p(upN).func_177230_c(); -+ if (block2.isAir(p_180709_1_, upN) || block2.isLeaves(p_180709_1_, upN)) - { - this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(j2), field_181629_a); - } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone1.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone1.java.patch new file mode 100644 index 0000000000..45ec439504 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone1.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone1.java ++++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone1.java +@@ -27,7 +27,7 @@ + { + BlockPos blockpos = p_180709_3_.func_177982_a(p_180709_2_.nextInt(8) - p_180709_2_.nextInt(8), -p_180709_2_.nextInt(12), p_180709_2_.nextInt(8) - p_180709_2_.nextInt(8)); + +- if (p_180709_1_.func_180495_p(blockpos).func_185904_a() == Material.field_151579_a) ++ if (p_180709_1_.func_175623_d(blockpos)) + { + int j = 0; + diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone2.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone2.java.patch new file mode 100644 index 0000000000..cec562cded --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone2.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone2.java ++++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenGlowStone2.java +@@ -27,7 +27,7 @@ + { + BlockPos blockpos = p_180709_3_.func_177982_a(p_180709_2_.nextInt(8) - p_180709_2_.nextInt(8), -p_180709_2_.nextInt(12), p_180709_2_.nextInt(8) - p_180709_2_.nextInt(8)); + +- if (p_180709_1_.func_180495_p(blockpos).func_185904_a() == Material.field_151579_a) ++ if (p_180709_1_.func_175623_d(blockpos)) + { + int j = 0; + diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenHellLava.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenHellLava.java.patch new file mode 100644 index 0000000000..b8ef8082e1 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenHellLava.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenHellLava.java ++++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenHellLava.java +@@ -24,7 +24,7 @@ + { + return false; + } +- else if (p_180709_1_.func_180495_p(p_180709_3_).func_185904_a() != Material.field_151579_a && p_180709_1_.func_180495_p(p_180709_3_).func_177230_c() != Blocks.field_150424_aL) ++ else if (!p_180709_1_.func_175623_d(p_180709_3_) && p_180709_1_.func_180495_p(p_180709_3_).func_177230_c() != Blocks.field_150424_aL) + { + return false; + } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenHugeTrees.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenHugeTrees.java.patch index 16ea524eba..c0785697b7 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenHugeTrees.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenHugeTrees.java.patch @@ -9,11 +9,13 @@ { flag = false; } -@@ -79,13 +79,14 @@ +@@ -78,14 +78,15 @@ + private boolean func_175927_a(BlockPos p_175927_1_, World p_175927_2_) { BlockPos blockpos = p_175927_1_.func_177977_b(); - Block block = p_175927_2_.func_180495_p(blockpos).func_177230_c(); -+ boolean isSoil = block.canSustainPlant(p_175927_2_, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); +- Block block = p_175927_2_.func_180495_p(blockpos).func_177230_c(); ++ IBlockState state = p_175927_2_.func_180495_p(blockpos); ++ boolean isSoil = state.func_177230_c().canSustainPlant(state, p_175927_2_, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); - if ((block == Blocks.field_150349_c || block == Blocks.field_150346_d) && p_175927_1_.func_177956_o() >= 2) + if (isSoil && p_175927_1_.func_177956_o() >= 2) @@ -33,11 +35,11 @@ if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i) { BlockPos blockpos = p_175925_2_.func_177982_a(j, 0, k); -- Material material = p_175925_1_.func_180495_p(blockpos).func_177230_c().func_149688_o(); -+ net.minecraft.block.state.IBlockState state = p_175925_1_.func_180495_p(blockpos); +- Material material = p_175925_1_.func_180495_p(blockpos).func_185904_a(); ++ IBlockState state = p_175925_1_.func_180495_p(blockpos); - if (material == Material.field_151579_a || material == Material.field_151584_j) -+ if (state.func_177230_c().isAir(p_175925_1_, blockpos) || state.func_177230_c().isLeaves(p_175925_1_, blockpos)) ++ if (state.func_177230_c().isAir(state, p_175925_1_, blockpos) || state.func_177230_c().isLeaves(state, p_175925_1_, blockpos)) { this.func_175903_a(p_175925_1_, blockpos, this.field_76521_c); } @@ -45,15 +47,15 @@ if (j * j + k * k <= i) { BlockPos blockpos = p_175928_2_.func_177982_a(j, 0, k); -- Material material = p_175928_1_.func_180495_p(blockpos).func_177230_c().func_149688_o(); -+ Block block = p_175928_1_.func_180495_p(blockpos).func_177230_c(); +- Material material = p_175928_1_.func_180495_p(blockpos).func_185904_a(); ++ IBlockState state = p_175928_1_.func_180495_p(blockpos); - if (material == Material.field_151579_a || material == Material.field_151584_j) -+ if (block.isAir(p_175928_1_, blockpos) || block.isLeaves(p_175928_1_, blockpos)) ++ if (state.func_177230_c().isAir(state, p_175928_1_, blockpos) || state.func_177230_c().isLeaves(state, p_175928_1_, blockpos)) { this.func_175903_a(p_175928_1_, blockpos, this.field_76521_c); } -@@ -145,4 +146,10 @@ +@@ -145,4 +146,11 @@ } } } @@ -61,6 +63,7 @@ + //Just a helper macro + private void onPlantGrow(World world, BlockPos pos, BlockPos source) + { -+ world.func_180495_p(pos).func_177230_c().onPlantGrow(world, pos, source); ++ IBlockState state = world.func_180495_p(pos); ++ state.func_177230_c().onPlantGrow(state, world, pos, source); + } } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenIceSpike.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenIceSpike.java.patch new file mode 100644 index 0000000000..1ac2953b8e --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenIceSpike.java.patch @@ -0,0 +1,29 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenIceSpike.java ++++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenIceSpike.java +@@ -51,7 +51,7 @@ + IBlockState iblockstate = p_180709_1_.func_180495_p(p_180709_3_.func_177982_a(i1, k, j1)); + Block block = iblockstate.func_177230_c(); + +- if (iblockstate.func_185904_a() == Material.field_151579_a || block == Blocks.field_150346_d || block == Blocks.field_150433_aE || block == Blocks.field_150432_aD) ++ if (iblockstate.func_177230_c().isAir(iblockstate, p_180709_1_, p_180709_3_.func_177982_a(i1, k, j1)) || block == Blocks.field_150346_d || block == Blocks.field_150433_aE || block == Blocks.field_150432_aD) + { + this.func_175903_a(p_180709_1_, p_180709_3_.func_177982_a(i1, k, j1), Blocks.field_150403_cj.func_176223_P()); + } +@@ -61,7 +61,7 @@ + iblockstate = p_180709_1_.func_180495_p(p_180709_3_.func_177982_a(i1, -k, j1)); + block = iblockstate.func_177230_c(); + +- if (iblockstate.func_185904_a() == Material.field_151579_a || block == Blocks.field_150346_d || block == Blocks.field_150433_aE || block == Blocks.field_150432_aD) ++ if (iblockstate.func_177230_c().isAir(iblockstate, p_180709_1_, p_180709_3_.func_177982_a(i1, -k, j1)) || block == Blocks.field_150346_d || block == Blocks.field_150433_aE || block == Blocks.field_150432_aD) + { + this.func_175903_a(p_180709_1_, p_180709_3_.func_177982_a(i1, -k, j1), Blocks.field_150403_cj.func_176223_P()); + } +@@ -99,7 +99,7 @@ + IBlockState iblockstate1 = p_180709_1_.func_180495_p(blockpos); + Block block1 = iblockstate1.func_177230_c(); + +- if (iblockstate1.func_185904_a() != Material.field_151579_a && block1 != Blocks.field_150346_d && block1 != Blocks.field_150433_aE && block1 != Blocks.field_150432_aD && block1 != Blocks.field_150403_cj) ++ if (!iblockstate1.func_177230_c().isAir(iblockstate1, p_180709_1_, blockpos) && block1 != Blocks.field_150346_d && block1 != Blocks.field_150433_aE && block1 != Blocks.field_150432_aD && block1 != Blocks.field_150403_cj) + { + break; + } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenLiquids.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenLiquids.java.patch new file mode 100644 index 0000000000..223fdde145 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenLiquids.java.patch @@ -0,0 +1,11 @@ +--- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenLiquids.java ++++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenLiquids.java +@@ -26,7 +26,7 @@ + { + return false; + } +- else if (p_180709_1_.func_180495_p(p_180709_3_).func_185904_a() != Material.field_151579_a && p_180709_1_.func_180495_p(p_180709_3_).func_177230_c() != Blocks.field_150348_b) ++ else if (!p_180709_1_.func_175623_d(p_180709_3_) && p_180709_1_.func_180495_p(p_180709_3_).func_177230_c() != Blocks.field_150348_b) + { + return false; + } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMegaJungle.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMegaJungle.java.patch index 6856a6cfc2..8964b67b1e 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMegaJungle.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMegaJungle.java.patch @@ -44,7 +44,7 @@ + //Helper macro + private boolean isAirLeaves(World world, BlockPos pos) + { -+ net.minecraft.block.Block block = world.func_180495_p(pos).func_177230_c(); -+ return block.isAir(world, pos) || block.isLeaves(world, pos); ++ IBlockState state = world.func_180495_p(pos); ++ return state.func_177230_c().isAir(state, world, pos) || state.func_177230_c().isLeaves(state, world, pos); + } } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java.patch index f658ebfe60..70ea1b4468 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java.patch @@ -1,55 +1,52 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java -@@ -43,30 +43,24 @@ - { - Block block = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(j)).func_177230_c(); +@@ -41,32 +41,25 @@ -- if (block.func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j) -+ if (isAirLeaves(p_180709_1_,p_180709_3_.func_177981_b(j))) + for (int j = 0; j < i; ++j) + { +- IBlockState iblockstate = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(j)); +- +- if (iblockstate.func_185904_a() == Material.field_151579_a || iblockstate.func_185904_a() == Material.field_151584_j) ++ if (isAirLeaves(p_180709_1_, p_180709_3_.func_177981_b(j))) { this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(j), this.field_76520_b); } if (j < i - 1) { -- block = p_180709_1_.func_180495_p(p_180709_3_.func_177982_a(1, j, 0)).func_177230_c(); +- iblockstate = p_180709_1_.func_180495_p(p_180709_3_.func_177982_a(1, j, 0)); - -- if (block.func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j) -+ if (isAirLeaves(p_180709_1_,p_180709_3_.func_177982_a(1, j, 0))) +- if (iblockstate.func_185904_a() == Material.field_151579_a || iblockstate.func_185904_a() == Material.field_151584_j) ++ if (isAirLeaves(p_180709_1_, p_180709_3_.func_177982_a(1, j, 0))) { this.func_175903_a(p_180709_1_, p_180709_3_.func_177982_a(1, j, 0), this.field_76520_b); } -- block = p_180709_1_.func_180495_p(p_180709_3_.func_177982_a(1, j, 1)).func_177230_c(); +- iblockstate = p_180709_1_.func_180495_p(p_180709_3_.func_177982_a(1, j, 1)); - -- if (block.func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j) -+ if (isAirLeaves(p_180709_1_,p_180709_3_.func_177982_a(1, j, 1))) +- if (iblockstate.func_185904_a() == Material.field_151579_a || iblockstate.func_185904_a() == Material.field_151584_j) ++ if (isAirLeaves(p_180709_1_, p_180709_3_.func_177982_a(1, j, 1))) { this.func_175903_a(p_180709_1_, p_180709_3_.func_177982_a(1, j, 1), this.field_76520_b); } -- block = p_180709_1_.func_180495_p(p_180709_3_.func_177982_a(0, j, 1)).func_177230_c(); -- -- if (block.func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j) -+ if (isAirLeaves(p_180709_1_,p_180709_3_.func_177982_a(0, j, 1))) +- iblockstate = p_180709_1_.func_180495_p(p_180709_3_.func_177982_a(0, j, 1)); + +- if (iblockstate.func_185904_a() == Material.field_151579_a || iblockstate.func_185904_a() == Material.field_151584_j) ++ if (isAirLeaves(p_180709_1_, p_180709_3_.func_177982_a(0, j, 1))) { this.func_175903_a(p_180709_1_, p_180709_3_.func_177982_a(0, j, 1), this.field_76520_b); } -@@ -132,16 +126,23 @@ - BlockPos blockpos = p_175934_2_.func_177981_b(i); - Block block = p_175934_1_.func_180495_p(blockpos).func_177230_c(); +@@ -133,7 +126,7 @@ + IBlockState iblockstate = p_175934_1_.func_180495_p(blockpos); + Block block = iblockstate.func_177230_c(); - if (block == Blocks.field_150349_c || block == Blocks.field_150346_d) -+ if (block.canSustainPlant(p_175934_1_, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g))) ++ if (block.canSustainPlant(iblockstate, p_175934_1_, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g))) { this.func_175903_a(p_175934_1_, blockpos, field_181635_g); break; - } - -- if (block.func_149688_o() != Material.field_151579_a && i < 0) -+ if (!block.isAir(p_175934_1_, blockpos) && i < 0) - { - break; +@@ -145,4 +138,11 @@ } } } @@ -57,7 +54,7 @@ + //Helper macro + private boolean isAirLeaves(World world, BlockPos pos) + { -+ net.minecraft.block.Block block = world.func_180495_p(pos).func_177230_c(); -+ return block.isAir(world, pos) || block.isLeaves(world, pos); ++ IBlockState state = world.func_180495_p(pos); ++ return state.func_177230_c().isAir(state, world, pos) || state.func_177230_c().isLeaves(state, world, pos); + } } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMinable.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMinable.java.patch index b3aef2aae5..d7cc9310a8 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMinable.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenMinable.java.patch @@ -1,11 +1,12 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenMinable.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenMinable.java -@@ -73,7 +73,7 @@ +@@ -73,7 +73,8 @@ { BlockPos blockpos = new BlockPos(l1, i2, j2); - if (this.field_175919_c.apply(p_180709_1_.func_180495_p(blockpos))) -+ if (p_180709_1_.func_180495_p(blockpos).func_177230_c().isReplaceableOreGen(p_180709_1_, blockpos, this.field_175919_c)) ++ IBlockState state = p_180709_1_.func_180495_p(blockpos); ++ if (state.func_177230_c().isReplaceableOreGen(state, p_180709_1_, blockpos, this.field_175919_c)) { p_180709_1_.func_180501_a(blockpos, this.field_175920_a, 2); } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenSavannaTree.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenSavannaTree.java.patch index 105b15ca4d..3a17a2173c 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenSavannaTree.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenSavannaTree.java.patch @@ -15,14 +15,14 @@ { - Block block = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()).func_177230_c(); + BlockPos down = p_180709_3_.func_177977_b(); -+ Block block = p_180709_1_.func_180495_p(down).func_177230_c(); -+ boolean isSoil = block.canSustainPlant(p_180709_1_, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); ++ IBlockState state = p_180709_1_.func_180495_p(down); ++ boolean isSoil = state.func_177230_c().canSustainPlant(state, p_180709_1_, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); - if ((block == Blocks.field_150349_c || block == Blocks.field_150346_d) && p_180709_3_.func_177956_o() < 256 - i - 1) -+ if (isSoil && p_180709_3_.func_177956_o() < 256 - i - 1) ++ if (isSoil && p_180709_3_.func_177956_o() < p_180709_1_.func_72800_K() - i - 1) { - this.func_175921_a(p_180709_1_, p_180709_3_.func_177977_b()); -+ block.onPlantGrow(p_180709_1_, down, p_180709_3_); ++ state.func_177230_c().onPlantGrow(state, p_180709_1_, down, p_180709_3_); EnumFacing enumfacing = EnumFacing.Plane.HORIZONTAL.func_179518_a(p_180709_2_); int k2 = i - p_180709_2_.nextInt(4) - 1; int l2 = 3 - p_180709_2_.nextInt(3); @@ -30,11 +30,11 @@ } BlockPos blockpos = new BlockPos(i3, i2, j1); -- Material material = p_180709_1_.func_180495_p(blockpos).func_177230_c().func_149688_o(); -+ block = p_180709_1_.func_180495_p(blockpos).func_177230_c(); +- Material material = p_180709_1_.func_180495_p(blockpos).func_185904_a(); ++ state = p_180709_1_.func_180495_p(blockpos); - if (material == Material.field_151579_a || material == Material.field_151584_j) -+ if (block.isAir(p_180709_1_, blockpos) || block.isLeaves(p_180709_1_, blockpos)) ++ if (state.func_177230_c().isAir(state, p_180709_1_, blockpos) || state.func_177230_c().isLeaves(state, p_180709_1_, blockpos)) { this.func_181642_b(p_180709_1_, blockpos); k1 = i2; @@ -42,11 +42,11 @@ i3 += enumfacing1.func_82601_c(); j1 += enumfacing1.func_82599_e(); BlockPos blockpos1 = new BlockPos(i3, j2, j1); -- Material material1 = p_180709_1_.func_180495_p(blockpos1).func_177230_c().func_149688_o(); -+ block = p_180709_1_.func_180495_p(blockpos1).func_177230_c(); +- Material material1 = p_180709_1_.func_180495_p(blockpos1).func_185904_a(); ++ state = p_180709_1_.func_180495_p(blockpos1); - if (material1 == Material.field_151579_a || material1 == Material.field_151584_j) -+ if (block.isAir(p_180709_1_, blockpos2) || block.isLeaves(p_180709_1_, blockpos2)) ++ if (state.func_177230_c().isAir(state, p_180709_1_, blockpos1) || state.func_177230_c().isLeaves(state, p_180709_1_, blockpos1)) { this.func_181642_b(p_180709_1_, blockpos1); k1 = j2; @@ -54,11 +54,11 @@ private void func_175924_b(World p_175924_1_, BlockPos p_175924_2_) { -- Material material = p_175924_1_.func_180495_p(p_175924_2_).func_177230_c().func_149688_o(); -+ Block block = p_175924_1_.func_180495_p(p_175924_2_).func_177230_c(); +- Material material = p_175924_1_.func_180495_p(p_175924_2_).func_185904_a(); ++ IBlockState state = p_175924_1_.func_180495_p(p_175924_2_); - if (material == Material.field_151579_a || material == Material.field_151584_j) -+ if (block.isAir(p_175924_1_, p_175924_2_) || block.isLeaves(p_175924_1_, p_175924_2_)) ++ if (state.func_177230_c().isAir(state, p_175924_1_, p_175924_2_) || state.func_177230_c().isLeaves(state, p_175924_1_, p_175924_2_)) { this.func_175903_a(p_175924_1_, p_175924_2_, field_181644_b); } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenShrub.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenShrub.java.patch index 70f640f5f8..250006da96 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenShrub.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenShrub.java.patch @@ -1,31 +1,37 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenShrub.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenShrub.java -@@ -24,14 +24,16 @@ - { - Block block; +@@ -22,16 +22,16 @@ -- while (((block = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c()).func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j) && p_180709_3_.func_177956_o() > 0) + public boolean func_180709_b(World p_180709_1_, Random p_180709_2_, BlockPos p_180709_3_) + { +- IBlockState iblockstate; +- +- while (((iblockstate = p_180709_1_.func_180495_p(p_180709_3_)).func_185904_a() == Material.field_151579_a || iblockstate.func_185904_a() == Material.field_151584_j) && p_180709_3_.func_177956_o() > 0) + do { -+ block = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c(); -+ if (!block.isAir(p_180709_1_, p_180709_3_) && !block.isLeaves(p_180709_1_, p_180709_3_)) break; ++ IBlockState state = p_180709_1_.func_180495_p(p_180709_3_); ++ if (!state.func_177230_c().isAir(state, p_180709_1_, p_180709_3_) && !state.func_177230_c().isLeaves(state, p_180709_1_, p_180709_3_)) break; p_180709_3_ = p_180709_3_.func_177977_b(); - } + } while (p_180709_3_.func_177956_o() > 0); - Block block1 = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c(); +- Block block = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c(); ++ IBlockState state = p_180709_1_.func_180495_p(p_180709_3_); -- if (block1 == Blocks.field_150346_d || block1 == Blocks.field_150349_c) -+ if (block1.canSustainPlant(p_180709_1_, p_180709_3_, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g))) +- if (block == Blocks.field_150346_d || block == Blocks.field_150349_c) ++ if (state.func_177230_c().canSustainPlant(state, p_180709_1_, p_180709_3_, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g))) { p_180709_3_ = p_180709_3_.func_177984_a(); this.func_175903_a(p_180709_1_, p_180709_3_, this.field_150527_b); -@@ -53,7 +55,7 @@ +@@ -52,9 +52,9 @@ + if (Math.abs(i1) != k || Math.abs(k1) != k || p_180709_2_.nextInt(2) != 0) { BlockPos blockpos = new BlockPos(l, i, j1); +- Material material = p_180709_1_.func_180495_p(blockpos).func_185904_a(); ++ state = p_180709_1_.func_180495_p(blockpos); -- if (!p_180709_1_.func_180495_p(blockpos).func_177230_c().func_149730_j()) -+ if (p_180709_1_.func_180495_p(blockpos).func_177230_c().canBeReplacedByLeaves(p_180709_1_, blockpos)) +- if (material == Material.field_151579_a || material == Material.field_151584_j) ++ if (state.func_177230_c().canBeReplacedByLeaves(state, p_180709_1_, blockpos)) { this.func_175903_a(p_180709_1_, blockpos, this.field_150528_a); } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenSwamp.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenSwamp.java.patch index 03b98a6c05..e24b762237 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenSwamp.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenSwamp.java.patch @@ -1,94 +1,98 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenSwamp.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenSwamp.java -@@ -60,7 +60,7 @@ - { - Block block = p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(l, j, i1)).func_177230_c(); +@@ -61,7 +61,7 @@ + IBlockState iblockstate = p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(l, j, i1)); + Block block = iblockstate.func_177230_c(); -- if (block.func_149688_o() != Material.field_151579_a && block.func_149688_o() != Material.field_151584_j) -+ if (!block.isAir(p_180709_1_, blockpos$mutableblockpos.func_181079_c(l, j, i1)) && !block.isLeaves(p_180709_1_, blockpos$mutableblockpos.func_181079_c(l, j, i1))) +- if (iblockstate.func_185904_a() != Material.field_151579_a && iblockstate.func_185904_a() != Material.field_151584_j) ++ if (!iblockstate.func_177230_c().isAir(iblockstate, p_180709_1_, blockpos$mutableblockpos.func_181079_c(l, j, i1)) && !iblockstate.func_177230_c().isLeaves(iblockstate, p_180709_1_, blockpos$mutableblockpos.func_181079_c(l, j, i1))) { if (block != Blocks.field_150355_j && block != Blocks.field_150358_i) { -@@ -86,11 +86,13 @@ +@@ -87,11 +87,13 @@ } else { - Block block1 = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()).func_177230_c(); + BlockPos down = p_180709_3_.func_177977_b(); -+ Block block1 = p_180709_1_.func_180495_p(down).func_177230_c(); -+ boolean isSoil = block1.canSustainPlant(p_180709_1_, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); ++ IBlockState state = p_180709_1_.func_180495_p(down); ++ boolean isSoil = state.func_177230_c().canSustainPlant(state, p_180709_1_, down, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.field_150345_g)); - if ((block1 == Blocks.field_150349_c || block1 == Blocks.field_150346_d) && p_180709_3_.func_177956_o() < 256 - i - 1) -+ if (isSoil && p_180709_3_.func_177956_o() < 256 - i - 1) ++ if (isSoil && p_180709_3_.func_177956_o() < p_180709_1_.func_72800_K() - i - 1) { - this.func_175921_a(p_180709_1_, p_180709_3_.func_177977_b()); -+ block1.onPlantGrow(p_180709_1_, p_180709_3_.func_177977_b(),p_180709_3_); ++ state.func_177230_c().onPlantGrow(state, p_180709_1_, p_180709_3_.func_177977_b(),p_180709_3_); - for (int l1 = p_180709_3_.func_177956_o() - 3 + i; l1 <= p_180709_3_.func_177956_o() + i; ++l1) + for (int k1 = p_180709_3_.func_177956_o() - 3 + i; k1 <= p_180709_3_.func_177956_o() + i; ++k1) { -@@ -109,7 +111,7 @@ +@@ -109,8 +111,9 @@ + if (Math.abs(k3) != l2 || Math.abs(j1) != l2 || p_180709_2_.nextInt(2) != 0 && j2 != 0) { - BlockPos blockpos = new BlockPos(k3, l1, j1); + BlockPos blockpos = new BlockPos(j3, k1, i4); ++ state = p_180709_1_.func_180495_p(blockpos); -- if (!p_180709_1_.func_180495_p(blockpos).func_177230_c().func_149730_j()) -+ if (p_180709_1_.func_180495_p(blockpos).func_177230_c().canBeReplacedByLeaves(p_180709_1_, blockpos)) +- if (!p_180709_1_.func_180495_p(blockpos).func_185913_b()) ++ if (state.func_177230_c().canBeReplacedByLeaves(state, p_180709_1_, blockpos)) { this.func_175903_a(p_180709_1_, blockpos, field_181649_b); } -@@ -120,9 +122,10 @@ +@@ -121,10 +124,11 @@ - for (int i2 = 0; i2 < i; ++i2) + for (int l1 = 0; l1 < i; ++l1) { -- Block block2 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(i2)).func_177230_c(); -+ BlockPos upN = p_180709_3_.func_177981_b(i2); -+ Block block2 = p_180709_1_.func_180495_p(upN).func_177230_c(); +- IBlockState iblockstate1 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(l1)); ++ BlockPos upN = p_180709_3_.func_177981_b(l1); ++ IBlockState iblockstate1 = p_180709_1_.func_180495_p(upN); + Block block2 = iblockstate1.func_177230_c(); -- if (block2.func_149688_o() == Material.field_151579_a || block2.func_149688_o() == Material.field_151584_j || block2 == Blocks.field_150358_i || block2 == Blocks.field_150355_j) -+ if (block2.isAir(p_180709_1_, upN) || block2.isLeaves(p_180709_1_, upN) || block2 == Blocks.field_150358_i || block2 == Blocks.field_150355_j) +- if (iblockstate1.func_185904_a() == Material.field_151579_a || iblockstate1.func_185904_a() == Material.field_151584_j || block2 == Blocks.field_150358_i || block2 == Blocks.field_150355_j) ++ if (block2.isAir(iblockstate1, p_180709_1_, upN) || block2.isLeaves(iblockstate1, p_180709_1_, upN) || block2 == Blocks.field_150358_i || block2 == Blocks.field_150355_j) { - this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(i2), field_181648_a); + this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(l1), field_181648_a); } -@@ -140,29 +143,29 @@ - { - blockpos$mutableblockpos1.func_181079_c(i4, j2, j4); - -- if (p_180709_1_.func_180495_p(blockpos$mutableblockpos1).func_177230_c().func_149688_o() == Material.field_151584_j) -+ if (p_180709_1_.func_180495_p(blockpos$mutableblockpos1).func_177230_c().isLeaves(p_180709_1_, blockpos$mutableblockpos1)) - { - BlockPos blockpos3 = blockpos$mutableblockpos1.func_177976_e(); - BlockPos blockpos4 = blockpos$mutableblockpos1.func_177974_f(); +@@ -149,22 +153,22 @@ BlockPos blockpos1 = blockpos$mutableblockpos1.func_177978_c(); BlockPos blockpos2 = blockpos$mutableblockpos1.func_177968_d(); -- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos3).func_177230_c().func_149688_o() == Material.field_151579_a) -+ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos3).func_177230_c().isAir(p_180709_1_,blockpos3)) +- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos3).func_185904_a() == Material.field_151579_a) ++ if (p_180709_2_.nextInt(4) == 0 && isAir(p_180709_1_, blockpos3)) { this.func_181647_a(p_180709_1_, blockpos3, BlockVine.field_176278_M); } -- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos4).func_177230_c().func_149688_o() == Material.field_151579_a) -+ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos4).func_177230_c().isAir(p_180709_1_,blockpos4)) +- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos4).func_185904_a() == Material.field_151579_a) ++ if (p_180709_2_.nextInt(4) == 0 && isAir(p_180709_1_, blockpos4)) { this.func_181647_a(p_180709_1_, blockpos4, BlockVine.field_176280_O); } -- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos1).func_177230_c().func_149688_o() == Material.field_151579_a) -+ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos1).func_177230_c().isAir(p_180709_1_,blockpos1)) +- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos1).func_185904_a() == Material.field_151579_a) ++ if (p_180709_2_.nextInt(4) == 0 && isAir(p_180709_1_, blockpos1)) { this.func_181647_a(p_180709_1_, blockpos1, BlockVine.field_176279_N); } -- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos2).func_177230_c().func_149688_o() == Material.field_151579_a) -+ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos2).func_177230_c().isAir(p_180709_1_,blockpos2)) +- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos2).func_185904_a() == Material.field_151579_a) ++ if (p_180709_2_.nextInt(4) == 0 && isAir(p_180709_1_, blockpos2)) { this.func_181647_a(p_180709_1_, blockpos2, BlockVine.field_176273_b); } -@@ -191,7 +194,7 @@ +@@ -193,10 +197,16 @@ this.func_175903_a(p_181647_1_, p_181647_2_, iblockstate); int i = 4; -- for (p_181647_2_ = p_181647_2_.func_177977_b(); p_181647_1_.func_180495_p(p_181647_2_).func_177230_c().func_149688_o() == Material.field_151579_a && i > 0; --i) -+ for (p_181647_2_ = p_181647_2_.func_177977_b(); p_181647_1_.func_180495_p(p_181647_2_).func_177230_c().isAir(p_181647_1_,p_181647_2_) && i > 0; --i) +- for (p_181647_2_ = p_181647_2_.func_177977_b(); p_181647_1_.func_180495_p(p_181647_2_).func_185904_a() == Material.field_151579_a && i > 0; --i) ++ for (p_181647_2_ = p_181647_2_.func_177977_b(); isAir(p_181647_1_, p_181647_2_) && i > 0; --i) { this.func_175903_a(p_181647_1_, p_181647_2_, iblockstate); p_181647_2_ = p_181647_2_.func_177977_b(); + } + } ++ ++ private boolean isAir(World world, BlockPos pos) ++ { ++ IBlockState state = world.func_180495_p(pos); ++ return state.func_177230_c().isAir(state, world, pos); ++ } + } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga1.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga1.java.patch index a8ca161885..c2f74f7472 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga1.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga1.java.patch @@ -15,36 +15,38 @@ { - Block block = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()).func_177230_c(); + BlockPos down = p_180709_3_.func_177977_b(); -+ Block block = p_180709_1_.func_180495_p(down).func_177230_c(); -+ boolean isSoil = block.canSustainPlant(p_180709_1_, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling)Blocks.field_150345_g); ++ IBlockState state = p_180709_1_.func_180495_p(down); ++ boolean isSoil = state.func_177230_c().canSustainPlant(state, p_180709_1_, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling)Blocks.field_150345_g); - if ((block == Blocks.field_150349_c || block == Blocks.field_150346_d) && p_180709_3_.func_177956_o() < 256 - i - 1) + if (isSoil && p_180709_3_.func_177956_o() < 256 - i - 1) { - this.func_175921_a(p_180709_1_, p_180709_3_.func_177977_b()); -+ block.onPlantGrow(p_180709_1_, down, p_180709_3_); ++ state.func_177230_c().onPlantGrow(state, p_180709_1_, down, p_180709_3_); int k2 = 0; for (int l2 = p_180709_3_.func_177956_o() + i; l2 >= p_180709_3_.func_177956_o() + j; --l2) -@@ -93,7 +95,7 @@ +@@ -92,8 +94,9 @@ + if (Math.abs(k3) != k2 || Math.abs(j2) != k2 || k2 <= 0) { BlockPos blockpos = new BlockPos(j3, l2, i2); ++ state = p_180709_1_.func_180495_p(blockpos); -- if (!p_180709_1_.func_180495_p(blockpos).func_177230_c().func_149730_j()) -+ if (p_180709_1_.func_180495_p(blockpos).func_177230_c().canBeReplacedByLeaves(p_180709_1_, blockpos)) +- if (!p_180709_1_.func_180495_p(blockpos).func_185913_b()) ++ if (state.func_177230_c().canBeReplacedByLeaves(state, p_180709_1_, blockpos)) { this.func_175903_a(p_180709_1_, blockpos, field_181637_b); } -@@ -113,9 +115,10 @@ +@@ -113,9 +116,10 @@ for (int i3 = 0; i3 < i - 1; ++i3) { -- Block block1 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(i3)).func_177230_c(); +- Material material = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(i3)).func_185904_a(); + BlockPos upN = p_180709_3_.func_177981_b(i3); -+ Block block1 = p_180709_1_.func_180495_p(upN).func_177230_c(); ++ state = p_180709_1_.func_180495_p(upN); -- if (block1.func_149688_o() == Material.field_151579_a || block1.func_149688_o() == Material.field_151584_j) -+ if (block1.isAir(p_180709_1_, upN) || block1.isLeaves(p_180709_1_, upN)) +- if (material == Material.field_151579_a || material == Material.field_151584_j) ++ if (state.func_177230_c().isAir(state, p_180709_1_, upN) || state.func_177230_c().isLeaves(state, p_180709_1_, upN)) { this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(i3), field_181636_a); } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga2.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga2.java.patch index 8f79b84623..611141161b 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga2.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga2.java.patch @@ -1,37 +1,53 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga2.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenTaiga2.java -@@ -55,7 +55,7 @@ - { - Block block = p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(k1, i1, l1)).func_177230_c(); +@@ -30,7 +30,7 @@ + int l = 2 + p_180709_2_.nextInt(2); + boolean flag = true; -- if (block.func_149688_o() != Material.field_151579_a && block.func_149688_o() != Material.field_151584_j) -+ if (!block.isAir(p_180709_1_, blockpos$mutableblockpos) && !block.isLeaves(p_180709_1_, blockpos$mutableblockpos)) +- if (p_180709_3_.func_177956_o() >= 1 && p_180709_3_.func_177956_o() + i + 1 <= 256) ++ if (p_180709_3_.func_177956_o() >= 1 && p_180709_3_.func_177956_o() + i + 1 <= p_180709_1_.func_72800_K()) + { + for (int i1 = p_180709_3_.func_177956_o(); i1 <= p_180709_3_.func_177956_o() + 1 + i && flag; ++i1) + { +@@ -51,11 +51,11 @@ + { + for (int l1 = p_180709_3_.func_177952_p() - j1; l1 <= p_180709_3_.func_177952_p() + j1 && flag; ++l1) + { +- if (i1 >= 0 && i1 < 256) ++ if (i1 >= 0 && i1 < p_180709_1_.func_72800_K()) + { +- Material material = p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(k1, i1, l1)).func_185904_a(); ++ IBlockState state = p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(k1, i1, l1)); + +- if (material != Material.field_151579_a && material != Material.field_151584_j) ++ if (!state.func_177230_c().isAir(state, p_180709_1_, blockpos$mutableblockpos.func_181079_c(k1, i1, l1)) && !state.func_177230_c().isLeaves(state, p_180709_1_, blockpos$mutableblockpos.func_181079_c(k1, i1, l1))) { flag = false; } -@@ -74,11 +74,13 @@ +@@ -74,11 +74,12 @@ } else { -- Block block1 = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()).func_177230_c(); +- Block block = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()).func_177230_c(); + BlockPos down = p_180709_3_.func_177977_b(); -+ Block block1 = p_180709_1_.func_180495_p(down).func_177230_c(); -+ boolean isSoil = block1.canSustainPlant(p_180709_1_, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling)Blocks.field_150345_g); ++ IBlockState state = p_180709_1_.func_180495_p(down); -- if ((block1 == Blocks.field_150349_c || block1 == Blocks.field_150346_d || block1 == Blocks.field_150458_ak) && p_180709_3_.func_177956_o() < 256 - i - 1) -+ if (isSoil && p_180709_3_.func_177956_o() < 256 - i - 1) +- if ((block == Blocks.field_150349_c || block == Blocks.field_150346_d || block == Blocks.field_150458_ak) && p_180709_3_.func_177956_o() < 256 - i - 1) ++ if (state.func_177230_c().canSustainPlant(state, p_180709_1_, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling)Blocks.field_150345_g) && p_180709_3_.func_177956_o() < p_180709_1_.func_72800_K() - i - 1) { - this.func_175921_a(p_180709_1_, p_180709_3_.func_177977_b()); -+ block1.onPlantGrow(p_180709_1_, down, p_180709_3_); ++ state.func_177230_c().onPlantGrow(state, p_180709_1_, down, p_180709_3_); int i3 = p_180709_2_.nextInt(2); int j3 = 1; int k3 = 0; -@@ -99,7 +101,7 @@ +@@ -98,8 +99,9 @@ + if (Math.abs(j2) != i3 || Math.abs(l2) != i3 || i3 <= 0) { BlockPos blockpos = new BlockPos(i2, j4, k2); ++ state = p_180709_1_.func_180495_p(blockpos); -- if (!p_180709_1_.func_180495_p(blockpos).func_177230_c().func_149730_j()) -+ if (p_180709_1_.func_180495_p(blockpos).func_177230_c().canBeReplacedByLeaves(p_180709_1_, blockpos)) +- if (!p_180709_1_.func_180495_p(blockpos).func_185913_b()) ++ if (state.func_177230_c().canBeReplacedByLeaves(state, p_180709_1_, blockpos)) { this.func_175903_a(p_180709_1_, blockpos, field_181646_b); } @@ -39,12 +55,12 @@ for (int k4 = 0; k4 < i - i4; ++k4) { -- Block block2 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(k4)).func_177230_c(); +- Material material1 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(k4)).func_185904_a(); + BlockPos upN = p_180709_3_.func_177981_b(k4); -+ Block block2 = p_180709_1_.func_180495_p(upN).func_177230_c(); ++ state = p_180709_1_.func_180495_p(upN); -- if (block2.func_149688_o() == Material.field_151579_a || block2.func_149688_o() == Material.field_151584_j) -+ if (block2.isAir(p_180709_1_, upN) || block2.isLeaves(p_180709_1_, upN)) +- if (material1 == Material.field_151579_a || material1 == Material.field_151584_j) ++ if (state.func_177230_c().isAir(state, p_180709_1_, upN) || state.func_177230_c().isLeaves(state, p_180709_1_, upN)) { this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(k4), field_181645_a); } diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTallGrass.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTallGrass.java.patch index 40233c4b20..c100cd6a24 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTallGrass.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTallGrass.java.patch @@ -1,14 +1,16 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenTallGrass.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenTallGrass.java -@@ -22,10 +22,12 @@ - { - Block block; +@@ -19,12 +19,12 @@ -- while (((block = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c()).func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j) && p_180709_3_.func_177956_o() > 0) + public boolean func_180709_b(World p_180709_1_, Random p_180709_2_, BlockPos p_180709_3_) + { +- IBlockState iblockstate; +- +- while (((iblockstate = p_180709_1_.func_180495_p(p_180709_3_)).func_185904_a() == Material.field_151579_a || iblockstate.func_185904_a() == Material.field_151584_j) && p_180709_3_.func_177956_o() > 0) + do { -+ block = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c(); -+ if (!block.isAir(p_180709_1_, p_180709_3_) && !block.isLeaves(p_180709_1_, p_180709_3_)) break; ++ IBlockState state = p_180709_1_.func_180495_p(p_180709_3_); ++ if (!state.func_177230_c().isAir(state, p_180709_1_, p_180709_3_) && !state.func_177230_c().isLeaves(state, p_180709_1_, p_180709_3_)) break; p_180709_3_ = p_180709_3_.func_177977_b(); - } + } while (p_180709_3_.func_177956_o() > 0); diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTrees.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTrees.java.patch index 74c9c14455..61034e3d19 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTrees.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGenTrees.java.patch @@ -1,94 +1,105 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenTrees.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenTrees.java -@@ -68,7 +68,7 @@ +@@ -44,7 +44,7 @@ + int i = p_180709_2_.nextInt(3) + this.field_76533_a; + boolean flag = true; + +- if (p_180709_3_.func_177956_o() >= 1 && p_180709_3_.func_177956_o() + i + 1 <= 256) ++ if (p_180709_3_.func_177956_o() >= 1 && p_180709_3_.func_177956_o() + i + 1 <= p_180709_1_.func_72800_K()) + { + for (int j = p_180709_3_.func_177956_o(); j <= p_180709_3_.func_177956_o() + 1 + i; ++j) + { +@@ -66,9 +66,9 @@ + { + for (int i1 = p_180709_3_.func_177952_p() - k; i1 <= p_180709_3_.func_177952_p() + k && flag; ++i1) { - if (j >= 0 && j < 256) +- if (j >= 0 && j < 256) ++ if (j >= 0 && j < p_180709_1_.func_72800_K()) { - if (!this.func_150523_a(p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(l, j, i1)).func_177230_c())) + if (!this.isReplaceable(p_180709_1_,blockpos$mutableblockpos.func_181079_c(l, j, i1))) { flag = false; } -@@ -87,11 +87,13 @@ +@@ -87,9 +87,9 @@ } else { -- Block block1 = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()).func_177230_c(); -+ BlockPos down = p_180709_3_.func_177977_b(); -+ Block block1 = p_180709_1_.func_180495_p(down).func_177230_c(); -+ boolean isSoil = block1.canSustainPlant(p_180709_1_, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling)Blocks.field_150345_g); +- Block block = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()).func_177230_c(); ++ IBlockState state = p_180709_1_.func_180495_p(p_180709_3_.func_177977_b()); -- if ((block1 == Blocks.field_150349_c || block1 == Blocks.field_150346_d || block1 == Blocks.field_150458_ak) && p_180709_3_.func_177956_o() < 256 - i - 1) -+ if (isSoil && p_180709_3_.func_177956_o() < 256 - i - 1) +- if ((block == Blocks.field_150349_c || block == Blocks.field_150346_d || block == Blocks.field_150458_ak) && p_180709_3_.func_177956_o() < 256 - i - 1) ++ if (state.func_177230_c().canSustainPlant(state, p_180709_1_, p_180709_3_.func_177977_b(), net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling)Blocks.field_150345_g) && p_180709_3_.func_177956_o() < p_180709_1_.func_72800_K() - i - 1) { -- this.func_175921_a(p_180709_1_, p_180709_3_.func_177977_b()); -+ block1.onPlantGrow(p_180709_1_, down, p_180709_3_); + this.func_175921_a(p_180709_1_, p_180709_3_.func_177977_b()); int k2 = 3; - int l2 = 0; - -@@ -113,7 +115,7 @@ +@@ -111,9 +111,9 @@ + if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || p_180709_2_.nextInt(2) != 0 && i4 != 0) + { BlockPos blockpos = new BlockPos(k1, i3, i2); - Block block = p_180709_1_.func_180495_p(blockpos).func_177230_c(); +- Material material = p_180709_1_.func_180495_p(blockpos).func_185904_a(); ++ state = p_180709_1_.func_180495_p(blockpos); -- if (block.func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j || block.func_149688_o() == Material.field_151582_l) -+ if (block.isAir(p_180709_1_, blockpos) || block.isLeaves(p_180709_1_, blockpos) || block.func_149688_o() == Material.field_151582_l) +- if (material == Material.field_151579_a || material == Material.field_151584_j || material == Material.field_151582_l) ++ if (state.func_177230_c().isAir(state, p_180709_1_, blockpos) || state.func_177230_c().isLeaves(state, p_180709_1_, blockpos) || state.func_185904_a() == Material.field_151582_l) { this.func_175903_a(p_180709_1_, blockpos, this.field_76530_d); } -@@ -124,9 +126,10 @@ +@@ -124,9 +124,10 @@ for (int j3 = 0; j3 < i; ++j3) { -- Block block2 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(j3)).func_177230_c(); +- Material material1 = p_180709_1_.func_180495_p(p_180709_3_.func_177981_b(j3)).func_185904_a(); + BlockPos upN = p_180709_3_.func_177981_b(j3); -+ Block block2 = p_180709_1_.func_180495_p(upN).func_177230_c(); ++ state = p_180709_1_.func_180495_p(upN); -- if (block2.func_149688_o() == Material.field_151579_a || block2.func_149688_o() == Material.field_151584_j || block2.func_149688_o() == Material.field_151582_l) -+ if (block2.isAir(p_180709_1_, upN) || block2.isLeaves(p_180709_1_, upN) || block2.func_149688_o() == Material.field_151582_l) +- if (material1 == Material.field_151579_a || material1 == Material.field_151584_j || material1 == Material.field_151582_l) ++ if (state.func_177230_c().isAir(state, p_180709_1_, upN) || state.func_177230_c().isLeaves(state, p_180709_1_, upN) || state.func_185904_a() == Material.field_151582_l) { this.func_175903_a(p_180709_1_, p_180709_3_.func_177981_b(j3), this.field_76532_c); -@@ -169,29 +172,29 @@ +@@ -169,29 +170,30 @@ { blockpos$mutableblockpos1.func_181079_c(l4, k3, i5); -- if (p_180709_1_.func_180495_p(blockpos$mutableblockpos1).func_177230_c().func_149688_o() == Material.field_151584_j) -+ if (p_180709_1_.func_180495_p(blockpos$mutableblockpos1).func_177230_c().isLeaves(p_180709_1_,blockpos$mutableblockpos1)) +- if (p_180709_1_.func_180495_p(blockpos$mutableblockpos1).func_185904_a() == Material.field_151584_j) ++ state = p_180709_1_.func_180495_p(blockpos$mutableblockpos1); ++ if (state.func_177230_c().isLeaves(state, p_180709_1_, blockpos$mutableblockpos1)) { BlockPos blockpos2 = blockpos$mutableblockpos1.func_177976_e(); BlockPos blockpos3 = blockpos$mutableblockpos1.func_177974_f(); BlockPos blockpos4 = blockpos$mutableblockpos1.func_177978_c(); BlockPos blockpos1 = blockpos$mutableblockpos1.func_177968_d(); -- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos2).func_177230_c().func_149688_o() == Material.field_151579_a) -+ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos2).func_177230_c().isAir(p_180709_1_,blockpos2)) +- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos2).func_185904_a() == Material.field_151579_a) ++ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_175623_d(blockpos2)) { this.func_181650_b(p_180709_1_, blockpos2, BlockVine.field_176278_M); } -- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos3).func_177230_c().func_149688_o() == Material.field_151579_a) -+ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos3).func_177230_c().isAir(p_180709_1_,blockpos3)) +- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos3).func_185904_a() == Material.field_151579_a) ++ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_175623_d(blockpos3)) { this.func_181650_b(p_180709_1_, blockpos3, BlockVine.field_176280_O); } -- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos4).func_177230_c().func_149688_o() == Material.field_151579_a) -+ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos4).func_177230_c().isAir(p_180709_1_,blockpos4)) +- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos4).func_185904_a() == Material.field_151579_a) ++ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_175623_d(blockpos4)) { this.func_181650_b(p_180709_1_, blockpos4, BlockVine.field_176279_N); } -- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos1).func_177230_c().func_149688_o() == Material.field_151579_a) -+ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos1).func_177230_c().isAir(p_180709_1_,blockpos1)) +- if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_180495_p(blockpos1).func_185904_a() == Material.field_151579_a) ++ if (p_180709_2_.nextInt(4) == 0 && p_180709_1_.func_175623_d(blockpos1)) { this.func_181650_b(p_180709_1_, blockpos1, BlockVine.field_176273_b); } -@@ -245,7 +248,7 @@ +@@ -245,7 +247,7 @@ this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_); int i = 4; -- for (p_181650_2_ = p_181650_2_.func_177977_b(); p_181650_1_.func_180495_p(p_181650_2_).func_177230_c().func_149688_o() == Material.field_151579_a && i > 0; --i) -+ for (p_181650_2_ = p_181650_2_.func_177977_b(); p_181650_1_.func_180495_p(p_181650_2_).func_177230_c().isAir(p_181650_1_,p_181650_2_) && i > 0; --i) +- for (p_181650_2_ = p_181650_2_.func_177977_b(); p_181650_1_.func_180495_p(p_181650_2_).func_185904_a() == Material.field_151579_a && i > 0; --i) ++ for (p_181650_2_ = p_181650_2_.func_177977_b(); p_181650_1_.func_175623_d(p_181650_2_) && i > 0; --i) { this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_); p_181650_2_ = p_181650_2_.func_177977_b(); diff --git a/patches/minecraft/net/minecraft/world/gen/feature/WorldGeneratorBonusChest.java.patch b/patches/minecraft/net/minecraft/world/gen/feature/WorldGeneratorBonusChest.java.patch index 79027d1db9..3a95d326f3 100644 --- a/patches/minecraft/net/minecraft/world/gen/feature/WorldGeneratorBonusChest.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/feature/WorldGeneratorBonusChest.java.patch @@ -1,17 +1,55 @@ --- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGeneratorBonusChest.java +++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGeneratorBonusChest.java -@@ -26,10 +26,12 @@ +@@ -14,12 +14,12 @@ + { + public boolean func_180709_b(World p_180709_1_, Random p_180709_2_, BlockPos p_180709_3_) { - Block block; - -- while (((block = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c()).func_149688_o() == Material.field_151579_a || block.func_149688_o() == Material.field_151584_j) && p_180709_3_.func_177956_o() > 1) +- IBlockState iblockstate; +- +- while (((iblockstate = p_180709_1_.func_180495_p(p_180709_3_)).func_185904_a() == Material.field_151579_a || iblockstate.func_185904_a() == Material.field_151584_j) && p_180709_3_.func_177956_o() > 1) + do { -+ block = p_180709_1_.func_180495_p(p_180709_3_).func_177230_c(); -+ if (!block.isAir(p_180709_1_, p_180709_3_) && !block.isLeaves(p_180709_1_, p_180709_3_)) break; ++ IBlockState state = p_180709_1_.func_180495_p(p_180709_3_); ++ if (!state.func_177230_c().isAir(state, p_180709_1_, p_180709_3_) && !state.func_177230_c().isLeaves(state, p_180709_1_, p_180709_3_)) break; p_180709_3_ = p_180709_3_.func_177977_b(); - } + } while (p_180709_3_.func_177956_o() > 0); if (p_180709_3_.func_177956_o() < 1) { +@@ -33,7 +33,7 @@ + { + BlockPos blockpos = p_180709_3_.func_177982_a(p_180709_2_.nextInt(4) - p_180709_2_.nextInt(4), p_180709_2_.nextInt(3) - p_180709_2_.nextInt(3), p_180709_2_.nextInt(4) - p_180709_2_.nextInt(4)); + +- if (p_180709_1_.func_175623_d(blockpos) && p_180709_1_.func_180495_p(blockpos.func_177977_b()).func_185896_q()) ++ if (p_180709_1_.func_175623_d(blockpos) && p_180709_1_.func_180495_p(blockpos.func_177977_b()).isSideSolid(p_180709_1_, blockpos.func_177977_b(), net.minecraft.util.EnumFacing.UP)) + { + p_180709_1_.func_180501_a(blockpos, Blocks.field_150486_ae.func_176223_P(), 2); + TileEntity tileentity = p_180709_1_.func_175625_s(blockpos); +@@ -48,22 +48,22 @@ + BlockPos blockpos3 = blockpos.func_177978_c(); + BlockPos blockpos4 = blockpos.func_177968_d(); + +- if (p_180709_1_.func_175623_d(blockpos2) && p_180709_1_.func_180495_p(blockpos2.func_177977_b()).func_185896_q()) ++ if (p_180709_1_.func_175623_d(blockpos2) && p_180709_1_.func_180495_p(blockpos2.func_177977_b()).isSideSolid(p_180709_1_, blockpos2.func_177977_b(), net.minecraft.util.EnumFacing.UP)) + { + p_180709_1_.func_180501_a(blockpos2, Blocks.field_150478_aa.func_176223_P(), 2); + } + +- if (p_180709_1_.func_175623_d(blockpos1) && p_180709_1_.func_180495_p(blockpos1.func_177977_b()).func_185896_q()) ++ if (p_180709_1_.func_175623_d(blockpos1) && p_180709_1_.func_180495_p(blockpos1.func_177977_b()).isSideSolid(p_180709_1_, blockpos1.func_177977_b(), net.minecraft.util.EnumFacing.UP)) + { + p_180709_1_.func_180501_a(blockpos1, Blocks.field_150478_aa.func_176223_P(), 2); + } + +- if (p_180709_1_.func_175623_d(blockpos3) && p_180709_1_.func_180495_p(blockpos3.func_177977_b()).func_185896_q()) ++ if (p_180709_1_.func_175623_d(blockpos3) && p_180709_1_.func_180495_p(blockpos3.func_177977_b()).isSideSolid(p_180709_1_, blockpos3.func_177977_b(), net.minecraft.util.EnumFacing.UP)) + { + p_180709_1_.func_180501_a(blockpos3, Blocks.field_150478_aa.func_176223_P(), 2); + } + +- if (p_180709_1_.func_175623_d(blockpos4) && p_180709_1_.func_180495_p(blockpos4.func_177977_b()).func_185896_q()) ++ if (p_180709_1_.func_175623_d(blockpos4) && p_180709_1_.func_180495_p(blockpos4.func_177977_b()).isSideSolid(p_180709_1_, blockpos4.func_177977_b(), net.minecraft.util.EnumFacing.UP)) + { + p_180709_1_.func_180501_a(blockpos4, Blocks.field_150478_aa.func_176223_P(), 2); + } diff --git a/patches/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch b/patches/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch index f1a5cfe3c0..3a9a317099 100644 --- a/patches/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/layer/GenLayer.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/gen/layer/GenLayer.java +++ ../src-work/minecraft/net/minecraft/world/gen/layer/GenLayer.java -@@ -52,12 +52,12 @@ +@@ -49,12 +49,12 @@ i = 6; } @@ -16,16 +16,17 @@ GenLayer genlayerhills = new GenLayerHills(1000L, genlayerbiomeedge, lvt_10_1_); GenLayer genlayer5 = GenLayerZoom.func_75915_a(1000L, genlayerriverinit, 2); genlayer5 = GenLayerZoom.func_75915_a(1000L, genlayer5, j); -@@ -191,7 +191,7 @@ +@@ -158,8 +158,7 @@ protected static boolean func_151618_b(int p_151618_0_) { -- return p_151618_0_ == BiomeGenBase.field_76771_b.field_76756_M || p_151618_0_ == BiomeGenBase.field_150575_M.field_76756_M || p_151618_0_ == BiomeGenBase.field_76776_l.field_76756_M; +- BiomeGenBase biomegenbase = BiomeGenBase.func_150568_d(p_151618_0_); +- return biomegenbase == Biomes.field_76771_b || biomegenbase == Biomes.field_150575_M || biomegenbase == Biomes.field_76776_l; + return net.minecraftforge.common.BiomeManager.oceanBiomes.contains(BiomeGenBase.func_150568_d(p_151618_0_)); } protected int func_151619_a(int... p_151619_1_) -@@ -203,4 +203,27 @@ +@@ -171,4 +170,27 @@ { return p_151617_2_ == p_151617_3_ && p_151617_3_ == p_151617_4_ ? p_151617_2_ : (p_151617_1_ == p_151617_2_ && p_151617_1_ == p_151617_3_ ? p_151617_1_ : (p_151617_1_ == p_151617_2_ && p_151617_1_ == p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_3_ && p_151617_1_ == p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_2_ && p_151617_3_ != p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_3_ && p_151617_2_ != p_151617_4_ ? p_151617_1_ : (p_151617_1_ == p_151617_4_ && p_151617_2_ != p_151617_3_ ? p_151617_1_ : (p_151617_2_ == p_151617_3_ && p_151617_1_ != p_151617_4_ ? p_151617_2_ : (p_151617_2_ == p_151617_4_ && p_151617_1_ != p_151617_3_ ? p_151617_2_ : (p_151617_3_ == p_151617_4_ && p_151617_1_ != p_151617_2_ ? p_151617_3_ : this.func_151619_a(new int[] {p_151617_1_, p_151617_2_, p_151617_3_, p_151617_4_})))))))))); } @@ -49,7 +50,7 @@ + { + net.minecraftforge.event.terraingen.WorldTypeEvent.BiomeSize event = new net.minecraftforge.event.terraingen.WorldTypeEvent.BiomeSize(worldType, original); + net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event); -+ return event.newSize; ++ return event.getNewSize(); + } + /* ========================================= FORGE END ======================================*/ } diff --git a/patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch b/patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch index 5e2daee960..61d673a2f7 100644 --- a/patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java.patch @@ -1,20 +1,19 @@ --- ../src-base/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java +++ ../src-work/minecraft/net/minecraft/world/gen/layer/GenLayerBiome.java -@@ -6,10 +6,9 @@ +@@ -7,10 +7,8 @@ public class GenLayerBiome extends GenLayer { -- private BiomeGenBase[] field_151623_c = new BiomeGenBase[] {BiomeGenBase.field_76769_d, BiomeGenBase.field_76769_d, BiomeGenBase.field_76769_d, BiomeGenBase.field_150588_X, BiomeGenBase.field_150588_X, BiomeGenBase.field_76772_c}; -- private BiomeGenBase[] field_151621_d = new BiomeGenBase[] {BiomeGenBase.field_76767_f, BiomeGenBase.field_150585_R, BiomeGenBase.field_76770_e, BiomeGenBase.field_76772_c, BiomeGenBase.field_150583_P, BiomeGenBase.field_76780_h}; -- private BiomeGenBase[] field_151622_e = new BiomeGenBase[] {BiomeGenBase.field_76767_f, BiomeGenBase.field_76770_e, BiomeGenBase.field_76768_g, BiomeGenBase.field_76772_c}; -- private BiomeGenBase[] field_151620_f = new BiomeGenBase[] {BiomeGenBase.field_76774_n, BiomeGenBase.field_76774_n, BiomeGenBase.field_76774_n, BiomeGenBase.field_150584_S}; +- private BiomeGenBase[] field_151623_c = new BiomeGenBase[] {Biomes.field_76769_d, Biomes.field_76769_d, Biomes.field_76769_d, Biomes.field_150588_X, Biomes.field_150588_X, Biomes.field_76772_c}; +- private BiomeGenBase[] field_151621_d = new BiomeGenBase[] {Biomes.field_76767_f, Biomes.field_150585_R, Biomes.field_76770_e, Biomes.field_76772_c, Biomes.field_150583_P, Biomes.field_76780_h}; +- private BiomeGenBase[] field_151622_e = new BiomeGenBase[] {Biomes.field_76767_f, Biomes.field_76770_e, Biomes.field_76768_g, Biomes.field_76772_c}; +- private BiomeGenBase[] field_151620_f = new BiomeGenBase[] {Biomes.field_76774_n, Biomes.field_76774_n, Biomes.field_76774_n, Biomes.field_150584_S}; + @SuppressWarnings("unchecked") + private java.util.List[] biomes = new java.util.ArrayList[net.minecraftforge.common.BiomeManager.BiomeType.values().length]; -+ private final ChunkProviderSettings field_175973_g; public GenLayerBiome(long p_i45560_1_, GenLayer p_i45560_3_, WorldType p_i45560_4_, String p_i45560_5_) -@@ -17,9 +16,30 @@ +@@ -18,9 +16,30 @@ super(p_i45560_1_); this.field_75909_a = p_i45560_3_; @@ -29,57 +28,57 @@ + + int desertIdx = net.minecraftforge.common.BiomeManager.BiomeType.DESERT.ordinal(); + -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.field_76769_d, 30)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.field_150588_X, 20)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.field_76772_c, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76769_d, 30)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_150588_X, 20)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76772_c, 10)); + if (p_i45560_4_ == WorldType.field_77136_e) { -- this.field_151623_c = new BiomeGenBase[] {BiomeGenBase.field_76769_d, BiomeGenBase.field_76767_f, BiomeGenBase.field_76770_e, BiomeGenBase.field_76780_h, BiomeGenBase.field_76772_c, BiomeGenBase.field_76768_g}; +- this.field_151623_c = new BiomeGenBase[] {Biomes.field_76769_d, Biomes.field_76767_f, Biomes.field_76770_e, Biomes.field_76780_h, Biomes.field_76772_c, Biomes.field_76768_g}; + biomes[desertIdx].clear(); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.field_76769_d, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.field_76767_f, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.field_76770_e, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.field_76780_h, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.field_76772_c, 10)); -+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(BiomeGenBase.field_76768_g, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76769_d, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76767_f, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76770_e, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76780_h, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76772_c, 10)); ++ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76768_g, 10)); this.field_175973_g = null; } else if (p_i45560_4_ == WorldType.field_180271_f) -@@ -73,7 +93,7 @@ +@@ -74,7 +93,7 @@ } else { -- aint1[j + i * p_75904_3_] = this.field_151623_c[this.func_75902_a(this.field_151623_c.length)].field_76756_M; -+ aint1[j + i * p_75904_3_] = getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.DESERT).biome.field_76756_M; +- aint1[j + i * p_75904_3_] = BiomeGenBase.func_185362_a(this.field_151623_c[this.func_75902_a(this.field_151623_c.length)]); ++ aint1[j + i * p_75904_3_] = BiomeGenBase.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.DESERT).biome); } } else if (k == 2) -@@ -84,7 +104,7 @@ +@@ -85,7 +104,7 @@ } else { -- aint1[j + i * p_75904_3_] = this.field_151621_d[this.func_75902_a(this.field_151621_d.length)].field_76756_M; -+ aint1[j + i * p_75904_3_] = getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.WARM).biome.field_76756_M; +- aint1[j + i * p_75904_3_] = BiomeGenBase.func_185362_a(this.field_151621_d[this.func_75902_a(this.field_151621_d.length)]); ++ aint1[j + i * p_75904_3_] = BiomeGenBase.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.WARM).biome); } } else if (k == 3) -@@ -95,12 +115,12 @@ +@@ -96,12 +115,12 @@ } else { -- aint1[j + i * p_75904_3_] = this.field_151622_e[this.func_75902_a(this.field_151622_e.length)].field_76756_M; -+ aint1[j + i * p_75904_3_] = getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.COOL).biome.field_76756_M; +- aint1[j + i * p_75904_3_] = BiomeGenBase.func_185362_a(this.field_151622_e[this.func_75902_a(this.field_151622_e.length)]); ++ aint1[j + i * p_75904_3_] = BiomeGenBase.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.COOL).biome); } } else if (k == 4) { -- aint1[j + i * p_75904_3_] = this.field_151620_f[this.func_75902_a(this.field_151620_f.length)].field_76756_M; -+ aint1[j + i * p_75904_3_] = getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.ICY).biome.field_76756_M; +- aint1[j + i * p_75904_3_] = BiomeGenBase.func_185362_a(this.field_151620_f[this.func_75902_a(this.field_151620_f.length)]); ++ aint1[j + i * p_75904_3_] = BiomeGenBase.func_185362_a(getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.ICY).biome); } else { -@@ -111,4 +131,12 @@ +@@ -112,4 +131,12 @@ return aint1; } diff --git a/patches/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch deleted file mode 100644 index a1ba802896..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java.patch +++ /dev/null @@ -1,79 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java -+++ ../src-work/minecraft/net/minecraft/world/gen/structure/ComponentScatteredFeaturePieces.java -@@ -40,6 +40,12 @@ - { - } - -+ static -+ { -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST, field_74941_i, 2, 7); -+ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.field_151134_bR, 1, 0), 1, 1, 1)); -+ } -+ - public DesertPyramid(Random p_i2062_1_, int p_i2062_2_, int p_i2062_3_) - { - super(p_i2062_1_, p_i2062_2_, 64, p_i2062_3_, 21, 15, 21); -@@ -258,7 +264,7 @@ - { - int l1 = enumfacing.func_82601_c() * 2; - int i2 = enumfacing.func_82599_e() * 2; -- this.field_74940_h[enumfacing.func_176736_b()] = this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 10 + l1, -11, 10 + i2, WeightedRandomChestContent.func_177629_a(field_74941_i, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92114_b(p_74875_2_)}), 2 + p_74875_2_.nextInt(5)); -+ this.field_74940_h[enumfacing.func_176736_b()] = this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 10 + l1, -11, 10 + i2, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST, p_74875_2_)); - } - } - -@@ -362,6 +368,13 @@ - private static final List field_175815_j = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.field_151032_g, 0, 2, 7, 30)}); - private static ComponentScatteredFeaturePieces.JunglePyramid.Stones field_74942_n = new ComponentScatteredFeaturePieces.JunglePyramid.Stones(); - -+ static -+ { -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER, field_175815_j, 2, 2); -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST, field_175816_i, 2, 7); -+ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.field_151134_bR, 1, 0), 1, 1, 1)); -+ } -+ - public JunglePyramid() - { - } -@@ -518,9 +531,12 @@ - this.func_175811_a(p_74875_1_, Blocks.field_150488_af.func_176223_P(), 4, -3, 1, p_74875_3_); - this.func_175811_a(p_74875_1_, Blocks.field_150341_Y.func_176223_P(), 3, -3, 1, p_74875_3_); - -+ net.minecraftforge.common.ChestGenHooks dispenser = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_DISPENSER); -+ net.minecraftforge.common.ChestGenHooks chest = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST); -+ - if (!this.field_74945_j) - { -- this.field_74945_j = this.func_175806_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, -2, 1, EnumFacing.NORTH.func_176745_a(), field_175815_j, 2); -+ this.field_74945_j = this.func_175806_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, -2, 1, EnumFacing.NORTH.func_176745_a(), dispenser.getItems(p_74875_2_), dispenser.getCount(p_74875_2_)); - } - - this.func_175811_a(p_74875_1_, Blocks.field_150395_bd.func_176203_a(15), 3, -2, 2, p_74875_3_); -@@ -537,7 +553,7 @@ - - if (!this.field_74946_k) - { -- this.field_74946_k = this.func_175806_a(p_74875_1_, p_74875_3_, p_74875_2_, 9, -2, 3, EnumFacing.WEST.func_176745_a(), field_175815_j, 2); -+ this.field_74946_k = this.func_175806_a(p_74875_1_, p_74875_3_, p_74875_2_, 9, -2, 3, EnumFacing.WEST.func_176745_a(), dispenser.getItems(p_74875_2_), dispenser.getCount(p_74875_2_)); - } - - this.func_175811_a(p_74875_1_, Blocks.field_150395_bd.func_176203_a(15), 8, -1, 3, p_74875_3_); -@@ -545,7 +561,7 @@ - - if (!this.field_74947_h) - { -- this.field_74947_h = this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 8, -3, 3, WeightedRandomChestContent.func_177629_a(field_175816_i, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92114_b(p_74875_2_)}), 2 + p_74875_2_.nextInt(5)); -+ this.field_74947_h = this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 8, -3, 3, chest.getItems(p_74875_2_), chest.getCount(p_74875_2_)); - } - - this.func_175811_a(p_74875_1_, Blocks.field_150341_Y.func_176223_P(), 9, -3, 2, p_74875_3_); -@@ -578,7 +594,7 @@ - - if (!this.field_74948_i) - { -- this.field_74948_i = this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 9, -3, 10, WeightedRandomChestContent.func_177629_a(field_175816_i, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92114_b(p_74875_2_)}), 2 + p_74875_2_.nextInt(5)); -+ this.field_74948_i = this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 9, -3, 10, chest.getItems(p_74875_2_), chest.getCount(p_74875_2_)); - } - - return true; diff --git a/patches/minecraft/net/minecraft/world/gen/structure/MapGenStronghold.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/MapGenStronghold.java.patch index a296c5436d..81289f9368 100644 --- a/patches/minecraft/net/minecraft/world/gen/structure/MapGenStronghold.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/structure/MapGenStronghold.java.patch @@ -1,15 +1,16 @@ --- ../src-base/minecraft/net/minecraft/world/gen/structure/MapGenStronghold.java +++ ../src-work/minecraft/net/minecraft/world/gen/structure/MapGenStronghold.java -@@ -28,11 +28,18 @@ +@@ -28,11 +28,19 @@ - for (BiomeGenBase biomegenbase : BiomeGenBase.func_150565_n()) + for (BiomeGenBase biomegenbase : BiomeGenBase.field_185377_q) { -- if (biomegenbase != null && biomegenbase.field_76748_D > 0.0F) -+ if (biomegenbase != null && biomegenbase.field_76748_D > 0.0F && !net.minecraftforge.common.BiomeManager.strongHoldBiomesBlackList.contains(biomegenbase)) +- if (biomegenbase != null && biomegenbase.func_185355_j() > 0.0F) ++ if (biomegenbase != null && biomegenbase.func_185355_j() > 0.0F && !net.minecraftforge.common.BiomeManager.strongHoldBiomesBlackList.contains(biomegenbase)) { this.field_151546_e.add(biomegenbase); } } ++ + for (BiomeGenBase biome : net.minecraftforge.common.BiomeManager.strongHoldBiomes) + { + if (!this.field_151546_e.contains(biome)) diff --git a/patches/minecraft/net/minecraft/world/gen/structure/MapGenStructure.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/MapGenStructure.java.patch index f97b0ccc36..628727ecee 100644 --- a/patches/minecraft/net/minecraft/world/gen/structure/MapGenStructure.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/structure/MapGenStructure.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/gen/structure/MapGenStructure.java +++ ../src-work/minecraft/net/minecraft/world/gen/structure/MapGenStructure.java -@@ -217,12 +217,12 @@ +@@ -221,12 +221,12 @@ { if (this.field_143029_e == null) { diff --git a/patches/minecraft/net/minecraft/world/gen/structure/StructureComponent.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/StructureComponent.java.patch index 8c525a6128..0d04563b48 100644 --- a/patches/minecraft/net/minecraft/world/gen/structure/StructureComponent.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/structure/StructureComponent.java.patch @@ -1,8 +1,8 @@ --- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureComponent.java +++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureComponent.java -@@ -35,6 +35,10 @@ +@@ -38,6 +38,10 @@ - public NBTTagCompound func_143010_b() + public final NBTTagCompound func_143010_b() { + if (MapGenStructureIO.func_143036_a(this) == null) // Friendlier error then the Null String error below. + { diff --git a/patches/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java.patch deleted file mode 100644 index 3a37d8b4c6..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java.patch +++ /dev/null @@ -1,33 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java -+++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureMineshaftPieces.java -@@ -32,6 +32,12 @@ - MapGenStructureIO.func_143031_a(StructureMineshaftPieces.Stairs.class, "MSStairs"); - } - -+ static -+ { -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.MINESHAFT_CORRIDOR, field_175893_a, 8, 8); -+ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.MINESHAFT_CORRIDOR, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.field_151134_bR, 1, 0), 1, 1, 1)); -+ } -+ - private static StructureComponent func_175892_a(List p_175892_0_, Random p_175892_1_, int p_175892_2_, int p_175892_3_, int p_175892_4_, EnumFacing p_175892_5_, int p_175892_6_) - { - int i = p_175892_1_.nextInt(100); -@@ -351,14 +357,15 @@ - this.func_175809_a(p_74875_1_, p_74875_3_, p_74875_2_, 0.05F, 1, 2, k1 - 1, Blocks.field_150478_aa.func_176203_a(EnumFacing.UP.func_176745_a())); - this.func_175809_a(p_74875_1_, p_74875_3_, p_74875_2_, 0.05F, 1, 2, k1 + 1, Blocks.field_150478_aa.func_176203_a(EnumFacing.UP.func_176745_a())); - -+ net.minecraftforge.common.ChestGenHooks info = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.MINESHAFT_CORRIDOR); - if (p_74875_2_.nextInt(100) == 0) - { -- this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 2, 0, k1 - 1, WeightedRandomChestContent.func_177629_a(StructureMineshaftPieces.field_175893_a, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92114_b(p_74875_2_)}), 3 + p_74875_2_.nextInt(4)); -+ this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 2, 0, k1 - 1, info.getItems(p_74875_2_), info.getCount(p_74875_2_)); - } - - if (p_74875_2_.nextInt(100) == 0) - { -- this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 0, 0, k1 + 1, WeightedRandomChestContent.func_177629_a(StructureMineshaftPieces.field_175893_a, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92114_b(p_74875_2_)}), 3 + p_74875_2_.nextInt(4)); -+ this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 0, 0, k1 + 1, info.getItems(p_74875_2_), info.getCount(p_74875_2_)); - } - - if (this.field_74956_b && !this.field_74957_c) diff --git a/patches/minecraft/net/minecraft/world/gen/structure/StructureNetherBridgePieces.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/StructureNetherBridgePieces.java.patch deleted file mode 100644 index 8d9ab3d849..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/structure/StructureNetherBridgePieces.java.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureNetherBridgePieces.java -+++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureNetherBridgePieces.java -@@ -154,7 +154,7 @@ - if (this.field_111021_b && p_74875_3_.func_175898_b(new BlockPos(this.func_74865_a(3, 3), this.func_74862_a(2), this.func_74873_b(3, 3)))) - { - this.field_111021_b = false; -- this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, 2, 3, field_111019_a, 2 + p_74875_2_.nextInt(4)); -+ this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, 2, 3, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.NETHER_FORTRESS, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.NETHER_FORTRESS, p_74875_2_)); - } - - this.func_175804_a(p_74875_1_, p_74875_3_, 0, 6, 0, 4, 6, 4, Blocks.field_150385_bj.func_176223_P(), Blocks.field_150385_bj.func_176223_P(), false); -@@ -225,7 +225,7 @@ - if (this.field_111020_b && p_74875_3_.func_175898_b(new BlockPos(this.func_74865_a(1, 3), this.func_74862_a(2), this.func_74873_b(1, 3)))) - { - this.field_111020_b = false; -- this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 1, 2, 3, field_111019_a, 2 + p_74875_2_.nextInt(4)); -+ this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 1, 2, 3, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.NETHER_FORTRESS, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.NETHER_FORTRESS, p_74875_2_)); - } - - this.func_175804_a(p_74875_1_, p_74875_3_, 0, 6, 0, 4, 6, 4, Blocks.field_150385_bj.func_176223_P(), Blocks.field_150385_bj.func_176223_P(), false); -@@ -943,6 +943,7 @@ - abstract static class Piece extends StructureComponent - { - protected static final List field_111019_a = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.field_151045_i, 0, 1, 3, 5), new WeightedRandomChestContent(Items.field_151042_j, 0, 1, 5, 5), new WeightedRandomChestContent(Items.field_151043_k, 0, 1, 3, 15), new WeightedRandomChestContent(Items.field_151010_B, 0, 1, 1, 5), new WeightedRandomChestContent(Items.field_151171_ah, 0, 1, 1, 5), new WeightedRandomChestContent(Items.field_151033_d, 0, 1, 1, 5), new WeightedRandomChestContent(Items.field_151075_bm, 0, 3, 7, 5), new WeightedRandomChestContent(Items.field_151141_av, 0, 1, 1, 10), new WeightedRandomChestContent(Items.field_151136_bY, 0, 1, 1, 8), new WeightedRandomChestContent(Items.field_151138_bX, 0, 1, 1, 5), new WeightedRandomChestContent(Items.field_151125_bZ, 0, 1, 1, 3), new WeightedRandomChestContent(Item.func_150898_a(Blocks.field_150343_Z), 0, 2, 4, 2)}); -+ static { net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.NETHER_FORTRESS, field_111019_a, 2, 5); } - - public Piece() - { diff --git a/patches/minecraft/net/minecraft/world/gen/structure/StructureStart.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/StructureStart.java.patch index 7ff46ea189..c8db28dbbd 100644 --- a/patches/minecraft/net/minecraft/world/gen/structure/StructureStart.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/structure/StructureStart.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureStart.java +++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureStart.java -@@ -62,6 +62,10 @@ +@@ -63,6 +63,10 @@ public NBTTagCompound func_143021_a(int p_143021_1_, int p_143021_2_) { @@ -11,7 +11,7 @@ NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.func_74778_a("id", MapGenStructureIO.func_143033_a(this)); nbttagcompound.func_74768_a("ChunkX", p_143021_1_); -@@ -97,7 +101,8 @@ +@@ -98,7 +102,8 @@ for (int i = 0; i < nbttaglist.func_74745_c(); ++i) { diff --git a/patches/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java.patch deleted file mode 100644 index 0d5ebc0bbd..0000000000 --- a/patches/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java.patch +++ /dev/null @@ -1,75 +0,0 @@ ---- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java -+++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureStrongholdPieces.java -@@ -240,6 +240,12 @@ - { - } - -+ static -+ { -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR, field_75003_a, 2, 4); -+ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.field_151134_bR, 1, 0), 1, 1, 1)); -+ } -+ - public ChestCorridor(int p_i45582_1_, Random p_i45582_2_, StructureBoundingBox p_i45582_3_, EnumFacing p_i45582_4_) - { - super(p_i45582_1_); -@@ -296,7 +302,7 @@ - if (!this.field_75002_c && p_74875_3_.func_175898_b(new BlockPos(this.func_74865_a(3, 3), this.func_74862_a(2), this.func_74873_b(3, 3)))) - { - this.field_75002_c = true; -- this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, 2, 3, WeightedRandomChestContent.func_177629_a(field_75003_a, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92114_b(p_74875_2_)}), 2 + p_74875_2_.nextInt(2)); -+ this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, 2, 3, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CORRIDOR, p_74875_2_)); - } - - return true; -@@ -592,6 +598,12 @@ - private static final List field_75007_b = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.field_151122_aG, 0, 1, 3, 20), new WeightedRandomChestContent(Items.field_151121_aF, 0, 2, 7, 20), new WeightedRandomChestContent(Items.field_151148_bJ, 0, 1, 1, 1), new WeightedRandomChestContent(Items.field_151111_aL, 0, 1, 1, 1)}); - private boolean field_75008_c; - -+ static -+ { -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_LIBRARY, field_75007_b, 1, 5); -+ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_LIBRARY, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.field_151134_bR, 1, 0), 1, 5, 2)); -+ } -+ - public Library() - { - } -@@ -736,12 +748,13 @@ - this.func_175811_a(p_74875_1_, Blocks.field_150478_aa.func_176223_P(), i1, 8, j1 + 1, p_74875_3_); - } - -- this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, 3, 5, WeightedRandomChestContent.func_177629_a(field_75007_b, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92112_a(p_74875_2_, 1, 5, 2)}), 1 + p_74875_2_.nextInt(4)); -+ net.minecraftforge.common.ChestGenHooks info = net.minecraftforge.common.ChestGenHooks.getInfo(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_LIBRARY); -+ this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, 3, 5, info.getItems(p_74875_2_), info.getCount(p_74875_2_)); - - if (this.field_75008_c) - { - this.func_175811_a(p_74875_1_, Blocks.field_150350_a.func_176223_P(), 12, 9, 1, p_74875_3_); -- this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 12, 8, 1, WeightedRandomChestContent.func_177629_a(field_75007_b, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92112_a(p_74875_2_, 1, 5, 2)}), 1 + p_74875_2_.nextInt(4)); -+ this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 12, 8, 1, info.getItems(p_74875_2_), info.getCount(p_74875_2_)); - } - - return true; -@@ -1013,6 +1026,12 @@ - private static final List field_75014_c = Lists.newArrayList(new WeightedRandomChestContent[] {new WeightedRandomChestContent(Items.field_151042_j, 0, 1, 5, 10), new WeightedRandomChestContent(Items.field_151043_k, 0, 1, 3, 5), new WeightedRandomChestContent(Items.field_151137_ax, 0, 4, 9, 5), new WeightedRandomChestContent(Items.field_151044_h, 0, 3, 8, 10), new WeightedRandomChestContent(Items.field_151025_P, 0, 1, 3, 15), new WeightedRandomChestContent(Items.field_151034_e, 0, 1, 3, 15), new WeightedRandomChestContent(Items.field_151035_b, 0, 1, 1, 1)}); - protected int field_75013_b; - -+ static -+ { -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING, field_75014_c, 1, 5); -+ net.minecraftforge.common.ChestGenHooks.addItem(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING, new WeightedRandomChestContent(new net.minecraft.item.ItemStack(Items.field_151134_bR, 1, 0), 1, 1, 1)); -+ } -+ - public RoomCrossing() - { - } -@@ -1151,7 +1170,7 @@ - this.func_175811_a(p_74875_1_, Blocks.field_150468_ap.func_176203_a(this.func_151555_a(Blocks.field_150468_ap, EnumFacing.WEST.func_176745_a())), 9, 1, 3, p_74875_3_); - this.func_175811_a(p_74875_1_, Blocks.field_150468_ap.func_176203_a(this.func_151555_a(Blocks.field_150468_ap, EnumFacing.WEST.func_176745_a())), 9, 2, 3, p_74875_3_); - this.func_175811_a(p_74875_1_, Blocks.field_150468_ap.func_176203_a(this.func_151555_a(Blocks.field_150468_ap, EnumFacing.WEST.func_176745_a())), 9, 3, 3, p_74875_3_); -- this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, 4, 8, WeightedRandomChestContent.func_177629_a(field_75014_c, new WeightedRandomChestContent[] {Items.field_151134_bR.func_92114_b(p_74875_2_)}), 1 + p_74875_2_.nextInt(4)); -+ this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 3, 4, 8, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.STRONGHOLD_CROSSING, p_74875_2_)); - } - - return true; diff --git a/patches/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch b/patches/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch index 43cc68cb17..b63848da22 100644 --- a/patches/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch +++ b/patches/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java +++ ../src-work/minecraft/net/minecraft/world/gen/structure/StructureVillagePieces.java -@@ -57,6 +57,7 @@ +@@ -58,6 +58,7 @@ list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Field2.class, 3, MathHelper.func_76136_a(p_75084_0_, 2 + p_75084_1_, 4 + p_75084_1_ * 2))); list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House2.class, 15, MathHelper.func_76136_a(p_75084_0_, 0, 1 + p_75084_1_))); list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House3.class, 8, MathHelper.func_76136_a(p_75084_0_, 0 + p_75084_1_, 3 + p_75084_1_ * 2))); @@ -8,7 +8,7 @@ Iterator iterator = list.iterator(); while (iterator.hasNext()) -@@ -129,6 +130,10 @@ +@@ -130,6 +131,10 @@ { structurevillagepieces$village = StructureVillagePieces.House3.func_175849_a(p_176065_0_, p_176065_2_, p_176065_3_, p_176065_4_, p_176065_5_, p_176065_6_, p_176065_7_, p_176065_8_); } @@ -19,28 +19,7 @@ return structurevillagepieces$village; } -@@ -833,6 +838,11 @@ - { - } - -+ static -+ { -+ net.minecraftforge.common.ChestGenHooks.init(net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH, field_74918_a, 3, 8); -+ } -+ - public House2(StructureVillagePieces.Start p_i45563_1_, int p_i45563_2_, Random p_i45563_3_, StructureBoundingBox p_i45563_4_, EnumFacing p_i45563_5_) - { - super(p_i45563_1_, p_i45563_2_); -@@ -911,7 +921,7 @@ - if (!this.field_74917_c && p_74875_3_.func_175898_b(new BlockPos(this.func_74865_a(5, 5), this.func_74862_a(1), this.func_74873_b(5, 5)))) - { - this.field_74917_c = true; -- this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 5, 1, 5, field_74918_a, 3 + p_74875_2_.nextInt(6)); -+ this.func_180778_a(p_74875_1_, p_74875_3_, p_74875_2_, 5, 1, 5, net.minecraftforge.common.ChestGenHooks.getItems(net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH, p_74875_2_), net.minecraftforge.common.ChestGenHooks.getCount(net.minecraftforge.common.ChestGenHooks.VILLAGE_BLACKSMITH, p_74875_2_)); - } - - for (int i = 6; i <= 8; ++i) -@@ -1403,6 +1413,7 @@ +@@ -1447,6 +1452,7 @@ public List field_74931_h; public List field_74932_i = Lists.newArrayList(); public List field_74930_j = Lists.newArrayList(); @@ -48,15 +27,15 @@ public Start() { -@@ -1416,6 +1427,7 @@ +@@ -1460,6 +1466,7 @@ this.field_74928_c = p_i2104_7_; - BiomeGenBase biomegenbase = p_i2104_1_.func_180300_a(new BlockPos(p_i2104_4_, 0, p_i2104_5_), BiomeGenBase.field_180279_ad); - this.field_74927_b = biomegenbase == BiomeGenBase.field_76769_d || biomegenbase == BiomeGenBase.field_76786_s; + BiomeGenBase biomegenbase = p_i2104_1_.func_180300_a(new BlockPos(p_i2104_4_, 0, p_i2104_5_), Biomes.field_180279_ad); + this.field_74927_b = biomegenbase == Biomes.field_76769_d || biomegenbase == Biomes.field_76786_s; + this.biome = biomegenbase; this.func_175846_a(this.field_74927_b); } -@@ -1477,6 +1489,7 @@ +@@ -1520,6 +1527,7 @@ protected int field_143015_k = -1; private int field_74896_a; private boolean field_143014_b; @@ -64,7 +43,7 @@ public Village() { -@@ -1489,6 +1502,7 @@ +@@ -1532,6 +1540,7 @@ if (p_i2107_1_ != null) { this.field_143014_b = p_i2107_1_.field_74927_b; @@ -72,13 +51,13 @@ } } -@@ -1613,6 +1627,9 @@ +@@ -1660,6 +1669,9 @@ protected IBlockState func_175847_a(IBlockState p_175847_1_) { + net.minecraftforge.event.terraingen.BiomeEvent.GetVillageBlockID event = new net.minecraftforge.event.terraingen.BiomeEvent.GetVillageBlockID(startPiece == null ? null : startPiece.biome, p_175847_1_); + net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event); -+ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.replacement; ++ if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return event.getReplacement(); if (this.field_143014_b) { if (p_175847_1_.func_177230_c() == Blocks.field_150364_r || p_175847_1_.func_177230_c() == Blocks.field_150363_s) diff --git a/patches/minecraft/net/minecraft/world/storage/MapData.java.patch b/patches/minecraft/net/minecraft/world/storage/MapData.java.patch index 4bddcf6dab..4f6cfb7141 100644 --- a/patches/minecraft/net/minecraft/world/storage/MapData.java.patch +++ b/patches/minecraft/net/minecraft/world/storage/MapData.java.patch @@ -6,10 +6,10 @@ public int field_76199_b; - public byte field_76200_c; + public int field_76200_c; //FML byte -> int + public boolean field_186210_e; public byte field_76197_d; public byte[] field_76198_e = new byte[16384]; - public List field_76196_g = Lists.newArrayList(); -@@ -44,7 +44,17 @@ +@@ -45,7 +45,17 @@ public void func_76184_a(NBTTagCompound p_76184_1_) { @@ -28,7 +28,7 @@ this.field_76201_a = p_76184_1_.func_74762_e("xCenter"); this.field_76199_b = p_76184_1_.func_74762_e("zCenter"); this.field_76197_d = p_76184_1_.func_74771_c("scale"); -@@ -85,7 +95,7 @@ +@@ -96,7 +106,7 @@ public void func_76187_b(NBTTagCompound p_76187_1_) { @@ -37,7 +37,7 @@ p_76187_1_.func_74768_a("xCenter", this.field_76201_a); p_76187_1_.func_74768_a("zCenter", this.field_76199_b); p_76187_1_.func_74774_a("scale", this.field_76197_d); -@@ -164,7 +174,7 @@ +@@ -176,7 +186,7 @@ p_82567_8_ = p_82567_8_ + (p_82567_8_ < 0.0D ? -8.0D : 8.0D); b2 = (byte)((int)(p_82567_8_ * 16.0D / 360.0D)); diff --git a/patches/minecraft/net/minecraft/world/storage/SaveFormatOld.java.patch b/patches/minecraft/net/minecraft/world/storage/SaveFormatOld.java.patch new file mode 100644 index 0000000000..5d70251ab4 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/storage/SaveFormatOld.java.patch @@ -0,0 +1,27 @@ +--- ../src-base/minecraft/net/minecraft/world/storage/SaveFormatOld.java ++++ ../src-work/minecraft/net/minecraft/world/storage/SaveFormatOld.java +@@ -106,6 +106,24 @@ + } + } + ++ //Forge: Special version of the above that runs during actual world loading and not metadata gathering. ++ public static WorldInfo loadAndFix(File file, DataFixer fixer, SaveHandler save) ++ { ++ try ++ { ++ NBTTagCompound nbt = CompressedStreamTools.func_74796_a(new FileInputStream(file)); ++ WorldInfo info = new WorldInfo(fixer.func_188257_a(FixTypes.LEVEL, nbt.func_74775_l("Data"))); ++ net.minecraftforge.fml.common.FMLCommonHandler.instance().handleWorldDataLoad(save, info, nbt); ++ return info; ++ } ++ catch (net.minecraftforge.fml.common.StartupQuery.AbortedException e) { throw e; } ++ catch (Exception exception) ++ { ++ field_151479_b.error((String)("Exception reading " + file), (Throwable)exception); ++ return null; ++ } ++ } ++ + @SideOnly(Side.CLIENT) + public void func_75806_a(String p_75806_1_, String p_75806_2_) + { diff --git a/patches/minecraft/net/minecraft/world/storage/SaveHandler.java.patch b/patches/minecraft/net/minecraft/world/storage/SaveHandler.java.patch index 6f920a6405..3cce351d0b 100644 --- a/patches/minecraft/net/minecraft/world/storage/SaveHandler.java.patch +++ b/patches/minecraft/net/minecraft/world/storage/SaveHandler.java.patch @@ -1,52 +1,26 @@ --- ../src-base/minecraft/net/minecraft/world/storage/SaveHandler.java +++ ../src-work/minecraft/net/minecraft/world/storage/SaveHandler.java -@@ -104,20 +104,29 @@ - { - File file1 = new File(this.field_75770_b, "level.dat"); +@@ -117,7 +117,7 @@ -+ WorldInfo worldInfo = null; -+ if (file1.exists()) { - try +- WorldInfo worldinfo = SaveFormatOld.func_186353_a(file1, this.field_186341_a); ++ WorldInfo worldinfo = SaveFormatOld.loadAndFix(file1, this.field_186341_a, this); + + if (worldinfo != null) { - NBTTagCompound nbttagcompound2 = CompressedStreamTools.func_74796_a(new FileInputStream(file1)); - NBTTagCompound nbttagcompound3 = nbttagcompound2.func_74775_l("Data"); -- return new WorldInfo(nbttagcompound3); -+ worldInfo = new WorldInfo(nbttagcompound3); -+ net.minecraftforge.fml.common.FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, nbttagcompound2); -+ return worldInfo; - } -+ catch (net.minecraftforge.fml.common.StartupQuery.AbortedException e) -+ { -+ throw e; -+ } - catch (Exception exception1) - { - exception1.printStackTrace(); +@@ -125,8 +125,9 @@ } } + net.minecraftforge.fml.common.FMLCommonHandler.instance().confirmBackupLevelDatUse(this); file1 = new File(this.field_75770_b, "level.dat_old"); +- return file1.exists() ? SaveFormatOld.func_186353_a(file1, this.field_186341_a) : null; ++ return file1.exists() ? SaveFormatOld.loadAndFix(file1, this.field_186341_a, this) : null; + } - if (file1.exists()) -@@ -126,7 +135,13 @@ - { - NBTTagCompound nbttagcompound = CompressedStreamTools.func_74796_a(new FileInputStream(file1)); - NBTTagCompound nbttagcompound1 = nbttagcompound.func_74775_l("Data"); -- return new WorldInfo(nbttagcompound1); -+ worldInfo = new WorldInfo(nbttagcompound1); -+ net.minecraftforge.fml.common.FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, nbttagcompound); -+ return worldInfo; -+ } -+ catch (net.minecraftforge.fml.common.StartupQuery.AbortedException e) -+ { -+ throw e; - } - catch (Exception exception) - { -@@ -143,6 +158,8 @@ + public void func_75755_a(WorldInfo p_75755_1_, NBTTagCompound p_75755_2_) +@@ -135,6 +136,8 @@ NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.func_74782_a("Data", nbttagcompound); @@ -55,16 +29,7 @@ try { File file1 = new File(this.field_75770_b, "level.dat_new"); -@@ -181,6 +198,8 @@ - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.func_74782_a("Data", nbttagcompound); - -+ net.minecraftforge.fml.common.FMLCommonHandler.instance().handleWorldDataSave(this, p_75761_1_, nbttagcompound1); -+ - try - { - File file1 = new File(this.field_75770_b, "level.dat_new"); -@@ -229,6 +248,7 @@ +@@ -188,6 +191,7 @@ } file1.renameTo(file2); @@ -72,17 +37,17 @@ } catch (Exception var5) { -@@ -259,6 +279,7 @@ - p_75752_1_.func_70020_e(nbttagcompound); +@@ -218,6 +222,7 @@ + p_75752_1_.func_70020_e(this.field_186341_a.func_188257_a(FixTypes.PLAYER, nbttagcompound)); } + net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(p_75752_1_, field_75771_c, p_75752_1_.func_110124_au().toString()); return nbttagcompound; } -@@ -300,4 +321,22 @@ +@@ -259,4 +264,22 @@ { - return this.field_75767_f; + return this.field_186342_h; } + + public NBTTagCompound getPlayerNBT(net.minecraft.entity.player.EntityPlayerMP player) diff --git a/patches/minecraft/net/minecraft/world/storage/WorldInfo.java.patch b/patches/minecraft/net/minecraft/world/storage/WorldInfo.java.patch index 8085364515..5ffd902c3a 100644 --- a/patches/minecraft/net/minecraft/world/storage/WorldInfo.java.patch +++ b/patches/minecraft/net/minecraft/world/storage/WorldInfo.java.patch @@ -1,18 +1,17 @@ --- ../src-base/minecraft/net/minecraft/world/storage/WorldInfo.java +++ ../src-work/minecraft/net/minecraft/world/storage/WorldInfo.java -@@ -51,6 +51,7 @@ - private int field_176154_I = 5; +@@ -60,6 +60,7 @@ private int field_176155_J = 15; + private final Map field_186348_N = Maps.newEnumMap(DimensionType.class); private GameRules field_82577_x = new GameRules(); + private java.util.Map additionalProperties; protected WorldInfo() { -@@ -745,4 +746,24 @@ - } +@@ -785,6 +786,26 @@ }); } -+ + + /** + * Allow access to additional mod specific world based properties + * Used by FML to store mod list associated with a world, and maybe an id map @@ -32,4 +31,7 @@ + { + return this.additionalProperties!=null? this.additionalProperties.get(additionalProperty) : null; + } - } ++ + public NBTTagCompound func_186347_a(DimensionType p_186347_1_) + { + NBTTagCompound nbttagcompound = (NBTTagCompound)this.field_186348_N.get(p_186347_1_); diff --git a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java index 87a196e485..0bad50d6a6 100644 --- a/src/main/java/net/minecraftforge/client/ClientCommandHandler.java +++ b/src/main/java/net/minecraftforge/client/ClientCommandHandler.java @@ -9,12 +9,13 @@ import net.minecraft.command.CommandHandler; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; -import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.server.MinecraftServer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.CommandEvent; import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraft.util.EnumChatFormatting; -import static net.minecraft.util.EnumChatFormatting.*; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TextFormatting; +import static net.minecraft.util.text.TextFormatting.*; /** * The class that handles client-side chat commands. You should register any @@ -48,7 +49,7 @@ public class ClientCommandHandler extends CommandHandler String[] args = new String[temp.length - 1]; String commandName = temp[0]; System.arraycopy(temp, 1, args, 0, args.length); - ICommand icommand = (ICommand) getCommands().get(commandName); + ICommand icommand = getCommands().get(commandName); try { @@ -57,19 +58,19 @@ public class ClientCommandHandler extends CommandHandler return 0; } - if (icommand.canCommandSenderUseCommand(sender)) + if (icommand.checkPermission(this.getServer(), sender)) { CommandEvent event = new CommandEvent(icommand, sender, args); if (MinecraftForge.EVENT_BUS.post(event)) { - if (event.exception != null) + if (event.getException() != null) { - throw event.exception; + throw event.getException(); } return 0; } - icommand.processCommand(sender, args); + this.tryExecute(sender, args, icommand, message); return 1; } else @@ -95,14 +96,14 @@ public class ClientCommandHandler extends CommandHandler } //Couple of helpers because the mcp names are stupid and long... - private ChatComponentTranslation format(EnumChatFormatting color, String str, Object... args) + private TextComponentTranslation format(TextFormatting color, String str, Object... args) { - ChatComponentTranslation ret = new ChatComponentTranslation(str, args); + TextComponentTranslation ret = new TextComponentTranslation(str, args); ret.getChatStyle().setColor(color); return ret; } - public void autoComplete(String leftOfCursor, String full) + public void autoComplete(String leftOfCursor) { latestAutoComplete = null; @@ -136,4 +137,9 @@ public class ClientCommandHandler extends CommandHandler } } } -} \ No newline at end of file + + @Override + protected MinecraftServer getServer() { + return Minecraft.getMinecraft().getIntegratedServer(); + } +} diff --git a/src/main/java/net/minecraftforge/client/EnumHelperClient.java b/src/main/java/net/minecraftforge/client/EnumHelperClient.java index 95a3f9997d..62604d9e78 100644 --- a/src/main/java/net/minecraftforge/client/EnumHelperClient.java +++ b/src/main/java/net/minecraftforge/client/EnumHelperClient.java @@ -7,8 +7,7 @@ import net.minecraftforge.common.util.EnumHelper; public class EnumHelperClient extends EnumHelper { - @SuppressWarnings("rawtypes") - private static Class[][] clentTypes = + private static Class[][] clientTypes = { {GameType.class, int.class, String.class}, {Options.class, String.class, boolean.class, boolean.class}, @@ -32,6 +31,6 @@ public class EnumHelperClient extends EnumHelper public static > T addEnum(Class enumType, String enumName, Object... paramValues) { - return addEnum(clentTypes, enumType, enumName, paramValues); + return addEnum(clientTypes, enumType, enumName, paramValues); } } diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 4a184c8116..a0b60506a1 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -1,5 +1,6 @@ package net.minecraftforge.client; +import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.BOSSINFO; import static net.minecraftforge.common.ForgeVersion.Status.BETA; import static net.minecraftforge.common.ForgeVersion.Status.BETA_OUTDATED; import static org.lwjgl.opengl.GL11.*; @@ -7,8 +8,10 @@ import static org.lwjgl.opengl.GL20.*; import java.nio.ByteBuffer; import java.nio.FloatBuffer; +import java.util.Collections; import java.util.Map; +import javax.vecmath.Matrix3f; import javax.vecmath.Matrix4f; import javax.vecmath.Vector3f; import javax.vecmath.Vector4f; @@ -17,20 +20,26 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.SoundEventAccessorComposite; import net.minecraft.client.audio.SoundManager; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.BlockFaceUV; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.block.model.ItemTransformVec3f; +import net.minecraft.client.renderer.block.model.ModelManager; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelRotation; +import net.minecraft.client.renderer.block.model.SimpleBakedModel; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; @@ -39,19 +48,23 @@ import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage; import net.minecraft.client.resources.I18n; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.client.resources.model.ModelRotation; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.*; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.registry.IRegistry; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.BossInfoLerping; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; @@ -61,22 +74,28 @@ import net.minecraftforge.client.event.FOVUpdateEvent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.MouseEvent; +import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.sound.PlaySoundEvent; -import net.minecraftforge.client.model.IFlexibleBakedModel; -import net.minecraftforge.client.model.IModelPart; import net.minecraftforge.client.model.IPerspectiveAwareModel; import net.minecraftforge.client.model.ModelLoader; -import net.minecraftforge.client.model.TRSRTransformation; +import net.minecraftforge.client.model.animation.Animation; import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.common.ForgeVersion.Status; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.ITransformation; +import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.client.GuiJava8Error; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.FMLLog; +import net.minecraftforge.fml.common.Java8VersionException; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.BufferUtils; @@ -84,7 +103,6 @@ import org.lwjgl.BufferUtils; import com.google.common.base.Optional; import com.google.common.collect.Maps; -@SuppressWarnings("deprecation") public class ForgeHooksClient { //private static final ResourceLocation ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); @@ -94,28 +112,28 @@ public class ForgeHooksClient return FMLClientHandler.instance().getClient().renderEngine; } - public static String getArmorTexture(Entity entity, ItemStack armor, String _default, int slot, String type) + public static String getArmorTexture(Entity entity, ItemStack armor, String _default, EntityEquipmentSlot slot, String type) { String result = armor.getItem().getArmorTexture(armor, entity, slot, type); return result != null ? result : _default; } //Optifine Helper Functions u.u, these are here specifically for Optifine - //Note: When using Optfine, these methods are invoked using reflection, which + //Note: When using Optifine, these methods are invoked using reflection, which //incurs a major performance penalty. public static void orientBedCamera(IBlockAccess world, BlockPos pos, IBlockState state, Entity entity) { Block block = state.getBlock(); - if (block != null && block.isBed(world, pos, entity)) + if (block != null && block.isBed(state, world, pos, entity)) { - glRotatef((float)(block.getBedDirection(world, pos).getHorizontalIndex() * 90), 0.0F, 1.0F, 0.0F); + glRotatef((float)(block.getBedDirection(state, world, pos).getHorizontalIndex() * 90), 0.0F, 1.0F, 0.0F); } } - public static boolean onDrawBlockHighlight(RenderGlobal context, EntityPlayer player, MovingObjectPosition target, int subID, ItemStack currentItem, float partialTicks) + public static boolean onDrawBlockHighlight(RenderGlobal context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks) { - return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, player, target, subID, currentItem, partialTicks)); + return MinecraftForge.EVENT_BUS.post(new DrawBlockHighlightEvent(context, player, target, subID, partialTicks)); } public static void dispatchRenderLast(RenderGlobal context, float partialTicks) @@ -131,7 +149,7 @@ public class ForgeHooksClient public static void onTextureStitchedPre(TextureMap map) { MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Pre(map)); - ModelLoader.White.instance.register(map); + ModelLoader.White.INSTANCE.register(map); } public static void onTextureStitchedPost(TextureMap map) @@ -145,22 +163,16 @@ public class ForgeHooksClient renderPass = pass; } - static final ThreadLocal renderLayer = new ThreadLocal() - { - protected EnumWorldBlockLayer initialValue() - { - return EnumWorldBlockLayer.SOLID; - } - }; + static final ThreadLocal renderLayer = new ThreadLocal(); - public static void setRenderLayer(EnumWorldBlockLayer layer) + public static void setRenderLayer(BlockRenderLayer layer) { renderLayer.set(layer); } - public static ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int slotID, ModelBiped _default) + public static ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot slot, ModelBiped _default) { - ModelBiped model = itemStack.getItem().getArmorModel(entityLiving, itemStack, slotID, _default); + ModelBiped model = itemStack.getItem().getArmorModel(entityLiving, itemStack, slot, _default); return model == null ? _default : model; } @@ -194,11 +206,11 @@ public class ForgeHooksClient { FOVUpdateEvent fovUpdateEvent = new FOVUpdateEvent(entity, fov); MinecraftForge.EVENT_BUS.post(fovUpdateEvent); - return fovUpdateEvent.newfov; + return fovUpdateEvent.getNewfov(); } - - public static float getFOVModifier(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks, float fov) { - EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, entity, block, renderPartialTicks, fov); + + public static float getFOVModifier(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float fov) { + EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, entity, state, renderPartialTicks, fov); MinecraftForge.EVENT_BUS.post(event); return event.getFOV(); } @@ -259,18 +271,30 @@ public class ForgeHooksClient //RenderingRegistry.registerBlockHandler(RenderBlockFluid.instance); } - public static void renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height) + private static int updatescrollcounter = 0; + public static String renderMainMenu(GuiMainMenu gui, FontRenderer font, int width, int height, String splashText) { Status status = ForgeVersion.getStatus(); if (status == BETA || status == BETA_OUTDATED) { // render a warning at the top of the screen, - String line = I18n.format("forge.update.beta.1", EnumChatFormatting.RED, EnumChatFormatting.RESET); + String line = I18n.format("forge.update.beta.1", TextFormatting.RED, TextFormatting.RESET); gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (0 * (font.FONT_HEIGHT + 1)), -1); line = I18n.format("forge.update.beta.2"); gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (1 * (font.FONT_HEIGHT + 1)), -1); } + if (!Loader.instance().java8) + { + String line = I18n.format("fml.messages.java8warning.1", TextFormatting.RED, TextFormatting.RESET); + gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (8 * (font.FONT_HEIGHT + 1)), -1); + line = I18n.format("fml.messages.java8warning.2"); + gui.drawString(font, line, (width - font.getStringWidth(line)) / 2, 4 + (9 * (font.FONT_HEIGHT + 1)), -1); + splashText = updatescrollcounter < 50 ? "UPDATE!" : "JAVA!"; + updatescrollcounter+=1; + updatescrollcounter%=100; + } + String line = null; switch(status) { @@ -287,17 +311,34 @@ public class ForgeHooksClient // if we have a line, render it in the bottom right, above Mojang's copyright line gui.drawString(font, line, width - font.getStringWidth(line) - 2, height - (2 * (font.FONT_HEIGHT + 1)), -1); } + + return splashText; + } + + public static void mainMenuMouseClick(int mouseX, int mouseY, int mouseButton, FontRenderer font, int width) + { + if (!Loader.instance().java8) + { + if (mouseY >= (4 + (8 * 10)) && mouseY < (4 + (10 * 10))) + { + int w = font.getStringWidth(I18n.format("fml.messages.java8warning.1", TextFormatting.RED, TextFormatting.RESET)); + w = Math.max(w, font.getStringWidth(I18n.format("fml.messages.java8warning.2"))); + if (mouseX >= ((width - w) / 2) && mouseX <= ((width + w) / 2)) + { + FMLClientHandler.instance().showGuiScreen(new GuiJava8Error(new Java8VersionException(Collections.emptyList()))); + } + } + } } public static ISound playSound(SoundManager manager, ISound sound) { - SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getSoundLocation()); - PlaySoundEvent e = new PlaySoundEvent(manager, sound, (accessor == null ? null : accessor.getSoundCategory())); + PlaySoundEvent e = new PlaySoundEvent(manager, sound); MinecraftForge.EVENT_BUS.post(e); - return e.result; + return e.getResultSound(); } - //static RenderBlocks worldRendererRB; + //static RenderBlocks VertexBufferRB; static int worldRenderPass; public static int getWorldRenderPass() @@ -312,51 +353,26 @@ public class ForgeHooksClient MinecraftForge.EVENT_BUS.post(new GuiScreenEvent.DrawScreenEvent.Post(screen, mouseX, mouseY, partialTicks)); } - public static float getFogDensity(EntityRenderer renderer, Entity entity, Block block, float partial, float density) + public static float getFogDensity(EntityRenderer renderer, Entity entity, IBlockState state, float partial, float density) { - EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(renderer, entity, block, partial, density); - if (MinecraftForge.EVENT_BUS.post(event)) return event.density; + EntityViewRenderEvent.FogDensity event = new EntityViewRenderEvent.FogDensity(renderer, entity, state, partial, density); + if (MinecraftForge.EVENT_BUS.post(event)) return event.getDensity(); return -1; } - public static void onFogRender(EntityRenderer renderer, Entity entity, Block block, float partial, int mode, float distance) + public static void onFogRender(EntityRenderer renderer, Entity entity, IBlockState state, float partial, int mode, float distance) { - MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(renderer, entity, block, partial, mode, distance)); + MinecraftForge.EVENT_BUS.post(new EntityViewRenderEvent.RenderFogEvent(renderer, entity, state, partial, mode, distance)); } - /* - public static void setWorldRendererRB(RenderBlocks renderBlocks) + public static void onModelBake(ModelManager modelManager, IRegistry modelRegistry, ModelLoader modelLoader) { - worldRendererRB = renderBlocks; + MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, modelLoader)); + modelLoader.onPostBakeEvent(modelRegistry); } - public static void onPreRenderWorld(WorldRenderer worldRenderer, int pass) - { - if(worldRendererRB != null) - { - worldRenderPass = pass; - MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Pre(worldRenderer, (ChunkCache)worldRendererRB.blockAccess, worldRendererRB, pass)); - } - } - - public static void onPostRenderWorld(WorldRenderer worldRenderer, int pass) - { - if(worldRendererRB != null) - { - MinecraftForge.EVENT_BUS.post(new RenderWorldEvent.Post(worldRenderer, (ChunkCache)worldRendererRB.blockAccess, worldRendererRB, pass)); - worldRenderPass = -1; - } - } - */ - - public static void onModelBake(ModelManager modelManager, IRegistry modelRegistry, ModelBakery modelBakery) - { - ModelLoader loader = (ModelLoader)modelBakery; - MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, loader)); - loader.onPostBakeEvent(modelRegistry); - } - - public static Matrix4f getMatrix(ItemTransformVec3f transform) + @SuppressWarnings("deprecation") + public static Matrix4f getMatrix(net.minecraft.client.renderer.block.model.ItemTransformVec3f transform) { javax.vecmath.Matrix4f m = new javax.vecmath.Matrix4f(), t = new javax.vecmath.Matrix4f(); m.setIdentity(); @@ -378,18 +394,37 @@ public class ForgeHooksClient return m; } - public static IBakedModel handleCameraTransforms(IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType) + private static final Matrix4f flipX; + static { + flipX = new Matrix4f(); + flipX.setIdentity(); + flipX.m00 = -1; + } + + @SuppressWarnings("deprecation") + public static IBakedModel handleCameraTransforms(IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType, boolean leftHandHackery) { if(model instanceof IPerspectiveAwareModel) { - Pair pair = ((IPerspectiveAwareModel)model).handlePerspective(cameraTransformType); + Pair pair = ((IPerspectiveAwareModel)model).handlePerspective(cameraTransformType); - if(pair.getRight() != null) multiplyCurrentGlMatrix(pair.getRight()); + if(pair.getRight() != null) + { + Matrix4f matrix = new Matrix4f(pair.getRight()); + if(leftHandHackery) + { + matrix.mul(flipX, matrix); + matrix.mul(matrix, flipX); + } + multiplyCurrentGlMatrix(matrix); + } return pair.getLeft(); } else { - model.getItemCameraTransforms().applyTransform(cameraTransformType); + //if(leftHandHackery) GlStateManager.scale(-1, 1, 1); + ItemCameraTransforms.applyTransformSide(model.getItemCameraTransforms().getTransform(cameraTransformType), leftHandHackery); + //if(leftHandHackery) GlStateManager.scale(-1, 1, 1); } return model; } @@ -416,7 +451,7 @@ public class ForgeHooksClient VertexFormatElement attr = format.getElement(element); int count = attr.getElementCount(); int constant = attr.getType().getGlConstant(); - buffer.position(format.func_181720_d(element)); + buffer.position(format.getOffset(element)); switch(attrType) { case POSITION: @@ -501,15 +536,18 @@ public class ForgeHooksClient return ret; } - public static void putQuadColor(WorldRenderer renderer, BakedQuad quad, int color) + public static void putQuadColor(VertexBuffer renderer, BakedQuad quad, int color) { - float cr = color & 0xFF; + float cb = color & 0xFF; float cg = (color >>> 8) & 0xFF; - float cb = (color >>> 16) & 0xFF; + float cr = (color >>> 16) & 0xFF; float ca = (color >>> 24) & 0xFF; + VertexFormat format = quad.getFormat(); + int size = format.getIntegerSize(); + int offset = format.getColorOffset() / 4; // assumes that color is aligned for(int i = 0; i < 4; i++) { - int vc = quad.getVertexData()[3 + 7 * i]; + int vc = quad.getVertexData()[offset + size * i]; float vcr = vc & 0xFF; float vcg = (vc >>> 8) & 0xFF; float vcb = (vc >>> 16) & 0xFF; @@ -569,10 +607,11 @@ public class ForgeHooksClient } } - public static Optional applyTransform(ItemTransformVec3f transform, Optional part) + @SuppressWarnings("deprecation") + public static Optional applyTransform(net.minecraft.client.renderer.block.model.ItemTransformVec3f transform, Optional part) { if(part.isPresent()) return Optional.absent(); - return Optional.of(new TRSRTransformation(transform)); + return Optional.of(TRSRTransformation.blockCenterToCorner(new TRSRTransformation(transform))); } public static Optional applyTransform(Matrix4f matrix, Optional part) @@ -592,4 +631,78 @@ public class ForgeHooksClient } } } + + public static IBakedModel getDamageModel(IBakedModel ibakedmodel, TextureAtlasSprite texture, IBlockState state, IBlockAccess world, BlockPos pos) + { + // TODO custom damage models + // state = state.block.getExtendedState(state, world, pos); + return (new SimpleBakedModel.Builder(state, ibakedmodel, texture, pos)).makeBakedModel(); + } + + private static int slotMainHand = 0; + // FIXME + public static boolean shouldCauseReequipAnimation(ItemStack from, ItemStack to, int slot) + { + if (from == null && to != null) return true; + if (from == null && to == null) return false; + if (from != null && to == null) return true; + boolean changed = false; + if (slot != -1) + { + changed = slot != slotMainHand; + slotMainHand = slot; + } + return from.getItem().shouldCauseReequipAnimation(from, to, changed); + } + + public static BlockFaceUV applyUVLock(BlockFaceUV blockFaceUV, EnumFacing originalSide, ITransformation rotation) + { + TRSRTransformation global = new TRSRTransformation(rotation.getMatrix()); + Matrix4f uv = global.getUVLockTransform(originalSide).getMatrix(); + Vector4f vec = new Vector4f(0, 0, 0, 1); + vec.x = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(0)) / 16; + vec.y = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(0)) / 16; + uv.transform(vec); + float uMin = 16 * vec.x; // / vec.w; + float vMin = 16 * vec.y; // / vec.w; + vec.x = blockFaceUV.getVertexU(blockFaceUV.getVertexRotatedRev(2)) / 16; + vec.y = blockFaceUV.getVertexV(blockFaceUV.getVertexRotatedRev(2)) / 16; + vec.z = 0; + vec.w = 1; + uv.transform(vec); + float uMax = 16 * vec.x; // / vec.w; + float vMax = 16 * vec.y; // / vec.w; + if(uMin > uMax) + { + float t = uMin; + uMin = uMax; + uMax = t; + } + if(vMin > vMax) + { + float t = vMin; + vMin = vMax; + vMax = t; + } + float a = (float)Math.toRadians(blockFaceUV.rotation); + Vector3f rv = new Vector3f(MathHelper.cos(a), MathHelper.sin(a), 0); + Matrix3f rot = new Matrix3f(); + uv.getRotationScale(rot); + rot.transform(rv); + int angle = MathHelper.normalizeAngle(-(int)Math.round(Math.toDegrees(Math.atan2(rv.y, rv.x)) / 90) * 90, 360); + return new BlockFaceUV(new float[]{ uMin, vMin, uMax, vMax }, angle); + } + + public static RenderGameOverlayEvent.BossInfo bossBarRenderPre(ScaledResolution res, BossInfoLerping bossInfo, int x, int y, int increment) + { + RenderGameOverlayEvent.BossInfo evt = new RenderGameOverlayEvent.BossInfo(new RenderGameOverlayEvent(Animation.getPartialTickTime(), res), + BOSSINFO, bossInfo, x, y, increment); + MinecraftForge.EVENT_BUS.post(evt); + return evt; + } + + public static void bossBarRenderPost(ScaledResolution res) + { + MinecraftForge.EVENT_BUS.post(new RenderGameOverlayEvent.Post(new RenderGameOverlayEvent(Animation.getPartialTickTime(), res), BOSSINFO)); + } } diff --git a/src/main/java/net/minecraftforge/client/GuiIngameForge.java b/src/main/java/net/minecraftforge/client/GuiIngameForge.java index 2b3140382f..9cfc6c2c9b 100644 --- a/src/main/java/net/minecraftforge/client/GuiIngameForge.java +++ b/src/main/java/net/minecraftforge/client/GuiIngameForge.java @@ -23,17 +23,17 @@ import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.IAttributeInstance; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.MobEffects; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.potion.Potion; import net.minecraft.scoreboard.ScoreObjective; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.FoodStats; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.common.ForgeHooks; @@ -88,8 +88,8 @@ public class GuiIngameForge extends GuiIngame eventParent = new RenderGameOverlayEvent(partialTicks, res); int width = res.getScaledWidth(); int height = res.getScaledHeight(); - renderHealthMount = mc.thePlayer.ridingEntity instanceof EntityLivingBase; - renderFood = mc.thePlayer.ridingEntity == null; + renderHealthMount = mc.thePlayer.getRidingEntity() instanceof EntityLivingBase; + renderFood = mc.thePlayer.getRidingEntity() == null; renderJumpBar = mc.thePlayer.isRidingHorse(); right_height = 39; @@ -107,25 +107,27 @@ public class GuiIngameForge extends GuiIngame } else { - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GlStateManager.enableDepth(); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); } if (renderHelmet) renderHelmet(res, partialTicks); - if (renderPortal && !mc.thePlayer.isPotionActive(Potion.confusion)) + if (renderPortal && !mc.thePlayer.isPotionActive(MobEffects.confusion)) { renderPortal(res, partialTicks); } - if (renderHotbar) renderTooltip(res, partialTicks); + if (renderHotbar) renderHotbar(res, partialTicks); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); zLevel = -90.0F; rand.setSeed((long)(updateCounter * 312871)); - if (renderCrosshairs) renderCrosshairs(width, height); + if (renderCrosshairs) renderCrosshairs(partialTicks); if (renderBossHealth) renderBossHealth(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); if (this.mc.playerController.shouldDrawHUD() && this.mc.getRenderViewEntity() instanceof EntityPlayer) { if (renderHealth) renderHealth(width, height); @@ -134,6 +136,7 @@ public class GuiIngameForge extends GuiIngame if (renderHealthMount) renderHealthMount(width, height); if (renderAir) renderAir(width, height); } + renderSleepFade(width, height); if (renderJumpBar) @@ -145,9 +148,11 @@ public class GuiIngameForge extends GuiIngame renderExperience(width, height); } - renderToolHightlight(res); + renderToolHighlight(res); renderHUDText(width, height); + renderPotionIcons(res); renderRecordOverlay(width, height, partialTicks); + renderSubtitles(res); renderTitle(width, height, partialTicks); @@ -185,31 +190,38 @@ public class GuiIngameForge extends GuiIngame return res; } - protected void renderCrosshairs(int width, int height) + protected void renderCrosshairs(float partialTicks) { if (pre(CROSSHAIRS)) return; - if (this.showCrosshair()) - { - bind(Gui.icons); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, 1, 0); - GlStateManager.enableAlpha(); - drawTexturedModalRect(width / 2 - 7, height / 2 - 7, 0, 0, 16, 16); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - GlStateManager.disableBlend(); - } + bind(Gui.icons); + GlStateManager.enableBlend(); + super.renderAttackIndicator(partialTicks, res); post(CROSSHAIRS); } - @Override + protected void renderPotionIcons(ScaledResolution resolution) + { + if (pre(POTION_ICONS)) return; + super.renderPotionEffects(resolution); + post(POTION_ICONS); + } + + protected void renderSubtitles(ScaledResolution resolution) + { + if (pre(SUBTITLES)) return; + this.overlaySubtitle.renderSubtitles(res); + post(SUBTITLES); + } + + //@Override protected void renderBossHealth() { if (pre(BOSSHEALTH)) return; bind(Gui.icons); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); mc.mcProfiler.startSection("bossHealth"); GlStateManager.enableBlend(); - super.renderBossHealth(); + this.overlayBoss.renderBossHealth(); GlStateManager.disableBlend(); mc.mcProfiler.endSection(); post(BOSSHEALTH); @@ -284,7 +296,7 @@ public class GuiIngameForge extends GuiIngame } @Override - protected void renderTooltip(ScaledResolution res, float partialTicks) + protected void renderHotbar(ScaledResolution res, float partialTicks) { if (pre(HOTBAR)) return; @@ -294,7 +306,7 @@ public class GuiIngameForge extends GuiIngame } else { - super.renderTooltip(res, partialTicks); + super.renderHotbar(res, partialTicks); } post(HOTBAR); @@ -359,9 +371,9 @@ public class GuiIngameForge extends GuiIngame this.playerHealth = health; int healthLast = this.lastPlayerHealth; - IAttributeInstance attrMaxHealth = player.getEntityAttribute(SharedMonsterAttributes.maxHealth); + IAttributeInstance attrMaxHealth = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); float healthMax = (float)attrMaxHealth.getAttributeValue(); - float absorb = player.getAbsorptionAmount(); + float absorb = MathHelper.ceiling_float_int(player.getAbsorptionAmount()); int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F); int rowHeight = Math.max(10 - (healthRows - 2), 3); @@ -374,7 +386,7 @@ public class GuiIngameForge extends GuiIngame if (rowHeight != 10) left_height += 10 - rowHeight; int regen = -1; - if (player.isPotionActive(Potion.regeneration)) + if (player.isPotionActive(MobEffects.regeneration)) { regen = updateCounter % 25; } @@ -382,8 +394,8 @@ public class GuiIngameForge extends GuiIngame final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0); final int BACKGROUND = (highlight ? 25 : 16); int MARGIN = 16; - if (player.isPotionActive(Potion.poison)) MARGIN += 36; - else if (player.isPotionActive(Potion.wither)) MARGIN += 72; + if (player.isPotionActive(MobEffects.poison)) MARGIN += 36; + else if (player.isPotionActive(MobEffects.wither)) MARGIN += 72; float absorbRemaining = absorb; for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) @@ -409,10 +421,15 @@ public class GuiIngameForge extends GuiIngame if (absorbRemaining > 0.0F) { if (absorbRemaining == absorb && absorb % 2.0F == 1.0F) + { drawTexturedModalRect(x, y, MARGIN + 153, TOP, 9, 9); //17 + absorbRemaining -= 1.0F; + } else + { drawTexturedModalRect(x, y, MARGIN + 144, TOP, 9, 9); //16 - absorbRemaining -= 2.0F; + absorbRemaining -= 2.0F; + } } else { @@ -450,21 +467,21 @@ public class GuiIngameForge extends GuiIngame int x = left - i * 8 - 9; int y = top; int icon = 16; - byte backgound = 0; + byte background = 0; - if (mc.thePlayer.isPotionActive(Potion.hunger)) + if (mc.thePlayer.isPotionActive(MobEffects.hunger)) { icon += 36; - backgound = 13; + background = 13; } - if (unused) backgound = 1; //Probably should be a += 1 but vanilla never uses this + if (unused) background = 1; //Probably should be a += 1 but vanilla never uses this if (player.getFoodStats().getSaturationLevel() <= 0.0F && updateCounter % (level * 3 + 1) == 0) { y = top + (rand.nextInt(3) - 1); } - drawTexturedModalRect(x, y, 16 + backgound * 9, 27, 9, 9); + drawTexturedModalRect(x, y, 16 + background * 9, 27, 9, 9); if (unused) { @@ -586,7 +603,7 @@ public class GuiIngameForge extends GuiIngame post(JUMPBAR); } - protected void renderToolHightlight(ScaledResolution res) + protected void renderToolHighlight(ScaledResolution res) { if (this.mc.gameSettings.heldItemTooltips && !this.mc.playerController.isSpectator()) { @@ -596,7 +613,7 @@ public class GuiIngameForge extends GuiIngame { String name = this.highlightingItemStack.getDisplayName(); if (this.highlightingItemStack.hasDisplayName()) - name = EnumChatFormatting.ITALIC + name; + name = TextFormatting.ITALIC + name; name = this.highlightingItemStack.getItem().getHighlightTip(this.highlightingItemStack, name); @@ -610,7 +627,7 @@ public class GuiIngameForge extends GuiIngame GlStateManager.pushMatrix(); GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); FontRenderer font = highlightingItemStack.getItem().getFontRenderer(highlightingItemStack); if (font != null) { @@ -631,7 +648,7 @@ public class GuiIngameForge extends GuiIngame } else if (this.mc.thePlayer.isSpectator()) { - this.spectatorGui.func_175263_a(res); + this.spectatorGui.renderSelectedItem(res); } } @@ -704,7 +721,7 @@ public class GuiIngameForge extends GuiIngame GlStateManager.pushMatrix(); GlStateManager.translate((float)(width / 2), (float)(height - 68), 0.0F); GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); int color = (recordIsPlaying ? Color.HSBtoRGB(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE); fontrenderer.drawString(recordPlaying, -fontrenderer.getStringWidth(recordPlaying) / 2, -4, color | (opacity << 24)); GlStateManager.disableBlend(); @@ -717,18 +734,18 @@ public class GuiIngameForge extends GuiIngame protected void renderTitle(int width, int height, float partialTicks) { - if (field_175195_w > 0) + if (titlesTimer > 0) { mc.mcProfiler.startSection("titleAndSubtitle"); - float age = (float)this.field_175195_w - partialTicks; + float age = (float)this.titlesTimer - partialTicks; int opacity = 255; - if (field_175195_w > field_175193_B + field_175192_A) + if (titlesTimer > titleFadeOut + titleDisplayTime) { - float f3 = (float)(field_175199_z + field_175192_A + field_175193_B) - age; - opacity = (int)(f3 * 255.0F / (float)field_175199_z); + float f3 = (float)(titleFadeIn + titleDisplayTime + titleFadeOut) - age; + opacity = (int)(f3 * 255.0F / (float)titleFadeIn); } - if (field_175195_w <= field_175193_B) opacity = (int)(age * 255.0F / (float)this.field_175193_B); + if (titlesTimer <= titleFadeOut) opacity = (int)(age * 255.0F / (float)this.titleFadeOut); opacity = MathHelper.clamp_int(opacity, 0, 255); @@ -737,15 +754,15 @@ public class GuiIngameForge extends GuiIngame GlStateManager.pushMatrix(); GlStateManager.translate((float)(width / 2), (float)(height / 2), 0.0F); GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.pushMatrix(); GlStateManager.scale(4.0F, 4.0F, 4.0F); int l = opacity << 24 & -16777216; - this.getFontRenderer().drawString(this.field_175201_x, (float)(-this.getFontRenderer().getStringWidth(this.field_175201_x) / 2), -10.0F, 16777215 | l, true); + this.getFontRenderer().drawString(this.displayedTitle, (float)(-this.getFontRenderer().getStringWidth(this.displayedTitle) / 2), -10.0F, 16777215 | l, true); GlStateManager.popMatrix(); GlStateManager.pushMatrix(); GlStateManager.scale(2.0F, 2.0F, 2.0F); - this.getFontRenderer().drawString(this.field_175200_y, (float)(-this.getFontRenderer().getStringWidth(this.field_175200_y) / 2), 5.0F, 16777215 | l, true); + this.getFontRenderer().drawString(this.displayedSubTitle, (float)(-this.getFontRenderer().getStringWidth(this.displayedSubTitle) / 2), 5.0F, 16777215 | l, true); GlStateManager.popMatrix(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); @@ -763,7 +780,7 @@ public class GuiIngameForge extends GuiIngame if (MinecraftForge.EVENT_BUS.post(event)) return; GlStateManager.pushMatrix(); - GlStateManager.translate((float)event.posX, (float)event.posY, 0.0F); + GlStateManager.translate((float) event.getPosX(), (float) event.getPosY(), 0.0F); persistantChatGUI.drawChat(updateCounter); GlStateManager.popMatrix(); @@ -793,7 +810,7 @@ public class GuiIngameForge extends GuiIngame protected void renderHealthMount(int width, int height) { EntityPlayer player = (EntityPlayer)mc.getRenderViewEntity(); - Entity tmp = player.ridingEntity; + Entity tmp = player.getRidingEntity(); if (!(tmp instanceof EntityLivingBase)) return; bind(icons); diff --git a/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java b/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java index b65665f685..c5ed224d56 100644 --- a/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java +++ b/src/main/java/net/minecraftforge/client/ItemModelMesherForge.java @@ -8,9 +8,9 @@ import com.google.common.collect.Maps; import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.procedure.TIntObjectProcedure; import net.minecraft.client.renderer.ItemModelMesher; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ModelManager; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; /** diff --git a/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java b/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java index 53801cb18a..5315c81fb2 100644 --- a/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java +++ b/src/main/java/net/minecraftforge/client/MinecraftForgeClient.java @@ -9,8 +9,8 @@ import java.util.BitSet; import java.util.concurrent.TimeUnit; import net.minecraft.client.renderer.RegionRenderCache; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.apache.commons.lang3.tuple.Pair; @@ -26,7 +26,7 @@ public class MinecraftForgeClient return ForgeHooksClient.renderPass; } - public static EnumWorldBlockLayer getRenderLayer() + public static BlockRenderLayer getRenderLayer() { return ForgeHooksClient.renderLayer.get(); } diff --git a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java index 8f57af949f..4639fae3af 100644 --- a/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ClientChatReceivedEvent.java @@ -1,23 +1,38 @@ package net.minecraftforge.client.event; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; @Cancelable public class ClientChatReceivedEvent extends Event { - public IChatComponent message; + private ITextComponent message; + private final byte type; + public ClientChatReceivedEvent(byte type, ITextComponent message) + { + this.type = type; + this.setMessage(message); + } + + public ITextComponent getMessage() + { + return message; + } + + public void setMessage(ITextComponent message) + { + this.message = message; + } + /** * Introduced in 1.8: * 0 : Standard Text Message * 1 : 'System' message, displayed as standard text. * 2 : 'Status' message, displayed above action bar, where song notifications are. */ - public final byte type; - public ClientChatReceivedEvent(byte type, IChatComponent message) + public byte getType() { - this.type = type; - this.message = message; + return type; } } diff --git a/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java b/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java index 242fb3d541..047c2ce486 100644 --- a/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java +++ b/src/main/java/net/minecraftforge/client/event/DrawBlockHighlightEvent.java @@ -3,28 +3,30 @@ package net.minecraftforge.client.event; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.client.renderer.RenderGlobal; @Cancelable public class DrawBlockHighlightEvent extends Event { - public final RenderGlobal context; - public final EntityPlayer player; - public final MovingObjectPosition target; - public final int subID; - public final ItemStack currentItem; - public final float partialTicks; - - public DrawBlockHighlightEvent(RenderGlobal context, EntityPlayer player, MovingObjectPosition target, int subID, ItemStack currentItem, float partialTicks) + private final RenderGlobal context; + private final EntityPlayer player; + private final RayTraceResult target; + private final int subID; + private final float partialTicks; + + public DrawBlockHighlightEvent(RenderGlobal context, EntityPlayer player, RayTraceResult target, int subID, float partialTicks) { this.context = context; this.player = player; this.target = target; this.subID = subID; - this.currentItem = currentItem; this.partialTicks= partialTicks; } + public RenderGlobal getContext() { return context; } + public EntityPlayer getPlayer() { return player; } + public RayTraceResult getTarget() { return target; } + public int getSubID() { return subID; } + public float getPartialTicks() { return partialTicks; } } diff --git a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java index 1f23314ac5..4f9a93aa12 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java @@ -1,6 +1,6 @@ package net.minecraftforge.client.event; -import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.entity.Entity; import net.minecraftforge.fml.common.eventhandler.Cancelable; @@ -12,31 +12,61 @@ import net.minecraftforge.fml.common.eventhandler.Event; */ public abstract class EntityViewRenderEvent extends Event { - public final EntityRenderer renderer; - public final Entity entity; - public final Block block; - public final double renderPartialTicks; + private final EntityRenderer renderer; + private final Entity entity; + private final IBlockState state; + private final double renderPartialTicks; - public EntityViewRenderEvent(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks) + public EntityViewRenderEvent(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks) { this.renderer = renderer; this.entity = entity; - this.block = block; + this.state = state; this.renderPartialTicks = renderPartialTicks; } - /** + public EntityRenderer getRenderer() + { + return renderer; + } + + public Entity getEntity() + { + return entity; + } + + public IBlockState getState() + { + return state; + } + + public double getRenderPartialTicks() + { + return renderPartialTicks; + } + + /** * Event that allows any feature to customize the fog density the player sees. * NOTE: In order to make this event have an effect, you must cancel the event */ @Cancelable public static class FogDensity extends EntityViewRenderEvent { - public float density; + private float density; - public FogDensity(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks, float density) + public FogDensity(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float density) + { + super(renderer, entity, state, renderPartialTicks); + this.setDensity(density); + } + + public float getDensity() + { + return density; + } + + public void setDensity(float density) { - super(renderer, entity, block, renderPartialTicks); this.density = density; } } @@ -47,15 +77,25 @@ public abstract class EntityViewRenderEvent extends Event @HasResult public static class RenderFogEvent extends EntityViewRenderEvent { - public final int fogMode; - public final float farPlaneDistance; + private final int fogMode; + private final float farPlaneDistance; - public RenderFogEvent(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks, int fogMode, float farPlaneDistance) + public RenderFogEvent(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, int fogMode, float farPlaneDistance) { - super(renderer, entity, block, renderPartialTicks); + super(renderer, entity, state, renderPartialTicks); this.fogMode = fogMode; this.farPlaneDistance = farPlaneDistance; } + + public int getFogMode() + { + return fogMode; + } + + public float getFarPlaneDistance() + { + return farPlaneDistance; + } } /** @@ -64,17 +104,24 @@ public abstract class EntityViewRenderEvent extends Event */ public static class FogColors extends EntityViewRenderEvent { - public float red; - public float green; - public float blue; + private float red; + private float green; + private float blue; - public FogColors(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks, float red, float green, float blue) + public FogColors(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float red, float green, float blue) { - super(renderer, entity, block, renderPartialTicks); - this.red = red; - this.green = green; - this.blue = blue; + super(renderer, entity, state, renderPartialTicks); + this.setRed(red); + this.setGreen(green); + this.setBlue(blue); } + + public float getRed() { return red; } + public void setRed(float red) { this.red = red; } + public float getGreen() { return green; } + public void setGreen(float green) { this.green = green; } + public float getBlue() { return blue; } + public void setBlue(float blue) { this.blue = blue; } } /** @@ -82,17 +129,24 @@ public abstract class EntityViewRenderEvent extends Event */ public static class CameraSetup extends EntityViewRenderEvent { - public float yaw; - public float pitch; - public float roll; + private float yaw; + private float pitch; + private float roll; - public CameraSetup(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks, float yaw, float pitch, float roll) + public CameraSetup(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float yaw, float pitch, float roll) { - super(renderer, entity, block, renderPartialTicks); - this.yaw = yaw; - this.pitch = pitch; - this.roll = roll; + super(renderer, entity, state, renderPartialTicks); + this.setYaw(yaw); + this.setPitch(pitch); + this.setRoll(roll); } + + public float getYaw() { return yaw; } + public void setYaw(float yaw) { this.yaw = yaw; } + public float getPitch() { return pitch; } + public void setPitch(float pitch) { this.pitch = pitch; } + public float getRoll() { return roll; } + public void setRoll(float roll) { this.roll = roll; } } /** @@ -103,8 +157,8 @@ public abstract class EntityViewRenderEvent extends Event { private float fov; - public FOVModifier(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks, float fov) { - super(renderer, entity, block, renderPartialTicks); + public FOVModifier(EntityRenderer renderer, Entity entity, IBlockState state, double renderPartialTicks, float fov) { + super(renderer, entity, state, renderPartialTicks); this.setFOV(fov); } diff --git a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java index 91863999ce..1c7bb60ffe 100644 --- a/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/FOVUpdateEvent.java @@ -9,14 +9,34 @@ import net.minecraftforge.fml.common.eventhandler.Event; */ public class FOVUpdateEvent extends Event { - public final EntityPlayer entity; - public final float fov; - public float newfov; + private final EntityPlayer entity; + private final float fov; + private float newfov; public FOVUpdateEvent(EntityPlayer entity, float fov) { this.entity = entity; this.fov = fov; - this.newfov = fov; + this.setNewfov(fov); + } + + public EntityPlayer getEntity() + { + return entity; + } + + public float getFov() + { + return fov; + } + + public float getNewfov() + { + return newfov; + } + + public void setNewfov(float newfov) + { + this.newfov = newfov; } } diff --git a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java index 85e2d247a4..362acfd2d5 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiOpenEvent.java @@ -14,8 +14,18 @@ import net.minecraft.client.gui.GuiScreen; @Cancelable public class GuiOpenEvent extends Event { - public GuiScreen gui; + private GuiScreen gui; public GuiOpenEvent(GuiScreen gui) + { + this.setGui(gui); + } + + public GuiScreen getGui() + { + return gui; + } + + public void setGui(GuiScreen gui) { this.gui = gui; } diff --git a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java b/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java index b38feff7d0..1017218a29 100644 --- a/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java +++ b/src/main/java/net/minecraftforge/client/event/GuiScreenEvent.java @@ -22,29 +22,44 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiScreenEvent extends Event { - /** - * The GuiScreen object generating this event. - */ - public final GuiScreen gui; + private final GuiScreen gui; public GuiScreenEvent(GuiScreen gui) { this.gui = gui; } + /** + * The GuiScreen object generating this event. + */ + public GuiScreen getGui() + { + return gui; + } + public static class InitGuiEvent extends GuiScreenEvent { - /** - * The {@code buttonList} field from the GuiScreen object referenced by {@code gui}. - */ - public List buttonList; + private List buttonList; public InitGuiEvent(GuiScreen gui, List buttonList) { super(gui); + this.setButtonList(buttonList); + } + + /** + * The {@code buttonList} field from the GuiScreen object referenced by {@code gui}. + */ + public List getButtonList() + { + return buttonList; + } + + public void setButtonList(List buttonList) + { this.buttonList = buttonList; } - + /** * This event fires just after initializing {@code GuiScreen.mc}, {@code GuiScreen.fontRendererObj}, * {@code GuiScreen.width}, and {@code GuiScreen.height}, and just before calling {@code GuiScreen.buttonList.clear()} @@ -78,18 +93,9 @@ public class GuiScreenEvent extends Event public static class DrawScreenEvent extends GuiScreenEvent { - /** - * The x coordinate of the mouse pointer on the screen. - */ - public final int mouseX; - /** - * The y coordinate of the mouse pointer on the screen. - */ - public final int mouseY; - /** - * Partial render ticks elapsed. - */ - public final float renderPartialTicks; + private final int mouseX; + private final int mouseY; + private final float renderPartialTicks; public DrawScreenEvent(GuiScreen gui, int mouseX, int mouseY, float renderPartialTicks) { @@ -98,7 +104,31 @@ public class GuiScreenEvent extends Event this.mouseY = mouseY; this.renderPartialTicks = renderPartialTicks; } - + + /** + * The x coordinate of the mouse pointer on the screen. + */ + public int getMouseX() + { + return mouseX; + } + + /** + * The y coordinate of the mouse pointer on the screen. + */ + public int getMouseY() + { + return mouseY; + } + + /** + * Partial render ticks elapsed. + */ + public float getRenderPartialTicks() + { + return renderPartialTicks; + } + /** * This event fires just before {@code GuiScreen.drawScreen()} is called. * Cancel this event to skip {@code GuiScreen.drawScreen()}. @@ -159,25 +189,59 @@ public class GuiScreenEvent extends Event return mouseY; } } + + /** + * This event fires in {@code InventoryEffectRenderer.updateActivePotionEffects()} + * when potion effects are active and the gui wants to move over. + * Cancel this event to prevent the Gui from being moved. + */ + @Cancelable + public static class PotionShiftEvent extends GuiScreenEvent + { + public PotionShiftEvent(GuiScreen gui) + { + super(gui); + } + } public static class ActionPerformedEvent extends GuiScreenEvent { - /** - * The button that was clicked. - */ - public GuiButton button; - /** - * A COPY of the {@code buttonList} field from the GuiScreen referenced by {@code gui}. - */ - public List buttonList; + private GuiButton button; + private List buttonList; public ActionPerformedEvent(GuiScreen gui, GuiButton button, List buttonList) { super(gui); - this.button = button; - this.buttonList = new ArrayList(buttonList); + this.setButton(button); + this.setButtonList(new ArrayList(buttonList)); } - + + /** + * The button that was clicked. + */ + public GuiButton getButton() + { + return button; + } + + public void setButton(GuiButton button) + { + this.button = button; + } + + /** + * A COPY of the {@code buttonList} field from the GuiScreen referenced by {@code gui}. + */ + public List getButtonList() + { + return buttonList; + } + + public void setButtonList(List buttonList) + { + this.buttonList = buttonList; + } + /** * This event fires once it has been determined that a GuiButton object has been clicked. * Cancel this event to bypass {@code GuiScreen.actionPerformed()}. diff --git a/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java b/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java index d4ac470b04..dd20b202dc 100644 --- a/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java +++ b/src/main/java/net/minecraftforge/client/event/ModelBakeEvent.java @@ -1,10 +1,9 @@ package net.minecraftforge.client.event; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.util.IRegistry; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ModelManager; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.util.registry.IRegistry; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.eventhandler.Event; @@ -12,25 +11,32 @@ import net.minecraftforge.fml.common.eventhandler.Event; * Fired when the ModelManager is notified of the resource manager reloading. * Called after model registry is setup, but before it's passed to BlockModelShapes. */ +// TODO: try to merge with ICustomModelLoader public class ModelBakeEvent extends Event { - public final ModelManager modelManager; - public final IRegistry modelRegistry; - @Deprecated - public final ModelBakery modelBakery; - public final ModelLoader modelLoader; - - @Deprecated - public ModelBakeEvent(ModelManager modelManager, IRegistry modelRegistry, ModelBakery modelBakery) - { - this(modelManager, modelRegistry, (ModelLoader)modelBakery); - } + private final ModelManager modelManager; + private final IRegistry modelRegistry; + private final ModelLoader modelLoader; public ModelBakeEvent(ModelManager modelManager, IRegistry modelRegistry, ModelLoader modelLoader) { this.modelManager = modelManager; this.modelRegistry = modelRegistry; - this.modelBakery = modelLoader; this.modelLoader = modelLoader; } + + public ModelManager getModelManager() + { + return modelManager; + } + + public IRegistry getModelRegistry() + { + return modelRegistry; + } + + public ModelLoader getModelLoader() + { + return modelLoader; + } } diff --git a/src/main/java/net/minecraftforge/client/event/MouseEvent.java b/src/main/java/net/minecraftforge/client/event/MouseEvent.java index b4e5782bf9..3652bcf2ee 100644 --- a/src/main/java/net/minecraftforge/client/event/MouseEvent.java +++ b/src/main/java/net/minecraftforge/client/event/MouseEvent.java @@ -12,14 +12,14 @@ import net.minecraftforge.fml.common.eventhandler.Event; @Cancelable public class MouseEvent extends Event { - public final int x; - public final int y; - public final int dx; - public final int dy; - public final int dwheel; - public final int button; - public final boolean buttonstate; - public final long nanoseconds; + private final int x; + private final int y; + private final int dx; + private final int dy; + private final int dwheel; + private final int button; + private final boolean buttonstate; + private final long nanoseconds; public MouseEvent() { @@ -32,4 +32,13 @@ public class MouseEvent extends Event this.buttonstate = Mouse.getEventButtonState(); this.nanoseconds = Mouse.getEventNanoseconds(); } + + public int getX() { return x; } + public int getY() { return y; } + public int getDx() { return dx; } + public int getDy() { return dy; } + public int getDwheel() { return dwheel; } + public int getButton() { return button; } + public boolean isButtonstate() { return buttonstate; } + public long getNanoseconds() { return nanoseconds; } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java index 97d7d5fdee..12cc88c534 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderBlockOverlayEvent.java @@ -3,7 +3,7 @@ package net.minecraftforge.client.event; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; @@ -12,25 +12,16 @@ import net.minecraftforge.fml.common.eventhandler.Event; */ @Cancelable public class RenderBlockOverlayEvent extends Event { - + public static enum OverlayType { FIRE, BLOCK, WATER } - /** - * The player which the overlay will apply to - */ - public final EntityPlayer player; - public final float renderPartialTicks; - /** - * The type of overlay to occur - */ - public final OverlayType overlayType; - /** - * If the overlay type is BLOCK, then this is the block which the overlay is getting it's icon from - */ - public final IBlockState blockForOverlay; - public final BlockPos blockPos; + private final EntityPlayer player; + private final float renderPartialTicks; + private final OverlayType overlayType; + private final IBlockState blockForOverlay; + private final BlockPos blockPos; @Deprecated public RenderBlockOverlayEvent(EntityPlayer player, float renderPartialTicks, OverlayType type, Block block, int x, int y, int z) @@ -48,4 +39,18 @@ public class RenderBlockOverlayEvent extends Event { } + /** + * The player which the overlay will apply to + */ + public EntityPlayer getPlayer() { return player; } + public float getRenderPartialTicks() { return renderPartialTicks; } + /** + * The type of overlay to occur + */ + public OverlayType getOverlayType() { return overlayType; } + /** + * If the overlay type is BLOCK, then this is the block which the overlay is getting it's icon from + */ + public IBlockState getBlockForOverlay() { return blockForOverlay; } + public BlockPos getBlockPos() { return blockPos; } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java index 0a7671a29e..8dd6ad19c6 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderGameOverlayEvent.java @@ -2,6 +2,7 @@ package net.minecraftforge.client.event; import java.util.ArrayList; +import net.minecraft.world.BossInfoLerping; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; @@ -10,13 +11,29 @@ import net.minecraft.client.gui.ScaledResolution; @Cancelable public class RenderGameOverlayEvent extends Event { + public float getPartialTicks() + { + return partialTicks; + } + + public ScaledResolution getResolution() + { + return resolution; + } + + public ElementType getType() + { + return type; + } + public static enum ElementType { ALL, HELMET, PORTAL, CROSSHAIRS, - BOSSHEALTH, + BOSSHEALTH, // All boss bars + BOSSINFO, // Individual boss bar ARMOR, HEALTH, FOOD, @@ -28,12 +45,14 @@ public class RenderGameOverlayEvent extends Event JUMPBAR, CHAT, PLAYER_LIST, - DEBUG + DEBUG, + POTION_ICONS, + SUBTITLES } - public final float partialTicks; - public final ScaledResolution resolution; - public final ElementType type; + private final float partialTicks; + private final ScaledResolution resolution; + private final ElementType type; public RenderGameOverlayEvent(float partialTicks, ScaledResolution resolution) { @@ -44,8 +63,8 @@ public class RenderGameOverlayEvent extends Event private RenderGameOverlayEvent(RenderGameOverlayEvent parent, ElementType type) { - this.partialTicks = parent.partialTicks; - this.resolution = parent.resolution; + this.partialTicks = parent.getPartialTicks(); + this.resolution = parent.getResolution(); this.type = type; } @@ -66,27 +85,114 @@ public class RenderGameOverlayEvent extends Event @Override public boolean isCancelable(){ return false; } } + public static class BossInfo extends Pre + { + private final BossInfoLerping bossInfo; + private final int x; + private final int y; + private int increment; + public BossInfo(RenderGameOverlayEvent parent, ElementType type, BossInfoLerping bossInfo, int x, int y, int increment) + { + super(parent, type); + this.bossInfo = bossInfo; + this.x = x; + this.y = y; + this.increment = increment; + } + + /** + * @return The {@link BossInfoLerping} currently being rendered + */ + public BossInfoLerping getBossInfo() + { + return bossInfo; + } + + /** + * @return The current x position we are rendering at + */ + public int getX() + { + return x; + } + + /** + * @return The current y position we are rendering at + */ + public int getY() + { + return y; + } + + /** + * @return How much to move down before rendering the next bar + */ + public int getIncrement() + { + return increment; + } + + /** + * Sets the amount to move down before rendering the next bar + * @param increment The increment to set + */ + public void setIncrement(int increment) + { + this.increment = increment; + } + } + public static class Text extends Pre { - public final ArrayList left; - public final ArrayList right; + private final ArrayList left; + private final ArrayList right; public Text(RenderGameOverlayEvent parent, ArrayList left, ArrayList right) { super(parent, ElementType.TEXT); this.left = left; this.right = right; } + + public ArrayList getLeft() + { + return left; + } + + public ArrayList getRight() + { + return right; + } } public static class Chat extends Pre { - public int posX; - public int posY; + private int posX; + private int posY; public Chat(RenderGameOverlayEvent parent, int posX, int posY) { super(parent, ElementType.CHAT); + this.setPosX(posX); + this.setPosY(posY); + } + + public int getPosX() + { + return posX; + } + + public void setPosX(int posX) + { this.posX = posX; + } + + public int getPosY() + { + return posY; + } + + public void setPosY(int posY) + { this.posY = posY; } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java index 0743f8db09..9af3b47581 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderHandEvent.java @@ -7,13 +7,28 @@ import net.minecraft.client.renderer.RenderGlobal; @Cancelable public class RenderHandEvent extends Event { - public final RenderGlobal context; - public final float partialTicks; - public final int renderPass; + private final RenderGlobal context; + private final float partialTicks; + private final int renderPass; public RenderHandEvent(RenderGlobal context, float partialTicks, int renderPass) { this.context = context; this.partialTicks = partialTicks; this.renderPass = renderPass; } + + public RenderGlobal getContext() + { + return context; + } + + public float getPartialTicks() + { + return partialTicks; + } + + public int getRenderPass() + { + return renderPass; + } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java index f394ae5f46..2efabac14c 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderItemInFrameEvent.java @@ -14,9 +14,9 @@ import net.minecraftforge.fml.common.eventhandler.Event; @Cancelable public class RenderItemInFrameEvent extends Event { - public final ItemStack item; - public final EntityItemFrame entityItemFrame; - public final RenderItemFrame renderer; + private final ItemStack item; + private final EntityItemFrame entityItemFrame; + private final RenderItemFrame renderer; public RenderItemInFrameEvent(EntityItemFrame itemFrame, RenderItemFrame renderItemFrame) { @@ -24,4 +24,19 @@ public class RenderItemInFrameEvent extends Event entityItemFrame = itemFrame; renderer = renderItemFrame; } + + public ItemStack getItem() + { + return item; + } + + public EntityItemFrame getEntityItemFrame() + { + return entityItemFrame; + } + + public RenderItemFrame getRenderer() + { + return renderer; + } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java index d7491eca60..9c9bc51d22 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderLivingEvent.java @@ -2,18 +2,18 @@ package net.minecraftforge.client.event; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.entity.EntityLivingBase; public abstract class RenderLivingEvent extends Event { - public final EntityLivingBase entity; - public final RendererLivingEntity renderer; - public final double x; - public final double y; - public final double z; + private final EntityLivingBase entity; + private final RenderLivingBase renderer; + private final double x; + private final double y; + private final double z; - public RenderLivingEvent(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z) + public RenderLivingEvent(EntityLivingBase entity, RenderLivingBase renderer, double x, double y, double z) { this.entity = entity; this.renderer = renderer; @@ -21,29 +21,35 @@ public abstract class RenderLivingEvent extends Even this.y = y; this.z = z; } - + + public EntityLivingBase getEntity() { return entity; } + public RenderLivingBase getRenderer() { return renderer; } + public double getX() { return x; } + public double getY() { return y; } + public double getZ() { return z; } + @Cancelable public static class Pre extends RenderLivingEvent { - public Pre(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + public Pre(EntityLivingBase entity, RenderLivingBase renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } } public static class Post extends RenderLivingEvent { - public Post(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + public Post(EntityLivingBase entity, RenderLivingBase renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } } public abstract static class Specials extends RenderLivingEvent { - public Specials(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + public Specials(EntityLivingBase entity, RenderLivingBase renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } @Cancelable public static class Pre extends Specials { - public Pre(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + public Pre(EntityLivingBase entity, RenderLivingBase renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } } public static class Post extends Specials { - public Post(EntityLivingBase entity, RendererLivingEntity renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } + public Post(EntityLivingBase entity, RenderLivingBase renderer, double x, double y, double z){ super(entity, renderer, x, y, z); } } } } diff --git a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java index 30ec16ccec..088ac8de3c 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderPlayerEvent.java @@ -8,11 +8,11 @@ import net.minecraftforge.event.entity.player.PlayerEvent; public abstract class RenderPlayerEvent extends PlayerEvent { - public final RenderPlayer renderer; - public final float partialRenderTick; - public final double x; - public final double y; - public final double z; + private final RenderPlayer renderer; + private final float partialRenderTick; + private final double x; + private final double y; + private final double z; public RenderPlayerEvent(EntityPlayer player, RenderPlayer renderer, float partialRenderTick, double x, double y, double z) { @@ -24,6 +24,12 @@ public abstract class RenderPlayerEvent extends PlayerEvent this.z = z; } + public RenderPlayer getRenderer() { return renderer; } + public float getPartialRenderTick() { return partialRenderTick; } + public double getX() { return x; } + public double getY() { return y; } + public double getZ() { return z; } + @Cancelable public static class Pre extends RenderPlayerEvent { @@ -50,10 +56,17 @@ public abstract class RenderPlayerEvent extends PlayerEvent @Cancelable public static class Pre extends Specials { - public boolean renderHelmet = true; - public boolean renderCape = true; - public boolean renderItem = true; + private boolean renderHelmet = true; + private boolean renderCape = true; + private boolean renderItem = true; public Pre(EntityPlayer player, RenderPlayer renderer, float partialTicks){ super(player, renderer, partialTicks); } + + public boolean shouldRenderHelmet() { return renderHelmet; } + public void setRenderHelmet(boolean renderHelmet) { this.renderHelmet = renderHelmet; } + public boolean shouldRenderCape() { return renderCape; } + public void setRenderCape(boolean renderCape) { this.renderCape = renderCape; } + public boolean shouldRenderItem() { return renderItem; } + public void setRenderItem(boolean renderItem) { this.renderItem = renderItem; } } public static class Post extends Specials @@ -65,18 +78,38 @@ public abstract class RenderPlayerEvent extends PlayerEvent @Deprecated public static class SetArmorModel extends RenderPlayerEvent { - /** - * Setting this to any value besides -1 will result in the function being - * Immediately exited with the return value specified. - */ - public int result = -1; - public final int slot; - public final ItemStack stack; + private int result = -1; + private final int slot; + private final ItemStack stack; public SetArmorModel(EntityPlayer player, RenderPlayer renderer, int slot, float partialTick, ItemStack stack) { super(player, renderer, partialTick, 0D, 0D, 0D); this.slot = slot; this.stack = stack; } + + /** + * Setting this to any value besides -1 will result in the function being + * Immediately exited with the return value specified. + */ + public int getResultValue() + { + return result; + } + + public void setResult(int result) + { + this.result = result; + } + + public int getSlot() + { + return slot; + } + + public ItemStack getStack() + { + return stack; + } } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/RenderWorldEvent.java b/src/main/java/net/minecraftforge/client/event/RenderWorldEvent.java deleted file mode 100644 index 1e3d1b026b..0000000000 --- a/src/main/java/net/minecraftforge/client/event/RenderWorldEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.minecraftforge.client.event; - -import net.minecraftforge.fml.common.eventhandler.Event; -//import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.world.ChunkCache; - -public abstract class RenderWorldEvent extends Event -{ - public final WorldRenderer renderer; - public final ChunkCache chunkCache; - //public final RenderBlocks renderBlocks; - public final int pass; - - public RenderWorldEvent(WorldRenderer renderer, ChunkCache chunkCache, /*RenderBlocks renderBlocks,*/ int pass) - { - this.renderer = renderer; - this.chunkCache = chunkCache; - //this.renderBlocks = renderBlocks; - this.pass = pass; - } - - /** - * Fired when 16x16x16 chunk area is being redrawn. - * Fired after GL state is setup, before tessellator is started. - */ - public static class Pre extends RenderWorldEvent - { - public Pre(WorldRenderer renderer, ChunkCache chunkCache, /*RenderBlocks renderBlocks,*/ int pass){ super(renderer, chunkCache, /*renderBlocks,*/ pass); } - } - - /** - * Fired after the tessellator is stopped, before the display list is ended. - */ - public static class Post extends RenderWorldEvent - { - public Post(WorldRenderer renderer, ChunkCache chunkCache, /*RenderBlocks renderBlocks,*/ int pass){ super(renderer, chunkCache, /*renderBlocks,*/ pass); } - } -} diff --git a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java index 0d92024e12..646fd23fbf 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderWorldLastEvent.java @@ -5,11 +5,21 @@ import net.minecraft.client.renderer.RenderGlobal; public class RenderWorldLastEvent extends Event { - public final RenderGlobal context; - public final float partialTicks; + private final RenderGlobal context; + private final float partialTicks; public RenderWorldLastEvent(RenderGlobal context, float partialTicks) { this.context = context; this.partialTicks = partialTicks; } + + public RenderGlobal getContext() + { + return context; + } + + public float getPartialTicks() + { + return partialTicks; + } } diff --git a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java index 21af9e192d..b943b7b8d1 100644 --- a/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java +++ b/src/main/java/net/minecraftforge/client/event/TextureStitchEvent.java @@ -6,13 +6,18 @@ import net.minecraft.client.renderer.texture.TextureMap; public class TextureStitchEvent extends Event { - public final TextureMap map; + private final TextureMap map; public TextureStitchEvent(TextureMap map) { this.map = map; } + public TextureMap getMap() + { + return map; + } + /** * Fired when the TextureMap is told to refresh it's stitched texture. * Called after the Stitched list is cleared, but before any blocks or items diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlayBackgroundMusicEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlayBackgroundMusicEvent.java deleted file mode 100644 index 77a2ad8dd0..0000000000 --- a/src/main/java/net/minecraftforge/client/event/sound/PlayBackgroundMusicEvent.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.minecraftforge.client.event.sound; - -import net.minecraft.client.audio.SoundManager; -import net.minecraft.client.audio.SoundPoolEntry; - -/** - * Raised when the SoundManager tries to play a Background Music file, - * If you return null from this function it will prevent the sound from being played, - * you can return a different entry if you want to change the sound being played. - */ -@Deprecated // Remove in 1.8 -public class PlayBackgroundMusicEvent extends SoundResultEvent -{ - public PlayBackgroundMusicEvent(SoundManager manager, SoundPoolEntry entry) - { super(manager, entry, null, 0.0f, 0.0f); } -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectEvent.java deleted file mode 100644 index 7c7268fcc2..0000000000 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.minecraftforge.client.event.sound; - -import net.minecraft.client.audio.SoundManager; -import net.minecraft.client.audio.SoundPoolEntry; - -@Deprecated //Remove in 1.8 -public class PlaySoundEffectEvent extends SoundResultEvent -{ - public PlaySoundEffectEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch) - { super(manager, source, name, volume, pitch); } -} diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectSourceEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectSourceEvent.java deleted file mode 100644 index 82b2600862..0000000000 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEffectSourceEvent.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.minecraftforge.client.event.sound; - -import net.minecraft.client.audio.SoundManager; - -@Deprecated //Remove in 1.8 -public class PlaySoundEffectSourceEvent extends SoundEvent -{ - public final SoundManager manager; - public final String name; - public PlaySoundEffectSourceEvent(SoundManager manager, String name) - { - super(manager); - this.manager = manager; - this.name = name; - } -} diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java index d3ae0382fb..8338d25f66 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/PlaySoundEvent.java @@ -1,7 +1,6 @@ package net.minecraftforge.client.event.sound; import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.SoundCategory; import net.minecraft.client.audio.SoundManager; /*** @@ -12,17 +11,35 @@ import net.minecraft.client.audio.SoundManager; */ public class PlaySoundEvent extends SoundEvent { - public final String name; - public final ISound sound; - public final SoundCategory category; - public ISound result; + private final String name; + private final ISound sound; + private ISound result; - public PlaySoundEvent(SoundManager manager, ISound sound, SoundCategory category) + public PlaySoundEvent(SoundManager manager, ISound sound) { super(manager); this.sound = sound; - this.category = category; this.name = sound.getSoundLocation().getResourcePath(); - this.result = sound; + this.setResultSound(sound); + } + + public String getName() + { + return name; + } + + public ISound getSound() + { + return sound; + } + + public ISound getResultSound() + { + return result; + } + + public void setResultSound(ISound result) + { + this.result = result; } } diff --git a/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingEvent.java b/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingEvent.java deleted file mode 100644 index 9dda41e81e..0000000000 --- a/src/main/java/net/minecraftforge/client/event/sound/PlayStreamingEvent.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.minecraftforge.client.event.sound; - -import net.minecraft.client.audio.SoundManager; -import net.minecraft.client.audio.SoundPoolEntry; - -/** - * Raised when the SoundManager tries to play a 'Streaming' file, - * in vanilla it is only the Jukebox that uses this function. - * - * If you return null from this function it will prevent the sound from being played, - * you can return a different entry if you want to change the sound being played. - * - */ -@Deprecated -public class PlayStreamingEvent extends SoundResultEvent -{ - public final float x; - public final float y; - public final float z; - public PlayStreamingEvent(SoundManager manager, SoundPoolEntry source, String name, float x, float y, float z) - { - super(manager, source, name, 0.0f, 0.0f); - this.x = x; - this.y = y; - this.z = z; - } -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java index c13d55b4b4..fa0d258a25 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundEvent.java @@ -3,29 +3,25 @@ package net.minecraftforge.client.event.sound; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.SoundManager; -import net.minecraft.client.audio.SoundPoolEntry; -import net.minecraftforge.common.MinecraftForge; public class SoundEvent extends Event { - public final SoundManager manager; + private final SoundManager manager; public SoundEvent(SoundManager manager) { this.manager = manager; } - @Deprecated - public static SoundPoolEntry getResult(SoundResultEvent event) + public SoundManager getManager() { - MinecraftForge.EVENT_BUS.post(event); - return event.result; + return manager; } public static class SoundSourceEvent extends SoundEvent { - public final ISound sound; - public final String uuid; - public final String name; + private final ISound sound; + private final String uuid; + private final String name; public SoundSourceEvent(SoundManager manager, ISound sound, String uuid) { @@ -34,5 +30,20 @@ public class SoundEvent extends Event this.sound = sound; this.uuid = uuid; } + + public ISound getSound() + { + return sound; + } + + public String getUuid() + { + return uuid; + } + + public String getName() + { + return name; + } } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java index eaff83becb..bcede8ad9f 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundLoadEvent.java @@ -3,16 +3,13 @@ package net.minecraftforge.client.event.sound; import net.minecraft.client.audio.SoundManager; /** - * Raised by the SoundManager.loadSoundSettings, this would be a good place for + * Raised by the SoundManager.loadSoundSettings, this would be a good place for * adding your custom sounds to the SoundPool. */ public class SoundLoadEvent extends SoundEvent { - @Deprecated - public final SoundManager manager; public SoundLoadEvent(SoundManager manager) { super(manager); - this.manager = manager; } } diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundResultEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundResultEvent.java deleted file mode 100644 index c3d431b640..0000000000 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundResultEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.minecraftforge.client.event.sound; - -import net.minecraft.client.audio.SoundManager; -import net.minecraft.client.audio.SoundPoolEntry; - -@Deprecated //Remove in 1.8 -public abstract class SoundResultEvent extends SoundEvent -{ - public final SoundManager manager; - public final SoundPoolEntry source; - public final String name; - public final float volume; - public final float pitch; - public SoundPoolEntry result; - - public SoundResultEvent(SoundManager manager, SoundPoolEntry source, String name, float volume, float pitch) - { - super(manager); - this.manager = manager; - this.source = source; - this.name = name; - this.volume = volume; - this.pitch = pitch; - this.result = source; - } -} diff --git a/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java b/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java index 2c6b454125..ef5cb37ed5 100644 --- a/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java +++ b/src/main/java/net/minecraftforge/client/event/sound/SoundSetupEvent.java @@ -3,16 +3,13 @@ package net.minecraftforge.client.event.sound; import net.minecraft.client.audio.SoundManager; /** - * This event is raised by the SoundManager when it does its first setup of the + * This event is raised by the SoundManager when it does its first setup of the * SoundSystemConfig's codecs, use this function to add your own codecs. */ public class SoundSetupEvent extends SoundEvent { - @Deprecated - public final SoundManager manager; public SoundSetupEvent(SoundManager manager) { super(manager); - this.manager = manager; } } diff --git a/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java b/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java new file mode 100644 index 0000000000..33f533c6cd --- /dev/null +++ b/src/main/java/net/minecraftforge/client/gui/NotificationModUpdateScreen.java @@ -0,0 +1,83 @@ +package net.minecraftforge.client.gui; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiMainMenu; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.ForgeModContainer; +import net.minecraftforge.common.ForgeVersion; +import net.minecraftforge.common.ForgeVersion.Status; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class NotificationModUpdateScreen extends GuiScreen +{ + + private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation("forge", "textures/gui/version_check_icons.png"); + + private final GuiButton modButton; + private Status showNotification = null; + private boolean hasCheckedForUpdates = false; + + public NotificationModUpdateScreen(GuiButton modButton) + { + this.modButton = modButton; + } + + @Override + public void initGui() + { + if (!hasCheckedForUpdates) + { + if (modButton != null) + { + for (ModContainer mod : Loader.instance().getModList()) + { + Status status = ForgeVersion.getResult(mod).status; + if (status == Status.OUTDATED || status == Status.BETA_OUTDATED) + { + // TODO: Needs better visualization, maybe stacked icons + // drawn in a terrace-like pattern? + showNotification = Status.OUTDATED; + } + } + } + hasCheckedForUpdates = true; + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) + { + if (showNotification == null || !showNotification.shouldDraw() || ForgeModContainer.disableVersionCheck) + { + return; + } + + Minecraft.getMinecraft().getTextureManager().bindTexture(VERSION_CHECK_ICONS); + GlStateManager.color(1, 1, 1, 1); + GlStateManager.pushMatrix(); + + int x = modButton.xPosition; + int y = modButton.yPosition; + int w = modButton.width; + int h = modButton.height; + + drawModalRectWithCustomSizedTexture(x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16); + GlStateManager.popMatrix(); + } + + public static NotificationModUpdateScreen init(GuiMainMenu guiMainMenu, GuiButton modButton) + { + NotificationModUpdateScreen notificationModUpdateScreen = new NotificationModUpdateScreen(modButton); + notificationModUpdateScreen.setGuiSize(guiMainMenu.width, guiMainMenu.height); + notificationModUpdateScreen.initGui(); + return notificationModUpdateScreen; + } + +} diff --git a/src/main/java/net/minecraftforge/client/model/Attributes.java b/src/main/java/net/minecraftforge/client/model/Attributes.java index df3581fd4d..c84d24f5ba 100644 --- a/src/main/java/net/minecraftforge/client/model/Attributes.java +++ b/src/main/java/net/minecraftforge/client/model/Attributes.java @@ -33,7 +33,7 @@ public class Attributes int padding = 0; int j = 0; - for(VertexFormatElement firstAttr : (List)first.getElements()) + for(VertexFormatElement firstAttr : first.getElements()) { while(j < second.getElementCount() && second.getElement(j).getUsage() == EnumUsage.PADDING) { diff --git a/src/main/java/net/minecraftforge/client/model/BlockStateLoader.java b/src/main/java/net/minecraftforge/client/model/BlockStateLoader.java index 958a21344a..6657f7a6aa 100644 --- a/src/main/java/net/minecraftforge/client/model/BlockStateLoader.java +++ b/src/main/java/net/minecraftforge/client/model/BlockStateLoader.java @@ -6,12 +6,16 @@ import java.io.InputStreamReader; import java.io.Reader; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.Map.Entry; import net.minecraft.client.renderer.block.model.ModelBlockDefinition; -import net.minecraft.client.resources.model.ModelRotation; +import net.minecraft.client.renderer.block.model.ModelRotation; +import net.minecraft.client.renderer.block.model.Variant; +import net.minecraft.client.renderer.block.model.VariantList; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.FMLLog; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; import org.apache.commons.io.Charsets; import org.apache.commons.io.IOUtils; @@ -20,6 +24,7 @@ import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -55,11 +60,11 @@ public class BlockStateLoader { case 1: // Version 1 ForgeBlockStateV1 v1 = GSON.fromJson(reader, ForgeBlockStateV1.class); - List variants = Lists.newArrayList(); + Map variants = Maps.newHashMap(); for (Entry> entry : v1.variants.asMap().entrySet()) { // Convert Version1 variants into vanilla variants for the ModelBlockDefinition. - List mcVars = Lists.newArrayList(); + List mcVars = Lists.newArrayList(); for (ForgeBlockStateV1.Variant var : entry.getValue()) { boolean uvLock = var.getUvLock().or(false); @@ -68,14 +73,14 @@ public class BlockStateLoader int weight = var.getWeight().or(1); if (var.getModel() != null && var.getSubmodels().size() == 0 && var.getTextures().size() == 0 && var.getCustomData().size() == 0 && var.getState().orNull() instanceof ModelRotation) - mcVars.add(new ModelBlockDefinition.Variant(var.getModel(), (ModelRotation)var.getState().get(), uvLock, weight)); + mcVars.add(new Variant(var.getModel(), (ModelRotation)var.getState().get(), uvLock, weight)); else mcVars.add(new ForgeVariant(var.getModel(), var.getState().or(TRSRTransformation.identity()), uvLock, smooth, gui3d, weight, var.getTextures(), var.getOnlyPartsVariant(), var.getCustomData())); } - variants.add(new ModelBlockDefinition.Variants(entry.getKey(), mcVars)); + variants.put(entry.getKey(), new VariantList(mcVars)); } - return new ModelBlockDefinition(variants); + return new ModelBlockDefinition(variants, null); default: //Unknown version.. try loading it as normal. return vanillaGSON.fromJson(reader, ModelBlockDefinition.class); @@ -104,12 +109,6 @@ public class BlockStateLoader private final ResourceLocation model; private final ImmutableMap customData; - @Deprecated // remove in 1.9 - public SubModel(IModelState state, boolean uvLock, ImmutableMap textures, ResourceLocation model, ImmutableMap customData) - { - this(state, uvLock, true, true, textures, model, customData); - } - public SubModel(IModelState state, boolean uvLock, boolean smooth, boolean gui3d, ImmutableMap textures, ResourceLocation model, ImmutableMap customData) { this.state = state; @@ -128,7 +127,7 @@ public class BlockStateLoader public ImmutableMap getCustomData() { return customData; } } - private static class ForgeVariant extends ModelBlockDefinition.Variant implements ISmartVariant + private static class ForgeVariant extends Variant implements ISmartVariant { private final ImmutableMap textures; private final ImmutableMap parts; @@ -148,67 +147,46 @@ public class BlockStateLoader this.gui3d = gui3d; } - private IModel runModelHooks(IModel base, boolean smooth, boolean gui3d, ImmutableMap textureMap, ImmutableMap customData) + private IModel runModelHooks(IModel base, boolean smooth, boolean gui3d, boolean uvlock, ImmutableMap textureMap, ImmutableMap customData) { - if (!customData.isEmpty() && base instanceof IModelCustomData) - { - base = ((IModelCustomData)base).process(customData); - } - - if (!textureMap.isEmpty() && base instanceof IRetexturableModel) - { - base = ((IRetexturableModel)base).retexture(textureMap); - } - - if (base instanceof IModelSimpleProperties) - { - base = ((IModelSimpleProperties) base).smoothLighting(smooth).gui3d(gui3d); - } - + base = ModelProcessingHelper.customData(base, customData); + base = ModelProcessingHelper.retexture(base, textureMap); + base = ModelProcessingHelper.smoothLighting(base, smooth); + base = ModelProcessingHelper.gui3d(base, gui3d); + base = ModelProcessingHelper.uvlock(base, uvlock); return base; } /** - * Used to replace the base model with a retextured model containing submodels. + * Used to replace the base model with a re-textured model containing sub-models. */ @Override - public IModel process(IModel base, ModelLoader loader) + public IModel process(IModel base) { int size = parts.size(); - boolean hasBase = base != loader.getMissingModel(); + // FIXME: should missing base be handled this way? + boolean hasBase = base != ModelLoaderRegistry.getMissingModel(); if (hasBase) { - base = runModelHooks(base, smooth, gui3d, textures, customData); + base = runModelHooks(base, smooth, gui3d, this.isUvLock(), textures, customData); if (size <= 0) return base; } - // Apply rotation of base model to submodels. + // Apply rotation of base model to sub-models. // If baseRot is non-null, then that rotation will be applied instead of the base model's rotation. - // This is used to allow replacing base model with a submodel when there is no base model for a variant. + // This is used to allow replacing base model with a sub-model when there is no base model for a variant. IModelState baseTr = getState(); ImmutableMap.Builder> models = ImmutableMap.builder(); for (Entry entry : parts.entrySet()) { SubModel part = entry.getValue(); - IModel model = null; - try - { - model = loader.getModel(part.getModelLocation()); - } - catch (IOException e) - { - FMLLog.warning("Unable to load block sub-model: \'" + part.getModelLocation() /*+ "\' for variant: \'" + parent*/ + "\': " + e.toString()); - model = loader.getMissingModel(); // Will make it look weird, but that is good. - } + IModel model = ModelLoaderRegistry.getModelOrLogError(part.getModelLocation(), "Unable to load block sub-model: \'" + part.getModelLocation()); - IModelState partState = new ModelStateComposition(baseTr, part.getState()); - if (part.isUVLock()) partState = new ModelLoader.UVLock(partState); - - models.put(entry.getKey(), Pair.of(runModelHooks(model, part.smooth, part.gui3d, part.getTextures(), part.getCustomData()), partState)); + models.put(entry.getKey(), Pair.of(runModelHooks(model, part.smooth, part.gui3d, part.uvLock, part.getTextures(), part.getCustomData()), part.getState())); } return new MultiModel(getModelLocation(), hasBase ? base : null, baseTr, models.build()); diff --git a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java index c079687925..8e8149b5f5 100644 --- a/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java +++ b/src/main/java/net/minecraftforge/client/model/ForgeBlockStateV1.java @@ -17,11 +17,13 @@ import javax.vecmath.Quat4f; import javax.vecmath.Vector3f; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.resources.model.ModelRotation; +import net.minecraft.client.renderer.block.model.ModelRotation; import net.minecraft.util.JsonUtils; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.BlockStateLoader.Marker; import net.minecraftforge.client.model.BlockStateLoader.SubModel; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.fml.common.FMLLog; import com.google.common.base.Optional; @@ -37,7 +39,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParseException; -@SuppressWarnings("deprecation") public class ForgeBlockStateV1 extends Marker { ForgeBlockStateV1.Variant defaults; @@ -372,7 +373,7 @@ public class ForgeBlockStateV1 extends Marker protected SubModel asGenericSubModel() { - return new SubModel(state.or(TRSRTransformation.identity()), uvLock.or(false), getTextures(), model, getCustomData()); + return new SubModel(state.or(TRSRTransformation.identity()), uvLock.or(false), smooth.or(true), gui3d.or(true), getTextures(), model, getCustomData()); } /** @@ -436,6 +437,22 @@ public class ForgeBlockStateV1 extends Marker throw new UnsupportedOperationException("Forge BlockStateLoader V1 does not support nested submodels."); } + private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s) + { + return TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(tx / 16, ty / 16, tz / 16), + TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)), + new Vector3f(s, s, s), + null)); + } + + private static final TRSRTransformation flipX = new TRSRTransformation(null, null, new Vector3f(-1, 1, 1), null); + + private static TRSRTransformation leftify(TRSRTransformation transform) + { + return TRSRTransformation.blockCenterToCorner(flipX.compose(TRSRTransformation.blockCornerToCenter(transform)).compose(flipX)); + } + @Override public ForgeBlockStateV1.Variant deserialize(JsonElement element, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { @@ -456,7 +473,7 @@ public class ForgeBlockStateV1 extends Marker for (Entry e : json.get("textures").getAsJsonObject().entrySet()) { if (e.getValue().isJsonNull()) - ret.textures.put(e.getKey(), ""); // We have to use "" because ImmutibleMaps don't allow nulls -.- + ret.textures.put(e.getKey(), ""); // We have to use "" because ImmutableMaps don't allow nulls -.- else ret.textures.put(e.getKey(), e.getValue().getAsString()); } @@ -477,46 +494,47 @@ public class ForgeBlockStateV1 extends Marker { String transform = json.get("transform").getAsString(); // Note: these strings might change to a full-blown resource locations in the future, and move from here to some json somewhere + // TODO: vanilla now includes from parent, deprecate? if (transform.equals("identity")) { ret.state = Optional.of(TRSRTransformation.identity()); } + // block/block else if (transform.equals("forge:default-block")) { - TRSRTransformation thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 1.5f / 16, -2.75f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(10, -45, 170)), - new Vector3f(0.375f, 0.375f, 0.375f), - null)); - ret.state = Optional.of(new SimpleModelState(ImmutableMap.of(TransformType.THIRD_PERSON, thirdperson))); + TRSRTransformation thirdperson = get(0, 2.5f, 0, 75, 45, 0, 0.375f); + ImmutableMap.Builder builder = ImmutableMap.builder(); + builder.put(TransformType.GUI, get(0, 0, 0, 30, 225, 0, 0.625f)); + builder.put(TransformType.GROUND, get(0, 3, 0, 0, 0, 0, 0.25f)); + builder.put(TransformType.FIXED, get(0, 0, 0, 0, 0, 0, 0.5f)); + builder.put(TransformType.THIRD_PERSON_RIGHT_HAND, thirdperson); + builder.put(TransformType.THIRD_PERSON_LEFT_HAND, leftify(thirdperson)); + builder.put(TransformType.FIRST_PERSON_RIGHT_HAND, get(0, 0, 0, 0, 45, 0, 0.4f)); + builder.put(TransformType.FIRST_PERSON_LEFT_HAND, get(0, 0, 0, 0, 225, 0, 0.4f)); + ret.state = Optional.of(new SimpleModelState(builder.build())); } + // item/generated else if (transform.equals("forge:default-item")) { - TRSRTransformation thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 1f / 16, -3f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(-90, 0, 0)), - new Vector3f(0.55f, 0.55f, 0.55f), - null)); - TRSRTransformation firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 4f / 16, 2f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), - new Vector3f(1.7f, 1.7f, 1.7f), - null)); - ret.state = Optional.of(new SimpleModelState(ImmutableMap.of(TransformType.THIRD_PERSON, thirdperson, TransformType.FIRST_PERSON, firstperson))); + TRSRTransformation thirdperson = get(0, 3, 1, 0, 0, 0, 0.55f); + TRSRTransformation firstperson = get(1.13f, 3.2f, 1.13f, 0, -90, 25, 0.68f); + ImmutableMap.Builder builder = ImmutableMap.builder(); + builder.put(TransformType.GROUND, get(0, 2, 0, 0, 0, 0, 0.5f)); + builder.put(TransformType.HEAD, get(0, 13, 7, 0, 180, 0, 1)); + builder.put(TransformType.THIRD_PERSON_RIGHT_HAND, thirdperson); + builder.put(TransformType.THIRD_PERSON_LEFT_HAND, leftify(thirdperson)); + builder.put(TransformType.FIRST_PERSON_RIGHT_HAND, firstperson); + builder.put(TransformType.FIRST_PERSON_LEFT_HAND, leftify(firstperson)); + ret.state = Optional.of(new SimpleModelState(builder.build())); } + // item/handheld else if (transform.equals("forge:default-tool")) { - TRSRTransformation thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 1.25f / 16, -3.5f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, 90, -35)), - new Vector3f(0.85f, 0.85f, 0.85f), - null)); - TRSRTransformation firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 4f / 16, 2f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), - new Vector3f(1.7f, 1.7f, 1.7f), - null)); - ret.state = Optional.of(new SimpleModelState(ImmutableMap.of(TransformType.THIRD_PERSON, thirdperson, TransformType.FIRST_PERSON, firstperson))); + ret.state = Optional.of(new SimpleModelState(ImmutableMap.of( + TransformType.THIRD_PERSON_RIGHT_HAND, get(0, 4, 0.5f, 0, -90, 55, 0.85f), + TransformType.THIRD_PERSON_LEFT_HAND, get(0, 4, 0.5f, 0, 90, -55, 0.85f), + TransformType.FIRST_PERSON_RIGHT_HAND, get(1.13f, 3.2f, 1.13f, 0, -90, 25, 0.68f), + TransformType.FIRST_PERSON_LEFT_HAND, get(1.13f, 3.2f, 1.13f, 0, 90, -25, 0.68f)))); } else { @@ -543,13 +561,37 @@ public class ForgeBlockStateV1 extends Marker { TRSRTransformation t = context.deserialize(transform.get("thirdperson"), TRSRTransformation.class); transform.remove("thirdperson"); - transforms.put(TransformType.THIRD_PERSON, TRSRTransformation.blockCenterToCorner(t)); + transforms.put(TransformType.THIRD_PERSON_RIGHT_HAND, TRSRTransformation.blockCenterToCorner(t)); + } + if(transform.has("thirdperson_righthand")) + { + TRSRTransformation t = context.deserialize(transform.get("thirdperson_righthand"), TRSRTransformation.class); + transform.remove("thirdperson_righthand"); + transforms.put(TransformType.THIRD_PERSON_RIGHT_HAND, TRSRTransformation.blockCenterToCorner(t)); + } + if(transform.has("thirdperson_lefthand")) + { + TRSRTransformation t = context.deserialize(transform.get("thirdperson_lefthand"), TRSRTransformation.class); + transform.remove("thirdperson_lefthand"); + transforms.put(TransformType.THIRD_PERSON_LEFT_HAND, TRSRTransformation.blockCenterToCorner(t)); } if(transform.has("firstperson")) { TRSRTransformation t = context.deserialize(transform.get("firstperson"), TRSRTransformation.class); transform.remove("firstperson"); - transforms.put(TransformType.FIRST_PERSON, TRSRTransformation.blockCenterToCorner(t)); + transforms.put(TransformType.FIRST_PERSON_RIGHT_HAND, TRSRTransformation.blockCenterToCorner(t)); + } + if(transform.has("firstperson_righthand")) + { + TRSRTransformation t = context.deserialize(transform.get("firstperson_righthand"), TRSRTransformation.class); + transform.remove("firstperson_righthand"); + transforms.put(TransformType.FIRST_PERSON_RIGHT_HAND, TRSRTransformation.blockCenterToCorner(t)); + } + if(transform.has("firstperson_lefthand")) + { + TRSRTransformation t = context.deserialize(transform.get("firstperson_lefthand"), TRSRTransformation.class); + transform.remove("firstperson_lefthand"); + transforms.put(TransformType.FIRST_PERSON_LEFT_HAND, TRSRTransformation.blockCenterToCorner(t)); } if(transform.has("head")) { @@ -707,7 +749,7 @@ public class ForgeBlockStateV1 extends Marker public static class TRSRDeserializer implements JsonDeserializer { - public static TRSRDeserializer INSTANCE = new TRSRDeserializer(); + public static final TRSRDeserializer INSTANCE = new TRSRDeserializer(); public TRSRTransformation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { diff --git a/src/main/java/net/minecraftforge/client/model/IColoredBakedQuad.java b/src/main/java/net/minecraftforge/client/model/IColoredBakedQuad.java deleted file mode 100644 index 95fce88a7a..0000000000 --- a/src/main/java/net/minecraftforge/client/model/IColoredBakedQuad.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.minecraftforge.client.model; - -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.util.EnumFacing; - -public interface IColoredBakedQuad { - public static class ColoredBakedQuad extends BakedQuad implements IColoredBakedQuad - { - public ColoredBakedQuad(int[] data, int tintIndex, EnumFacing side) - { - super(data, tintIndex, side); - } - } -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/model/ICustomModelLoader.java b/src/main/java/net/minecraftforge/client/model/ICustomModelLoader.java index beeaecbaae..3aea07e733 100644 --- a/src/main/java/net/minecraftforge/client/model/ICustomModelLoader.java +++ b/src/main/java/net/minecraftforge/client/model/ICustomModelLoader.java @@ -1,7 +1,5 @@ package net.minecraftforge.client.model; -import java.io.IOException; - import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.util.ResourceLocation; @@ -16,5 +14,5 @@ public interface ICustomModelLoader extends IResourceManagerReloadListener /* * loads (or reloads) specified model */ - public IModel loadModel(ResourceLocation modelLocation) throws IOException; + public IModel loadModel(ResourceLocation modelLocation) throws Exception; } diff --git a/src/main/java/net/minecraftforge/client/model/IFlexibleBakedModel.java b/src/main/java/net/minecraftforge/client/model/IFlexibleBakedModel.java deleted file mode 100644 index 371f236743..0000000000 --- a/src/main/java/net/minecraftforge/client/model/IFlexibleBakedModel.java +++ /dev/null @@ -1,78 +0,0 @@ -package net.minecraftforge.client.model; - -import java.util.List; - -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.util.EnumFacing; - -/* - * Version of IBakedModel with less restriction on camera transformations and with explicit format of the baked array. - */ -@SuppressWarnings("deprecation") -public interface IFlexibleBakedModel extends IBakedModel -{ - /* - * Specifies the format which BakedQuads' getVertexData will have. - */ - VertexFormat getFormat(); - - /* - * Default implementation of IFlexibleBakedModel that should be useful in most cases - */ - public static class Wrapper implements IFlexibleBakedModel - { - private final IBakedModel parent; - VertexFormat format; - - public Wrapper(IBakedModel parent, VertexFormat format) - { - this.parent = parent; - this.format = format; - } - - public List getFaceQuads(EnumFacing side) - { - return parent.getFaceQuads(side); - } - - public List getGeneralQuads() - { - return parent.getGeneralQuads(); - } - - public boolean isAmbientOcclusion() - { - return parent.isAmbientOcclusion(); - } - - public boolean isGui3d() - { - return parent.isGui3d(); - } - - public boolean isBuiltInRenderer() - { - return parent.isBuiltInRenderer(); - } - - public TextureAtlasSprite getParticleTexture() - { - return parent.getParticleTexture(); - } - - @Deprecated - public ItemCameraTransforms getItemCameraTransforms() - { - return parent.getItemCameraTransforms(); - } - - public VertexFormat getFormat() - { - return new VertexFormat(format); - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/IModel.java b/src/main/java/net/minecraftforge/client/model/IModel.java index 6a9e1c47fd..9cb33f277a 100644 --- a/src/main/java/net/minecraftforge/client/model/IModel.java +++ b/src/main/java/net/minecraftforge/client/model/IModel.java @@ -2,9 +2,11 @@ package net.minecraftforge.client.model; import java.util.Collection; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.model.IModelState; import com.google.common.base.Function; @@ -36,7 +38,7 @@ public interface IModel * format argument (some attributes can be replaced with padding), * if there's no such info in this model. */ - IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter); + IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter); /* * Default state this model will be baked with. diff --git a/src/main/java/net/minecraftforge/client/model/IModelCustomData.java b/src/main/java/net/minecraftforge/client/model/IModelCustomData.java index 810e768f05..76d8e10397 100644 --- a/src/main/java/net/minecraftforge/client/model/IModelCustomData.java +++ b/src/main/java/net/minecraftforge/client/model/IModelCustomData.java @@ -2,13 +2,12 @@ package net.minecraftforge.client.model; import com.google.common.collect.ImmutableMap; -public interface IModelCustomData> extends IModel +public interface IModelCustomData extends IModel { /** * Allows the model to process custom data from the variant definition. * If unknown data is encountered it should be skipped. * @return a new model, with data applied. */ - // 1.9: change IModel to M IModel process(ImmutableMap customData); } diff --git a/src/main/java/net/minecraftforge/client/model/IModelSimpleProperties.java b/src/main/java/net/minecraftforge/client/model/IModelSimpleProperties.java index 0e963ef057..0c9b7858ab 100644 --- a/src/main/java/net/minecraftforge/client/model/IModelSimpleProperties.java +++ b/src/main/java/net/minecraftforge/client/model/IModelSimpleProperties.java @@ -3,8 +3,8 @@ package net.minecraftforge.client.model; /** * Implement this if the model can process "smooth_lighting" or "gui3d" attributes from the json. */ -public interface IModelSimpleProperties> extends IModel +public interface IModelSimpleProperties extends IModel { - M smoothLighting(boolean value); - M gui3d(boolean value); + IModel smoothLighting(boolean value); + IModel gui3d(boolean value); } diff --git a/src/main/java/net/minecraftforge/client/model/IModelUVLock.java b/src/main/java/net/minecraftforge/client/model/IModelUVLock.java new file mode 100644 index 0000000000..aa3dd8fdf0 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/IModelUVLock.java @@ -0,0 +1,6 @@ +package net.minecraftforge.client.model; + +public interface IModelUVLock extends IModel +{ + public IModel uvlock(boolean value); +} diff --git a/src/main/java/net/minecraftforge/client/model/IModelWithSubmodels.java b/src/main/java/net/minecraftforge/client/model/IModelWithSubmodels.java deleted file mode 100644 index f259f9e94a..0000000000 --- a/src/main/java/net/minecraftforge/client/model/IModelWithSubmodels.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.minecraftforge.client.model; - -import com.google.common.collect.ImmutableSet; - -/** - * Created by rainwarrior on 2/2/16. - */ -public interface IModelWithSubmodels> extends IModel -{ - M setDefaultSubmodelEnabled (boolean value); - M setSubmodelsEnabled(ImmutableSet submodelNames, boolean show); -} diff --git a/src/main/java/net/minecraftforge/client/model/IPerspectiveAwareModel.java b/src/main/java/net/minecraftforge/client/model/IPerspectiveAwareModel.java index 16fd01d013..fae295981f 100644 --- a/src/main/java/net/minecraftforge/client/model/IPerspectiveAwareModel.java +++ b/src/main/java/net/minecraftforge/client/model/IPerspectiveAwareModel.java @@ -4,12 +4,16 @@ import java.util.List; import javax.vecmath.Matrix4f; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; import org.apache.commons.lang3.tuple.Pair; @@ -20,26 +24,26 @@ import com.google.common.collect.ImmutableMap; * Model that changes based on the rendering perspective * (first-person, GUI, e.t.c - see TransformType) */ -public interface IPerspectiveAwareModel extends IFlexibleBakedModel +public interface IPerspectiveAwareModel extends IBakedModel { /* * Returns the pair of the model for the given perspective, and the matrix * that should be applied to the GL state before rendering it (matrix may be null). */ - Pair handlePerspective(TransformType cameraTransformType); + Pair handlePerspective(TransformType cameraTransformType); public static class MapWrapper implements IPerspectiveAwareModel { - private final IFlexibleBakedModel parent; + private final IBakedModel parent; private final ImmutableMap transforms; - public MapWrapper(IFlexibleBakedModel parent, ImmutableMap transforms) + public MapWrapper(IBakedModel parent, ImmutableMap transforms) { this.parent = parent; this.transforms = transforms; } - public MapWrapper(IFlexibleBakedModel parent, IModelState state) + public MapWrapper(IBakedModel parent, IModelState state) { this(parent, getTransforms(state)); } @@ -58,17 +62,18 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel return builder.build(); } + @SuppressWarnings("deprecation") public static ImmutableMap getTransforms(ItemCameraTransforms transforms) { ImmutableMap.Builder builder = ImmutableMap.builder(); for(TransformType type : TransformType.values()) { - builder.put(type, new TRSRTransformation(transforms.getTransform(type))); + builder.put(type, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(transforms.getTransform(type)))); } return builder.build(); } - public static Pair handlePerspective(IFlexibleBakedModel model, ImmutableMap transforms, TransformType cameraTransformType) + public static Pair handlePerspective(IBakedModel model, ImmutableMap transforms, TransformType cameraTransformType) { TRSRTransformation tr = transforms.get(cameraTransformType); Matrix4f mat = null; @@ -76,7 +81,7 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel return Pair.of(model, mat); } - public static Pair handlePerspective(IFlexibleBakedModel model, IModelState state, TransformType cameraTransformType) + public static Pair handlePerspective(IBakedModel model, IModelState state, TransformType cameraTransformType) { TRSRTransformation tr = state.apply(Optional.of(cameraTransformType)).or(TRSRTransformation.identity()); if(tr != TRSRTransformation.identity()) @@ -90,13 +95,13 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel public boolean isGui3d() { return parent.isGui3d(); } public boolean isBuiltInRenderer() { return parent.isBuiltInRenderer(); } public TextureAtlasSprite getParticleTexture() { return parent.getParticleTexture(); } + @SuppressWarnings("deprecation") public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); } - public List getFaceQuads(EnumFacing side) { return parent.getFaceQuads(side); } - public List getGeneralQuads() { return parent.getGeneralQuads(); } - public VertexFormat getFormat() { return parent.getFormat(); } + public List getQuads(IBlockState state, EnumFacing side, long rand) { return parent.getQuads(state, side, rand); } + public ItemOverrideList getOverrides() { return parent.getOverrides(); } @Override - public Pair handlePerspective(TransformType cameraTransformType) + public Pair handlePerspective(TransformType cameraTransformType) { return handlePerspective(this, transforms, cameraTransformType); } diff --git a/src/main/java/net/minecraftforge/client/model/IRetexturableModel.java b/src/main/java/net/minecraftforge/client/model/IRetexturableModel.java index b6b14ccd5e..eb6248706a 100644 --- a/src/main/java/net/minecraftforge/client/model/IRetexturableModel.java +++ b/src/main/java/net/minecraftforge/client/model/IRetexturableModel.java @@ -2,7 +2,7 @@ package net.minecraftforge.client.model; import com.google.common.collect.ImmutableMap; -public interface IRetexturableModel> extends IModel +public interface IRetexturableModel extends IModel { /** * Applies new textures to the model. @@ -21,6 +21,5 @@ public interface IRetexturableModel> extends IMo * @param textures New * @return Model with textures applied. */ - // 1.9: change IModel to M IModel retexture(ImmutableMap textures); } diff --git a/src/main/java/net/minecraftforge/client/model/ISmartBlockModel.java b/src/main/java/net/minecraftforge/client/model/ISmartBlockModel.java deleted file mode 100644 index 4ad91757fe..0000000000 --- a/src/main/java/net/minecraftforge/client/model/ISmartBlockModel.java +++ /dev/null @@ -1,94 +0,0 @@ -package net.minecraftforge.client.model; - -import java.util.List; - -import javax.vecmath.Matrix4f; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.util.EnumFacing; - -import org.apache.commons.lang3.tuple.Pair; - -public interface ISmartBlockModel extends IBakedModel -{ - IBakedModel handleBlockState(IBlockState state); - - public static abstract class Wrapper implements ISmartBlockModel, IFlexibleBakedModel - { - protected final IFlexibleBakedModel parent; - - public Wrapper(IFlexibleBakedModel parent) - { - this.parent = parent; - } - - public List getFaceQuads(EnumFacing side) - { - return parent.getFaceQuads(side); - } - - public List getGeneralQuads() - { - return parent.getGeneralQuads(); - } - - public boolean isAmbientOcclusion() - { - return parent.isAmbientOcclusion(); - } - - public boolean isGui3d() - { - return parent.isGui3d(); - } - - public boolean isBuiltInRenderer() - { - return parent.isBuiltInRenderer(); - } - - public TextureAtlasSprite getParticleTexture() - { - return parent.getParticleTexture(); - } - - public ItemCameraTransforms getItemCameraTransforms() - { - return parent.getItemCameraTransforms(); - } - - public VertexFormat getFormat() - { - return parent.getFormat(); - } - } - - public static abstract class PerspectiveWrapper extends Wrapper implements IPerspectiveAwareModel - { - protected final IPerspectiveAwareModel parent; - - public PerspectiveWrapper(IPerspectiveAwareModel parent) - { - super(parent); - this.parent = parent; - } - - public Pair handlePerspective(TransformType type) - { - Pair pair = parent.handlePerspective(type); - return Pair.of(new ISmartBlockModel.Wrapper(pair.getLeft()) - { - public IBakedModel handleBlockState(IBlockState state) - { - return PerspectiveWrapper.this.handleBlockState(state); - } - }, pair.getRight()); - } - } -} diff --git a/src/main/java/net/minecraftforge/client/model/ISmartItemModel.java b/src/main/java/net/minecraftforge/client/model/ISmartItemModel.java deleted file mode 100644 index 7973271d44..0000000000 --- a/src/main/java/net/minecraftforge/client/model/ISmartItemModel.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.minecraftforge.client.model; - -import net.minecraft.item.ItemStack; -import net.minecraft.client.resources.model.IBakedModel; - -public interface ISmartItemModel extends IBakedModel -{ - IBakedModel handleItemState(ItemStack stack); -} diff --git a/src/main/java/net/minecraftforge/client/model/ISmartVariant.java b/src/main/java/net/minecraftforge/client/model/ISmartVariant.java index 8a03b4a3f8..5a1a9185d8 100644 --- a/src/main/java/net/minecraftforge/client/model/ISmartVariant.java +++ b/src/main/java/net/minecraftforge/client/model/ISmartVariant.java @@ -3,5 +3,5 @@ package net.minecraftforge.client.model; public interface ISmartVariant { - IModel process(IModel base, ModelLoader loader); + IModel process(IModel base); } diff --git a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java index 873bceae93..7483baa75f 100644 --- a/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java +++ b/src/main/java/net/minecraftforge/client/model/ItemLayerModel.java @@ -10,9 +10,12 @@ import javax.vecmath.Vector4f; import org.apache.commons.lang3.tuple.Pair; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.block.model.ModelBlock; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; @@ -20,27 +23,36 @@ import net.minecraft.client.resources.IResourceManager; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -public class ItemLayerModel implements IRetexturableModel +public final class ItemLayerModel implements IRetexturableModel { - - public static final ItemLayerModel instance = new ItemLayerModel(ImmutableList.of()); + public static final ItemLayerModel INSTANCE = new ItemLayerModel(ImmutableList.of()); private final ImmutableList textures; + private final ItemOverrideList overrides; public ItemLayerModel(ImmutableList textures) + { + this(textures, ItemOverrideList.NONE); + } + + public ItemLayerModel(ImmutableList textures, ItemOverrideList overrides) { this.textures = textures; + this.overrides = overrides; } public ItemLayerModel(ModelBlock model) { - this(getTextures(model)); + this(getTextures(model), model.createOverrides()); } private static ImmutableList getTextures(ModelBlock model) @@ -68,7 +80,7 @@ public class ItemLayerModel implements IRetexturableModel return TRSRTransformation.identity(); } - public IModel retexture(ImmutableMap textures) + public ItemLayerModel retexture(ImmutableMap textures) { ImmutableList.Builder builder = ImmutableList.builder(); for(int i = 0; i < textures.size() + this.textures.size(); i++) @@ -82,10 +94,10 @@ public class ItemLayerModel implements IRetexturableModel builder.add(this.textures.get(i)); } } - return new ItemLayerModel(builder.build()); + return new ItemLayerModel(builder.build(), overrides); } - public IFlexibleBakedModel bake(IModelState state, final VertexFormat format, Function bakedTextureGetter) + public IBakedModel bake(IModelState state, final VertexFormat format, Function bakedTextureGetter) { ImmutableList.Builder builder = ImmutableList.builder(); Optional transform = state.apply(Optional.absent()); @@ -96,48 +108,24 @@ public class ItemLayerModel implements IRetexturableModel } TextureAtlasSprite particle = bakedTextureGetter.apply(textures.isEmpty() ? new ResourceLocation("missingno") : textures.get(0)); ImmutableMap map = IPerspectiveAwareModel.MapWrapper.getTransforms(state); - return new BakedItemModel(builder.build(), particle, format, map, null); + return new BakedItemModel(builder.build(), particle, map, overrides, null); } - @Deprecated // remove 1.9 - public static class BakedModel implements IFlexibleBakedModel + private static final class BakedItemModel implements IPerspectiveAwareModel { private final ImmutableList quads; private final TextureAtlasSprite particle; - private final VertexFormat format; - - public BakedModel(ImmutableList quads, TextureAtlasSprite particle, VertexFormat format) - { - this.quads = quads; - this.particle = particle; - this.format = format; - } - - public boolean isAmbientOcclusion() { return true; } - public boolean isGui3d() { return false; } - public boolean isBuiltInRenderer() { return false; } - public TextureAtlasSprite getParticleTexture() { return particle; } - public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; } - public List getFaceQuads(EnumFacing side) { return ImmutableList.of(); } - public List getGeneralQuads() { return quads; } - public VertexFormat getFormat() { return format; } - } - - private static class BakedItemModel implements IFlexibleBakedModel, IPerspectiveAwareModel - { - private final ImmutableList quads; - private final TextureAtlasSprite particle; - private final VertexFormat format; private final ImmutableMap transforms; - private final IFlexibleBakedModel otherModel; + private final IBakedModel otherModel; private final boolean isCulled; + private final ItemOverrideList overrides; - public BakedItemModel(ImmutableList quads, TextureAtlasSprite particle, VertexFormat format, ImmutableMap transforms, IFlexibleBakedModel otherModel) + public BakedItemModel(ImmutableList quads, TextureAtlasSprite particle, ImmutableMap transforms, ItemOverrideList overrides, IBakedModel otherModel) { this.quads = quads; this.particle = particle; - this.format = format; this.transforms = transforms; + this.overrides = overrides; if(otherModel != null) { this.otherModel = otherModel; @@ -153,7 +141,7 @@ public class ItemLayerModel implements IRetexturableModel builder.add(quad); } } - this.otherModel = new BakedItemModel(builder.build(), particle, format, transforms, this); + this.otherModel = new BakedItemModel(builder.build(), particle, transforms, overrides, this); isCulled = false; } } @@ -163,13 +151,16 @@ public class ItemLayerModel implements IRetexturableModel public boolean isBuiltInRenderer() { return false; } public TextureAtlasSprite getParticleTexture() { return particle; } public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; } - public List getFaceQuads(EnumFacing side) { return ImmutableList.of(); } - public List getGeneralQuads() { return quads; } - public VertexFormat getFormat() { return format; } - - public Pair handlePerspective(TransformType type) + public ItemOverrideList getOverrides() { return overrides; } + public List getQuads(IBlockState state, EnumFacing side, long rand) { - Pair pair = IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, type); + if(side == null) return quads; + return ImmutableList.of(); + } + + public Pair handlePerspective(TransformType type) + { + Pair pair = IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, type); if(type == TransformType.GUI && !isCulled && pair.getRight() == null) { return Pair.of(otherModel, null); @@ -182,7 +173,7 @@ public class ItemLayerModel implements IRetexturableModel } } - public ImmutableList getQuadsForSprite(int tint, TextureAtlasSprite sprite, VertexFormat format, Optional transform) + public static ImmutableList getQuadsForSprite(int tint, TextureAtlasSprite sprite, VertexFormat format, Optional transform) { ImmutableList.Builder builder = ImmutableList.builder(); @@ -236,14 +227,14 @@ public class ItemLayerModel implements IRetexturableModel } } // front - builder.add(buildQuad(format, transform, EnumFacing.NORTH, tint, + builder.add(buildQuad(format, transform, EnumFacing.NORTH, sprite, tint, 0, 0, 7.5f / 16f, sprite.getMinU(), sprite.getMaxV(), 0, 1, 7.5f / 16f, sprite.getMinU(), sprite.getMinV(), 1, 1, 7.5f / 16f, sprite.getMaxU(), sprite.getMinV(), 1, 0, 7.5f / 16f, sprite.getMaxU(), sprite.getMaxV() )); // back - builder.add(buildQuad(format, transform, EnumFacing.SOUTH, tint, + builder.add(buildQuad(format, transform, EnumFacing.SOUTH, sprite, tint, 0, 0, 8.5f / 16f, sprite.getMinU(), sprite.getMaxV(), 1, 0, 8.5f / 16f, sprite.getMaxU(), sprite.getMaxV(), 1, 1, 8.5f / 16f, sprite.getMaxU(), sprite.getMinV(), @@ -252,7 +243,7 @@ public class ItemLayerModel implements IRetexturableModel return builder.build(); } - protected boolean isTransparent(int[] pixels, int uMax, int vMax, int u, int v) + private static boolean isTransparent(int[] pixels, int uMax, int vMax, int u, int v) { return (pixels[u + (vMax - 1 - v) * uMax] >> 24 & 0xFF) == 0; } @@ -341,7 +332,7 @@ public class ItemLayerModel implements IRetexturableModel throw new IllegalArgumentException("can't handle z-oriented side"); } return buildQuad( - format, transform, side.getOpposite(), tint, // getOpposite is related either to the swapping of V direction, or something else + format, transform, side.getOpposite(), sprite, tint, // getOpposite is related either to the swapping of V direction, or something else x0, y0, z1, sprite.getInterpolatedU(u0), sprite.getInterpolatedV(v0), x1, y1, z1, sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1), x1, y1, z2, sprite.getInterpolatedU(u1), sprite.getInterpolatedV(v1), @@ -350,7 +341,7 @@ public class ItemLayerModel implements IRetexturableModel } private static final BakedQuad buildQuad( - VertexFormat format, Optional transform, EnumFacing side, int tint, + VertexFormat format, Optional transform, EnumFacing side, TextureAtlasSprite sprite, int tint, float x0, float y0, float z0, float u0, float v0, float x1, float y1, float z1, float u1, float v1, float x2, float y2, float z2, float u2, float v2, @@ -359,6 +350,7 @@ public class ItemLayerModel implements IRetexturableModel UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format); builder.setQuadTint(tint); builder.setQuadOrientation(side); + builder.setTexture(sprite); putVertex(builder, format, transform, side, x0, y0, z0, u0, v0); putVertex(builder, format, transform, side, x1, y1, z1, u1, v1); putVertex(builder, format, transform, side, x2, y2, z2, u2, v2); @@ -408,7 +400,7 @@ public class ItemLayerModel implements IRetexturableModel public static enum Loader implements ICustomModelLoader { - instance; + INSTANCE; public void onResourceManagerReload(IResourceManager resourceManager) {} @@ -422,7 +414,7 @@ public class ItemLayerModel implements IRetexturableModel public IModel loadModel(ResourceLocation modelLocation) { - return ItemLayerModel.instance; + return ItemLayerModel.INSTANCE; } } } diff --git a/src/main/java/net/minecraftforge/client/model/ItemTextureQuadConverter.java b/src/main/java/net/minecraftforge/client/model/ItemTextureQuadConverter.java index 074e687e55..d95f7958ef 100644 --- a/src/main/java/net/minecraftforge/client/model/ItemTextureQuadConverter.java +++ b/src/main/java/net/minecraftforge/client/model/ItemTextureQuadConverter.java @@ -1,12 +1,15 @@ package net.minecraftforge.client.model; import com.google.common.collect.Lists; + import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.util.EnumFacing; import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; +import net.minecraftforge.common.model.TRSRTransformation; import javax.vecmath.Vector4f; + import java.util.List; public final class ItemTextureQuadConverter @@ -195,10 +198,10 @@ public final class ItemTextureQuadConverter y1 = 1f - y2; y2 = 1f - tmp; - return putQuad(format, transform, facing, color, x1, y1, x2, y2, z, u1, v1, u2, v2); + return putQuad(format, transform, facing, sprite, color, x1, y1, x2, y2, z, u1, v1, u2, v2); } - private static UnpackedBakedQuad putQuad(VertexFormat format, TRSRTransformation transform, EnumFacing side, int color, + private static UnpackedBakedQuad putQuad(VertexFormat format, TRSRTransformation transform, EnumFacing side, TextureAtlasSprite sprite, int color, float x1, float y1, float x2, float y2, float z, float u1, float v1, float u2, float v2) { @@ -206,7 +209,7 @@ public final class ItemTextureQuadConverter UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format); builder.setQuadTint(-1); builder.setQuadOrientation(side); - builder.setQuadColored(); + builder.setTexture(sprite); if (side == EnumFacing.NORTH) { diff --git a/src/main/java/net/minecraftforge/client/model/MapModelState.java b/src/main/java/net/minecraftforge/client/model/MapModelState.java index 2f1469f3c9..5f5dbc9ad4 100644 --- a/src/main/java/net/minecraftforge/client/model/MapModelState.java +++ b/src/main/java/net/minecraftforge/client/model/MapModelState.java @@ -2,6 +2,10 @@ package net.minecraftforge.client.model; import java.util.Map; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; + import com.google.common.base.Objects; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; @@ -27,7 +31,7 @@ public class MapModelState implements IModelState public MapModelState(Map map, IModelState def) { - this.map = ImmutableMap.copyOf(map); + this.map = ImmutableMap.copyOf(map); this.def = def; } diff --git a/src/main/java/net/minecraftforge/client/model/ModelDynBucket.java b/src/main/java/net/minecraftforge/client/model/ModelDynBucket.java index 983b2854ad..90037fc109 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelDynBucket.java +++ b/src/main/java/net/minecraftforge/client/model/ModelDynBucket.java @@ -1,33 +1,48 @@ package net.minecraftforge.client.model; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import javax.vecmath.Matrix4f; +import javax.vecmath.Quat4f; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverride; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; + +import org.apache.commons.lang3.tuple.Pair; + import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.*; -import org.apache.commons.lang3.tuple.Pair; -import javax.vecmath.Matrix4f; -import javax.vecmath.Quat4f; -import java.io.IOException; -import java.util.Collection; -import java.util.Map; - -public class ModelDynBucket implements IModel, IModelCustomData, IRetexturableModel +public final class ModelDynBucket implements IModel, IModelCustomData, IRetexturableModel { public static final ModelResourceLocation LOCATION = new ModelResourceLocation(new ResourceLocation("forge", "dynbucket"), "inventory"); @@ -39,12 +54,12 @@ public class ModelDynBucket implements IModel, IModelCustomData, public static final IModel MODEL = new ModelDynBucket(); - protected final ResourceLocation baseLocation; - protected final ResourceLocation liquidLocation; - protected final ResourceLocation coverLocation; + private final ResourceLocation baseLocation; + private final ResourceLocation liquidLocation; + private final ResourceLocation coverLocation; - protected final Fluid fluid; - protected final boolean flipGas; + private final Fluid fluid; + private final boolean flipGas; public ModelDynBucket() { @@ -81,7 +96,7 @@ public class ModelDynBucket implements IModel, IModelCustomData, } @Override - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, + public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) { @@ -104,8 +119,8 @@ public class ModelDynBucket implements IModel, IModelCustomData, if (baseLocation != null) { // build base (insidest) - IFlexibleBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(state, format, bakedTextureGetter); - builder.addAll(model.getGeneralQuads()); + IBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(state, format, bakedTextureGetter); + builder.addAll(model.getQuads(null, null, 0)); } if (liquidLocation != null && fluidSprite != null) { @@ -123,7 +138,7 @@ public class ModelDynBucket implements IModel, IModelCustomData, } - return new BakedDynBucket(this, builder.build(), fluidSprite, format, Maps.immutableEnumMap(transformMap), Maps.newHashMap()); + return new BakedDynBucket(this, builder.build(), fluidSprite, format, Maps.immutableEnumMap(transformMap), Maps.newHashMap()); } @Override @@ -140,7 +155,7 @@ public class ModelDynBucket implements IModel, IModelCustomData, * If the fluid can't be found, water is used */ @Override - public IModel process(ImmutableMap customData) + public ModelDynBucket process(ImmutableMap customData) { String fluidName = customData.get("fluid"); Fluid fluid = FluidRegistry.getFluid(fluidName); @@ -171,7 +186,7 @@ public class ModelDynBucket implements IModel, IModelCustomData, * If no liquid is given a hardcoded variant for the bucket is used. */ @Override - public IModel retexture(ImmutableMap textures) + public ModelDynBucket retexture(ImmutableMap textures) { ResourceLocation base = baseLocation; @@ -190,7 +205,7 @@ public class ModelDynBucket implements IModel, IModelCustomData, public enum LoaderDynBucket implements ICustomModelLoader { - instance; + INSTANCE; @Override public boolean accepts(ResourceLocation modelLocation) @@ -199,7 +214,7 @@ public class ModelDynBucket implements IModel, IModelCustomData, } @Override - public IModel loadModel(ResourceLocation modelLocation) throws IOException + public IModel loadModel(ResourceLocation modelLocation) { return MODEL; } @@ -211,26 +226,16 @@ public class ModelDynBucket implements IModel, IModelCustomData, } } - // the dynamic bucket is based on the empty bucket - protected static class BakedDynBucket extends ItemLayerModel.BakedModel implements ISmartItemModel, IPerspectiveAwareModel + private static final class BakedDynBucketOverrideHandler extends ItemOverrideList { - - private final ModelDynBucket parent; - private final Map cache; // contains all the baked models since they'll never change - private final ImmutableMap transforms; - - public BakedDynBucket(ModelDynBucket parent, - ImmutableList quads, TextureAtlasSprite particle, VertexFormat format, ImmutableMap transforms, - Map cache) + public static final BakedDynBucketOverrideHandler INSTANCE = new BakedDynBucketOverrideHandler(); + private BakedDynBucketOverrideHandler() { - super(quads, particle, format); - this.parent = parent; - this.transforms = transforms; - this.cache = cache; + super(ImmutableList.of()); } @Override - public IBakedModel handleItemState(ItemStack stack) + public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack); if (fluidStack == null) @@ -245,16 +250,17 @@ public class ModelDynBucket implements IModel, IModelCustomData, if (fluidStack == null) { // empty bucket - return this; + return originalModel; } + BakedDynBucket model = (BakedDynBucket)originalModel; Fluid fluid = fluidStack.getFluid(); String name = fluid.getName(); - if (!cache.containsKey(name)) + if (!model.cache.containsKey(name)) { - IModel model = parent.process(ImmutableMap.of("fluid", name)); + IModel parent = model.parent.process(ImmutableMap.of("fluid", name)); Function textureGetter; textureGetter = new Function() { @@ -264,18 +270,62 @@ public class ModelDynBucket implements IModel, IModelCustomData, } }; - IFlexibleBakedModel bakedModel = model.bake(new SimpleModelState(transforms), this.getFormat(), textureGetter); - cache.put(name, bakedModel); + IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format, textureGetter); + model.cache.put(name, bakedModel); return bakedModel; } - return cache.get(name); + return model.cache.get(name); + } + } + + // the dynamic bucket is based on the empty bucket + private static final class BakedDynBucket implements IPerspectiveAwareModel + { + + private final ModelDynBucket parent; + // FIXME: guava cache? + private final Map cache; // contains all the baked models since they'll never change + private final ImmutableMap transforms; + private final ImmutableList quads; + private final TextureAtlasSprite particle; + private final VertexFormat format; + + public BakedDynBucket(ModelDynBucket parent, + ImmutableList quads, TextureAtlasSprite particle, VertexFormat format, ImmutableMap transforms, + Map cache) + { + this.quads = quads; + this.particle = particle; + this.format = format; + this.parent = parent; + this.transforms = transforms; + this.cache = cache; } @Override - public Pair handlePerspective(TransformType cameraTransformType) + public ItemOverrideList getOverrides() + { + return BakedDynBucketOverrideHandler.INSTANCE; + } + + @Override + public Pair handlePerspective(TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, cameraTransformType); } + + @Override + public List getQuads(IBlockState state, EnumFacing side, long rand) + { + if(side == null) return quads; + return ImmutableList.of(); + } + + public boolean isAmbientOcclusion() { return true; } + public boolean isGui3d() { return false; } + public boolean isBuiltInRenderer() { return false; } + public TextureAtlasSprite getParticleTexture() { return particle; } + public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; } } } diff --git a/src/main/java/net/minecraftforge/client/model/ModelFluid.java b/src/main/java/net/minecraftforge/client/model/ModelFluid.java index fdd3cda7f0..1b56a62604 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelFluid.java +++ b/src/main/java/net/minecraftforge/client/model/ModelFluid.java @@ -10,18 +10,21 @@ import javax.vecmath.Vector4f; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.block.model.ModelRotation; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelRotation; import net.minecraft.util.EnumFacing; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.pipeline.LightUtil; +import net.minecraft.util.math.MathHelper; import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.Fluid; @@ -42,11 +45,10 @@ import com.google.common.collect.Maps; import com.google.gson.JsonElement; import com.google.gson.JsonParser; -@SuppressWarnings("deprecation") -public class ModelFluid implements IModelCustomData +public final class ModelFluid implements IModelCustomData { - public static final ModelFluid waterModel = new ModelFluid(FluidRegistry.WATER); - public static final ModelFluid lavaModel = new ModelFluid(FluidRegistry.LAVA); + public static final ModelFluid WATER = new ModelFluid(FluidRegistry.WATER); + public static final ModelFluid LAVA = new ModelFluid(FluidRegistry.LAVA); private final Fluid fluid; public ModelFluid(Fluid fluid) @@ -64,7 +66,7 @@ public class ModelFluid implements IModelCustomData return ImmutableSet.of(fluid.getStill(), fluid.getFlowing()); } - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) { ImmutableMap map = IPerspectiveAwareModel.MapWrapper.getTransforms(state); return new BakedFluid(state.apply(Optional.absent()), map, format, fluid.getColor(), bakedTextureGetter.apply(fluid.getStill()), bakedTextureGetter.apply(fluid.getFlowing()), fluid.isGaseous(), Optional.absent()); @@ -77,7 +79,7 @@ public class ModelFluid implements IModelCustomData public static enum FluidLoader implements ICustomModelLoader { - instance; + INSTANCE; public void onResourceManagerReload(IResourceManager resourceManager) {} @@ -91,11 +93,11 @@ public class ModelFluid implements IModelCustomData public IModel loadModel(ResourceLocation modelLocation) { - return waterModel; + return WATER; } } - public static class BakedFluid implements IFlexibleBakedModel, ISmartBlockModel, IPerspectiveAwareModel + private static final class BakedFluid implements IPerspectiveAwareModel { private static final int x[] = { 0, 0, 1, 1 }; private static final int z[] = { 0, 1, 1, 0 }; @@ -126,16 +128,6 @@ public class ModelFluid implements IModelCustomData private final boolean gas; private final EnumMap> faceQuads; - public BakedFluid(Optional transformation, VertexFormat format, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, boolean gas) - { - this(transformation, format, color, still, flowing, gas, Optional.absent()); - } - - public BakedFluid(Optional transformation, VertexFormat format, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, boolean gas, Optional stateOption) - { - this(transformation, ImmutableMap.of(), format, color, still, flowing, gas, stateOption); - } - public BakedFluid(Optional transformation, ImmutableMap transforms, VertexFormat format, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, boolean gas, Optional stateOption) { this(transformation, transforms, format, color, still, flowing, gas, stateOption.isPresent(), getCorners(stateOption), getFlow(stateOption)); @@ -217,25 +209,32 @@ public class ModelFluid implements IModelCustomData float s = MathHelper.sin(flow) * scale; EnumFacing side = gas ? EnumFacing.DOWN : EnumFacing.UP; - UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format); - builder.setQuadOrientation(side); - builder.setQuadColored(); - for(int i = gas ? 3 : 0; i != (gas ? -1 : 4); i+= (gas ? -1 : 1)) + UnpackedBakedQuad.Builder builder; + ImmutableList.Builder topFaceBuilder = ImmutableList.builder(); + for(int k = 0; k < 2; k++) { - putVertex( - builder, side, - x[i], y[i], z[i], - topSprite.getInterpolatedU(8 + c * (x[i] * 2 - 1) + s * (z[i] * 2 - 1)), - topSprite.getInterpolatedV(8 + c * (x[(i + 1) % 4] * 2 - 1) + s * (z[(i + 1) % 4] * 2 - 1))); + builder = new UnpackedBakedQuad.Builder(format); + builder.setQuadOrientation(side); + builder.setTexture(topSprite); + for (int i = gas ? 3 : 0; i != (gas ? -1 : 4); i += (gas ? -1 : 1)) + { + int l = (k * 3) + (1 - 2 * k) * i; + putVertex( + builder, side, + x[l], y[l], z[l], + topSprite.getInterpolatedU(8 + c * (x[l] * 2 - 1) + s * (z[l] * 2 - 1)), + topSprite.getInterpolatedV(8 + c * (x[(l + 1) % 4] * 2 - 1) + s * (z[(l + 1) % 4] * 2 - 1))); + } + topFaceBuilder.add(builder.build()); } - faceQuads.put(side, ImmutableList.of(builder.build())); + faceQuads.put(side, topFaceBuilder.build()); // bottom side = side.getOpposite(); builder = new UnpackedBakedQuad.Builder(format); builder.setQuadOrientation(side); - builder.setQuadColored(); + builder.setTexture(still); for(int i = gas ? 3 : 0; i != (gas ? -1 : 4); i+= (gas ? -1 : 1)) { putVertex( @@ -257,7 +256,7 @@ public class ModelFluid implements IModelCustomData { builder = new UnpackedBakedQuad.Builder(format); builder.setQuadOrientation(side); - builder.setQuadColored(); + builder.setTexture(flowing); for(int j = 0; j < 4; j++) { int l = (k * 3) + (1 - 2 * k) * j; @@ -279,7 +278,7 @@ public class ModelFluid implements IModelCustomData // 1 quad for inventory UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format); builder.setQuadOrientation(EnumFacing.UP); - builder.setQuadColored(); + builder.setTexture(still); for(int i = 0; i < 4; i++) { putVertex( @@ -309,11 +308,10 @@ public class ModelFluid implements IModelCustomData builder.put(e, data); break; case COLOR: - float d = LightUtil.diffuseLight(side); builder.put(e, - d * ((color >> 16) & 0xFF) / 255f, - d * ((color >> 8) & 0xFF) / 255f, - d * (color & 0xFF) / 255f, + ((color >> 16) & 0xFF) / 255f, + ((color >> 8) & 0xFF) / 255f, + (color & 0xFF) / 255f, ((color >> 24) & 0xFF) / 255f); break; case UV: if(format.getElement(e).getIndex() == 0) @@ -333,7 +331,7 @@ public class ModelFluid implements IModelCustomData public boolean isAmbientOcclusion() { - return false; + return true; } public boolean isGui3d() @@ -356,23 +354,9 @@ public class ModelFluid implements IModelCustomData return ItemCameraTransforms.DEFAULT; } - public List getFaceQuads(EnumFacing side) - { - return faceQuads.get(side); - } - - public List getGeneralQuads() - { - return ImmutableList.of(); - } - - public VertexFormat getFormat() - { - return format; - } - - public IBakedModel handleBlockState(IBlockState state) + public List getQuads(IBlockState state, EnumFacing side, long rand) { + BakedFluid model = this; if(state instanceof IExtendedBlockState) { IExtendedBlockState exState = (IExtendedBlockState)state; @@ -386,20 +370,26 @@ public class ModelFluid implements IModelCustomData } key <<= 1; key |= 1; - return modelCache.getUnchecked(key); + model = modelCache.getUnchecked(key); } - return this; + if(side == null) return ImmutableList.of(); + return model.faceQuads.get(side); + } + + public ItemOverrideList getOverrides() + { + return ItemOverrideList.NONE; } @Override - public Pair handlePerspective(TransformType type) + public Pair handlePerspective(TransformType type) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, type); } } @Override - public IModel process(ImmutableMap customData) + public ModelFluid process(ImmutableMap customData) { if(!customData.containsKey("fluid")) return this; @@ -409,7 +399,7 @@ public class ModelFluid implements IModelCustomData if(!FluidRegistry.isFluidRegistered(fluid)) { FMLLog.severe("fluid '%s' not found", fluid); - return waterModel; + return WATER; } return new ModelFluid(FluidRegistry.getFluid(fluid)); } diff --git a/src/main/java/net/minecraftforge/client/model/ModelLoader.java b/src/main/java/net/minecraftforge/client/model/ModelLoader.java index 4a42453054..dc5326bd29 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelLoader.java +++ b/src/main/java/net/minecraftforge/client/model/ModelLoader.java @@ -3,8 +3,6 @@ package net.minecraftforge.client.model; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; -import java.io.FileNotFoundException; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -15,25 +13,36 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import com.google.common.base.Joiner; -import com.google.common.collect.*; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.ItemModelMesher; +import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockPart; import net.minecraft.client.renderer.block.model.BlockPartFace; import net.minecraft.client.renderer.block.model.BlockPartRotation; +import net.minecraft.client.renderer.block.model.BuiltInModel; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; import net.minecraft.client.renderer.block.model.ItemModelGenerator; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelBlock; import net.minecraft.client.renderer.block.model.ModelBlockDefinition; import net.minecraft.client.renderer.block.model.ModelBlockDefinition.MissingVariantException; -import net.minecraft.client.renderer.block.model.ModelBlockDefinition.Variant; -import net.minecraft.client.renderer.block.model.ModelBlockDefinition.Variants; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelRotation; +import net.minecraft.client.renderer.block.model.MultipartBakedModel; +import net.minecraft.client.renderer.block.model.SimpleBakedModel; +import net.minecraft.client.renderer.block.model.Variant; +import net.minecraft.client.renderer.block.model.VariantList; +import net.minecraft.client.renderer.block.model.WeightedBakedModel; +import net.minecraft.client.renderer.block.model.multipart.Multipart; +import net.minecraft.client.renderer.block.model.multipart.Selector; +import net.minecraft.client.renderer.block.statemap.BlockStateMapper; import net.minecraft.client.renderer.block.statemap.IStateMapper; import net.minecraft.client.renderer.texture.IIconCreator; import net.minecraft.client.renderer.texture.TextureAtlasSprite; @@ -41,25 +50,21 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.model.BuiltInModel; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.client.resources.model.ModelRotation; -import net.minecraft.client.resources.model.SimpleBakedModel; -import net.minecraft.client.resources.model.WeightedBakedModel; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.launchwrapper.Launch; import net.minecraft.util.EnumFacing; -import net.minecraft.util.IRegistry; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.animation.Animation; +import net.minecraft.util.registry.IRegistry; +import net.minecraftforge.client.model.animation.AnimationItemOverrideList; import net.minecraftforge.client.model.animation.IAnimatedModel; -import net.minecraftforge.client.model.animation.IClip; import net.minecraftforge.client.model.animation.ModelBlockAnimation; import net.minecraftforge.common.ForgeModContainer; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; +import net.minecraftforge.common.model.animation.IClip; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.Properties; import net.minecraftforge.fluids.Fluid; @@ -75,19 +80,26 @@ import net.minecraftforge.fml.common.registry.RegistryDelegate; import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Function; +import com.google.common.base.Joiner; import com.google.common.base.Optional; -import com.google.common.base.Throwables; +import com.google.common.base.Predicate; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.collect.Multimaps; +import com.google.common.collect.Sets; -@SuppressWarnings("ALL") -public class ModelLoader extends ModelBakery +public final class ModelLoader extends ModelBakery { private final Map stateModels = Maps.newHashMap(); - private final Set textures = Sets.newHashSet(); - private final Set loadingModels = Sets.newHashSet(); private final Set missingVariants = Sets.newHashSet(); private final Map loadingExceptions = Maps.newHashMap(); private IModel missingModel = null; - private IModel itemModel = new ItemLayerModel(MODEL_GENERATED); private boolean isLoading = false; public boolean isLoading() @@ -96,12 +108,14 @@ public class ModelLoader extends ModelBakery } private final boolean enableVerboseMissingInfo = (Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment") || Boolean.parseBoolean(System.getProperty("forge.verboseMissingModelLogging", "false")); + private final int verboseMissingInfoCount = Integer.parseInt(System.getProperty("forge.verboseMissingModelLoggingCount", "5")); public ModelLoader(IResourceManager manager, TextureMap map, BlockModelShapes shapes) { super(manager, map, shapes); - VanillaLoader.instance.setLoader(this); - ModelLoaderRegistry.clearModelCache(); + VanillaLoader.INSTANCE.setLoader(this); + VariantLoader.INSTANCE.setLoader(this); + ModelLoaderRegistry.clearModelCache(manager); } @Override @@ -109,19 +123,14 @@ public class ModelLoader extends ModelBakery { isLoading = true; loadBlocks(); - loadItems(); - try - { - missingModel = getModel(new ResourceLocation(MODEL_MISSING.getResourceDomain(), MODEL_MISSING.getResourcePath())); - } - catch (IOException e) - { - // If this ever happens things are bad. Should never NOT be able to load the missing model. - Throwables.propagate(e); - } + loadVariantItemModels(); + missingModel = ModelLoaderRegistry.getMissingModel(); stateModels.put(MODEL_MISSING, missingModel); + + final Set textures = Sets.newHashSet(ModelLoaderRegistry.getTextures()); textures.remove(TextureMap.LOCATION_MISSING_TEXTURE); textures.addAll(LOCATIONS_BUILTIN_TEXTURES); + textureMap.loadSprites(resourceManager, new IIconCreator() { public void registerSprites(TextureMap map) @@ -132,39 +141,72 @@ public class ModelLoader extends ModelBakery } } }); - IFlexibleBakedModel missingBaked = missingModel.bake(missingModel.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.instance); - for (Entry e : stateModels.entrySet()) + + IBakedModel missingBaked = missingModel.bake(missingModel.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE); + Map bakedModels = Maps.newHashMap(); + HashMultimap models = HashMultimap.create(); + Multimaps.invertFrom(Multimaps.forMap(stateModels), models); + + ProgressBar bakeBar = ProgressManager.push("ModelLoader: baking", models.keySet().size()); + + for(IModel model : models.keySet()) { - if(e.getValue() == getMissingModel()) + bakeBar.step("[" + Joiner.on(", ").join(models.get(model)) + "]"); + if(model == getMissingModel()) { - bakedRegistry.putObject(e.getKey(), missingBaked); + bakedModels.put(model, missingBaked); } else { - bakedRegistry.putObject(e.getKey(), e.getValue().bake(e.getValue().getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.instance)); + bakedModels.put(model, model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE)); } } + + ProgressManager.pop(bakeBar); + + for (Entry e : stateModels.entrySet()) + { + bakedRegistry.putObject(e.getKey(), bakedModels.get(e.getValue())); + } return bakedRegistry; } - private void loadBlocks() + // NOOP, replaced by dependency resolution + @Override + protected void loadVariantModels() {} + + // NOOP, replaced by dependency resolution + @Override + protected void loadMultipartVariantModels() {} + + @Override + protected void loadBlocks() { - Map stateMap = blockModelShapes.getBlockStateMapper().putAllStateModelLocations(); - List variants = Lists.newArrayList(stateMap.values()); - variants.add(new ModelResourceLocation("minecraft:item_frame", "normal")); //Vanilla special cases item_frames so must we - variants.add(new ModelResourceLocation("minecraft:item_frame", "map")); - Collections.sort(variants, new Comparator() + List blocks = Lists.newArrayList(Iterables.filter(Block.blockRegistry, new Predicate() { - public int compare(ModelResourceLocation v1, ModelResourceLocation v2) + public boolean apply(Block block) { - return v1.toString().compareTo(v2.toString()); + return block.getRegistryName() != null; + } + })); + Collections.sort(blocks, new Comparator() + { + public int compare(Block b1, Block b2) + { + return b1.getRegistryName().toString().compareTo(b2.getRegistryName().toString()); } }); - ProgressBar blockBar = ProgressManager.push("ModelLoader: blocks", variants.size()); - for(ModelResourceLocation variant : variants) + ProgressBar blockBar = ProgressManager.push("ModelLoader: blocks", blocks.size()); + + BlockStateMapper mapper = this.blockModelShapes.getBlockStateMapper(); + + for(Block block : blocks) { - loadVariants(ImmutableList.of(variant)); - blockBar.step(variant.toString()); + blockBar.step(block.getRegistryName().toString()); + for(ResourceLocation location : mapper.getBlockstateLocations(block)) + { + loadBlock(mapper, block, location); + } } ProgressManager.pop(blockBar); } @@ -172,25 +214,25 @@ public class ModelLoader extends ModelBakery @Override protected void registerVariant(ModelBlockDefinition definition, ModelResourceLocation location) { - Variants variants = null; + IModel model; try { - variants = definition.getVariants(location.getVariant()); + model = ModelLoaderRegistry.getModel(location); } - catch(MissingVariantException e) + catch(Exception e) { - missingVariants.add(location); + storeException(location, e); + model = getMissingModel(); } - if (variants != null && !variants.getVariants().isEmpty()) + stateModels.put(location, model); + } + + @Override + protected void registerMultipartVariant(ModelBlockDefinition definition, Collection locations) + { + for (ModelResourceLocation location : locations) { - try - { - stateModels.put(location, new WeightedRandomModel(location, variants)); - } - catch(Throwable e) - { - throw new RuntimeException(e); - } + registerVariant(null, location); } } @@ -213,7 +255,8 @@ public class ModelLoader extends ModelBakery return new ModelBlockDefinition(new ArrayList()); } - private void loadItems() + @Override + protected void loadItemModels() { // register model for the universal bucket, if it exists if(FluidRegistry.isUniversalBucketEnabled()) @@ -222,46 +265,54 @@ public class ModelLoader extends ModelBakery } registerVariantNames(); - - List itemVariants = Lists.newArrayList(); - for(Item item : GameData.getItemRegistry().typeSafeIterable()) + + List items = Lists.newArrayList(Iterables.filter(Item.itemRegistry, new Predicate() { - itemVariants.addAll(getVariantNames(item)); - } - Collections.sort(itemVariants); - ProgressBar itemBar = ProgressManager.push("ModelLoader: items", itemVariants.size()); - for(String s : itemVariants) - { - ResourceLocation file = getItemLocation(s); - ModelResourceLocation memory = getInventoryVariant(s); - itemBar.step(memory.toString()); - IModel model = null; - try + public boolean apply(Item item) { - // default loading - model = getModel(file); - if (model == null) - { - model = getMissingModel(); - } - stateModels.put(memory, model); + return item.getRegistryName() != null; } - catch (FileNotFoundException e) + })); + Collections.sort(items, new Comparator() + { + public int compare(Item i1, Item i2) { - // try blockstate json if the item model is missing - FMLLog.fine("Item json isn't found for '" + memory + "', trying to load the variant from the blockstate json"); + return i1.getRegistryName().toString().compareTo(i2.getRegistryName().toString()); + } + }); + + ProgressBar itemBar = ProgressManager.push("ModelLoader: items", items.size()); + for(Item item : items) + { + itemBar.step(item.getRegistryName().toString()); + for(String s : getVariantNames(item)) + { + ResourceLocation file = getItemLocation(s); + ModelResourceLocation memory = getInventoryVariant(s); + IModel model = ModelLoaderRegistry.getMissingModel(); + Exception exception = null; try { - registerVariant(getModelBlockDefinition(memory), memory); + model = ModelLoaderRegistry.getModel(file); } - catch (Exception exception) + catch(Exception normalException) { - storeException(memory, new Exception("Could not load item model either from the normal location " + file + " or from the blockstate", exception)); + // try blockstate json if the item model is missing + FMLLog.fine("Item json isn't found for '" + memory + "', trying to load the variant from the blockstate json"); + try + { + model = ModelLoaderRegistry.getModel(memory); + } + catch (Exception blockstateException) + { + exception = new ItemLoadingException("Could not load item model either from the normal location " + file + " or from the blockstate", normalException, blockstateException); + } + } + stateModels.put(memory, model); + if(exception != null) + { + storeException(memory, exception); } - } - catch (Exception exception) - { - storeException(memory, exception); } } ProgressManager.pop(itemBar); @@ -288,16 +339,12 @@ public class ModelLoader extends ModelBakery for(String s : getVariantNames(Items.bucket)) { ModelResourceLocation memory = getInventoryVariant(s); - try + IModel model = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation("forge", "item/bucket")); + // only on successful load, otherwise continue using the old model + if(model != getMissingModel()) { - IModel model = getModel(new ResourceLocation("forge", "item/bucket")); - // only on successful load, otherwise continue using the old model stateModels.put(memory, model); } - catch(IOException e) - { - // use the original vanilla model - } } setBucketModel(Items.water_bucket); @@ -319,16 +366,12 @@ public class ModelLoader extends ModelBakery for(String s : getVariantNames(Items.milk_bucket)) { ModelResourceLocation memory = getInventoryVariant(s); - try + IModel model = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation("forge", "item/bucket_milk")); + // only on successful load, otherwise continue using the old model + if(model != getMissingModel()) { - IModel model = getModel(new ResourceLocation("forge", "item/bucket_milk")); - // only on successful load, otherwise continue using the old model stateModels.put(memory, model); } - catch(IOException e) - { - // use the original vanilla model - } } } } @@ -347,6 +390,9 @@ public class ModelLoader extends ModelBakery } } + /** + * Hooked from ModelBakery, allows using MRLs that don't end with "inventory" for items. + */ public static ModelResourceLocation getInventoryVariant(String s) { if(s.contains("#")) @@ -356,77 +402,44 @@ public class ModelLoader extends ModelBakery return new ModelResourceLocation(s, "inventory"); } - public IModel getModel(ResourceLocation location) throws IOException - { - if(!ModelLoaderRegistry.loaded(location)) loadAnyModel(location); - return ModelLoaderRegistry.getModel(location); - } - @Override protected ResourceLocation getModelLocation(ResourceLocation model) { return new ResourceLocation(model.getResourceDomain(), model.getResourcePath() + ".json"); } - private void loadAnyModel(ResourceLocation location) throws IOException - { - if(loadingModels.contains(location)) - { - throw new IllegalStateException("circular model dependencies involving model " + location); - } - loadingModels.add(location); - try - { - IModel model = ModelLoaderRegistry.getModel(location); - resolveDependencies(model); - } - finally - { - loadingModels.remove(location); - } - } - - IModel getVariantModel(ModelResourceLocation location) - { - loadVariants(ImmutableList.of(location)); - IModel model = stateModels.get(location); - if(model == null) model = getMissingModel(); - return model; - } - - private void resolveDependencies(IModel model) throws IOException - { - for (ResourceLocation dep : model.getDependencies()) - { - if(dep instanceof ModelResourceLocation) - { - getVariantModel((ModelResourceLocation)dep); - } - else - { - getModel(dep); - } - } - textures.addAll(model.getTextures()); - } - - private class VanillaModelWrapper implements IRetexturableModel, IModelSimpleProperties, IAnimatedModel + private final class VanillaModelWrapper implements IRetexturableModel, IModelSimpleProperties, IModelUVLock, IAnimatedModel { private final ResourceLocation location; private final ModelBlock model; + private final boolean uvlock; private final ModelBlockAnimation animation; - public VanillaModelWrapper(ResourceLocation location, ModelBlock model, ModelBlockAnimation animation) + public VanillaModelWrapper(ResourceLocation location, ModelBlock model, boolean uvlock, ModelBlockAnimation animation) { this.location = location; this.model = model; + this.uvlock = uvlock; this.animation = animation; } public Collection getDependencies() { - if(model.getParentLocation() == null || model.getParentLocation().getResourcePath().startsWith("builtin/")) return Collections.emptyList(); - return Collections.singletonList(model.getParentLocation()); + Set set = Sets.newHashSet(); + for(ResourceLocation dep : model.getOverrideLocations()) + { + if(!location.equals(dep)) + { + set.add(dep); + // TODO: check if this can go somewhere else, random access to global things is bad + stateModels.put(getInventoryVariant(dep.toString()), ModelLoaderRegistry.getModelOrLogError(dep, "Could not load override model " + dep + " for model " + location)); + } + } + if(model.getParentLocation() != null && !model.getParentLocation().getResourcePath().startsWith("builtin/")) + { + set.add(model.getParentLocation()); + } + return ImmutableSet.copyOf(set); } public Collection getTextures() @@ -440,30 +453,14 @@ public class ModelLoader extends ModelBakery } else { - try + IModel parent = ModelLoaderRegistry.getModelOrLogError(model.getParentLocation(), "Could not load vanilla model parent '" + model.getParentLocation() + "' for '" + model); + if(parent instanceof VanillaModelWrapper) { - IModel parent = getModel(model.getParentLocation()); - if(parent instanceof VanillaModelWrapper) - { - model.parent = ((VanillaModelWrapper) parent).model; - } - else - { - throw new IllegalStateException("vanilla model '" + model + "' can't have non-vanilla parent"); - } + model.parent = ((VanillaModelWrapper) parent).model; } - catch (IOException e) + else { - FMLLog.warning("Could not load vanilla model parent '" + model.getParentLocation() + "' for '" + model + "': " + e.toString()); - IModel missing = ModelLoader.this.getMissingModel(); - if (missing instanceof VanillaModelWrapper) - { - model.parent = ((VanillaModelWrapper)missing).model; - } - else - { - throw new IllegalStateException("vanilla model '" + model + "' has missing parent, and missing model is not a vanilla model"); - } + throw new IllegalStateException("vanilla model '" + model + "' can't have non-vanilla parent"); } } } @@ -480,15 +477,6 @@ public class ModelLoader extends ModelBakery { builder.add(loc); } - // mojang hardcode - if(model.getRootModel() == MODEL_COMPASS && !loc.equals(TextureMap.LOCATION_MISSING_TEXTURE)) - { - TextureAtlasSprite.setLocationNameCompass(loc.toString()); - } - else if(model.getRootModel() == MODEL_CLOCK && !loc.equals(TextureMap.LOCATION_MISSING_TEXTURE)) - { - TextureAtlasSprite.setLocationNameClock(loc.toString()); - } } } for(String s : model.textures.values()) @@ -501,7 +489,7 @@ public class ModelLoader extends ModelBakery return builder.build(); } - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + public IBakedModel bake(IModelState state, final VertexFormat format, Function bakedTextureGetter) { if(!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT)) { @@ -517,13 +505,7 @@ public class ModelLoader extends ModelBakery newTransforms.add(animation.getPartTransform(state, part, i)); } - ItemCameraTransforms transforms = model.func_181682_g(); - boolean uvlock = false; - if(state instanceof UVLock) - { - uvlock = true; - state = ((UVLock)state).getParent(); - } + ItemCameraTransforms transforms = model.getAllTransforms(); Map tMap = Maps.newHashMap(); tMap.putAll(IPerspectiveAwareModel.MapWrapper.getTransforms(transforms)); tMap.putAll(IPerspectiveAwareModel.MapWrapper.getTransforms(state)); @@ -533,18 +515,19 @@ public class ModelLoader extends ModelBakery { return new ItemLayerModel(model).bake(perState, format, bakedTextureGetter); } - if(isCustomRenderer(model)) return new IFlexibleBakedModel.Wrapper(new BuiltInModel(transforms), format); - return bakeNormal(model, perState, state.apply(Optional.absent()).or(TRSRTransformation.identity()), newTransforms, format, bakedTextureGetter, uvlock); + if(isCustomRenderer(model)) return new BuiltInModel(transforms, model.createOverrides()); + return bakeNormal(model, perState, state, newTransforms, format, bakedTextureGetter, uvlock); } - private IFlexibleBakedModel bakeNormal(ModelBlock model, IModelState perState, final TRSRTransformation modelState, List newTransforms, VertexFormat format, final Function bakedTextureGetter, boolean uvLocked) + private IBakedModel bakeNormal(ModelBlock model, IModelState perState, final IModelState modelState, List newTransforms, final VertexFormat format, final Function bakedTextureGetter, boolean uvLocked) { + final TRSRTransformation baseState = modelState.apply(Optional.absent()).or(TRSRTransformation.identity()); TextureAtlasSprite particle = bakedTextureGetter.apply(new ResourceLocation(model.resolveTextureName("particle"))); - SimpleBakedModel.Builder builder = (new SimpleBakedModel.Builder(model)).setTexture(particle); + SimpleBakedModel.Builder builder = (new SimpleBakedModel.Builder(model, model.createOverrides())).setTexture(particle); for(int i = 0; i < model.getElements().size(); i++) { BlockPart part = model.getElements().get(i); - TRSRTransformation transformation = modelState; + TRSRTransformation transformation = baseState; if(newTransforms.get(i) != null) { transformation = transformation.compose(newTransforms.get(i)); @@ -562,39 +545,44 @@ public class ModelLoader extends ModelBakery } else { - builder.addFaceQuad(modelState.rotate(e.getValue().cullFace), makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), transformation, uvLocked)); + builder.addFaceQuad(baseState.rotate(e.getValue().cullFace), makeBakedQuad(part, e.getValue(), textureatlassprite1, e.getKey(), transformation, uvLocked)); } } } - return new ISmartBlockModel.PerspectiveWrapper(new IPerspectiveAwareModel.MapWrapper(new IFlexibleBakedModel.Wrapper(builder.makeBakedModel(), format), perState)) + return new IPerspectiveAwareModel.MapWrapper(builder.makeBakedModel(), perState) { - public IBakedModel handleBlockState(IBlockState state) + private final ItemOverrideList overrides = new AnimationItemOverrideList(VanillaModelWrapper.this, modelState, format, bakedTextureGetter, super.getOverrides()); + + @Override + public List getQuads(IBlockState state, EnumFacing side, long rand) { - return VanillaModelWrapper.this.handleBlockState(parent, bakedTextureGetter, modelState, state); + if(state instanceof IExtendedBlockState) + { + IExtendedBlockState exState = (IExtendedBlockState)state; + if(exState.getUnlistedNames().contains(Properties.AnimationProperty)) + { + IModelState newState = exState.getValue(Properties.AnimationProperty); + IExtendedBlockState newExState = exState.withProperty(Properties.AnimationProperty, null); + if(newState != null) + { + return VanillaModelWrapper.this.bake(new ModelStateComposition(modelState, newState), format, bakedTextureGetter).getQuads(newExState, side, rand); + } + } + } + return super.getQuads(state, side, rand); + } + + @Override + public ItemOverrideList getOverrides() + { + return overrides; } }; } - private IBakedModel handleBlockState(IFlexibleBakedModel model, Function bakedTextureGetter, TRSRTransformation modelState, IBlockState state) - { - if(state instanceof IExtendedBlockState) - { - IExtendedBlockState exState = (IExtendedBlockState)state; - if(exState.getUnlistedNames().contains(Properties.AnimationProperty)) - { - IModelState newState = exState.getValue(Properties.AnimationProperty); - if(newState != null) - { - return VanillaModelWrapper.this.bake(new ModelStateComposition(modelState, newState), model.getFormat(), bakedTextureGetter); - } - } - } - return model; - } - @Override - public IModel retexture(ImmutableMap textures) + public VanillaModelWrapper retexture(ImmutableMap textures) { if (textures.isEmpty()) return this; @@ -607,7 +595,7 @@ public class ModelLoader extends ModelBakery ModelBlock newModel = new ModelBlock(this.model.getParentLocation(), elements, Maps.newHashMap(this.model.textures), this.model.isAmbientOcclusion(), this.model.isGui3d(), //New Textures man VERY IMPORTANT - model.func_181682_g()); + model.getAllTransforms(), Lists.newArrayList(model.getOverrides())); newModel.name = this.model.name; newModel.parent = this.model.parent; @@ -651,7 +639,7 @@ public class ModelLoader extends ModelBakery } } - return new VanillaModelWrapper(location, newModel, animation); + return new VanillaModelWrapper(location, newModel, uvlock, animation); } @Override @@ -676,10 +664,10 @@ public class ModelLoader extends ModelBakery { return this; } - ModelBlock newModel = new ModelBlock(model.getParentLocation(), model.getElements(), model.textures, value, model.isGui3d(), model.func_181682_g()); + ModelBlock newModel = new ModelBlock(model.getParentLocation(), model.getElements(), model.textures, value, model.isGui3d(), model.getAllTransforms(), Lists.newArrayList(model.getOverrides())); newModel.parent = model.parent; newModel.name = model.name; - return new VanillaModelWrapper(location, newModel, animation); + return new VanillaModelWrapper(location, newModel, uvlock, animation); } @Override @@ -689,79 +677,63 @@ public class ModelLoader extends ModelBakery { return this; } - ModelBlock newModel = new ModelBlock(model.getParentLocation(), model.getElements(), model.textures, model.ambientOcclusion, value, model.func_181682_g()); + ModelBlock newModel = new ModelBlock(model.getParentLocation(), model.getElements(), model.textures, model.ambientOcclusion, value, model.getAllTransforms(), Lists.newArrayList(model.getOverrides())); newModel.parent = model.parent; newModel.name = model.name; - return new VanillaModelWrapper(location, newModel, animation); + return new VanillaModelWrapper(location, newModel, uvlock, animation); + } + + @Override + public IModel uvlock(boolean value) + { + if(uvlock == value) + { + return this; + } + return new VanillaModelWrapper(location, model, value, animation); } } - @Deprecated // rework in 1.9 - public static class UVLock implements IModelState - { - private final IModelState parent; - - public UVLock(IModelState parent) - { - this.parent = parent; - } - - public IModelState getParent() - { - return parent; - } - - public Optional apply(Optional part) - { - return parent.apply(part); - } - } - - private class WeightedRandomModel implements IModel + private static final class WeightedRandomModel implements IModel { private final List variants; private final List locations = new ArrayList(); + private final Set textures = Sets.newHashSet(); private final List models = new ArrayList(); private final IModelState defaultState; - public WeightedRandomModel(ModelResourceLocation parent, Variants variants) + public WeightedRandomModel(ResourceLocation parent, VariantList variants) throws Exception { - this.variants = variants.getVariants(); + this.variants = variants.getVariantList(); ImmutableList.Builder> builder = ImmutableList.builder(); - for (Variant v : variants.getVariants()) + for (Variant v : this.variants) { ResourceLocation loc = v.getModelLocation(); locations.add(loc); - IModel model = null; - try + /* + * Vanilla eats this, which makes it only show variants that have models. + * But that doesn't help debugging, so throw the exception + */ + IModel model; + if(loc.equals(MODEL_MISSING)) { - model = getModel(loc); + // explicit missing location, happens if blockstate has "model"=null + model = ModelLoaderRegistry.getMissingModel(); } - catch (Exception e) + else { - /* - * Vanilla eats this, which makes it only show variants that have models. - * But that doesn't help debugging, so we maintain the missing model - * so that resource pack makers have a hint that their states are broken. - */ - FMLLog.warning("Unable to load block model: \'" + loc + "\' for variant: \'" + parent + "\': " + e.toString()); - model = getMissingModel(); + model = ModelLoaderRegistry.getModel(loc); } - if (v instanceof ISmartVariant) + // FIXME: is this the place? messes up dependency and texture resolution + model = v.process(model); + for(ResourceLocation location : model.getDependencies()) { - model = ((ISmartVariant)v).process(model, ModelLoader.this); - try - { - resolveDependencies(model); - } - catch (IOException e) - { - FMLLog.getLogger().error("Exception resolving indirect dependencies for model" + loc, e); - } - textures.addAll(model.getTextures()); // Kick this, just in case. + ModelLoaderRegistry.getModelOrMissing(location); } + //FMLLog.getLogger().error("Exception resolving indirect dependencies for model" + loc, e); + textures.addAll(model.getTextures()); // Kick this, just in case. models.add(model); builder.add(Pair.of(model, v.getState())); @@ -769,7 +741,8 @@ public class ModelLoader extends ModelBakery if (models.size() == 0) //If all variants are missing, add one with the missing model and default rotation. { - IModel missing = getMissingModel(); + // FIXME: log this? + IModel missing = ModelLoaderRegistry.getMissingModel(); models.add(missing); builder.add(Pair.of(missing, TRSRTransformation.identity())); } @@ -784,16 +757,10 @@ public class ModelLoader extends ModelBakery public Collection getTextures() { - return Collections.emptyList(); + return ImmutableSet.copyOf(textures); } - private IModelState addUV(boolean uv, IModelState state) - { - if(uv) return new UVLock(state); - return state; - } - - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) { if(!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT)) { @@ -801,18 +768,16 @@ public class ModelLoader extends ModelBakery } if(variants.size() == 1) { - Variant v = variants.get(0); IModel model = models.get(0); - return model.bake(addUV(v.isUvLocked(), MultiModelState.getPartState(state, model, 0)), format, bakedTextureGetter); + return model.bake(MultiModelState.getPartState(state, model, 0), format, bakedTextureGetter); } WeightedBakedModel.Builder builder = new WeightedBakedModel.Builder(); for(int i = 0; i < variants.size(); i++) { IModel model = models.get(i); - Variant v = variants.get(i); - builder.add(model.bake(addUV(v.isUvLocked(), MultiModelState.getPartState(state, model, i)), format, bakedTextureGetter), variants.get(i).getWeight()); + builder.add(model.bake(MultiModelState.getPartState(state, model, i), format, bakedTextureGetter), variants.get(i).getWeight()); } - return new FlexibleWeightedBakedModel(builder.build(), Attributes.DEFAULT_BAKED_FORMAT); + return builder.build(); } public IModelState getDefaultState() @@ -821,47 +786,25 @@ public class ModelLoader extends ModelBakery } } - private static class FlexibleWeightedBakedModel extends WeightedBakedModel implements IFlexibleBakedModel - { - private final VertexFormat format; - - public FlexibleWeightedBakedModel(WeightedBakedModel parent, VertexFormat format) - { - super(parent.models); - this.format = format; - } - - public VertexFormat getFormat() - { - return format; - } - } - - public IModel getMissingModel() + protected IModel getMissingModel() { if (missingModel == null) { try { - missingModel = getModel(new ResourceLocation(MODEL_MISSING.getResourceDomain(), MODEL_MISSING.getResourcePath())); + missingModel = VanillaLoader.INSTANCE.loadModel(new ResourceLocation(MODEL_MISSING.getResourceDomain(), MODEL_MISSING.getResourcePath())); } - catch (IOException e) + catch(Exception e) { - // If this ever happens things are bad. Should never NOT be able to load the missing model. - Throwables.propagate(e); + throw new RuntimeException("Missing the missing model, this should never happen"); } } return missingModel; } - public IModel getItemModel() + protected static enum VanillaLoader implements ICustomModelLoader { - return itemModel; - } - - static enum VanillaLoader implements ICustomModelLoader - { - instance; + INSTANCE; private ModelLoader loader; @@ -875,37 +818,54 @@ public class ModelLoader extends ModelBakery return loader; } - public void onResourceManagerReload(IResourceManager resourceManager) - { - // do nothing, cause loader will store the reference to the resourceManager - } + // NOOP, handled in loader + public void onResourceManagerReload(IResourceManager resourceManager) {} public boolean accepts(ResourceLocation modelLocation) { return true; } - public IModel loadModel(ResourceLocation modelLocation) throws IOException + public IModel loadModel(ResourceLocation modelLocation) throws Exception { + if(modelLocation.equals(MODEL_MISSING) && loader.missingModel != null) + { + return loader.getMissingModel(); + } String modelPath = modelLocation.getResourcePath(); if(modelLocation.getResourcePath().startsWith("models/")) { modelPath = modelPath.substring("models/".length()); } ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getResourceDomain(), "armatures/" + modelPath + ".json"); - ModelBlockAnimation animation = Animation.INSTANCE.loadVanillaAnimation(armatureLocation); - return loader.new VanillaModelWrapper(modelLocation, loader.loadModel(modelLocation), animation); + ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation(loader.resourceManager, armatureLocation); + ModelBlock model = loader.loadModel(modelLocation); + IModel iModel = loader.new VanillaModelWrapper(modelLocation, model, false, animation); + if(loader.missingModel == null && modelLocation.equals(MODEL_MISSING)) + { + loader.missingModel = iModel; + } + return iModel; + } + + @Override + public String toString() + { + return "VanillaLoader.INSTANCE"; } } - public static class White extends TextureAtlasSprite + /** + * 16x16 pure white sprite. + */ + public static final class White extends TextureAtlasSprite { - public static ResourceLocation loc = new ResourceLocation("white"); - public static White instance = new White(); + public static final ResourceLocation LOCATION = new ResourceLocation("white"); + public static final White INSTANCE = new White(); - protected White() + private White() { - super(loc.toString()); + super(LOCATION.toString()); } @Override @@ -921,29 +881,41 @@ public class ModelLoader extends ModelBakery Graphics2D graphics = image.createGraphics(); graphics.setBackground(Color.WHITE); graphics.clearRect(0, 0, 16, 16); - BufferedImage[] images = new BufferedImage[Minecraft.getMinecraft().gameSettings.mipmapLevels + 1]; - images[0] = image; - try - { - loadSprite(images, null); - } - catch(IOException e) - { - throw new RuntimeException(e); - } + int[][] pixels = new int[Minecraft.getMinecraft().gameSettings.mipmapLevels + 1][]; + pixels[0] = new int[image.getWidth() * image.getHeight()]; + image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels[0], 0, image.getWidth()); + this.clearFramesTextureData(); + this.framesTextureData.add(pixels); return false; } public void register(TextureMap map) { - map.setTextureEntry(White.loc.toString(), White.instance); + map.setTextureEntry(White.LOCATION.toString(), White.INSTANCE); } } + private static class ItemLoadingException extends ModelLoaderRegistry.LoaderException + { + private final Exception normalException; + private final Exception blockstateException; + + public ItemLoadingException(String message, Exception normalException, Exception blockstateException) + { + super(message); + this.normalException = normalException; + this.blockstateException = blockstateException; + } + } + + /** + * Internal, do not use. + */ public void onPostBakeEvent(IRegistry modelRegistry) { IBakedModel missingModel = modelRegistry.getObject(MODEL_MISSING); Map modelErrors = Maps.newHashMap(); + Set printedBlockStateErrors = Sets.newHashSet(); Multimap reverseBlockMap = null; Multimap reverseItemMap = null; if(enableVerboseMissingInfo) @@ -959,7 +931,7 @@ public class ModelLoader extends ModelBakery for(String s : getVariantNames(item)) { ModelResourceLocation memory = getInventoryVariant(s); - reverseItemMap.put(memory, item.getRegistryName()); + reverseItemMap.put(memory, item.getRegistryName().toString()); } } } @@ -977,7 +949,7 @@ public class ModelLoader extends ModelBakery Integer errorCountBox = modelErrors.get(domain); int errorCount = errorCountBox == null ? 0 : errorCountBox; errorCount++; - if(errorCount < 5) + if(errorCount < verboseMissingInfoCount) { String errorMsg = "Exception loading model for variant " + entry.getKey(); if(enableVerboseMissingInfo) @@ -1008,7 +980,22 @@ public class ModelLoader extends ModelBakery } } } - FMLLog.getLogger().error(errorMsg, entry.getValue()); + if(entry.getValue() instanceof ItemLoadingException) + { + ItemLoadingException ex = (ItemLoadingException)entry.getValue(); + FMLLog.getLogger().error(errorMsg + ", normal location exception: ", ex.normalException); + FMLLog.getLogger().error(errorMsg + ", blockstate location exception: ", ex.blockstateException); + } + else + { + FMLLog.getLogger().error(errorMsg, entry.getValue()); + } + ResourceLocation blockstateLocation = new ResourceLocation(location.getResourceDomain(), location.getResourcePath()); + if(loadingExceptions.containsKey(blockstateLocation) && !printedBlockStateErrors.contains(blockstateLocation)) + { + FMLLog.getLogger().error("Exception loading blockstate for the variant " + location + ": ", loadingExceptions.get(blockstateLocation)); + printedBlockStateErrors.add(blockstateLocation); + } } modelErrors.put(domain, errorCount); } @@ -1027,7 +1014,7 @@ public class ModelLoader extends ModelBakery Integer errorCountBox = modelErrors.get(domain); int errorCount = errorCountBox == null ? 0 : errorCountBox; errorCount++; - if(errorCount < 5) + if(errorCount < verboseMissingInfoCount) { FMLLog.severe("Model definition for location %s not found", missing); } @@ -1040,9 +1027,9 @@ public class ModelLoader extends ModelBakery } for(Map.Entry e : modelErrors.entrySet()) { - if(e.getValue() >= 5) + if(e.getValue() >= verboseMissingInfoCount) { - FMLLog.severe("Suppressed additional %s model loading errors for domain %s", e.getValue(), e.getKey()); + FMLLog.severe("Suppressed additional %s model loading errors for domain %s", e.getValue() - verboseMissingInfoCount, e.getKey()); } } isLoading = false; @@ -1058,6 +1045,9 @@ public class ModelLoader extends ModelBakery customStateMappers.put(block.delegate, mapper); } + /** + * Internal, do not use. + */ public static void onRegisterAllBlocks(BlockModelShapes shapes) { for (Entry, IStateMapper> e : customStateMappers.entrySet()) @@ -1088,6 +1078,9 @@ public class ModelLoader extends ModelBakery customMeshDefinitions.put(item.delegate, meshDefinition); } + /** + * Helper method for registering all itemstacks for given item to map to universal bucket model. + */ public static void setBucketModelDefinition(Item item) { ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { @@ -1100,6 +1093,9 @@ public class ModelLoader extends ModelBakery ModelBakery.registerItemVariants(item, ModelDynBucket.LOCATION); } + /** + * Internal, do not use. + */ public static void onRegisterItems(ItemModelMesher mesher) { for (Map.Entry, ItemMeshDefinition> e : customMeshDefinitions.entrySet()) @@ -1114,7 +1110,7 @@ public class ModelLoader extends ModelBakery private static enum DefaultTextureGetter implements Function { - instance; + INSTANCE; public TextureAtlasSprite apply(ResourceLocation location) { @@ -1122,8 +1118,112 @@ public class ModelLoader extends ModelBakery } } + /** + * Get the default texture getter the models will be baked with. + */ public static Function defaultTextureGetter() { - return DefaultTextureGetter.instance; + return DefaultTextureGetter.INSTANCE; + } + + protected static enum VariantLoader implements ICustomModelLoader + { + INSTANCE; + + private ModelLoader loader; + + void setLoader(ModelLoader loader) + { + this.loader = loader; + } + + // NOOP, handled in loader + @Override + public void onResourceManagerReload(IResourceManager resourceManager) {} + + @Override + public boolean accepts(ResourceLocation modelLocation) + { + return modelLocation instanceof ModelResourceLocation; + } + + @Override + public IModel loadModel(ResourceLocation modelLocation) throws Exception + { + ModelResourceLocation variant = (ModelResourceLocation) modelLocation; + ModelBlockDefinition definition = loader.getModelBlockDefinition(variant); + try + { + VariantList variants = definition.getVariant(variant.getVariant()); + return new WeightedRandomModel(variant, variants); + } + catch(MissingVariantException e) + { + if(definition.hasMultipartData()) + { + return new MultipartModel(new ResourceLocation(variant.getResourceDomain(), variant.getResourcePath()), definition.getMultipartData()); + } + throw e; + } + } + + @Override + public String toString() + { + return "VariantLoader.INSTANCE"; + } + } + + private static class MultipartModel implements IModel + { + private final ResourceLocation location; + private final Multipart multipart; + private final ImmutableMap partModels; + + public MultipartModel(ResourceLocation location, Multipart multipart) throws Exception + { + this.location = location; + this.multipart = multipart; + ImmutableMap.Builder builder = ImmutableMap.builder(); + for (Selector selector : multipart.getSelectors()) + { + builder.put(selector, new WeightedRandomModel(location, selector.getVariantList())); + } + partModels = builder.build(); + } + + // FIXME: represent selectors as dependencies? + @Override + public Collection getDependencies() + { + return ImmutableSet.of(); + } + + @Override + public Collection getTextures() + { + return ImmutableSet.of(); + } + + // FIXME + @Override + public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + { + MultipartBakedModel.Builder builder = new MultipartBakedModel.Builder(); + + for (Selector selector : multipart.getSelectors()) + { + builder.putModel(selector.getPredicate(multipart.getStateContainer()), partModels.get(selector).bake(partModels.get(selector).getDefaultState(), format, bakedTextureGetter)); + } + + IBakedModel bakedModel = builder.makeMultipartModel(); + return bakedModel; + } + + @Override + public IModelState getDefaultState() + { + return TRSRTransformation.identity(); + } } } diff --git a/src/main/java/net/minecraftforge/client/model/ModelLoaderRegistry.java b/src/main/java/net/minecraftforge/client/model/ModelLoaderRegistry.java index 33fdf8531a..46ae29dd22 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelLoaderRegistry.java +++ b/src/main/java/net/minecraftforge/client/model/ModelLoaderRegistry.java @@ -1,41 +1,49 @@ package net.minecraftforge.client.model; -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; +import java.util.Deque; import java.util.Map; import java.util.Set; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.resources.IReloadableResourceManager; import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader.VanillaLoader; +import net.minecraftforge.client.model.ModelLoader.VariantLoader; import net.minecraftforge.client.model.b3d.B3DLoader; import net.minecraftforge.client.model.obj.OBJLoader; +import net.minecraftforge.common.animation.ITimeValue; +import net.minecraftforge.common.model.animation.AnimationStateMachine; +import net.minecraftforge.common.model.animation.IAnimationStateMachine; import net.minecraftforge.fml.common.FMLLog; -import org.apache.logging.log4j.Level; +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.common.collect.Queues; +import com.google.common.collect.Sets; /* * Central hub for custom model loaders. */ public class ModelLoaderRegistry { - private static final Set loaders = new HashSet(); - private static final Map cache = new HashMap(); + private static final Set loaders = Sets.newHashSet(); + private static final Map cache = Maps.newHashMap(); + private static final Deque loadingModels = Queues.newArrayDeque(); + private static final Set textures = Sets.newHashSet(); + private static IResourceManager manager; // Forge built-in loaders static { - registerLoader(B3DLoader.instance); - registerLoader(OBJLoader.instance); - registerLoader(ModelFluid.FluidLoader.instance); - registerLoader(ItemLayerModel.Loader.instance); - registerLoader(MultiLayerModel.Loader.instance); - registerLoader(ModelDynBucket.LoaderDynBucket.instance); + registerLoader(B3DLoader.INSTANCE); + registerLoader(OBJLoader.INSTANCE); + registerLoader(ModelFluid.FluidLoader.INSTANCE); + registerLoader(ItemLayerModel.Loader.INSTANCE); + registerLoader(MultiLayerModel.Loader.INSTANCE); + registerLoader(ModelDynBucket.LoaderDynBucket.INSTANCE); } /* @@ -55,6 +63,7 @@ public class ModelLoaderRegistry public static ResourceLocation getActualLocation(ResourceLocation location) { + if(location instanceof ModelResourceLocation) return location; if(location.getResourcePath().startsWith("builtin/")) return location; return new ResourceLocation(location.getResourceDomain(), "models/" + location.getResourcePath()); } @@ -64,25 +73,20 @@ public class ModelLoaderRegistry * ResourceLocation argument will be passed directly to the custom model loaders, * ModelResourceLocation argument will be loaded through the blockstate system. */ - public static IModel getModel(ResourceLocation location) throws IOException + public static IModel getModel(ResourceLocation location) throws Exception { IModel model; - if(location instanceof ModelResourceLocation) + if(cache.containsKey(location)) return cache.get(location); + for(ResourceLocation loading : loadingModels) { - ModelLoader loader = ModelLoader.VanillaLoader.instance.getLoader(); - if(loader != null) + if(location.getClass() == loading.getClass() && location.equals(loading)) { - model = loader.getVariantModel((ModelResourceLocation)location); - } - else - { - FMLLog.log(Level.ERROR, "Loading model too early, skipping: %s", location); - model = getMissingModel(); + throw new LoaderException("circular model dependencies, stack: [" + Joiner.on(", ").join(loadingModels) + "]"); } } - else + loadingModels.addLast(location); + try { - if(cache.containsKey(location)) return cache.get(location); ResourceLocation actual = getActualLocation(location); ICustomModelLoader accepted = null; for(ICustomModelLoader loader : loaders) @@ -93,61 +97,140 @@ public class ModelLoaderRegistry { if(accepted != null) { - FMLLog.severe("2 loaders (%s and %s) want to load the same model %s", accepted, loader, location); - throw new IllegalStateException("2 loaders want to load the same model"); + throw new LoaderException(String.format("2 loaders (%s and %s) want to load the same model %s", accepted, loader, location)); } accepted = loader; } } catch(Exception e) { - FMLLog.log(Level.ERROR, e, "Exception checking if model %s can be loaded with loader %s, skipping", location, loader); + throw new LoaderException(String.format("Exception checking if model %s can be loaded with loader %s, skipping", location, loader), e); } } - // no custom loaders found, try vanilla one + // no custom loaders found, try vanilla ones if(accepted == null) { - if(VanillaLoader.instance.accepts(actual)) accepted = VanillaLoader.instance; + if(VariantLoader.INSTANCE.accepts(actual)) + { + accepted = VariantLoader.INSTANCE; + } + else if(VanillaLoader.INSTANCE.accepts(actual)) + { + accepted = VanillaLoader.INSTANCE; + } } if(accepted == null) { - FMLLog.severe("no suitable loader found for the model %s, skipping", location); - model = getMissingModel(); + throw new LoaderException("no suitable loader found for the model " + location + ", skipping"); } - else + try { - try - { - model = accepted.loadModel(actual); - } - catch (IOException e) - { - throw e; - } - catch(Exception e) - { - FMLLog.log(Level.ERROR, e, "Exception loading model %s with loader %s, skipping", location, accepted); - model = getMissingModel(); - } + model = accepted.loadModel(actual); + } + catch(Exception e) + { + throw new LoaderException(String.format("Exception loading model %s with loader %s, skipping", location, accepted), e); + } + if(model == getMissingModel()) + { + throw new LoaderException(String.format("Loader %s returned missing model while loading model %s", accepted, location)); + } + if(model == null) + { + throw new LoaderException(String.format("Loader %s returned null while loading model %s", accepted, location)); + } + textures.addAll(model.getTextures()); + } + finally + { + ResourceLocation popLoc = loadingModels.removeLast(); + if(popLoc != location) + { + throw new IllegalStateException("Corrupted loading model stack: " + popLoc + " != " + location); } } cache.put(location, model); + for (ResourceLocation dep : model.getDependencies()) + { + getModelOrMissing(dep); + } return model; } + /** + * Use this if you don't care about the exception and want some model anyway. + */ + public static IModel getModelOrMissing(ResourceLocation location) + { + try + { + return getModel(location); + } + catch(Exception e) + { + return getMissingModel(); + } + } + + /** + * Use this if you want the model, but need to log the error. + */ + public static IModel getModelOrLogError(ResourceLocation location, String error) + { + try + { + return getModel(location); + } + catch(Exception e) + { + FMLLog.getLogger().error(error, e); + return getMissingModel(); + } + } + public static IModel getMissingModel() { - return ModelLoader.VanillaLoader.instance.getLoader().getMissingModel(); + if(ModelLoader.VanillaLoader.INSTANCE.getLoader() == null) + { + throw new IllegalStateException("Using ModelLoaderRegistry too early."); + } + return ModelLoader.VanillaLoader.INSTANCE.getLoader().getMissingModel(); } - public static void clearModelCache() + public static void clearModelCache(IResourceManager manager) { + ModelLoaderRegistry.manager = manager; cache.clear(); // putting the builtin models in - cache.put(new ResourceLocation("minecraft:builtin/generated"), ModelLoader.VanillaLoader.instance.getLoader().getItemModel()); - cache.put(new ResourceLocation("minecraft:block/builtin/generated"), ModelLoader.VanillaLoader.instance.getLoader().getItemModel()); - cache.put(new ResourceLocation("minecraft:item/builtin/generated"), ModelLoader.VanillaLoader.instance.getLoader().getItemModel()); + cache.put(new ResourceLocation("minecraft:builtin/generated"), ItemLayerModel.INSTANCE); + cache.put(new ResourceLocation("minecraft:block/builtin/generated"), ItemLayerModel.INSTANCE); + cache.put(new ResourceLocation("minecraft:item/builtin/generated"), ItemLayerModel.INSTANCE); + } + + static Iterable getTextures() + { + return textures; + } + + public static class LoaderException extends Exception + { + public LoaderException(String message) + { + super(message); + } + + public LoaderException(String message, Throwable cause) + { + super(message, cause); + } + + private static final long serialVersionUID = 1L; + } + + public static IAnimationStateMachine loadASM(ResourceLocation location, ImmutableMap customParameters) + { + return AnimationStateMachine.load(manager, location, customParameters); } } diff --git a/src/main/java/net/minecraftforge/client/model/ModelProcessingHelper.java b/src/main/java/net/minecraftforge/client/model/ModelProcessingHelper.java new file mode 100644 index 0000000000..c4d5d82dfc --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/ModelProcessingHelper.java @@ -0,0 +1,51 @@ +package net.minecraftforge.client.model; + +import com.google.common.collect.ImmutableMap; + +public class ModelProcessingHelper +{ + public static IModel retexture(IModel model, ImmutableMap textures) + { + if(model instanceof IRetexturableModel) + { + model = ((IRetexturableModel)model).retexture(textures); + } + return model; + } + + public static IModel customData(IModel model, ImmutableMap customData) + { + if(model instanceof IModelCustomData) + { + model = ((IModelCustomData)model).process(customData); + } + return model; + } + + public static IModel smoothLighting(IModel model, boolean smooth) + { + if(model instanceof IModelSimpleProperties) + { + model = ((IModelSimpleProperties)model).smoothLighting(smooth); + } + return model; + } + + public static IModel gui3d(IModel model, boolean gui3d) + { + if(model instanceof IModelSimpleProperties) + { + model = ((IModelSimpleProperties)model).gui3d(gui3d); + } + return model; + } + + public static IModel uvlock(IModel model, boolean uvlock) + { + if(model instanceof IModelUVLock) + { + model = ((IModelUVLock)model).uvlock(uvlock); + } + return model; + } +} diff --git a/src/main/java/net/minecraftforge/client/model/ModelStateComposition.java b/src/main/java/net/minecraftforge/client/model/ModelStateComposition.java index 231b47b0ed..07eed52826 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelStateComposition.java +++ b/src/main/java/net/minecraftforge/client/model/ModelStateComposition.java @@ -1,5 +1,9 @@ package net.minecraftforge.client.model; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; + import com.google.common.base.Optional; public class ModelStateComposition implements IModelState diff --git a/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java b/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java index 8a67e2a750..80e0d4caf7 100644 --- a/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java +++ b/src/main/java/net/minecraftforge/client/model/MultiLayerModel.java @@ -1,29 +1,29 @@ package net.minecraftforge.client.model; -import java.io.IOException; import java.util.Collection; import java.util.List; import javax.vecmath.Matrix4f; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.fml.common.FMLLog; import org.apache.commons.lang3.tuple.Pair; -import org.apache.logging.log4j.Level; import com.google.common.base.Function; import com.google.common.base.Optional; @@ -32,13 +32,13 @@ import com.google.common.collect.ImmutableMap; import com.google.gson.JsonElement; import com.google.gson.JsonParser; -public class MultiLayerModel implements IModelCustomData +public final class MultiLayerModel implements IModelCustomData { - public static final MultiLayerModel instance = new MultiLayerModel(ImmutableMap., ModelResourceLocation>of()); + public static final MultiLayerModel INSTANCE = new MultiLayerModel(ImmutableMap., ModelResourceLocation>of()); - private final ImmutableMap, ModelResourceLocation> models; + private final ImmutableMap, ModelResourceLocation> models; - public MultiLayerModel(ImmutableMap, ModelResourceLocation> models) + public MultiLayerModel(ImmutableMap, ModelResourceLocation> models) { this.models = models; } @@ -55,34 +55,24 @@ public class MultiLayerModel implements IModelCustomData return ImmutableList.of(); } - private static ImmutableMap, IFlexibleBakedModel> buildModels(ImmutableMap, ModelResourceLocation> models, IModelState state, VertexFormat format, Function bakedTextureGetter) + private static ImmutableMap, IBakedModel> buildModels(ImmutableMap, ModelResourceLocation> models, IModelState state, VertexFormat format, Function bakedTextureGetter) { - ImmutableMap.Builder, IFlexibleBakedModel> builder = ImmutableMap.builder(); - for(Optional key : models.keySet()) + ImmutableMap.Builder, IBakedModel> builder = ImmutableMap.builder(); + for(Optional key : models.keySet()) { - IModel model; - try - { - model = ModelLoaderRegistry.getModel(models.get(key)); - } - catch (IOException e) - { - FMLLog.log(Level.ERROR, e, "Couldn't load MultiLayerModel dependency: %s", models.get(key)); - model = ModelLoaderRegistry.getMissingModel(); - } + IModel model = ModelLoaderRegistry.getModelOrLogError(models.get(key), "Couldn't load MultiLayerModel dependency: " + models.get(key)); builder.put(key, model.bake(new ModelStateComposition(state, model.getDefaultState()), format, bakedTextureGetter)); } return builder.build(); } @Override - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) { IModel missing = ModelLoaderRegistry.getMissingModel(); return new MultiLayerBakedModel( buildModels(models, state, format, bakedTextureGetter), missing.bake(missing.getDefaultState(), format, bakedTextureGetter), - format, IPerspectiveAwareModel.MapWrapper.getTransforms(state) ); } @@ -94,16 +84,16 @@ public class MultiLayerModel implements IModelCustomData } @Override - public IModel process(ImmutableMap customData) + public MultiLayerModel process(ImmutableMap customData) { - ImmutableMap.Builder, ModelResourceLocation> builder = ImmutableMap.builder(); + ImmutableMap.Builder, ModelResourceLocation> builder = ImmutableMap.builder(); for(String key : customData.keySet()) { if("base".equals(key)) { - builder.put(Optional.absent(), getLocation(customData.get(key))); + builder.put(Optional.absent(), getLocation(customData.get(key))); } - for(EnumWorldBlockLayer layer : EnumWorldBlockLayer.values()) + for(BlockRenderLayer layer : BlockRenderLayer.values()) { if(layer.toString().equals(key)) { @@ -111,8 +101,8 @@ public class MultiLayerModel implements IModelCustomData } } } - ImmutableMap, ModelResourceLocation> models = builder.build(); - if(models.isEmpty()) return instance; + ImmutableMap, ModelResourceLocation> models = builder.build(); + if(models.isEmpty()) return INSTANCE; return new MultiLayerModel(models); } @@ -127,38 +117,17 @@ public class MultiLayerModel implements IModelCustomData return new ModelResourceLocation("builtin/missing", "missing"); } - public static class MultiLayerBakedModel implements IFlexibleBakedModel, ISmartBlockModel, IPerspectiveAwareModel + private static final class MultiLayerBakedModel implements IPerspectiveAwareModel { - private final ImmutableMap, IFlexibleBakedModel> models; - private final VertexFormat format; + private final ImmutableMap, IBakedModel> models; private final ImmutableMap cameraTransforms;; - private final IFlexibleBakedModel base; - private final IFlexibleBakedModel missing; + private final IBakedModel base; + private final IBakedModel missing; private final ImmutableMap, ImmutableList> quads; - private static final Function defaultTextureGetter = new Function() - { - public TextureAtlasSprite apply(ResourceLocation location) - { - return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString()); - } - }; - - @Deprecated // remove 1.9 - public MultiLayerBakedModel(ImmutableMap, ModelResourceLocation> models, VertexFormat format, ImmutableMap cameraTransforms) - { - this( - buildModels(models, TRSRTransformation.identity(), format, defaultTextureGetter), - ModelLoaderRegistry.getMissingModel().bake(ModelLoaderRegistry.getMissingModel().getDefaultState(), format, defaultTextureGetter), - format, - cameraTransforms - ); - } - - public MultiLayerBakedModel(ImmutableMap, IFlexibleBakedModel> models, IFlexibleBakedModel missing, VertexFormat format, ImmutableMap cameraTransforms) + public MultiLayerBakedModel(ImmutableMap, IBakedModel> models, IBakedModel missing, ImmutableMap cameraTransforms) { this.models = models; - this.format = format; this.cameraTransforms = cameraTransforms; this.missing = missing; if(models.containsKey(Optional.absent())) @@ -178,33 +147,35 @@ public class MultiLayerModel implements IModelCustomData quads = quadBuilder.build(); } - private static ImmutableList buildQuads(ImmutableMap, IFlexibleBakedModel> models, Optional side) + private static ImmutableList buildQuads(ImmutableMap, IBakedModel> models, Optional side) { ImmutableList.Builder builder = ImmutableList.builder(); for(IBakedModel model : models.values()) { - if(side.isPresent()) - { - builder.addAll(model.getFaceQuads(side.get())); - } - else - { - builder.addAll(model.getGeneralQuads()); - } + builder.addAll(model.getQuads(null, side.orNull(), 0)); } return builder.build(); } @Override - public List getFaceQuads(EnumFacing side) + public List getQuads(IBlockState state, EnumFacing side, long rand) { - return quads.get(Optional.of(side)); - } - - @Override - public List getGeneralQuads() - { - return quads.get(Optional.absent()); + IBakedModel model; + BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer(); + if(layer == null) + { + return quads.get(Optional.fromNullable(side)); + } + else if(!models.containsKey(Optional.of(layer))) + { + model = missing; + } + else + { + model = models.get(Optional.of(layer)); + } + // assumes that child model will handle this state properly. FIXME? + return model.getQuads(state, side, rand); } @Override @@ -238,32 +209,21 @@ public class MultiLayerModel implements IModelCustomData } @Override - public IBakedModel handleBlockState(IBlockState state) - { - Optional layer = Optional.of(MinecraftForgeClient.getRenderLayer()); - if(!models.containsKey(layer)) - { - return missing; - } - return models.get(layer); - } - - @Override - public VertexFormat getFormat() - { - return format; - } - - @Override - public Pair handlePerspective(TransformType cameraTransformType) + public Pair handlePerspective(TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType); } + + @Override + public ItemOverrideList getOverrides() + { + return ItemOverrideList.NONE; + } } public static enum Loader implements ICustomModelLoader { - instance; + INSTANCE; public void onResourceManagerReload(IResourceManager resourceManager) {} @@ -277,7 +237,7 @@ public class MultiLayerModel implements IModelCustomData public IModel loadModel(ResourceLocation modelLocation) { - return MultiLayerModel.instance; + return MultiLayerModel.INSTANCE; } } } diff --git a/src/main/java/net/minecraftforge/client/model/MultiModel.java b/src/main/java/net/minecraftforge/client/model/MultiModel.java index f90a747df7..e32a9456c6 100644 --- a/src/main/java/net/minecraftforge/client/model/MultiModel.java +++ b/src/main/java/net/minecraftforge/client/model/MultiModel.java @@ -1,7 +1,6 @@ package net.minecraftforge.client.model; import java.util.Collection; -import java.util.EnumMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -10,44 +9,89 @@ import java.util.Set; import javax.vecmath.Matrix4f; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverride; +import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.fml.common.FMLLog; import org.apache.commons.lang3.tuple.Pair; import org.apache.logging.log4j.Level; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; +import com.google.common.collect.Lists; import com.google.common.collect.Sets; -@SuppressWarnings("deprecation") -public class MultiModel implements IModel +// TODO: Switch to vanilla class, or to something similar +@Deprecated +public final class MultiModel implements IModel { - public static class Baked implements IFlexibleBakedModel, IPerspectiveAwareModel + private static final class Baked implements IPerspectiveAwareModel { - protected final IFlexibleBakedModel base; - protected final ImmutableMap parts; + private final ResourceLocation location; + private final IBakedModel base; + private final ImmutableMap parts; - protected final IFlexibleBakedModel internalBase; - protected ImmutableList general; - protected ImmutableMap> faces; - protected final ImmutableMap> transforms; - - public Baked(IFlexibleBakedModel base, ImmutableMap parts) + private final IBakedModel internalBase; + private ImmutableMap, ImmutableList> quads; + private final ImmutableMap> transforms; + private final ItemOverrideList overrides = new ItemOverrideList(Lists.newArrayList()) { - this(null, false, base, parts); - } + @Override + public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) + { + if(originalModel != Baked.this) + { + return originalModel; + } + boolean dirty = false; + IBakedModel newBase = null; - public Baked(ResourceLocation location, boolean perspective, IFlexibleBakedModel base, ImmutableMap parts) + if(base != null) + { + newBase = base.getOverrides().handleItemState(base, stack, world, entity); + if(base != newBase) + { + dirty = true; + } + } + ImmutableMap.Builder builder = ImmutableMap.builder(); + for(Map.Entry entry : parts.entrySet()) + { + IBakedModel newPart = entry.getValue().getOverrides().handleItemState(entry.getValue(), stack, world, entity); + builder.put(entry.getKey(), newPart); + if(entry.getValue() != newPart) + { + dirty = true; + } + } + if(dirty) + { + // TODO: caching? + return new Baked(location, newBase instanceof IPerspectiveAwareModel, newBase, builder.build()); + } + return Baked.this; + } + }; + + public Baked(ResourceLocation location, boolean perspective, IBakedModel base, ImmutableMap parts) { + this.location = location; this.base = base; this.parts = parts; @@ -55,7 +99,7 @@ public class MultiModel implements IModel internalBase = base; else { - Iterator iter = parts.values().iterator(); + Iterator iter = parts.values().iterator(); if (iter.hasNext()) internalBase = iter.next(); else @@ -69,8 +113,8 @@ public class MultiModel implements IModel ImmutableMap.Builder> builder = ImmutableMap.builder(); for(TransformType type : TransformType.values()) { - Pair p = perBase.handlePerspective(type); - IFlexibleBakedModel newBase = p.getLeft(); + Pair p = perBase.handlePerspective(type); + IBakedModel newBase = p.getLeft(); builder.put(type, Pair.of(new Baked(location, false, newBase, parts), new TRSRTransformation(p.getRight()))); } transforms = builder.build(); @@ -112,72 +156,59 @@ public class MultiModel implements IModel } @Override - public List getFaceQuads(EnumFacing side) + public List getQuads(IBlockState state, EnumFacing side, long rand) { - if(faces == null) + if(quads == null) { - // Create map of each face's quads. - EnumMap> faces = Maps.newEnumMap(EnumFacing.class); + ImmutableMap.Builder, ImmutableList> builder = ImmutableMap.builder(); for (EnumFacing face : EnumFacing.values()) { - ImmutableList.Builder faceQuads = ImmutableList.builder(); + ImmutableList.Builder quads = ImmutableList.builder(); if (base != null) - faceQuads.addAll(base.getFaceQuads(face)); - for (IFlexibleBakedModel bakedPart : parts.values()) - faceQuads.addAll(bakedPart.getFaceQuads(face)); - faces.put(face, faceQuads.build()); + { + quads.addAll(base.getQuads(state, face, 0)); + } + for (IBakedModel bakedPart : parts.values()) + { + quads.addAll(bakedPart.getQuads(state, face, 0)); + } + builder.put(Optional.of(face), quads.build()); } - this.faces = Maps.immutableEnumMap(faces); - } - return faces.get(side); - } - - @Override - public List getGeneralQuads() - { - if(general == null) - { - // Create list of general quads. - ImmutableList.Builder genQuads = ImmutableList.builder(); + ImmutableList.Builder quads = ImmutableList.builder(); if (base != null) - genQuads.addAll(base.getGeneralQuads()); - for (IFlexibleBakedModel bakedPart : parts.values()) - genQuads.addAll(bakedPart.getGeneralQuads()); - general = genQuads.build(); + { + quads.addAll(base.getQuads(state, null, 0)); + } + for (IBakedModel bakedPart : parts.values()) + { + quads.addAll(bakedPart.getQuads(state, null, 0)); + } + builder.put(Optional.absent(), quads.build()); + this.quads = builder.build(); } - return general; + return quads.get(Optional.fromNullable(side)); } @Override - public VertexFormat getFormat() - { - return internalBase.getFormat(); - } - - public IFlexibleBakedModel getBaseModel() - { - return base; - } - - public Map getParts() - { - return parts; - } - - @Override - public Pair handlePerspective(TransformType cameraTransformType) + public Pair handlePerspective(TransformType cameraTransformType) { if(transforms.isEmpty()) return Pair.of(this, null); Pair p = transforms.get(cameraTransformType); return Pair.of(p.getLeft(), p.getRight().getMatrix()); } + + @Override + public ItemOverrideList getOverrides() + { + return overrides; + } } - protected final ResourceLocation location; - protected final IModel base; - protected final IModelState baseState; - protected final Map> parts; + private final ResourceLocation location; + private final IModel base; + private final IModelState baseState; + private final Map> parts; public MultiModel(ResourceLocation location, IModel base, IModelState baseState, ImmutableMap> parts) { @@ -187,16 +218,6 @@ public class MultiModel implements IModel this.parts = parts; } - public MultiModel(IModel base, IModelState baseState, ImmutableMap> parts) - { - this(null, base, baseState, parts); - } - - public MultiModel(IModel base, IModelState baseState, Map> parts) - { - this(null, base, baseState, ImmutableMap.copyOf(parts)); - } - public MultiModel(ResourceLocation location, IModel base, IModelState baseState, Map> parts) { this(location, base, baseState, ImmutableMap.copyOf(parts)); @@ -231,19 +252,19 @@ public class MultiModel implements IModel } @Override - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) { - IFlexibleBakedModel bakedBase = null; + IBakedModel bakedBase = null; if (base != null) bakedBase = base.bake(state, format, bakedTextureGetter); - ImmutableMap.Builder mapBuilder = ImmutableMap.builder(); + ImmutableMap.Builder mapBuilder = ImmutableMap.builder(); for (Entry> entry : parts.entrySet()) { Pair pair = entry.getValue(); - mapBuilder.put(entry.getKey(), pair.getLeft().bake(pair.getRight(), format, bakedTextureGetter)); + mapBuilder.put(entry.getKey(), pair.getLeft().bake(new ModelStateComposition(state, pair.getRight()), format, bakedTextureGetter)); } if(bakedBase == null && parts.isEmpty()) @@ -255,22 +276,6 @@ public class MultiModel implements IModel return new Baked(location, true, bakedBase, mapBuilder.build()); } - /** - * @return The base model of this MultiModel. May be null. - */ - public IModel getBaseModel() - { - return base; - } - - /** - * @return A map of the submodel name to its IModel and IModelState. - */ - public Map> getParts() - { - return parts; - } - @Override public IModelState getDefaultState() { diff --git a/src/main/java/net/minecraftforge/client/model/MultiModelState.java b/src/main/java/net/minecraftforge/client/model/MultiModelState.java index 15e9dff77a..c3a5c8cfb4 100644 --- a/src/main/java/net/minecraftforge/client/model/MultiModelState.java +++ b/src/main/java/net/minecraftforge/client/model/MultiModelState.java @@ -1,5 +1,9 @@ package net.minecraftforge.client.model; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; + import org.apache.commons.lang3.tuple.Pair; import com.google.common.base.Objects; @@ -7,7 +11,7 @@ import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -public class MultiModelState implements IModelState +public final class MultiModelState implements IModelState { private final ImmutableMap states; diff --git a/src/main/java/net/minecraftforge/client/model/SimpleModelState.java b/src/main/java/net/minecraftforge/client/model/SimpleModelState.java index a4da1cc287..2f52a660ea 100644 --- a/src/main/java/net/minecraftforge/client/model/SimpleModelState.java +++ b/src/main/java/net/minecraftforge/client/model/SimpleModelState.java @@ -1,12 +1,16 @@ package net.minecraftforge.client.model; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; + import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; /* * Simple implementation of IModelState via a map and a default value. */ -public class SimpleModelState implements IModelState +public final class SimpleModelState implements IModelState { private final ImmutableMap map; private final Optional def; diff --git a/src/main/java/net/minecraftforge/client/model/animation/Animation.java b/src/main/java/net/minecraftforge/client/model/animation/Animation.java index 75cc9ccac1..59c3700364 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/Animation.java +++ b/src/main/java/net/minecraftforge/client/model/animation/Animation.java @@ -1,28 +1,8 @@ package net.minecraftforge.client.model.animation; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; - -import net.minecraft.client.resources.IResource; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import net.minecraftforge.common.model.animation.IAnimationStateMachine; -import net.minecraftforge.common.util.JsonUtils; -import net.minecraftforge.fml.common.FMLLog; -import org.apache.logging.log4j.Level; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonParseException; - -public enum Animation implements IResourceManagerReloadListener +public enum Animation { INSTANCE; @@ -53,151 +33,9 @@ public enum Animation implements IResourceManagerReloadListener } /** - * Load a new instance if AnimationStateMachine at specified location, with specified custom parameters. - */ - public IAnimationStateMachine load(ResourceLocation location, ImmutableMap customParameters) - { - try - { - ClipResolver clipResolver = new ClipResolver(); - ParameterResolver parameterResolver = new ParameterResolver(customParameters); - Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver); - TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver); - IResource resource = manager.getResource(location); - AnimationStateMachine asm = asmGson.fromJson(new InputStreamReader(resource.getInputStream(), "UTF-8"), AnimationStateMachine.class); - clipResolver.asm = asm; - parameterResolver.asm = asm; - asm.initialize(); - //String json = asmGson.toJson(asm); - //System.out.println(location + ": " + json); - return asm; - } - catch(IOException e) - { - FMLLog.log(Level.ERROR, e, "Exception loading Animation State Machine %s, skipping", location); - return missing; - } - catch(JsonParseException e) - { - FMLLog.log(Level.ERROR, e, "Exception loading Animation State Machine %s, skipping", location); - return missing; - } - finally - { - Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(null); - TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(null); - } - } - - /** - * Load armature associated with a vanilla model. - */ - public ModelBlockAnimation loadVanillaAnimation(ResourceLocation armatureLocation) - { - try - { - IResource resource = null; - try - { - resource = manager.getResource(armatureLocation); - } - catch(FileNotFoundException e) - { - // this is normal. FIXME: error reporting? - return defaultModelBlockAnimation; - } - ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.getInputStream(), "UTF-8"), ModelBlockAnimation.class); - String json = mbaGson.toJson(mba); - return mba; - } - catch(IOException e) - { - FMLLog.log(Level.ERROR, e, "Exception loading vanilla model aniamtion %s, skipping", armatureLocation); - return defaultModelBlockAnimation; - } - catch(JsonParseException e) - { - FMLLog.log(Level.ERROR, e, "Exception loading vanilla model aniamtion %s, skipping", armatureLocation); - return defaultModelBlockAnimation; - } - } - - private IResourceManager manager; - - private final AnimationStateMachine missing = new AnimationStateMachine( - ImmutableMap.of(), - ImmutableMap.of("missingno", (IClip)Clips.IdentityClip.instance), - ImmutableList.of("missingno"), - ImmutableMap.of(), - "missingno"); - - { - missing.initialize(); - } - - private final Gson asmGson = new GsonBuilder() - .registerTypeAdapter(ImmutableList.class, JsonUtils.ImmutableListTypeAdapter.INSTANCE) - .registerTypeAdapter(ImmutableMap.class, JsonUtils.ImmutableMapTypeAdapter.INSTANCE) - .registerTypeAdapterFactory(Clips.CommonClipTypeAdapterFactory.INSTANCE) - //.registerTypeAdapterFactory(ClipProviders.CommonClipProviderTypeAdapterFactory.INSTANCE) - .registerTypeAdapterFactory(TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE) - .setPrettyPrinting() - .enableComplexMapKeySerialization() - .disableHtmlEscaping() - .create(); - - private static final class ClipResolver implements Function - { - private AnimationStateMachine asm; - - public IClip apply(String name) - { - return asm.getClips().get(name); - } - } - - private static final class ParameterResolver implements Function - { - private final ImmutableMap customParameters; - private AnimationStateMachine asm; - - public ParameterResolver(ImmutableMap customParameters) - { - this.customParameters = customParameters; - } - - public ITimeValue apply(String name) - { - if(asm.getParameters().containsKey(name)) - { - return asm.getParameters().get(name); - } - return customParameters.get(name); - } - } - - private final Gson mbaGson = new GsonBuilder() - .registerTypeAdapter(ImmutableList.class, JsonUtils.ImmutableListTypeAdapter.INSTANCE) - .registerTypeAdapter(ImmutableMap.class, JsonUtils.ImmutableMapTypeAdapter.INSTANCE) - .setPrettyPrinting() - .enableComplexMapKeySerialization() - .disableHtmlEscaping() - .create(); - - private final ModelBlockAnimation defaultModelBlockAnimation = new ModelBlockAnimation(ImmutableMap.>of(), ImmutableMap.of()); - - /** - * Iternal hook, do not use. + * Internal hook, do not use. */ public static void setClientPartialTickTime(float clientPartialTickTime) { Animation.INSTANCE.clientPartialTickTime = clientPartialTickTime; } - - /** - * Iternal hook, do not use. - */ - public void onResourceManagerReload(IResourceManager manager) - { - this.manager = manager; - } } diff --git a/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java b/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java new file mode 100644 index 0000000000..e281dd2b43 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/model/animation/AnimationItemOverrideList.java @@ -0,0 +1,64 @@ +package net.minecraftforge.client.model.animation; + +import java.util.List; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ItemOverride; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.ModelStateComposition; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.animation.CapabilityAnimation; +import net.minecraftforge.common.model.animation.IAnimationStateMachine; + +import com.google.common.base.Function; + +public final class AnimationItemOverrideList extends ItemOverrideList +{ + private final IModel model; + private final IModelState state; + private final VertexFormat format; + private final Function bakedTextureGetter; + + public AnimationItemOverrideList(IModel model, IModelState state, VertexFormat format, Function bakedTextureGetter, ItemOverrideList overrides) + { + this(model, state, format, bakedTextureGetter, overrides.getOverrides()); + } + + public AnimationItemOverrideList(IModel model, IModelState state, VertexFormat format, Function bakedTextureGetter, List overrides) + { + super(overrides); + this.model = model; + this.state = state; + this.format = format; + this.bakedTextureGetter = bakedTextureGetter; + } + + @Override + public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) + { + if(stack.hasCapability(net.minecraftforge.common.model.animation.CapabilityAnimation.ANIMATION_CAPABILITY, null)) + { + // TODO: caching? + IAnimationStateMachine asm = stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null); + if(world == null) + { + world = entity.worldObj; + } + if(world == null) + { + world = Minecraft.getMinecraft().theWorld; + } + IModelState state = asm.apply(Animation.getWorldTime(world, Animation.getPartialTickTime())).getLeft(); + return model.bake(new ModelStateComposition(state, this.state), format, bakedTextureGetter); + } + return originalModel; + } +} diff --git a/src/main/java/net/minecraftforge/client/model/animation/AnimationModelBase.java b/src/main/java/net/minecraftforge/client/model/animation/AnimationModelBase.java index a688aa0fda..d36f03ca00 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/AnimationModelBase.java +++ b/src/main/java/net/minecraftforge/client/model/animation/AnimationModelBase.java @@ -6,19 +6,24 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModel; -import net.minecraftforge.client.model.IModelState; import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.pipeline.VertexLighterFlat; -import net.minecraftforge.client.model.pipeline.WorldRendererConsumer; +import net.minecraftforge.client.model.pipeline.VertexBufferConsumer; +import net.minecraftforge.common.animation.Event; +import net.minecraftforge.common.animation.IEventHandler; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.animation.CapabilityAnimation; import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.opengl.GL11; @@ -28,14 +33,14 @@ import org.lwjgl.opengl.GL11; * Some quirks are still left, deprecated for the moment. */ @Deprecated -public class AnimationModelBase extends ModelBase implements IEventHandler +public class AnimationModelBase extends ModelBase implements IEventHandler { private final VertexLighterFlat lighter; - private final IModel model; + private final ResourceLocation modelLocation; - public AnimationModelBase(IModel model, VertexLighterFlat lighter) + public AnimationModelBase(ResourceLocation modelLocation, VertexLighterFlat lighter) { - this.model = model; + this.modelLocation = modelLocation; this.lighter = lighter; } @@ -43,13 +48,14 @@ public class AnimationModelBase extends M @Override public void render(Entity entity, float limbSwing, float limbSwingSpeed, float timeAlive, float yawHead, float rotationPitch, float scale) { - if(!(entity instanceof IAnimationProvider)) + if(!(entity.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null))) { - throw new ClassCastException("AnimationModelBase expects IAnimationProvider"); + return; } - Pair> pair = ((IAnimationProvider)entity).asm().apply(timeAlive / 20); + Pair> pair = entity.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(timeAlive / 20); handleEvents((T)entity, timeAlive / 20, pair.getRight()); + IModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation); IBakedModel bakedModel = model.bake(pair.getLeft(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); BlockPos pos = new BlockPos(entity.posX, entity.posY + entity.height, entity.posZ); @@ -58,16 +64,16 @@ public class AnimationModelBase extends M GlStateManager.pushMatrix(); GlStateManager.rotate(180, 0, 0, 1); Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - worldRenderer.setTranslation(-0.5, -1.5, -0.5); + VertexBuffer VertexBuffer = tessellator.getBuffer(); + VertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + VertexBuffer.setTranslation(-0.5, -1.5, -0.5); - lighter.setParent(new WorldRendererConsumer(worldRenderer)); + lighter.setParent(new VertexBufferConsumer(VertexBuffer)); lighter.setWorld(entity.worldObj); - lighter.setBlock(Blocks.air); + lighter.setState(Blocks.air.getDefaultState()); lighter.setBlockPos(pos); boolean empty = true; - List quads = bakedModel.getGeneralQuads(); + List quads = bakedModel.getQuads(null, null, 0); if(!quads.isEmpty()) { lighter.updateBlockInfo(); @@ -79,7 +85,7 @@ public class AnimationModelBase extends M } for(EnumFacing side : EnumFacing.values()) { - quads = bakedModel.getFaceQuads(side); + quads = bakedModel.getQuads(null, side, 0); if(!quads.isEmpty()) { if(empty) lighter.updateBlockInfo(); @@ -92,12 +98,12 @@ public class AnimationModelBase extends M } // debug quad - /*worldRenderer.pos(0, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 0).lightmap(240, 0).endVertex(); - worldRenderer.pos(0, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 1).lightmap(240, 0).endVertex(); - worldRenderer.pos(1, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 1).lightmap(240, 0).endVertex(); - worldRenderer.pos(1, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 0).lightmap(240, 0).endVertex();*/ + /*VertexBuffer.pos(0, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 0).lightmap(240, 0).endVertex(); + VertexBuffer.pos(0, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 1).lightmap(240, 0).endVertex(); + VertexBuffer.pos(1, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 1).lightmap(240, 0).endVertex(); + VertexBuffer.pos(1, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 0).lightmap(240, 0).endVertex();*/ - worldRenderer.setTranslation(0, 0, 0); + VertexBuffer.setTranslation(0, 0, 0); tessellator.draw(); GlStateManager.popMatrix(); diff --git a/src/main/java/net/minecraftforge/client/model/animation/AnimationTESR.java b/src/main/java/net/minecraftforge/client/model/animation/AnimationTESR.java index 56a6d89644..c1e2f0e91c 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/AnimationTESR.java +++ b/src/main/java/net/minecraftforge/client/model/animation/AnimationTESR.java @@ -1,54 +1,36 @@ package net.minecraftforge.client.model.animation; -import java.util.concurrent.TimeUnit; - import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BlockRendererDispatcher; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraftforge.client.MinecraftForgeClient; -import net.minecraftforge.client.model.IModelState; -import net.minecraftforge.client.model.ISmartBlockModel; +import net.minecraftforge.common.animation.Event; +import net.minecraftforge.common.animation.IEventHandler; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.animation.CapabilityAnimation; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.Properties; import org.apache.commons.lang3.tuple.Pair; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; - /** * Generic TileEntitySpecialRenderer that works with the Forge model system and animations. */ -public class AnimationTESR extends FastTESR implements IEventHandler +public class AnimationTESR extends FastTESR implements IEventHandler { protected static BlockRendererDispatcher blockRenderer; - protected static final LoadingCache, IBakedModel> modelCache = CacheBuilder.newBuilder().maximumSize(10).expireAfterWrite(100, TimeUnit.MILLISECONDS).build(new CacheLoader, IBakedModel>() + public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, VertexBuffer renderer) { - public IBakedModel load(Pair key) throws Exception + if(!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)) { - IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(key.getLeft().getClean()); - if(model instanceof ISmartBlockModel) - { - model = ((ISmartBlockModel)model).handleBlockState(key.getLeft().withProperty(Properties.AnimationProperty, key.getRight())); - } - return model; + return; } - }); - - protected static IBakedModel getModel(IExtendedBlockState state, IModelState modelState) - { - return modelCache.getUnchecked(Pair.of(state, modelState)); - } - - public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, WorldRenderer renderer) - { if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); BlockPos pos = te.getPos(); IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos); @@ -63,14 +45,16 @@ public class AnimationTESR extends Fa if(exState.getUnlistedNames().contains(Properties.AnimationProperty)) { float time = Animation.getWorldTime(getWorld(), partialTick); - Pair> pair = te.asm().apply(time); + Pair> pair = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time); handleEvents(te, time, pair.getRight()); - IBakedModel model = getModel(exState, pair.getLeft()); + // TODO: caching? + IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean()); + exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft()); renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ()); - blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, renderer, false); + blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false); } } } diff --git a/src/main/java/net/minecraftforge/client/model/animation/FastTESR.java b/src/main/java/net/minecraftforge/client/model/animation/FastTESR.java index ed3baad490..33b59da334 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/FastTESR.java +++ b/src/main/java/net/minecraftforge/client/model/animation/FastTESR.java @@ -6,7 +6,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; @@ -18,7 +18,7 @@ public abstract class FastTESR extends TileEntitySpecialRe public final void renderTileEntityAt(T te, double x, double y, double z, float partialTicks, int destroyStage) { Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + VertexBuffer VertexBuffer = tessellator.getBuffer(); this.bindTexture(TextureMap.locationBlocksTexture); RenderHelper.disableStandardItemLighting(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -34,10 +34,10 @@ public abstract class FastTESR extends TileEntitySpecialRe GlStateManager.shadeModel(GL11.GL_FLAT); } - worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); + VertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, worldRenderer); - worldRenderer.setTranslation(0, 0, 0); + renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, VertexBuffer); + VertexBuffer.setTranslation(0, 0, 0); tessellator.draw(); @@ -45,5 +45,5 @@ public abstract class FastTESR extends TileEntitySpecialRe } @Override - public abstract void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, WorldRenderer worldRenderer); + public abstract void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, VertexBuffer VertexBuffer); } diff --git a/src/main/java/net/minecraftforge/client/model/animation/IAnimatedModel.java b/src/main/java/net/minecraftforge/client/model/animation/IAnimatedModel.java index e4d6df8ee0..a841ed12b8 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/IAnimatedModel.java +++ b/src/main/java/net/minecraftforge/client/model/animation/IAnimatedModel.java @@ -1,6 +1,7 @@ package net.minecraftforge.client.model.animation; import net.minecraftforge.client.model.IModel; +import net.minecraftforge.common.model.animation.IClip; import com.google.common.base.Optional; diff --git a/src/main/java/net/minecraftforge/client/model/animation/IAnimationProvider.java b/src/main/java/net/minecraftforge/client/model/animation/IAnimationProvider.java deleted file mode 100644 index 94723d38f1..0000000000 --- a/src/main/java/net/minecraftforge/client/model/animation/IAnimationProvider.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.minecraftforge.client.model.animation; - -import net.minecraftforge.common.model.animation.IAnimationStateMachine; - - -/** - * Something that can provide the Animation State Machine, for example and Entity or a Block - */ -public interface IAnimationProvider -{ - public IAnimationStateMachine asm(); -} diff --git a/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java b/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java index a7480b20d7..42e5818d5f 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java +++ b/src/main/java/net/minecraftforge/client/model/animation/ModelBlockAnimation.java @@ -1,5 +1,8 @@ package net.minecraftforge.client.model.animation; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.Collections; import java.util.EnumSet; import java.util.Iterator; @@ -12,13 +15,25 @@ import javax.vecmath.Matrix4f; import javax.vecmath.Quat4f; import javax.vecmath.Vector3f; +import org.apache.logging.log4j.Level; + import net.minecraft.client.renderer.block.model.BlockPart; -import net.minecraft.util.MathHelper; -import net.minecraftforge.client.model.IModelState; -import net.minecraftforge.client.model.TRSRTransformation; +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.MathHelper; import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Interpolation; import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Type; import net.minecraftforge.client.model.animation.ModelBlockAnimation.Parameter.Variable; +import net.minecraftforge.common.animation.Event; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; +import net.minecraftforge.common.model.animation.IClip; +import net.minecraftforge.common.model.animation.IJoint; +import net.minecraftforge.common.model.animation.IJointClip; +import net.minecraftforge.common.model.animation.JointClips; +import net.minecraftforge.common.util.JsonUtils; +import net.minecraftforge.fml.common.FMLLog; import com.google.common.base.Optional; import com.google.common.collect.ImmutableCollection; @@ -28,6 +43,9 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.collect.UnmodifiableIterator; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; import com.google.gson.annotations.SerializedName; public class ModelBlockAnimation @@ -152,7 +170,7 @@ public class ModelBlockAnimation MBJointClip clip = jointClips.get(mbJoint.getName()); if(clip != null) return clip; } - return JointClips.IdentityJointClip.instance; + return JointClips.IdentityJointClip.INSTANCE; } @Override @@ -509,4 +527,47 @@ public class ModelBlockAnimation } return null; } + + /** + * Load armature associated with a vanilla model. + */ + public static ModelBlockAnimation loadVanillaAnimation(IResourceManager manager, ResourceLocation armatureLocation) + { + try + { + IResource resource = null; + try + { + resource = manager.getResource(armatureLocation); + } + catch(FileNotFoundException e) + { + // this is normal. FIXME: error reporting? + return defaultModelBlockAnimation; + } + ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.getInputStream(), "UTF-8"), ModelBlockAnimation.class); + //String json = mbaGson.toJson(mba); + return mba; + } + catch(IOException e) + { + FMLLog.log(Level.ERROR, e, "Exception loading vanilla model animation %s, skipping", armatureLocation); + return defaultModelBlockAnimation; + } + catch(JsonParseException e) + { + FMLLog.log(Level.ERROR, e, "Exception loading vanilla model animation %s, skipping", armatureLocation); + return defaultModelBlockAnimation; + } + } + + private static final Gson mbaGson = new GsonBuilder() + .registerTypeAdapter(ImmutableList.class, JsonUtils.ImmutableListTypeAdapter.INSTANCE) + .registerTypeAdapter(ImmutableMap.class, JsonUtils.ImmutableMapTypeAdapter.INSTANCE) + .setPrettyPrinting() + .enableComplexMapKeySerialization() + .disableHtmlEscaping() + .create(); + + private static final ModelBlockAnimation defaultModelBlockAnimation = new ModelBlockAnimation(ImmutableMap.>of(), ImmutableMap.of()); } diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java index 91df31ae1e..50b1407fd5 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DClip.java @@ -1,27 +1,27 @@ package net.minecraftforge.client.model.b3d; -import net.minecraftforge.client.model.TRSRTransformation; -import net.minecraftforge.client.model.animation.Event; -import net.minecraftforge.client.model.animation.IClip; -import net.minecraftforge.client.model.animation.IJoint; -import net.minecraftforge.client.model.animation.IJointClip; -import net.minecraftforge.client.model.animation.JointClips; import net.minecraftforge.client.model.b3d.B3DLoader.NodeJoint; import net.minecraftforge.client.model.b3d.B3DModel.Key; import net.minecraftforge.client.model.b3d.B3DModel.Node; +import net.minecraftforge.common.animation.Event; +import net.minecraftforge.common.model.TRSRTransformation; +import net.minecraftforge.common.model.animation.IClip; +import net.minecraftforge.common.model.animation.IJoint; +import net.minecraftforge.common.model.animation.IJointClip; +import net.minecraftforge.common.model.animation.JointClips; import com.google.common.collect.ImmutableSet; // FIXME: is this fast enough? public enum B3DClip implements IClip { - instance; + INSTANCE; public IJointClip apply(final IJoint joint) { if(!(joint instanceof NodeJoint)) { - return JointClips.IdentityJointClip.instance; + return JointClips.IdentityJointClip.INSTANCE; } return new NodeClip(((NodeJoint)joint).getNode()); } @@ -60,7 +60,7 @@ public enum B3DClip implements IClip { ret = ret.compose(new TRSRTransformation(node.getPos(), node.getRot(), node.getScale(), null)); } - // TODO animated TRSR for speed? + // TODO animated TRSRTransformation for speed? else { ret = ret.compose(endTr); diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java index 3dfbcc041b..02f92be5de 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DLoader.java @@ -16,30 +16,40 @@ import javax.vecmath.Vector3f; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; -import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.*; -import net.minecraftforge.client.model.animation.IClip; +import net.minecraft.util.math.MathHelper; +import net.minecraftforge.client.model.ICustomModelLoader; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.IModelCustomData; +import net.minecraftforge.client.model.IModelSimpleProperties; +import net.minecraftforge.client.model.IPerspectiveAwareModel; +import net.minecraftforge.client.model.IRetexturableModel; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.client.model.ModelLoaderRegistry; +import net.minecraftforge.client.model.ModelStateComposition; import net.minecraftforge.client.model.animation.IAnimatedModel; -import net.minecraftforge.client.model.animation.IJoint; import net.minecraftforge.client.model.b3d.B3DModel.Animation; import net.minecraftforge.client.model.b3d.B3DModel.Face; -import net.minecraftforge.client.model.b3d.B3DModel.IKind; import net.minecraftforge.client.model.b3d.B3DModel.Key; import net.minecraftforge.client.model.b3d.B3DModel.Mesh; import net.minecraftforge.client.model.b3d.B3DModel.Node; import net.minecraftforge.client.model.b3d.B3DModel.Texture; import net.minecraftforge.client.model.b3d.B3DModel.Vertex; -import net.minecraftforge.client.model.pipeline.LightUtil; import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; +import net.minecraftforge.common.model.animation.IClip; +import net.minecraftforge.common.model.animation.IJoint; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.common.property.Properties; @@ -64,13 +74,12 @@ import com.google.gson.JsonParser; /* * Loader for Blitz3D models. - * To enable for your mod call instance.addDomain(modid). + * To enable for your mod call instance.addDomain(modId). * If you need more control over accepted resources - extend the class, and register a new instance with ModelLoaderRegistry. */ -@SuppressWarnings("deprecation") -public class B3DLoader implements ICustomModelLoader +public enum B3DLoader implements ICustomModelLoader { - public static final B3DLoader instance = new B3DLoader(); + INSTANCE; private IResourceManager manager; @@ -94,7 +103,7 @@ public class B3DLoader implements ICustomModelLoader } @SuppressWarnings("unchecked") - public IModel loadModel(ResourceLocation modelLocation) throws IOException + public IModel loadModel(ResourceLocation modelLocation) throws Exception { ResourceLocation file = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath()); if(!cache.containsKey(file)) @@ -120,75 +129,20 @@ public class B3DLoader implements ICustomModelLoader } catch(IOException e) { - //FMLLog.log(Level.ERROR, e, "Exception loading model %s with B3D loader, skipping", modelLocation); cache.put(file, null); throw e; } } B3DModel model = cache.get(file); - if(model == null) return ModelLoaderRegistry.getMissingModel(); - if(modelLocation instanceof B3DMeshLocation) - { - String mesh = ((B3DMeshLocation)modelLocation).getMesh(); - if(!model.getMeshes().containsKey(mesh)) - { - FMLLog.severe("No mesh named %s in model %s, skipping", mesh, modelLocation); - return ModelLoaderRegistry.getMissingModel(); - } - return new ModelWrapper(modelLocation, model, ImmutableSet.of(mesh), 1); - } + if(model == null) throw new ModelLoaderRegistry.LoaderException("Error loading model previously: " + file); if(!(model.getRoot().getKind() instanceof Mesh)) { - return new ModelWrapper(modelLocation, model, ImmutableSet.of(), 1); + return new ModelWrapper(modelLocation, model, ImmutableSet.of(), true, true, 1); } - return new ModelWrapper(modelLocation, model, ImmutableSet.of(((Node)model.getRoot()).getName()), 1); + return new ModelWrapper(modelLocation, model, ImmutableSet.of(model.getRoot().getName()), true, true, 1); } - /** - * @deprecated Use json or IModelCustomData.process - */ - @Deprecated - public static class B3DMeshLocation extends ResourceLocation - { - public final String mesh; - - public B3DMeshLocation(String domain, String path, String mesh) - { - super(domain, path); - this.mesh = mesh; - } - - public String getMesh() - { - return mesh; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((mesh == null) ? 0 : mesh.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) return true; - if (!super.equals(obj)) return false; - if (getClass() != obj.getClass()) return false; - B3DMeshLocation other = (B3DMeshLocation) obj; - if (mesh == null) - { - if (other.mesh != null) return false; - } - else if (!mesh.equals(other.mesh)) return false; - return true; - } - } - - public static class B3DState implements IModelState + public static final class B3DState implements IModelState { private final Animation animation; private final int frame; @@ -254,7 +208,7 @@ public class B3DLoader implements ICustomModelLoader public Optional apply(Optional part) { - // TODO optionify better + // TODO make more use of Optional if(!part.isPresent()) return parent.apply(part); if(!(part.get() instanceof NodeJoint)) { @@ -323,7 +277,7 @@ public class B3DLoader implements ICustomModelLoader // current node local pose ret = ret.compose(new TRSRTransformation(key.getPos(), key.getRot(), key.getScale(), null)); // this part moved inside the model - // inverse bind of the curent node + // inverse bind of the current node /*Matrix4f rm = new TRSRTransformation(node.getPos(), node.getRot(), node.getScale(), null).getMatrix(); rm.invert(); ret = ret.compose(new TRSRTransformation(rm)); @@ -358,7 +312,7 @@ public class B3DLoader implements ICustomModelLoader } } - public static class NodeJoint implements IJoint + static final class NodeJoint implements IJoint { private final Node node; @@ -412,7 +366,7 @@ public class B3DLoader implements ICustomModelLoader public static enum B3DFrameProperty implements IUnlistedProperty { - instance; + INSTANCE; public String getName() { return "B3DFrame"; @@ -434,187 +388,7 @@ public class B3DLoader implements ICustomModelLoader } } - public static class PartWrapper> implements IModelPart - { - private final Node node; - - public static > PartWrapper create(Node node) - { - return new PartWrapper(node); - } - - public PartWrapper(Node node) - { - this.node = node; - } - - public Node getNode() - { - return node; - } - } - - /** - * @deprecated Use ModelWrapper, this will be removed in 1.9 - */ - @Deprecated - public static class Wrapper extends PartWrapper implements IRetexturableModel, IModelCustomData - { - private final ResourceLocation location; - private final ImmutableSet meshes; - private final ImmutableMap textures; - - public Wrapper(ResourceLocation location, List textures, B3DModel.Node mesh) - { - this(location, ImmutableSet.of(), buildTextures(textures), mesh); - } - - public Wrapper(ResourceLocation location, ImmutableMap textures, B3DModel.Node mesh) - { - this(location, ImmutableSet.of(), textures, mesh); - } - - public Wrapper(ResourceLocation location, ImmutableSet meshes, List textures, B3DModel.Node mesh) - { - this(location, meshes, buildTextures(textures), mesh); - } - - public Wrapper(ResourceLocation location, ImmutableSet meshes, ImmutableMap textures, B3DModel.Node mesh) - { - super(mesh); - this.location = location; - this.meshes = meshes; - this.textures = textures; - } - - private static ImmutableMap buildTextures(List textures) - { - ImmutableMap.Builder builder = ImmutableMap.builder(); - - for(Texture t : textures) - { - String path = t.getPath(); - String location = getLocation(path); - if(!location.startsWith("#")) location = "#" + location; - builder.put(path, new ResourceLocation(location)); - } - return builder.build(); - } - - private static String getLocation(String path) - { - if(path.endsWith(".png")) path = path.substring(0, path.length() - ".png".length()); - return path; - } - - public Collection getDependencies() - { - // no dependencies for in-file models - // FIXME maybe add child meshes - return Collections.emptyList(); - } - - public Collection getTextures() - { - return Collections2.filter(textures.values(), new Predicate() - { - public boolean apply(ResourceLocation loc) - { - return !loc.getResourcePath().startsWith("#"); - } - }); - } - - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) - { - ImmutableMap.Builder builder = ImmutableMap.builder(); - TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno")); - for(Map.Entry e : textures.entrySet()) - { - if(e.getValue().getResourcePath().startsWith("#")) - { - FMLLog.severe("unresolved texture '%s' for b3d model '%s'", e.getValue().getResourcePath(), location); - builder.put(e.getKey(), missing); - } - else - { - builder.put(e.getKey(), bakedTextureGetter.apply(e.getValue())); - } - } - builder.put("missingno", missing); - return new BakedWrapper(getNode(), state, format, meshes, builder.build()); - } - - public ResourceLocation getLocation() - { - return location; - } - - public ImmutableMap getTextureMap() - { - return textures; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((location == null) ? 0 : location.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - Wrapper other = (Wrapper) obj; - if (location == null) - { - if (other.location != null) return false; - } - else if (!location.equals(other.location)) return false; - return true; - } - - @Override - public IModel retexture(ImmutableMap textures) - { - ImmutableMap.Builder builder = ImmutableMap.builder(); - for(Map.Entry e : this.textures.entrySet()) - { - String path = e.getKey(); - String loc = getLocation(path); - if(textures.containsKey(loc)) - { - String newLoc = textures.get(loc); - if(newLoc == null) newLoc = getLocation(path); - builder.put(e.getKey(), new ResourceLocation(newLoc)); - } - else - { - builder.put(e); - } - } - return new Wrapper(location, builder.build(), getNode()); - } - - @Override - public IModel process(ImmutableMap customData) - { - return this; - } - - @Override - public IModelState getDefaultState() - { - return new B3DState(getNode().getAnimation(), 1); - } - } - - public static class ModelWrapper implements IRetexturableModel, IModelCustomData, IModelSimpleProperties, IAnimatedModel + private static final class ModelWrapper implements IRetexturableModel, IModelCustomData, IModelSimpleProperties, IAnimatedModel { private final ResourceLocation modelLocation; private final B3DModel model; @@ -624,23 +398,11 @@ public class B3DLoader implements ICustomModelLoader private final boolean gui3d; private final int defaultKey; - @Deprecated // remove in 1.9 - public ModelWrapper(ResourceLocation modelLocation, B3DModel model, ImmutableSet meshes, int defaultKey) - { - this(modelLocation, model, meshes, true, true, defaultKey); - } - public ModelWrapper(ResourceLocation modelLocation, B3DModel model, ImmutableSet meshes, boolean smooth, boolean gui3d, int defaultKey) { this(modelLocation, model, meshes, smooth, gui3d, defaultKey, buildTextures(model.getTextures())); } - @Deprecated // remove in 1.9 - public ModelWrapper(ResourceLocation modelLocation, B3DModel model, ImmutableSet meshes, int defaultKey, ImmutableMap textures) - { - this(modelLocation, model, meshes, true, true, defaultKey, textures); - } - public ModelWrapper(ResourceLocation modelLocation, B3DModel model, ImmutableSet meshes, boolean smooth, boolean gui3d, int defaultKey, ImmutableMap textures) { this.modelLocation = modelLocation; @@ -691,7 +453,7 @@ public class B3DLoader implements ICustomModelLoader } @Override - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) { ImmutableMap.Builder builder = ImmutableMap.builder(); TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno")); @@ -712,7 +474,7 @@ public class B3DLoader implements ICustomModelLoader } @Override - public IModel retexture(ImmutableMap textures) + public ModelWrapper retexture(ImmutableMap textures) { ImmutableMap.Builder builder = ImmutableMap.builder(); for(Map.Entry e : this.textures.entrySet()) @@ -730,18 +492,18 @@ public class B3DLoader implements ICustomModelLoader builder.put(e); } } - return new ModelWrapper(modelLocation, model, meshes, defaultKey, builder.build()); + return new ModelWrapper(modelLocation, model, meshes, smooth, gui3d, defaultKey, builder.build()); } @Override - public IModel process(ImmutableMap data) + public ModelWrapper process(ImmutableMap data) { if(data.containsKey("mesh")) { JsonElement e = new JsonParser().parse(data.get("mesh")); if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isString()) { - return new ModelWrapper(modelLocation, model, ImmutableSet.of(e.getAsString()), defaultKey, textures); + return new ModelWrapper(modelLocation, model, ImmutableSet.of(e.getAsString()), smooth, gui3d, defaultKey, textures); } else if (e.isJsonArray()) { @@ -758,7 +520,7 @@ public class B3DLoader implements ICustomModelLoader return this; } } - return new ModelWrapper(modelLocation, model, builder.build(), defaultKey, textures); + return new ModelWrapper(modelLocation, model, builder.build(), smooth, gui3d, defaultKey, textures); } else { @@ -771,7 +533,7 @@ public class B3DLoader implements ICustomModelLoader JsonElement e = new JsonParser().parse(data.get("key")); if(e.isJsonPrimitive() && e.getAsJsonPrimitive().isNumber()) { - return new ModelWrapper(modelLocation, model, meshes, e.getAsNumber().intValue(), textures); + return new ModelWrapper(modelLocation, model, meshes, smooth, gui3d, e.getAsNumber().intValue(), textures); } else { @@ -786,7 +548,7 @@ public class B3DLoader implements ICustomModelLoader { if(name.equals("main")) { - return Optional.of(B3DClip.instance); + return Optional.of(B3DClip.INSTANCE); } return Optional.absent(); } @@ -817,7 +579,7 @@ public class B3DLoader implements ICustomModelLoader } } - private static class BakedWrapper implements IFlexibleBakedModel, ISmartBlockModel, ISmartItemModel, IPerspectiveAwareModel + private static final class BakedWrapper implements IPerspectiveAwareModel { private final Node node; private final IModelState state; @@ -826,24 +588,18 @@ public class B3DLoader implements ICustomModelLoader private final VertexFormat format; private final ImmutableSet meshes; private final ImmutableMap textures; - private final LoadingCache cache; + private final LoadingCache cache; private ImmutableList quads; - @Deprecated // remove in 1.9 - public BakedWrapper(Node node, IModelState state, VertexFormat format, ImmutableSet meshes, ImmutableMap textures) - { - this(node, state, true, true, format, meshes, textures); - } - public BakedWrapper(final Node node, final IModelState state, final boolean smooth, final boolean gui3d, final VertexFormat format, final ImmutableSet meshes, final ImmutableMap textures) { this(node, state, smooth, gui3d, format, meshes, textures, CacheBuilder.newBuilder() .maximumSize(128) .expireAfterAccess(2, TimeUnit.MINUTES) - .build(new CacheLoader() + .build(new CacheLoader() { - public BakedWrapper load(Integer frame) throws Exception + public B3DState load(Integer frame) throws Exception { IModelState parent = state; Animation newAnimation = node.getAnimation(); @@ -852,18 +608,12 @@ public class B3DLoader implements ICustomModelLoader B3DState ps = (B3DState)parent; parent = ps.getParent(); } - return new BakedWrapper(node, new B3DState(newAnimation, frame, frame, 0, parent), smooth, gui3d, format, meshes, textures); + return new B3DState(newAnimation, frame, frame, 0, parent); } })); } - @Deprecated // remove in 1.9 - public BakedWrapper(Node node, IModelState state, VertexFormat format, ImmutableSet meshes, ImmutableMap textures, LoadingCache cache) - { - this(node, state, true, true, format, meshes, textures, cache); - } - - public BakedWrapper(Node node, IModelState state, boolean smooth, boolean gui3d, VertexFormat format, ImmutableSet meshes, ImmutableMap textures, LoadingCache cache) + public BakedWrapper(Node node, IModelState state, boolean smooth, boolean gui3d, VertexFormat format, ImmutableSet meshes, ImmutableMap textures, LoadingCache cache) { this.node = node; this.state = state; @@ -875,64 +625,121 @@ public class B3DLoader implements ICustomModelLoader this.cache = cache; } - public List getFaceQuads(EnumFacing side) - { - return Collections.emptyList(); - } - - public List getGeneralQuads() + @Override + public List getQuads(IBlockState state, EnumFacing side, long rand) { + if(side != null) return ImmutableList.of(); + IModelState modelState = this.state; + if(state instanceof IExtendedBlockState) + { + IExtendedBlockState exState = (IExtendedBlockState)state; + if(exState.getUnlistedNames().contains(B3DFrameProperty.INSTANCE)) + { + B3DState s = exState.getValue(B3DFrameProperty.INSTANCE); + if(s != null) + { + //return getCachedModel(s.getFrame()); + IModelState parent = this.state; + Animation newAnimation = s.getAnimation(); + if(parent instanceof B3DState) + { + B3DState ps = (B3DState)parent; + parent = ps.getParent(); + } + if(newAnimation == null) + { + newAnimation = node.getAnimation(); + } + if(s.getFrame() == s.getNextFrame()) + { + modelState = cache.getUnchecked(s.getFrame()); + } + else + { + modelState = new B3DState(newAnimation, s.getFrame(), s.getNextFrame(), s.getProgress(), parent); + } + } + } + else if(exState.getUnlistedNames().contains(Properties.AnimationProperty)) + { + // FIXME: should animation state handle the parent state, or should it remain here? + IModelState parent = this.state; + if(parent instanceof B3DState) + { + B3DState ps = (B3DState)parent; + parent = ps.getParent(); + } + IModelState newState = exState.getValue(Properties.AnimationProperty); + if(newState != null) + { + modelState = new ModelStateComposition(parent, newState); + } + } + } if(quads == null) { ImmutableList.Builder builder = ImmutableList.builder(); - for(Node child : node.getNodes().values()) - { - builder.addAll(new BakedWrapper(child, state, format, meshes, textures).getGeneralQuads()); - } - if(node.getKind() instanceof Mesh && meshes.contains(node.getName())) - { - Mesh mesh = (Mesh)node.getKind(); - Collection faces = mesh.bake(new Function, Matrix4f>() - { - private final TRSRTransformation global = state.apply(Optional.absent()).or(TRSRTransformation.identity()); - private final LoadingCache, TRSRTransformation> localCache = CacheBuilder.newBuilder() - .maximumSize(32) - .build(new CacheLoader, TRSRTransformation>() - { - public TRSRTransformation load(Node node) throws Exception - { - return state.apply(Optional.of(new NodeJoint(node))).or(TRSRTransformation.identity()); - } - }); - - public Matrix4f apply(Node node) - { - return global.compose(localCache.getUnchecked(node)).getMatrix(); - } - }); - for(Face f : faces) - { - UnpackedBakedQuad.Builder quadBuilder = new UnpackedBakedQuad.Builder(format); - quadBuilder.setQuadOrientation(EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z)); - quadBuilder.setQuadColored(); - List textures = null; - if(f.getBrush() != null) textures = f.getBrush().getTextures(); - TextureAtlasSprite sprite; - if(textures == null || textures.isEmpty()) sprite = this.textures.get("missingno"); - else if(textures.get(0) == B3DModel.Texture.White) sprite = ModelLoader.White.instance; - else sprite = this.textures.get(textures.get(0).getPath()); - putVertexData(quadBuilder, f.getV1(), f.getNormal(), sprite); - putVertexData(quadBuilder, f.getV2(), f.getNormal(), sprite); - putVertexData(quadBuilder, f.getV3(), f.getNormal(), sprite); - putVertexData(quadBuilder, f.getV3(), f.getNormal(), sprite); - builder.add(quadBuilder.build()); - } - } + generateQuads(builder, node, this.state); quads = builder.build(); } + // TODO: caching? + if(this.state != modelState) + { + ImmutableList.Builder builder = ImmutableList.builder(); + generateQuads(builder, node, modelState); + return builder.build(); + } return quads; } + private void generateQuads(ImmutableList.Builder builder, Node node, final IModelState state) + { + for(Node child : node.getNodes().values()) + { + generateQuads(builder, child, state); + } + if(node.getKind() instanceof Mesh && meshes.contains(node.getName())) + { + Mesh mesh = (Mesh)node.getKind(); + Collection faces = mesh.bake(new Function, Matrix4f>() + { + private final TRSRTransformation global = state.apply(Optional.absent()).or(TRSRTransformation.identity()); + private final LoadingCache, TRSRTransformation> localCache = CacheBuilder.newBuilder() + .maximumSize(32) + .build(new CacheLoader, TRSRTransformation>() + { + public TRSRTransformation load(Node node) throws Exception + { + return state.apply(Optional.of(new NodeJoint(node))).or(TRSRTransformation.identity()); + } + }); + + public Matrix4f apply(Node node) + { + return global.compose(localCache.getUnchecked(node)).getMatrix(); + } + }); + for(Face f : faces) + { + UnpackedBakedQuad.Builder quadBuilder = new UnpackedBakedQuad.Builder(format); + quadBuilder.setContractUVs(true); + quadBuilder.setQuadOrientation(EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z)); + List textures = null; + if(f.getBrush() != null) textures = f.getBrush().getTextures(); + TextureAtlasSprite sprite; + if(textures == null || textures.isEmpty()) sprite = this.textures.get("missingno"); + else if(textures.get(0) == B3DModel.Texture.White) sprite = ModelLoader.White.INSTANCE; + else sprite = this.textures.get(textures.get(0).getPath()); + quadBuilder.setTexture(sprite); + putVertexData(quadBuilder, f.getV1(), f.getNormal(), sprite); + putVertexData(quadBuilder, f.getV2(), f.getNormal(), sprite); + putVertexData(quadBuilder, f.getV3(), f.getNormal(), sprite); + putVertexData(quadBuilder, f.getV3(), f.getNormal(), sprite); + builder.add(quadBuilder.build()); + } + } + } + private final void putVertexData(UnpackedBakedQuad.Builder builder, Vertex v, Vector3f faceNormal, TextureAtlasSprite sprite) { // TODO handle everything not handled (texture transformations, bones, transformations, normals, e.t.c) @@ -944,14 +751,13 @@ public class B3DLoader implements ICustomModelLoader builder.put(e, v.getPos().x, v.getPos().y, v.getPos().z, 1); break; case COLOR: - float d = LightUtil.diffuseLight(faceNormal.x, faceNormal.y, faceNormal.z); if(v.getColor() != null) { - builder.put(e, d * v.getColor().x, d * v.getColor().y, d * v.getColor().z, v.getColor().w); + builder.put(e, v.getColor().x, v.getColor().y, v.getColor().z, v.getColor().w); } else { - builder.put(e, d, d, d, 1); + builder.put(e, 1, 1, 1, 1); } break; case UV: @@ -1012,70 +818,15 @@ public class B3DLoader implements ICustomModelLoader return ItemCameraTransforms.DEFAULT; } - @Override - public BakedWrapper handleBlockState(IBlockState state) - { - if(state instanceof IExtendedBlockState) - { - IExtendedBlockState exState = (IExtendedBlockState)state; - if(exState.getUnlistedNames().contains(B3DFrameProperty.instance)) - { - B3DState s = exState.getValue(B3DFrameProperty.instance); - if(s != null) - { - //return getCachedModel(s.getFrame()); - IModelState parent = this.state; - Animation newAnimation = s.getAnimation(); - if(parent instanceof B3DState) - { - B3DState ps = (B3DState)parent; - parent = ps.getParent(); - } - if(newAnimation == null) - { - newAnimation = node.getAnimation(); - } - if(s.getFrame() == s.getNextFrame()) - { - return cache.getUnchecked(s.getFrame()); - } - B3DState newState = new B3DState(newAnimation, s.getFrame(), s.getNextFrame(), s.getProgress(), parent); - return new BakedWrapper(node, newState, format, meshes, textures); - } - } - else if(exState.getUnlistedNames().contains(Properties.AnimationProperty)) - { - // FIXME: should animation state handle the parent state, or should it remain here? - IModelState parent = this.state; - if(parent instanceof B3DState) - { - B3DState ps = (B3DState)parent; - parent = ps.getParent(); - } - IModelState newState = exState.getValue(Properties.AnimationProperty); - if(newState != null) - { - return new BakedWrapper(node, new ModelStateComposition(parent, newState), format, meshes, textures); - } - } - } - return this; - } - - public VertexFormat getFormat() - { - return format; - } - - public BakedWrapper handleItemState(ItemStack stack) - { - // TODO specify how to get B3DState from ItemStack - return this; - } - - public Pair handlePerspective(TransformType cameraTransformType) + public Pair handlePerspective(TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, state, cameraTransformType); } + + public ItemOverrideList getOverrides() + { + // TODO handle items + return ItemOverrideList.NONE; + } } } diff --git a/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java b/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java index 3cc123107b..d65b4f2085 100644 --- a/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java +++ b/src/main/java/net/minecraftforge/client/model/b3d/B3DModel.java @@ -60,7 +60,7 @@ public class B3DModel public static class Parser { - private static final int version = 0001; + private static final int version = 1; private final ByteBuffer buf; private byte[] tag = new byte[4]; @@ -204,7 +204,7 @@ public class B3DModel if(version / 100 > Parser.version / 100) throw new IOException("Unsupported major model version: " + ((float)version / 100)); if(version % 100 > Parser.version % 100) - logger.warn(String.format("Minor version differnce in model: ", ((float)version / 100))); + logger.warn(String.format("Minor version difference in model: ", ((float)version / 100))); List textures = Collections.emptyList(); List brushes = Collections.emptyList(); Node root = null; @@ -511,7 +511,7 @@ public class B3DModel public static class Texture { - public static Texture White = new Texture("builtin/white", 0, 0, new Vector2f(0, 0), new Vector2f(1, 1), 0); + public static final Texture White = new Texture("builtin/white", 0, 0, new Vector2f(0, 0), new Vector2f(1, 1), 0); private final String path; private final int flags; private final int blend; diff --git a/src/main/java/net/minecraftforge/client/model/obj/OBJLoader.java b/src/main/java/net/minecraftforge/client/model/obj/OBJLoader.java index 6d71fe7225..aa1c8792d7 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/OBJLoader.java +++ b/src/main/java/net/minecraftforge/client/model/obj/OBJLoader.java @@ -1,7 +1,6 @@ package net.minecraftforge.client.model.obj; import java.io.FileNotFoundException; -import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -22,11 +21,13 @@ import org.apache.logging.log4j.Level; * To enable your mod call instance.addDomain(modid). * If you need more control over accepted resources - extend the class, and register a new instance with ModelLoaderRegistry. */ -public class OBJLoader implements ICustomModelLoader { - public static final OBJLoader instance = new OBJLoader(); +public enum OBJLoader implements ICustomModelLoader { + INSTANCE; + private IResourceManager manager; private final Set enabledDomains = new HashSet(); private final Map cache = new HashMap(); + private final Map errors = new HashMap(); public void addDomain(String domain) { @@ -38,6 +39,7 @@ public class OBJLoader implements ICustomModelLoader { { this.manager = resourceManager; cache.clear(); + errors.clear(); } public boolean accepts(ResourceLocation modelLocation) @@ -45,45 +47,41 @@ public class OBJLoader implements ICustomModelLoader { return enabledDomains.contains(modelLocation.getResourceDomain()) && modelLocation.getResourcePath().endsWith(".obj"); } - public IModel loadModel(ResourceLocation modelLocation) throws IOException + public IModel loadModel(ResourceLocation modelLocation) throws Exception { ResourceLocation file = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath()); if (!cache.containsKey(file)) { + IResource resource = null; try { - IResource resource = null; - try - { - resource = manager.getResource(file); - } - catch (FileNotFoundException e) - { - if (modelLocation.getResourcePath().startsWith("models/block/")) - resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/item/" + file.getResourcePath().substring("models/block/".length()))); - else if (modelLocation.getResourcePath().startsWith("models/item/")) - resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/block/" + file.getResourcePath().substring("models/item/".length()))); - else throw e; - } - OBJModel.Parser parser = new OBJModel.Parser(resource, manager); - OBJModel model = null; - try - { - model = parser.parse(); - } - finally - { - cache.put(modelLocation, model); - } + resource = manager.getResource(file); } - catch (IOException e) + catch (FileNotFoundException e) { -// FMLLog.log(Level.ERROR, e, "Exception loading model '%s' with OBJ loader, skipping", modelLocation); - throw e; + if (modelLocation.getResourcePath().startsWith("models/block/")) + resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/item/" + file.getResourcePath().substring("models/block/".length()))); + else if (modelLocation.getResourcePath().startsWith("models/item/")) + resource = manager.getResource(new ResourceLocation(file.getResourceDomain(), "models/block/" + file.getResourcePath().substring("models/item/".length()))); + else throw e; + } + OBJModel.Parser parser = new OBJModel.Parser(resource, manager); + OBJModel model = null; + try + { + model = parser.parse(); + } + catch (Exception e) + { + errors.put(modelLocation, e); + } + finally + { + cache.put(modelLocation, model); } } OBJModel model = cache.get(file); - if (model == null) return ModelLoaderRegistry.getMissingModel(); + if (model == null) throw new ModelLoaderRegistry.LoaderException("Error loading model previously: " + file, errors.get(modelLocation)); return model; } } diff --git a/src/main/java/net/minecraftforge/client/model/obj/OBJModel.java b/src/main/java/net/minecraftforge/client/model/obj/OBJModel.java index b988721468..88844c6454 100644 --- a/src/main/java/net/minecraftforge/client/model/obj/OBJModel.java +++ b/src/main/java/net/minecraftforge/client/model/obj/OBJModel.java @@ -22,24 +22,30 @@ import javax.vecmath.Vector4f; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverrideList; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.*; -import net.minecraftforge.client.model.pipeline.LightUtil; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.IModelCustomData; +import net.minecraftforge.client.model.IPerspectiveAwareModel; +import net.minecraftforge.client.model.IRetexturableModel; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; -import net.minecraftforge.common.property.IExtendedBlockState; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.fml.common.FMLLog; import org.apache.commons.lang3.tuple.Pair; +import org.apache.logging.log4j.core.helpers.Strings; import com.google.common.base.Charsets; import com.google.common.base.Function; @@ -53,8 +59,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -@SuppressWarnings("deprecation") -public class OBJModel implements IRetexturableModel, IModelCustomData +public class OBJModel implements IRetexturableModel, IModelCustomData { //private Gson GSON = new GsonBuilder().create(); private MaterialLibrary matLib; @@ -95,10 +100,10 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< } @Override - public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) + public IBakedModel bake(IModelState state, VertexFormat format, Function bakedTextureGetter) { ImmutableMap.Builder builder = ImmutableMap.builder(); - builder.put(ModelLoader.White.loc.toString(), ModelLoader.White.instance); + builder.put(ModelLoader.White.LOCATION.toString(), ModelLoader.White.INSTANCE); TextureAtlasSprite missing = bakedTextureGetter.apply(new ResourceLocation("missingno")); for (Map.Entry e : matLib.materials.entrySet()) { @@ -197,212 +202,164 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< return this.groupList; } + private float[] parseFloats(String[] data) // Helper converting strings to floats + { + float[] ret = new float[data.length]; + for (int i = 0; i < data.length; i++) + ret[i] = Float.parseFloat(data[i]); + return ret; + } + + //Partial reading of the OBJ format. Documentation taken from http://paulbourke.net/dataformats/obj/ public OBJModel parse() throws IOException { String currentLine = ""; Material material = new Material(); material.setName(Material.DEFAULT_NAME); int usemtlCounter = 0; - -// float[] minUVBounds = new float[] {0.0f, 0.0f}; -// float[] maxUVBounds = new float[] {1.0f, 1.0f}; + int lineNum = 0; for (;;) { + lineNum++; currentLine = objReader.readLine(); if (currentLine == null) break; currentLine.trim(); if (currentLine.isEmpty() || currentLine.startsWith("#")) continue; - String[] fields = WHITE_SPACE.split(currentLine, 2); - String key = fields[0]; - String data = fields[1]; - String[] splitData = WHITE_SPACE.split(data); - - if (key.equalsIgnoreCase("mtllib")) - this.materialLibrary.parseMaterials(manager, data, objFrom); - else if (key.equalsIgnoreCase("usemtl")) + try { - material = this.materialLibrary.materials.get(data); - usemtlCounter++; - } - else if (key.equalsIgnoreCase("v")) - { - float[] floatSplitData = new float[splitData.length]; - for (int i = 0; i < splitData.length; i++) - floatSplitData[i] = Float.parseFloat(splitData[i]); - Vector4f pos = new Vector4f(floatSplitData[0], floatSplitData[1], floatSplitData[2], floatSplitData.length == 4 ? floatSplitData[3] : 1); - Vertex vertex = new Vertex(pos, material); - this.vertices.add(vertex); - } - else if (key.equalsIgnoreCase("vn")) - { - float[] floatSplitData = new float[splitData.length]; - for (int i = 0; i < splitData.length; i++) - floatSplitData[i] = Float.parseFloat(splitData[i]); - Normal normal = new Normal(floatSplitData); - this.normals.add(normal); - } - else if (key.equalsIgnoreCase("vt")) - { - float[] floatSplitData = new float[splitData.length]; - for (int i = 0; i < splitData.length; i++) - floatSplitData[i] = Float.parseFloat(splitData[i]); - TextureCoordinate texCoord = new TextureCoordinate(new Vector3f(floatSplitData[0], floatSplitData[1], floatSplitData.length == 3 ? floatSplitData[2] : 1)); - if (texCoord.u < 0.0f || texCoord.u > 1.0f || texCoord.v < 0.0f || texCoord.v > 1.0f) - throw new UVsOutOfBoundsException(this.objFrom); -// this.UVsOutOfBounds = (texCoord.u < 0.0f || texCoord.u > 1.0f || texCoord.v < 0.0f || texCoord.v > 1.0f); + String[] fields = WHITE_SPACE.split(currentLine, 2); + String key = fields[0]; + String data = fields[1]; + String[] splitData = WHITE_SPACE.split(data); -// if (texCoord.u < 0.0f || texCoord.u > 1.0f || texCoord.v < 0.0f || texCoord.v > 1.0f) -// { -// this.UVsOutOfBounds = true; -// texCoord.u -= Math.floor(texCoord.u); -// texCoord.v -= Math.floor(texCoord.v); -// } - -// minUVBounds[0] = floatSplitData[0] < minUVBounds[0] ? floatSplitData[0] : minUVBounds[0]; -// minUVBounds[1] = floatSplitData[1] < minUVBounds[1] ? floatSplitData[1] : minUVBounds[1]; -// maxUVBounds[0] = floatSplitData[0] > maxUVBounds[0] ? floatSplitData[0] : maxUVBounds[0]; -// maxUVBounds[1] = floatSplitData[1] > maxUVBounds[1] ? floatSplitData[1] : maxUVBounds[1]; -// FMLLog.info("u: [%f, %f] v: [%f, %f]", minUVBounds[]); - this.texCoords.add(texCoord); - } - else if (key.equalsIgnoreCase("f")) - { - String[][] splitSlash = new String[splitData.length][]; - if (splitData.length > 4) FMLLog.warning("OBJModel.Parser: found a face ('f') with more than 4 vertices, only the first 4 of these vertices will be rendered!"); - - int vert = 0; - int texCoord = 0; - int norm = 0; - - List v = Lists.newArrayListWithCapacity(splitData.length); -// List t = Lists.newArrayListWithCapacity(splitData.length); -// List n = Lists.newArrayListWithCapacity(splitData.length); - - for (int i = 0; i < splitData.length; i++) + if (key.equalsIgnoreCase("mtllib")) { - if (splitData[i].contains("//")) + this.materialLibrary.parseMaterials(manager, data, objFrom); + } + else if (key.equalsIgnoreCase("usemtl")) + { + material = this.materialLibrary.materials.get(data); + usemtlCounter++; + } + else if (key.equalsIgnoreCase("v")) // Vertices: x y z [w] - w Defaults to 1.0 + { + float[] coords = parseFloats(splitData); + Vector4f pos = new Vector4f(coords[0], coords[1], coords[2], coords.length == 4 ? coords[3] : 1.0F); + this.vertices.add(new Vertex(pos, material)); + } + else if (key.equalsIgnoreCase("vn")) // Vertex normals: x y z + { + this.normals.add(new Normal(parseFloats(splitData))); + } + else if (key.equalsIgnoreCase("vt")) // Vertex Textures: u [v] [w] - v/w Defaults to 0 + { + float[] coords = parseFloats(splitData); + TextureCoordinate texCoord = new TextureCoordinate(coords[0], + coords.length >= 2 ? coords[1] : 0.0F, + coords.length >= 3 ? coords[2] : 0.0F); + if (texCoord.u < 0.0f || texCoord.u > 1.0f || texCoord.v < 0.0f || texCoord.v > 1.0f) + throw new UVsOutOfBoundsException(this.objFrom); + this.texCoords.add(texCoord); + } + else if (key.equalsIgnoreCase("f")) // Face Elements: f v1[/vt1][/vn1] ... + { + if (splitData.length > 4) + FMLLog.warning("OBJModel.Parser: found a face ('f') with more than 4 vertices, only the first 4 of these vertices will be rendered!"); + + List v = Lists.newArrayListWithCapacity(splitData.length); + + for (int i = 0; i < splitData.length; i++) { - splitSlash[i] = splitData[i].split("//"); + String[] pts = splitData[i].split("/"); + + int vert = Integer.parseInt(pts[0]); + Integer texture = pts.length < 2 || Strings.isEmpty(pts[1]) ? null : Integer.parseInt(pts[1]); + Integer normal = pts.length < 3 || Strings.isEmpty(pts[2]) ? null : Integer.parseInt(pts[2]); - vert = Integer.parseInt(splitSlash[i][0]); vert = vert < 0 ? this.vertices.size() - 1 : vert - 1; - norm = Integer.parseInt(splitSlash[i][1]); - norm = norm < 0 ? this.normals.size() - 1 : norm - 1; - Vertex newV = new Vertex(new Vector4f(this.vertices.get(vert).getPos()), this.vertices.get(vert).getMaterial()); - newV.setNormal(this.normals.get(norm)); + + if (texture != null) + newV.setTextureCoordinate(this.texCoords.get(texture < 0 ? this.texCoords.size() - 1 : texture - 1)); + if (normal != null) + newV.setNormal(this.normals.get(normal < 0 ? this.normals.size() - 1 : normal - 1)); v.add(newV); -// n.add(this.normals.get(norm)); } - else if (splitData[i].contains("/")) - { - splitSlash[i] = splitData[i].split("/"); - vert = Integer.parseInt(splitSlash[i][0]); - vert = vert < 0 ? this.vertices.size() - 1 : vert - 1; - texCoord = Integer.parseInt(splitSlash[i][1]); - texCoord = texCoord < 0 ? this.texCoords.size() - 1 : texCoord - 1; - if (splitSlash[i].length > 2) + Vertex[] va = v.toArray(new Vertex[v.size()]); + + Face face = new Face(va, material.name); + if (usemtlCounter < this.vertices.size()) + { + for (Vertex ver : face.getVertices()) { - norm = Integer.parseInt(splitSlash[i][2]); - norm = norm < 0 ? this.normals.size() - 1 : norm - 1; + ver.setMaterial(material); } - - Vertex newV = new Vertex(new Vector4f(this.vertices.get(vert).getPos()), this.vertices.get(vert).getMaterial()); - newV.setTextureCoordinate(this.texCoords.get(texCoord)); - newV.setNormal(splitSlash[i].length > 2 ? this.normals.get(norm) : null); - - v.add(newV); -// t.add(this.texCoords.get(texCoord)); -// if (splitSlash[i].length > 2) n.add(this.normals.get(norm)); } - else - { - splitSlash[i] = splitData[i].split(""); - vert = Integer.parseInt(splitSlash[i][0]); - vert = vert < 0 ? this.vertices.size() - 1 : vert - 1; - - Vertex newV = new Vertex(new Vector4f(this.vertices.get(vert).getPos()), this.vertices.get(vert).getMaterial()); - v.add(newV); - } - } - - Vertex[] va = new Vertex[v.size()]; - v.toArray(va); -// TextureCoordinate[] ta = new TextureCoordinate[t.size()]; -// t.toArray(ta); -// Normal[] na = new Normal[n.size()]; -// n.toArray(na); - Face face = new Face(va, material.name); - if (usemtlCounter < this.vertices.size()) - { - for (Vertex ver : face.getVertices()) + if (groupList.isEmpty()) { - ver.setMaterial(material); - } - } - - if (groupList.isEmpty()) - { - if (this.materialLibrary.getGroups().containsKey(Group.DEFAULT_NAME)) - { - this.materialLibrary.getGroups().get(Group.DEFAULT_NAME).addFace(face); - } - else - { - Group def = new Group(Group.DEFAULT_NAME, null); - def.addFace(face); - this.materialLibrary.getGroups().put(Group.DEFAULT_NAME, def); - } - } - else - { - for (String s : groupList) - { - if (this.materialLibrary.getGroups().containsKey(s)) + if (this.materialLibrary.getGroups().containsKey(Group.DEFAULT_NAME)) { - this.materialLibrary.getGroups().get(s).addFace(face); + this.materialLibrary.getGroups().get(Group.DEFAULT_NAME).addFace(face); } else { - Group e = new Group(s, null); - e.addFace(face); - this.materialLibrary.getGroups().put(s, e); + Group def = new Group(Group.DEFAULT_NAME, null); + def.addFace(face); + this.materialLibrary.getGroups().put(Group.DEFAULT_NAME, def); + } + } + else + { + for (String s : groupList) + { + if (this.materialLibrary.getGroups().containsKey(s)) + { + this.materialLibrary.getGroups().get(s).addFace(face); + } + else + { + Group e = new Group(s, null); + e.addFace(face); + this.materialLibrary.getGroups().put(s, e); + } } } } - } - else if (key.equalsIgnoreCase("g") || key.equalsIgnoreCase("o")) - { - groupList.clear(); - if (key.equalsIgnoreCase("g")) + else if (key.equalsIgnoreCase("g") || key.equalsIgnoreCase("o")) { - String[] splitSpace = data.split(" "); - for (String s : splitSpace) - groupList.add(s); + groupList.clear(); + if (key.equalsIgnoreCase("g")) + { + String[] splitSpace = data.split(" "); + for (String s : splitSpace) + groupList.add(s); + } + else + { + groupList.add(data); + } } else { - groupList.add(data); + if (!unknownObjectCommands.contains(key)) + { + unknownObjectCommands.add(key); + FMLLog.info("OBJLoader.Parser: command '%s' (model: '%s') is not currently supported, skipping. Line: %d '%s'", key, objFrom, lineNum, currentLine); + } } } - else + catch (RuntimeException e) { - if (!unknownObjectCommands.contains(key)) - { - unknownObjectCommands.add(key); - FMLLog.info("OBJLoader.Parser: command '%s' (model: '%s') is not currently supported, skipping", key, objFrom); - } + throw new RuntimeException(String.format("OBJLoader.Parser: Exception parsing line #%d: `%s`", lineNum, currentLine), e); } } - OBJModel model = new OBJModel(this.materialLibrary, this.objFrom); -// model.getMatLib().setUVBounds(minUVBounds[0], maxUVBounds[0], minUVBounds[1], maxUVBounds[1]); - return model; + return new OBJModel(this.materialLibrary, this.objFrom); } } @@ -821,8 +778,8 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< { return this.materialName; } - - public boolean isTriangles() + + public boolean isTriangles() { return isTri; } @@ -1275,10 +1232,10 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< public enum OBJProperty implements IUnlistedProperty { - instance; + INSTANCE; public String getName() { - return "OBJPropery"; + return "OBJProperty"; } @Override @@ -1300,14 +1257,14 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< } } - public class OBJBakedModel implements IFlexibleBakedModel, ISmartBlockModel, ISmartItemModel, IPerspectiveAwareModel + public class OBJBakedModel implements IPerspectiveAwareModel { private final OBJModel model; private IModelState state; private final VertexFormat format; private Set quads; private ImmutableMap textures; - private TextureAtlasSprite sprite = ModelLoader.White.instance; + private TextureAtlasSprite sprite = ModelLoader.White.INSTANCE; public OBJBakedModel(OBJModel model, IModelState state, VertexFormat format, ImmutableMap textures) { @@ -1323,15 +1280,11 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< this.quads = null; } + // FIXME: merge with getQuads @Override - public List getFaceQuads(EnumFacing side) - { - return Collections.emptyList(); - } - - @Override - public List getGeneralQuads() + public List getQuads(IBlockState blockState, EnumFacing side, long rand) { + if(side != null) return ImmutableList.of(); if (quads == null) { quads = Collections.synchronizedSet(new LinkedHashSet()); @@ -1400,11 +1353,12 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< v.setMaterial(this.model.getMatLib().getMaterial(v.getMaterial().getName())); } } - sprite = ModelLoader.White.instance; + sprite = ModelLoader.White.INSTANCE; } else sprite = this.textures.get(f.getMaterialName()); UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format); + builder.setContractUVs(true); builder.setQuadOrientation(EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z)); - builder.setQuadColored(); + builder.setTexture(sprite); Normal faceNormal = f.getNormal(); putVertexData(builder, f.verts[0], faceNormal, TextureCoordinate.getDefaultUVs()[0], sprite); putVertexData(builder, f.verts[1], faceNormal, TextureCoordinate.getDefaultUVs()[1], sprite); @@ -1427,20 +1381,14 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< builder.put(e, v.getPos().x, v.getPos().y, v.getPos().z, v.getPos().w); break; case COLOR: - float d; - if (v.hasNormal()) - d = LightUtil.diffuseLight(v.getNormal().x, v.getNormal().y, v.getNormal().z); - else - d = LightUtil.diffuseLight(faceNormal.x, faceNormal.y, faceNormal.z); - if (v.getMaterial() != null) builder.put(e, - d * v.getMaterial().getColor().x, - d * v.getMaterial().getColor().y, - d * v.getMaterial().getColor().z, + v.getMaterial().getColor().x, + v.getMaterial().getColor().y, + v.getMaterial().getColor().z, v.getMaterial().getColor().w); else - builder.put(e, d, d, d, 1); + builder.put(e, 1, 1, 1, 1); break; case UV: if (!v.hasTextureCoordinate()) @@ -1496,19 +1444,8 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< return ItemCameraTransforms.DEFAULT; } - @Override - public VertexFormat getFormat() - { - return format; - } - - @Override - public IBakedModel handleItemState(ItemStack stack) - { - return this; - } - - @Override + // FIXME: merge with getQuads + /* @Override public OBJBakedModel handleBlockState(IBlockState state) { if (state instanceof IExtendedBlockState) @@ -1528,7 +1465,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< } } return this; - } + }*/ private void updateStateVisibilityMap(OBJState state) { @@ -1591,7 +1528,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< } @Override - public Pair handlePerspective(TransformType cameraTransformType) + public Pair handlePerspective(TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, state, cameraTransformType); } @@ -1601,6 +1538,12 @@ public class OBJModel implements IRetexturableModel, IModelCustomData< { return this.model.modelLocation.toString(); } + + @Override + public ItemOverrideList getOverrides() + { + return ItemOverrideList.NONE; + } } @SuppressWarnings("serial") diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java b/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java index 2ea9676e55..fa78ce40be 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/BlockInfo.java @@ -1,16 +1,18 @@ package net.minecraftforge.client.model.pipeline; -import net.minecraft.block.Block; import net.minecraft.block.Block.EnumOffsetType; -import net.minecraft.util.BlockPos; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.util.EnumFacing; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.IBlockAccess; public class BlockInfo { + private final BlockColors colors; private IBlockAccess world; - private Block block; + private IBlockState state; private BlockPos blockPos; private final boolean[][][] translucent = new boolean[3][3][3]; @@ -25,11 +27,16 @@ public class BlockInfo private int cachedTint = -1; private int cachedMultiplier = -1; + public BlockInfo(BlockColors colors) + { + this.colors = colors; + } + public int getColorMultiplier(int tint) { if(cachedTint == tint) return cachedMultiplier; cachedTint = tint; - cachedMultiplier = block.colorMultiplier(world, blockPos, tint); + cachedMultiplier = colors.colorMultiplier(state, world, blockPos, tint); return cachedMultiplier; } @@ -41,12 +48,12 @@ public class BlockInfo public void updateShift(boolean ignoreY) { long rand = 0; - if(block.getOffsetType() != EnumOffsetType.NONE) + if(state.getBlock().getOffsetType() != EnumOffsetType.NONE) { rand = MathHelper.getCoordinateRandom(blockPos.getX(), ignoreY ? 0 : blockPos.getY(), blockPos.getZ()); shx = ((float)((rand >> 16) & 0xF) / 0xF - .5f) * .5f; shz = ((float)((rand >> 24) & 0xF) / 0xF - .5f) * .5f; - if(block.getOffsetType() == EnumOffsetType.XYZ) + if(state.getBlock().getOffsetType() == EnumOffsetType.XYZ) { shy = ((float)((rand >> 20) & 0xF) / 0xF - 1) * .2f; } @@ -60,9 +67,9 @@ public class BlockInfo cachedMultiplier = -1; } - public void setBlock(Block block) + public void setState(IBlockState state) { - this.block = block; + this.state = state; cachedTint = -1; cachedMultiplier = -1; } @@ -94,16 +101,16 @@ public class BlockInfo for(int z = 0; z <= 2; z++) { BlockPos pos = blockPos.add(x - 1, y - 1, z - 1); - Block block = world.getBlockState(pos).getBlock(); - translucent[x][y][z] = block.isTranslucent(); + IBlockState state = world.getBlockState(pos); + translucent[x][y][z] = state.isTranslucent(); //translucent[x][y][z] = world.getBlockState(pos).getBlock().getLightOpacity(world, pos) == 0; - int brightness = this.block.getMixedBrightnessForBlock(world, pos); + int brightness = state.getPackedLightmapCoords(world, pos); s[x][y][z] = (brightness >> 0x14) & 0xF; b[x][y][z] = (brightness >> 0x04) & 0xF; - ao[x][y][z] = block.getAmbientOcclusionLightValue(); + ao[x][y][z] = state.getAmbientOcclusionLightValue(); if(x == 1 && y == 1 && z == 1) { - full = block.isFullCube(); + full = state.isFullCube(); } } } @@ -150,9 +157,9 @@ public class BlockInfo return world; } - public Block getBlock() + public IBlockState getState() { - return block; + return state; } public BlockPos getBlockPos() diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/ForgeBlockModelRenderer.java b/src/main/java/net/minecraftforge/client/model/pipeline/ForgeBlockModelRenderer.java index f7c7cf1965..b460661899 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/ForgeBlockModelRenderer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/ForgeBlockModelRenderer.java @@ -2,13 +2,14 @@ package net.minecraftforge.client.model.pipeline; import java.util.List; -import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.BlockModelRenderer; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.util.BlockPos; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.ForgeModContainer; @@ -19,7 +20,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer @Override protected VertexLighterFlat initialValue() { - return new VertexLighterFlat(); + return new VertexLighterFlat(colors); } }; @@ -28,64 +29,73 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer @Override protected VertexLighterSmoothAo initialValue() { - return new VertexLighterSmoothAo(); + return new VertexLighterSmoothAo(colors); } }; - private final ThreadLocal wrFlat = new ThreadLocal(); - private final ThreadLocal wrSmooth = new ThreadLocal(); - private final ThreadLocal lastRendererFlat = new ThreadLocal(); - private final ThreadLocal lastRendererSmooth = new ThreadLocal(); + private final ThreadLocal wrFlat = new ThreadLocal(); + private final ThreadLocal wrSmooth = new ThreadLocal(); + private final ThreadLocal lastRendererFlat = new ThreadLocal(); + private final ThreadLocal lastRendererSmooth = new ThreadLocal(); + + private final BlockColors colors; + + public ForgeBlockModelRenderer(BlockColors colors) + { + // TODO Auto-generated constructor stub + super(colors); + this.colors = colors; + } @Override - public boolean renderModelStandard(IBlockAccess world, IBakedModel model, Block block, BlockPos pos, WorldRenderer wr, boolean checkSides) + public boolean renderModelFlat(IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, VertexBuffer buffer, boolean checkSides, long rand) { if(ForgeModContainer.forgeLightPipelineEnabled) { - if(wr != lastRendererFlat.get()) + if(buffer != lastRendererFlat.get()) { - lastRendererFlat.set(wr); - WorldRendererConsumer newCons = new WorldRendererConsumer(wr); + lastRendererFlat.set(buffer); + VertexBufferConsumer newCons = new VertexBufferConsumer(buffer); wrFlat.set(newCons); lighterFlat.get().setParent(newCons); } wrFlat.get().setOffset(pos); - return render(lighterFlat.get(), world, model, block, pos, wr, checkSides); + return render(lighterFlat.get(), world, model, state, pos, buffer, checkSides, rand); } else { - return super.renderModelStandard(world, model, block, pos, wr, checkSides); + return super.renderModelFlat(world, model, state, pos, buffer, checkSides, rand); } } @Override - public boolean renderModelAmbientOcclusion(IBlockAccess world, IBakedModel model, Block block, BlockPos pos, WorldRenderer wr, boolean checkSides) + public boolean renderModelSmooth(IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, VertexBuffer buffer, boolean checkSides, long rand) { if(ForgeModContainer.forgeLightPipelineEnabled) { - if(wr != lastRendererSmooth.get()) + if(buffer != lastRendererSmooth.get()) { - lastRendererSmooth.set(wr); - WorldRendererConsumer newCons = new WorldRendererConsumer(wr); + lastRendererSmooth.set(buffer); + VertexBufferConsumer newCons = new VertexBufferConsumer(buffer); wrSmooth.set(newCons); lighterSmooth.get().setParent(newCons); } wrSmooth.get().setOffset(pos); - return render(lighterSmooth.get(), world, model, block, pos, wr, checkSides); + return render(lighterSmooth.get(), world, model, state, pos, buffer, checkSides, rand); } else { - return super.renderModelAmbientOcclusion(world, model, block, pos, wr, checkSides); + return super.renderModelSmooth(world, model, state, pos, buffer, checkSides, rand); } } - public static boolean render(VertexLighterFlat lighter, IBlockAccess world, IBakedModel model, Block block, BlockPos pos, WorldRenderer wr, boolean checkSides) + public static boolean render(VertexLighterFlat lighter, IBlockAccess world, IBakedModel model, IBlockState state, BlockPos pos, VertexBuffer wr, boolean checkSides, long rand) { lighter.setWorld(world); - lighter.setBlock(block); + lighter.setState(state); lighter.setBlockPos(pos); boolean empty = true; - List quads = model.getGeneralQuads(); + List quads = model.getQuads(state, null, rand); if(!quads.isEmpty()) { lighter.updateBlockInfo(); @@ -97,10 +107,10 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer } for(EnumFacing side : EnumFacing.values()) { - quads = model.getFaceQuads(side); + quads = model.getQuads(state, side, rand); if(!quads.isEmpty()) { - if(!checkSides || block.shouldSideBeRendered(world, pos.offset(side), side)) + if(!checkSides || state.shouldSideBeRendered(world, pos, side)) { if(empty) lighter.updateBlockInfo(); empty = false; diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/IVertexConsumer.java b/src/main/java/net/minecraftforge/client/model/pipeline/IVertexConsumer.java index 92cf355ca9..2adff8964c 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/IVertexConsumer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/IVertexConsumer.java @@ -17,7 +17,7 @@ public interface IVertexConsumer void setQuadTint(int tint); void setQuadOrientation(EnumFacing orientation); - void setQuadColored(); + void setApplyDiffuseLighting(boolean diffuse); void put(int element, float... data); } diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java b/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java index 9a23a1109a..cbcdb23ccc 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/LightUtil.java @@ -1,15 +1,15 @@ package net.minecraftforge.client.model.pipeline; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage; import net.minecraft.util.EnumFacing; import net.minecraftforge.client.ForgeHooksClient; -import net.minecraftforge.client.model.IColoredBakedQuad; + +import org.apache.commons.lang3.tuple.Pair; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; @@ -71,18 +71,16 @@ public class LightUtil } } - private static final LoadingCache formatMaps = CacheBuilder.newBuilder() + private static final LoadingCache, int[]> formatMaps = CacheBuilder.newBuilder() .maximumSize(10) - .build(new CacheLoader() + .build(new CacheLoader, int[]>() { - public int[] load(VertexFormat format) + public int[] load(Pair pair) { - return mapFormats(format, DefaultVertexFormats.ITEM); + return mapFormats(pair.getLeft(), pair.getRight()); } }); - private static final int itemCount = DefaultVertexFormats.ITEM.getElementCount(); - public static void putBakedQuad(IVertexConsumer consumer, BakedQuad quad) { consumer.setQuadOrientation(quad.getFace()); @@ -90,22 +88,21 @@ public class LightUtil { consumer.setQuadTint(quad.getTintIndex()); } - if(quad instanceof IColoredBakedQuad) - { - consumer.setQuadColored(); - } + consumer.setApplyDiffuseLighting(quad.shouldApplyDiffuseLighting()); //int[] eMap = mapFormats(consumer.getVertexFormat(), DefaultVertexFormats.ITEM); float[] data = new float[4]; - VertexFormat format = consumer.getVertexFormat(); - int count = format.getElementCount(); - int[] eMap = formatMaps.getUnchecked(format); + VertexFormat formatFrom = consumer.getVertexFormat(); + VertexFormat formatTo = quad.getFormat(); + int countFrom = formatFrom.getElementCount(); + int countTo = formatTo.getElementCount(); + int[] eMap = formatMaps.getUnchecked(Pair.of(formatFrom, formatTo)); for(int v = 0; v < 4; v++) { - for(int e = 0; e < count; e++) + for(int e = 0; e < countFrom; e++) { - if(eMap[e] != itemCount) + if(eMap[e] != countTo) { - unpack(quad.getVertexData(), data, DefaultVertexFormats.ITEM, v, eMap[e]); + unpack(quad.getVertexData(), data, quad.getFormat(), v, eMap[e]); consumer.put(e, data); } else @@ -143,7 +140,7 @@ public class LightUtil { int length = 4 < to.length ? 4 : to.length; VertexFormatElement element = formatFrom.getElement(e); - int vertexStart = v * formatFrom.getNextOffset() + formatFrom.func_181720_d(e); + int vertexStart = v * formatFrom.getNextOffset() + formatFrom.getOffset(e); int count = element.getElementCount(); VertexFormatElement.EnumType type = element.getType(); int size = type.getSize(); @@ -197,7 +194,7 @@ public class LightUtil public static void pack(float[] from, int[] to, VertexFormat formatTo, int v, int e) { VertexFormatElement element = formatTo.getElement(e); - int vertexStart = v * formatTo.getNextOffset() + formatTo.func_181720_d(e); + int vertexStart = v * formatTo.getNextOffset() + formatTo.getOffset(e); int count = element.getElementCount(); VertexFormatElement.EnumType type = element.getType(); int size = type.getSize(); @@ -240,8 +237,8 @@ public class LightUtil if(tessellator == null) { Tessellator tes = Tessellator.getInstance(); - WorldRenderer wr = tes.getWorldRenderer(); - tessellator = new WorldRendererConsumer(wr); + VertexBuffer wr = tes.getBuffer(); + tessellator = new VertexBufferConsumer(wr); } return tessellator; } @@ -257,16 +254,16 @@ public class LightUtil } // renders quad in any Vertex Format, but is slower - public static void renderQuadColorSlow(WorldRenderer wr, BakedQuad quad, int auxColor) + public static void renderQuadColorSlow(VertexBuffer wr, BakedQuad quad, int auxColor) { ItemConsumer cons; - if(wr == Tessellator.getInstance().getWorldRenderer()) + if(wr == Tessellator.getInstance().getBuffer()) { cons = getItemConsumer(); } else { - cons = new ItemConsumer(new WorldRendererConsumer(wr)); + cons = new ItemConsumer(new VertexBufferConsumer(wr)); } float b = (float)(auxColor & 0xFF) / 0xFF; float g = (float)((auxColor >>> 8) & 0xFF) / 0xFF; @@ -277,22 +274,14 @@ public class LightUtil quad.pipe(cons); } - public static void renderQuadColor(WorldRenderer wr, BakedQuad quad, int auxColor) + public static void renderQuadColor(VertexBuffer wr, BakedQuad quad, int auxColor) { wr.addVertexData(quad.getVertexData()); - if(quad instanceof IColoredBakedQuad) - { - ForgeHooksClient.putQuadColor(wr, quad, auxColor); - } - else - { - wr.putColor4(auxColor); - } + ForgeHooksClient.putQuadColor(wr, quad, auxColor); } public static class ItemConsumer extends VertexTransformer { - private boolean colored = false; private int vertices = 0; private float[] auxColor = new float[]{1, 1, 1, 1}; @@ -308,23 +297,14 @@ public class LightUtil System.arraycopy(auxColor, 0, this.auxColor, 0, this.auxColor.length); } - @Override - public void setQuadColored() - { - colored = true; - } - public void put(int element, float... data) { if(getVertexFormat().getElement(element).getUsage() == EnumUsage.COLOR) { System.arraycopy(auxColor, 0, buf, 0, buf.length); - if(colored) + for(int i = 0; i < 4; i++) { - for(int i = 0; i < 4; i++) - { - buf[i] *= data[i]; - } + buf[i] *= data[i]; } super.put(element, buf); } @@ -338,7 +318,6 @@ public class LightUtil if(vertices == 4) { vertices = 0; - colored = false; } } } diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/UnpackedBakedQuad.java b/src/main/java/net/minecraftforge/client/model/pipeline/UnpackedBakedQuad.java index 430207d08b..fae9806e3d 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/UnpackedBakedQuad.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/UnpackedBakedQuad.java @@ -1,9 +1,10 @@ package net.minecraftforge.client.model.pipeline; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.util.EnumFacing; -import net.minecraftforge.client.model.IColoredBakedQuad; // advantages: non-fixed-length vertex format, no overhead of packing and unpacking attributes to transform the model // disadvantages: (possibly) larger memory footprint, overhead on packing the attributes at the final rendering stage @@ -13,9 +14,9 @@ public class UnpackedBakedQuad extends BakedQuad protected final VertexFormat format; protected boolean packed = false; - public UnpackedBakedQuad(float[][][] unpackedData, int tint, EnumFacing orientation, VertexFormat format) + public UnpackedBakedQuad(float[][][] unpackedData, int tint, EnumFacing orientation, TextureAtlasSprite texture, boolean applyDiffuseLighting, VertexFormat format) { - super(new int[format.getNextOffset() /* / 4 * 4 */], tint, orientation); + super(new int[format.getNextOffset() /* / 4 * 4 */], tint, orientation, texture, applyDiffuseLighting, format); this.unpackedData = unpackedData; this.format = format; } @@ -47,10 +48,6 @@ public class UnpackedBakedQuad extends BakedQuad consumer.setQuadTint(getTintIndex()); } consumer.setQuadOrientation(getFace()); - if(this instanceof IColoredBakedQuad) - { - consumer.setQuadColored(); - } for(int v = 0; v < 4; v++) { for(int e = 0; e < consumer.getVertexFormat().getElementCount(); e++) @@ -67,25 +64,19 @@ public class UnpackedBakedQuad extends BakedQuad } } - public static class Colored extends UnpackedBakedQuad implements IColoredBakedQuad - { - public Colored(float[][][] unpackedData, int tint, EnumFacing orientation, VertexFormat format) - { - super(unpackedData, tint, orientation, format); - } - } - public static class Builder implements IVertexConsumer { private final VertexFormat format; private final float[][][] unpackedData; private int tint = -1; private EnumFacing orientation; - private boolean isColored = false; + private TextureAtlasSprite texture; + private boolean applyDiffuseLighting = true; private int vertices = 0; private int elements = 0; private boolean full = false; + private boolean contractUVs = false; public Builder(VertexFormat format) { @@ -98,6 +89,10 @@ public class UnpackedBakedQuad extends BakedQuad return format; } + public void setContractUVs(boolean value) + { + this.contractUVs = value; + } public void setQuadTint(int tint) { this.tint = tint; @@ -108,9 +103,14 @@ public class UnpackedBakedQuad extends BakedQuad this.orientation = orientation; } - public void setQuadColored() + public void setTexture(TextureAtlasSprite texture) { - this.isColored = true; + this.texture = texture; + } + + public void setApplyDiffuseLighting(boolean diffuse) + { + this.applyDiffuseLighting = diffuse; } public void put(int element, float... data) @@ -138,17 +138,69 @@ public class UnpackedBakedQuad extends BakedQuad } } + private final float eps = 1f / 0x100; + public UnpackedBakedQuad build() { if(!full) { throw new IllegalStateException("not enough data"); } - if(isColored) + if(contractUVs) { - return new Colored(unpackedData, tint, orientation, format); + float tX = texture.getOriginX() / texture.getMinU(); + float tY = texture.getOriginY() / texture.getMinV(); + float tS = tX > tY ? tX : tY; + float ep = 1f / (tS * 0x100); + int uve = 0; + while(uve < format.getElementCount()) + { + VertexFormatElement e = format.getElement(uve); + if(e.getUsage() == VertexFormatElement.EnumUsage.UV && e.getIndex() == 0) + { + break; + } + uve++; + } + if(uve == format.getElementCount()) + { + throw new IllegalStateException("Can't contract UVs: format doesn't contain UVs"); + } + float[] uvc = new float[4]; + for(int v = 0; v < 4; v++) + { + for(int i = 0; i < 4; i++) + { + uvc[i] += unpackedData[v][uve][i] / 4; + } + } + for(int v = 0; v < 4; v++) + { + for (int i = 0; i < 4; i++) + { + float uo = unpackedData[v][uve][i]; + float un = uo * (1 - eps) + uvc[i] * eps; + float ud = uo - un; + float aud = ud; + if(aud < 0) aud = -aud; + if(aud < ep) // not moving a fraction of a pixel + { + float udc = uo - uvc[i]; + if(udc < 0) udc = -udc; + if(udc < 2 * ep) // center is closer than 2 fractions of a pixel, don't move too close + { + un = (uo + uvc[i]) / 2; + } + else // move at least by a fraction + { + un = uo + (ud < 0 ? ep : -ep); + } + } + unpackedData[v][uve][i] = un; + } + } } - return new UnpackedBakedQuad(unpackedData, tint, orientation, format); + return new UnpackedBakedQuad(unpackedData, tint, orientation, texture, applyDiffuseLighting, format); } } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/WorldRendererConsumer.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexBufferConsumer.java similarity index 80% rename from src/main/java/net/minecraftforge/client/model/pipeline/WorldRendererConsumer.java rename to src/main/java/net/minecraftforge/client/model/pipeline/VertexBufferConsumer.java index 9822afdac1..de40252230 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/WorldRendererConsumer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexBufferConsumer.java @@ -1,23 +1,23 @@ package net.minecraftforge.client.model.pipeline; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormatElement.EnumUsage; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; /** - * Assumes VertexFormatElement is present in the WorlRenderer's vertex format. + * Assumes VertexFormatElement is present in the VertexBuffer's vertex format. */ -public class WorldRendererConsumer implements IVertexConsumer +public class VertexBufferConsumer implements IVertexConsumer { private static final float[] dummyColor = new float[]{ 1, 1, 1, 1 }; - private final WorldRenderer renderer; + private final VertexBuffer renderer; private final int[] quadData; private int v = 0; private BlockPos offset = BlockPos.ORIGIN; - public WorldRendererConsumer(WorldRenderer renderer) + public VertexBufferConsumer(VertexBuffer renderer) { super(); this.renderer = renderer; @@ -57,5 +57,5 @@ public class WorldRendererConsumer implements IVertexConsumer public void setQuadTint(int tint) {} public void setQuadOrientation(EnumFacing orientation) {} - public void setQuadColored() {} + public void setApplyDiffuseLighting(boolean diffuse) {} } diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java index ca23d9fc09..8492dda252 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterFlat.java @@ -2,26 +2,33 @@ package net.minecraftforge.client.model.pipeline; import javax.vecmath.Vector3f; -import com.google.common.base.Objects; - -import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormatElement; -import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; +import com.google.common.base.Objects; + public class VertexLighterFlat extends QuadGatheringTransformer { - protected final BlockInfo blockInfo = new BlockInfo(); + protected final BlockInfo blockInfo; private int tint = -1; + private boolean diffuse = true; protected int posIndex = -1; protected int normalIndex = -1; protected int colorIndex = -1; protected int lightmapIndex = -1; + public VertexLighterFlat(BlockColors colors) + { + this.blockInfo = new BlockInfo(colors); + } + @Override public void setParent(IVertexConsumer parent) { @@ -142,6 +149,14 @@ public class VertexLighterFlat extends QuadGatheringTransformer if(skyLight > lightmap[v][1]) lightmap[v][1] = skyLight; } updateColor(normal[v], color[v], x, y, z, tint, multiplier); + if(diffuse) + { + float d = LightUtil.diffuseLight(normal[v][0], normal[v][1], normal[v][2]); + for(int i = 0; i < 3; i++) + { + color[v][i] *= d; + } + } if(EntityRenderer.anaglyphEnable) { applyAnaglyph(color[v]); @@ -154,7 +169,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer switch(element.getUsage()) { case POSITION: - // position adding moved to WorldRendererConsumer due to x and z not fitting completely into a float + // position adding moved to VertexBufferConsumer due to x and z not fitting completely into a float /*float[] pos = new float[4]; System.arraycopy(position[v], 0, pos, 0, position[v].length); pos[0] += blockInfo.getBlockPos().getX(); @@ -197,7 +212,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer float e2 = 0.95f; BlockPos pos = blockInfo.getBlockPos(); - boolean full = blockInfo.getBlock().isFullCube(); + boolean full = blockInfo.getState().isFullCube(); if((full || y < -e1) && normal[1] < -e2) pos = pos.down(); if((full || y > e1) && normal[1] > e2) pos = pos.up(); @@ -206,7 +221,7 @@ public class VertexLighterFlat extends QuadGatheringTransformer if((full || x < -e1) && normal[0] < -e2) pos = pos.west(); if((full || x > e1) && normal[0] > e2) pos = pos.east(); - int brightness = blockInfo.getBlock().getMixedBrightnessForBlock(blockInfo.getWorld(), pos); + int brightness = blockInfo.getState().getPackedLightmapCoords(blockInfo.getWorld(), pos); lightmap[0] = ((float)((brightness >> 0x04) & 0xF) * 0x20) / 0xFFFF; lightmap[1] = ((float)((brightness >> 0x14) & 0xF) * 0x20) / 0xFFFF; @@ -228,16 +243,19 @@ public class VertexLighterFlat extends QuadGatheringTransformer } public void setQuadOrientation(EnumFacing orientation) {} public void setQuadCulled() {} - public void setQuadColored() {} + public void setApplyDiffuseLighting(boolean diffuse) + { + this.diffuse = diffuse; + } public void setWorld(IBlockAccess world) { blockInfo.setWorld(world); } - public void setBlock(Block block) + public void setState(IBlockState state) { - blockInfo.setBlock(block); + blockInfo.setState(state); } public void setBlockPos(BlockPos blockPos) diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java index bc1d80ebbd..160f689b3d 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexLighterSmoothAo.java @@ -1,10 +1,16 @@ package net.minecraftforge.client.model.pipeline; -import net.minecraft.util.MathHelper; +import net.minecraft.client.renderer.color.BlockColors; +import net.minecraft.util.math.MathHelper; public class VertexLighterSmoothAo extends VertexLighterFlat { + public VertexLighterSmoothAo(BlockColors colors) + { + super(colors); + } + @Override protected void updateLightmap(float[] normal, float[] lightmap, float x, float y, float z) { diff --git a/src/main/java/net/minecraftforge/client/model/pipeline/VertexTransformer.java b/src/main/java/net/minecraftforge/client/model/pipeline/VertexTransformer.java index 5fe6565ed9..1bd4ecda73 100644 --- a/src/main/java/net/minecraftforge/client/model/pipeline/VertexTransformer.java +++ b/src/main/java/net/minecraftforge/client/model/pipeline/VertexTransformer.java @@ -27,9 +27,9 @@ public class VertexTransformer implements IVertexConsumer parent.setQuadOrientation(orientation); } - public void setQuadColored() + public void setApplyDiffuseLighting(boolean diffuse) { - parent.setQuadColored(); + parent.setApplyDiffuseLighting(diffuse); } public void put(int element, float... data) diff --git a/src/main/java/net/minecraftforge/client/settings/IKeyConflictContext.java b/src/main/java/net/minecraftforge/client/settings/IKeyConflictContext.java new file mode 100644 index 0000000000..00297211aa --- /dev/null +++ b/src/main/java/net/minecraftforge/client/settings/IKeyConflictContext.java @@ -0,0 +1,20 @@ +package net.minecraftforge.client.settings; + +import net.minecraft.client.settings.KeyBinding; + +/** + * Defines the context that a {@link KeyBinding} is used. + * Key conflicts occur when a {@link KeyBinding} has the same {@link IKeyConflictContext} and has conflicting modifiers and keyCodes. + */ +public interface IKeyConflictContext { + /** + * @return true if conditions are met to activate {@link KeyBinding}s with this context + */ + boolean isActive(); + + /** + * @return true if the other context can have {@link KeyBinding} conflicts with this one. + * This will be called on both contexts to check for conflicts. + */ + boolean conflicts(IKeyConflictContext other); +} diff --git a/src/main/java/net/minecraftforge/client/settings/KeyBindingMap.java b/src/main/java/net/minecraftforge/client/settings/KeyBindingMap.java new file mode 100644 index 0000000000..bdf84bea2c --- /dev/null +++ b/src/main/java/net/minecraftforge/client/settings/KeyBindingMap.java @@ -0,0 +1,102 @@ +package net.minecraftforge.client.settings; + +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.util.IntHashMap; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.EnumMap; +import java.util.List; + +public class KeyBindingMap +{ + private static final EnumMap>> map = new java.util.EnumMap>>(KeyModifier.class); + static + { + for (KeyModifier modifier : KeyModifier.values()) + { + map.put(modifier, new IntHashMap>()); + } + } + + public KeyBinding lookupActive(int keyCode) + { + KeyModifier activeModifier = KeyModifier.getActiveModifier(); + if (!activeModifier.matches(keyCode)) + { + KeyBinding binding = getBinding(keyCode, activeModifier); + if (binding != null) + { + return binding; + } + } + return getBinding(keyCode, KeyModifier.NONE); + } + + private KeyBinding getBinding(int keyCode, KeyModifier keyModifier) + { + Collection bindings = map.get(keyModifier).lookup(keyCode); + if (bindings != null) + { + for (KeyBinding binding : bindings) + { + if (binding.isActiveAndMatches(keyCode)) + { + return binding; + } + } + } + return null; + } + + public List lookupAll(int keyCode) + { + List matchingBindings = new ArrayList(); + for (IntHashMap> bindingsMap : map.values()) + { + Collection bindings = bindingsMap.lookup(keyCode); + if (bindings != null) + { + matchingBindings.addAll(bindings); + } + } + return matchingBindings; + } + + public void addKey(int keyCode, KeyBinding keyBinding) + { + KeyModifier keyModifier = keyBinding.getKeyModifier(); + IntHashMap> bindingsMap = map.get(keyModifier); + Collection bindingsForKey = bindingsMap.lookup(keyCode); + if (bindingsForKey == null) + { + bindingsForKey = new ArrayList(); + bindingsMap.addKey(keyCode, bindingsForKey); + } + bindingsForKey.add(keyBinding); + } + + public void removeKey(KeyBinding keyBinding) + { + KeyModifier keyModifier = keyBinding.getKeyModifier(); + int keyCode = keyBinding.getKeyCode(); + IntHashMap> bindingsMap = map.get(keyModifier); + Collection bindingsForKey = bindingsMap.lookup(keyCode); + if (bindingsForKey != null) + { + bindingsForKey.remove(keyBinding); + if (bindingsForKey.isEmpty()) + { + bindingsMap.removeObject(keyCode); + } + } + } + + public void clearMap() + { + for (IntHashMap> bindings : map.values()) + { + bindings.clearMap(); + } + } +} diff --git a/src/main/java/net/minecraftforge/client/settings/KeyConflictContext.java b/src/main/java/net/minecraftforge/client/settings/KeyConflictContext.java new file mode 100644 index 0000000000..964dadd0c6 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/settings/KeyConflictContext.java @@ -0,0 +1,59 @@ +package net.minecraftforge.client.settings; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; + +public enum KeyConflictContext implements IKeyConflictContext +{ + /** + * Universal key bindings are used in every context and will conflict with any other context. + * Key Bindings are universal by default. + */ + UNIVERSAL { + @Override + public boolean isActive() + { + return true; + } + + @Override + public boolean conflicts(IKeyConflictContext other) + { + return true; + } + }, + + /** + * Gui key bindings are only used when a {@link GuiScreen} is open. + */ + GUI { + @Override + public boolean isActive() + { + return Minecraft.getMinecraft().currentScreen != null; + } + + @Override + public boolean conflicts(IKeyConflictContext other) + { + return this == other; + } + }, + + /** + * In-game key bindings are only used when a {@link GuiScreen} is not open. + */ + IN_GAME { + @Override + public boolean isActive() + { + return !GUI.isActive(); + } + + @Override + public boolean conflicts(IKeyConflictContext other) + { + return this == other; + } + } +} diff --git a/src/main/java/net/minecraftforge/client/settings/KeyModifier.java b/src/main/java/net/minecraftforge/client/settings/KeyModifier.java new file mode 100644 index 0000000000..c2183bd22a --- /dev/null +++ b/src/main/java/net/minecraftforge/client/settings/KeyModifier.java @@ -0,0 +1,145 @@ +package net.minecraftforge.client.settings; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; +import org.lwjgl.input.Keyboard; + +public enum KeyModifier { + CONTROL { + @Override + public boolean matches(int keyCode) + { + if (Minecraft.isRunningOnMac) + { + return keyCode == Keyboard.KEY_LMETA || keyCode == Keyboard.KEY_RMETA; + } + else + { + return keyCode == Keyboard.KEY_LCONTROL || keyCode == Keyboard.KEY_RCONTROL; + } + } + + @Override + public boolean isActive() + { + return GuiScreen.isCtrlKeyDown(); + } + + @Override + public String getLocalizedComboName(int keyCode) + { + String keyName = GameSettings.getKeyDisplayString(keyCode); + String localizationFormatKey = Minecraft.isRunningOnMac ? "forge.controlsgui.control.mac" : "forge.controlsgui.control"; + return I18n.format(localizationFormatKey, keyName); + } + }, + SHIFT { + @Override + public boolean matches(int keyCode) + { + return keyCode == Keyboard.KEY_LSHIFT || keyCode == Keyboard.KEY_RSHIFT; + } + + @Override + public boolean isActive() + { + return GuiScreen.isShiftKeyDown(); + } + + @Override + public String getLocalizedComboName(int keyCode) + { + String keyName = GameSettings.getKeyDisplayString(keyCode); + return I18n.format("forge.controlsgui.shift", keyName); + } + }, + ALT { + @Override + public boolean matches(int keyCode) + { + return keyCode == Keyboard.KEY_LMENU || keyCode == Keyboard.KEY_RMENU; + } + + @Override + public boolean isActive() + { + return GuiScreen.isAltKeyDown(); + } + + @Override + public String getLocalizedComboName(int keyCode) + { + String keyName = GameSettings.getKeyDisplayString(keyCode); + return I18n.format("forge.controlsgui.alt", keyName); + } + }, + NONE { + @Override + public boolean matches(int keyCode) + { + return false; + } + + @Override + public boolean isActive() + { + return true; + } + + @Override + public String getLocalizedComboName(int keyCode) + { + return GameSettings.getKeyDisplayString(keyCode); + } + }; + + public static final KeyModifier[] MODIFIER_VALUES = {SHIFT, CONTROL, ALT}; + + public static KeyModifier getActiveModifier() + { + for (KeyModifier keyModifier : MODIFIER_VALUES) + { + if (keyModifier.isActive()) + { + return keyModifier; + } + } + return NONE; + } + + public static boolean isKeyCodeModifier(int keyCode) + { + for (KeyModifier keyModifier : MODIFIER_VALUES) + { + if (keyModifier.matches(keyCode)) + { + return true; + } + } + return false; + } + + public static KeyModifier valueFromString(String stringValue) + { + try + { + return valueOf(stringValue); + } + catch (NullPointerException ignored) + { + return NONE; + } + catch (IllegalArgumentException ignored) + { + return NONE; + } + } + + public abstract boolean matches(int keyCode); + + public abstract boolean isActive(); + + public abstract String getLocalizedComboName(int keyCode); +} diff --git a/src/main/java/net/minecraftforge/common/BiomeDictionary.java b/src/main/java/net/minecraftforge/common/BiomeDictionary.java index df4cf2e6a5..3b535e9e72 100644 --- a/src/main/java/net/minecraftforge/common/BiomeDictionary.java +++ b/src/main/java/net/minecraftforge/common/BiomeDictionary.java @@ -3,11 +3,13 @@ package net.minecraftforge.common; import java.util.*; import net.minecraftforge.fml.common.FMLLog; + +import net.minecraft.init.Biomes; import net.minecraft.init.Blocks; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.*; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.terraingen.DeferredBiomeDecorator; -import static net.minecraft.world.biome.BiomeGenBase.*; import static net.minecraftforge.common.BiomeDictionary.Type.*; public class BiomeDictionary @@ -53,15 +55,7 @@ public class BiomeDictionary SANDY, SNOWY, WASTELAND, - BEACH, - - /*Deprecated tags, kept for compatibility*/ - @Deprecated - /**Replaced by SANDY**/ - DESERT(SANDY), - @Deprecated - /**Replaced by SNOWY**/ - FROZEN(SNOWY); + BEACH; private List subTags; @@ -78,8 +72,8 @@ public class BiomeDictionary /** * Retrieves a Type value by name, * if one does not exist already it creates one. - * This can be used as interm measure for modders to - * add there own category of Biome. + * This can be used as intermediate measure for modders to + * add their own category of Biome. * * There are NO naming conventions besides: * MUST be all upper case (enforced by name.toUpper()) @@ -106,7 +100,7 @@ public class BiomeDictionary { typeInfoList = Arrays.copyOf(typeInfoList, ret.ordinal()+1); } - for(BiomeInfo bInfo:biomeList) + for(BiomeInfo bInfo:biomeInfoMap.values()) { if(bInfo != null) { @@ -119,8 +113,7 @@ public class BiomeDictionary } } - private static final int BIOME_LIST_SIZE = BiomeGenBase.getBiomeGenArray().length; - private static BiomeInfo[] biomeList = new BiomeInfo[BIOME_LIST_SIZE]; + private static HashMap biomeInfoMap = new HashMap(); @SuppressWarnings("unchecked") private static ArrayList[] typeInfoList = new ArrayList[Type.values().length]; @@ -154,7 +147,7 @@ public class BiomeDictionary { types = listSubTags(types); - if(BiomeGenBase.getBiomeGenArray()[biome.biomeID] != null) + if(BiomeGenBase.biomeRegistry.getNameForObject(biome) != null) { for(Type type : types) { @@ -166,15 +159,16 @@ public class BiomeDictionary typeInfoList[type.ordinal()].add(biome); } - if(biomeList[biome.biomeID] == null) + if(!isBiomeRegistered(biome)) { - biomeList[biome.biomeID] = new BiomeInfo(types); + ResourceLocation location = BiomeGenBase.biomeRegistry.getNameForObject(biome); + biomeInfoMap.put(location, new BiomeInfo(types)); } else { for(Type type : types) { - biomeList[biome.biomeID].typeList.add(type); + getBiomeInfo(biome).typeList.add(type); } } @@ -194,7 +188,7 @@ public class BiomeDictionary { if(typeInfoList[type.ordinal()] != null) { - return (BiomeGenBase[])typeInfoList[type.ordinal()].toArray(new BiomeGenBase[0]); + return typeInfoList[type.ordinal()].toArray(new BiomeGenBase[0]); } return new BiomeGenBase[0]; @@ -208,14 +202,8 @@ public class BiomeDictionary */ public static Type[] getTypesForBiome(BiomeGenBase biome) { - checkRegistration(biome); - - if(biomeList[biome.biomeID] != null) - { - return (Type[])biomeList[biome.biomeID].typeList.toArray(new Type[0]); - } - - return new Type[0]; + checkRegistration(biome); + return getBiomeInfo(biome).typeList.toArray(new Type[0]); } /** @@ -227,21 +215,15 @@ public class BiomeDictionary */ public static boolean areBiomesEquivalent(BiomeGenBase biomeA, BiomeGenBase biomeB) { - int a = biomeA.biomeID; - int b = biomeB.biomeID; - checkRegistration(biomeA); checkRegistration(biomeB); - if(biomeList[a] != null && biomeList[b] != null) + for(Type type : getTypesForBiome(biomeA)) { - for(Type type : biomeList[a].typeList) - { - if(containsType(biomeList[b], type)) - { - return true; - } - } + if(containsType(getBiomeInfo(biomeB), type)) + { + return true; + } } return false; @@ -257,13 +239,7 @@ public class BiomeDictionary public static boolean isBiomeOfType(BiomeGenBase biome, Type type) { checkRegistration(biome); - - if(biomeList[biome.biomeID] != null) - { - return containsType(biomeList[biome.biomeID], type); - } - - return false; + return containsType(getBiomeInfo(biome), type); } /** @@ -273,12 +249,7 @@ public class BiomeDictionary */ public static boolean isBiomeRegistered(BiomeGenBase biome) { - return biomeList[biome.biomeID] != null; - } - - public static boolean isBiomeRegistered(int biomeID) - { - return biomeList[biomeID] != null; + return biomeInfoMap.containsKey(BiomeGenBase.biomeRegistry.getNameForObject(biome)); } public static void registerAllBiomes() @@ -294,15 +265,10 @@ public class BiomeDictionary */ public static void registerAllBiomesAndGenerateEvents() { - for(int i = 0; i < BiomeGenBase.getBiomeGenArray().length; i++) - { - BiomeGenBase biome = BiomeGenBase.getBiomeGenArray()[i]; - - if(biome == null) - { - continue; - } - + for (ResourceLocation biomeResource : BiomeGenBase.biomeRegistry.getKeys()) + { + BiomeGenBase biome = BiomeGenBase.biomeRegistry.getObject(biomeResource); + if (biome.theBiomeDecorator instanceof DeferredBiomeDecorator) { DeferredBiomeDecorator decorator = (DeferredBiomeDecorator) biome.theBiomeDecorator; @@ -324,7 +290,7 @@ public class BiomeDictionary { if (biome.theBiomeDecorator.treesPerChunk >= 3) { - if (biome.isHighHumidity() && biome.temperature >= 0.9F) + if (biome.isHighHumidity() && biome.getTemperature() >= 0.9F) { BiomeDictionary.registerBiomeType(biome, JUNGLE); } @@ -332,36 +298,36 @@ public class BiomeDictionary { BiomeDictionary.registerBiomeType(biome, FOREST); - if (biome.temperature <= 0.2f) + if (biome.getTemperature() <= 0.2f) { BiomeDictionary.registerBiomeType(biome, CONIFEROUS); } } } - else if(biome.maxHeight <= 0.3F && biome.maxHeight >= 0.0F) + else if(biome.getHeightVariation() <= 0.3F && biome.getHeightVariation() >= 0.0F) { - if(!biome.isHighHumidity() || biome.minHeight >= 0.0F) + if(!biome.isHighHumidity() || biome.getBaseHeight() >= 0.0F) { BiomeDictionary.registerBiomeType(biome, PLAINS); } } - if (biome.rainfall > 0.85f) + if (biome.getRainfall() > 0.85f) { BiomeDictionary.registerBiomeType(biome, WET); } - if (biome.rainfall < 0.15f) + if (biome.getRainfall() < 0.15f) { BiomeDictionary.registerBiomeType(biome, DRY); } - if (biome.temperature > 0.85f) + if (biome.getTemperature() > 0.85f) { BiomeDictionary.registerBiomeType(biome, HOT); } - if (biome.temperature < 0.15f) + if (biome.getTemperature() < 0.15f) { BiomeDictionary.registerBiomeType(biome, COLD); } @@ -375,14 +341,14 @@ public class BiomeDictionary BiomeDictionary.registerBiomeType(biome, DENSE); } - if (biome.isHighHumidity() && biome.minHeight < 0.0F && (biome.maxHeight <= 0.3F && biome.maxHeight >= 0.0F)) + if (biome.isHighHumidity() && biome.getBaseHeight() < 0.0F && (biome.getHeightVariation() <= 0.3F && biome.getHeightVariation() >= 0.0F)) { BiomeDictionary.registerBiomeType(biome, SWAMP); } - if (biome.minHeight <= -0.5F) + if (biome.getBaseHeight() <= -0.5F) { - if (biome.maxHeight == 0.0F) + if (biome.getHeightVariation() == 0.0F) { BiomeDictionary.registerBiomeType(biome, RIVER); } @@ -392,12 +358,12 @@ public class BiomeDictionary } } - if (biome.maxHeight >= 0.4F && biome.maxHeight < 1.5F) + if (biome.getHeightVariation() >= 0.4F && biome.getHeightVariation() < 1.5F) { BiomeDictionary.registerBiomeType(biome, HILLS); } - if (biome.maxHeight >= 1.5F) + if (biome.getHeightVariation() >= 1.5F) { BiomeDictionary.registerBiomeType(biome, MOUNTAIN); } @@ -407,7 +373,7 @@ public class BiomeDictionary BiomeDictionary.registerBiomeType(biome, SNOWY); } - if (biome.topBlock != Blocks.sand && biome.temperature >= 1.0f && biome.rainfall < 0.2f) + if (biome.topBlock != Blocks.sand && biome.getTemperature() >= 1.0f && biome.getRainfall() < 0.2f) { BiomeDictionary.registerBiomeType(biome, SAVANNA); } @@ -427,6 +393,11 @@ public class BiomeDictionary } //Internal implementation + private static BiomeInfo getBiomeInfo(BiomeGenBase biome) + { + return biomeInfoMap.get(BiomeGenBase.biomeRegistry.getNameForObject(biome)); + } + private static void checkRegistration(BiomeGenBase biome) { if(!isBiomeRegistered(biome)) @@ -465,45 +436,45 @@ public class BiomeDictionary private static void registerVanillaBiomes() { - registerBiomeType(ocean, OCEAN ); - registerBiomeType(plains, PLAINS ); - registerBiomeType(desert, HOT, DRY, SANDY ); - registerBiomeType(extremeHills, MOUNTAIN, HILLS ); - registerBiomeType(forest, FOREST ); - registerBiomeType(taiga, COLD, CONIFEROUS, FOREST ); - registerBiomeType(taigaHills, COLD, CONIFEROUS, FOREST, HILLS ); - registerBiomeType(swampland, WET, SWAMP ); - registerBiomeType(river, RIVER ); - registerBiomeType(frozenOcean, COLD, OCEAN, SNOWY ); - registerBiomeType(frozenRiver, COLD, RIVER, SNOWY ); - registerBiomeType(icePlains, COLD, SNOWY, WASTELAND ); - registerBiomeType(iceMountains, COLD, SNOWY, MOUNTAIN ); - registerBiomeType(beach, BEACH ); - registerBiomeType(desertHills, HOT, DRY, SANDY, HILLS ); - registerBiomeType(jungle, HOT, WET, DENSE, JUNGLE ); - registerBiomeType(jungleHills, HOT, WET, DENSE, JUNGLE, HILLS); - registerBiomeType(forestHills, FOREST, HILLS ); - registerBiomeType(sky, COLD, DRY, END ); - registerBiomeType(hell, HOT, DRY, NETHER ); - registerBiomeType(mushroomIsland, MUSHROOM ); - registerBiomeType(extremeHillsEdge, MOUNTAIN ); - registerBiomeType(mushroomIslandShore, MUSHROOM, BEACH ); - registerBiomeType(jungleEdge, HOT, WET, JUNGLE, FOREST ); - registerBiomeType(deepOcean, OCEAN ); - registerBiomeType(stoneBeach, BEACH ); - registerBiomeType(coldBeach, COLD, BEACH, SNOWY ); - registerBiomeType(birchForest, FOREST ); - registerBiomeType(birchForestHills, FOREST, HILLS ); - registerBiomeType(roofedForest, SPOOKY, DENSE, FOREST ); - registerBiomeType(coldTaiga, COLD, CONIFEROUS, FOREST, SNOWY ); - registerBiomeType(coldTaigaHills, COLD, CONIFEROUS, FOREST, SNOWY, HILLS); - registerBiomeType(megaTaiga, COLD, CONIFEROUS, FOREST ); - registerBiomeType(megaTaigaHills, COLD, CONIFEROUS, FOREST, HILLS ); - registerBiomeType(extremeHillsPlus, MOUNTAIN, FOREST, SPARSE ); - registerBiomeType(savanna, HOT, SAVANNA, PLAINS, SPARSE ); - registerBiomeType(savannaPlateau, HOT, SAVANNA, PLAINS, SPARSE ); - registerBiomeType(mesa, MESA, SANDY ); - registerBiomeType(mesaPlateau_F, MESA, SPARSE, SANDY ); - registerBiomeType(mesaPlateau, MESA, SANDY ); + registerBiomeType(Biomes.ocean, OCEAN ); + registerBiomeType(Biomes.plains, PLAINS ); + registerBiomeType(Biomes.desert, HOT, DRY, SANDY ); + registerBiomeType(Biomes.extremeHills, MOUNTAIN, HILLS ); + registerBiomeType(Biomes.forest, FOREST ); + registerBiomeType(Biomes.taiga, COLD, CONIFEROUS, FOREST ); + registerBiomeType(Biomes.taigaHills, COLD, CONIFEROUS, FOREST, HILLS ); + registerBiomeType(Biomes.swampland, WET, SWAMP ); + registerBiomeType(Biomes.river, RIVER ); + registerBiomeType(Biomes.frozenOcean, COLD, OCEAN, SNOWY ); + registerBiomeType(Biomes.frozenRiver, COLD, RIVER, SNOWY ); + registerBiomeType(Biomes.icePlains, COLD, SNOWY, WASTELAND ); + registerBiomeType(Biomes.iceMountains, COLD, SNOWY, MOUNTAIN ); + registerBiomeType(Biomes.beach, BEACH ); + registerBiomeType(Biomes.desertHills, HOT, DRY, SANDY, HILLS ); + registerBiomeType(Biomes.jungle, HOT, WET, DENSE, JUNGLE ); + registerBiomeType(Biomes.jungleHills, HOT, WET, DENSE, JUNGLE, HILLS); + registerBiomeType(Biomes.forestHills, FOREST, HILLS ); + registerBiomeType(Biomes.sky, COLD, DRY, END ); + registerBiomeType(Biomes.hell, HOT, DRY, NETHER ); + registerBiomeType(Biomes.mushroomIsland, MUSHROOM ); + registerBiomeType(Biomes.extremeHillsEdge, MOUNTAIN ); + registerBiomeType(Biomes.mushroomIslandShore, MUSHROOM, BEACH ); + registerBiomeType(Biomes.jungleEdge, HOT, WET, JUNGLE, FOREST ); + registerBiomeType(Biomes.deepOcean, OCEAN ); + registerBiomeType(Biomes.stoneBeach, BEACH ); + registerBiomeType(Biomes.coldBeach, COLD, BEACH, SNOWY ); + registerBiomeType(Biomes.birchForest, FOREST ); + registerBiomeType(Biomes.birchForestHills, FOREST, HILLS ); + registerBiomeType(Biomes.roofedForest, SPOOKY, DENSE, FOREST ); + registerBiomeType(Biomes.coldTaiga, COLD, CONIFEROUS, FOREST, SNOWY ); + registerBiomeType(Biomes.coldTaigaHills, COLD, CONIFEROUS, FOREST, SNOWY, HILLS); + registerBiomeType(Biomes.megaTaiga, COLD, CONIFEROUS, FOREST ); + registerBiomeType(Biomes.megaTaigaHills, COLD, CONIFEROUS, FOREST, HILLS ); + registerBiomeType(Biomes.extremeHillsPlus, MOUNTAIN, FOREST, SPARSE ); + registerBiomeType(Biomes.savanna, HOT, SAVANNA, PLAINS, SPARSE ); + registerBiomeType(Biomes.savannaPlateau, HOT, SAVANNA, PLAINS, SPARSE ); + registerBiomeType(Biomes.mesa, MESA, SANDY ); + registerBiomeType(Biomes.mesaPlateau_F, MESA, SPARSE, SANDY ); + registerBiomeType(Biomes.mesaPlateau, MESA, SANDY ); } } diff --git a/src/main/java/net/minecraftforge/common/BiomeManager.java b/src/main/java/net/minecraftforge/common/BiomeManager.java index 474bf18946..8eb1315335 100644 --- a/src/main/java/net/minecraftforge/common/BiomeManager.java +++ b/src/main/java/net/minecraftforge/common/BiomeManager.java @@ -7,9 +7,10 @@ import java.util.List; import com.google.common.collect.ImmutableList; +import net.minecraft.init.Biomes; import net.minecraft.util.WeightedRandom; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.biome.WorldChunkManager; +import net.minecraft.world.biome.BiomeProvider; import net.minecraft.world.gen.structure.MapGenVillage; import net.minecraftforge.common.util.EnumHelper; @@ -24,9 +25,9 @@ public class BiomeManager static { - oceanBiomes.add(BiomeGenBase.ocean); - oceanBiomes.add(BiomeGenBase.deepOcean); - oceanBiomes.add(BiomeGenBase.frozenOcean); + oceanBiomes.add(Biomes.ocean); + oceanBiomes.add(Biomes.deepOcean); + oceanBiomes.add(Biomes.frozenOcean); } private static TrackedList[] setupBiomes() @@ -35,26 +36,26 @@ public class BiomeManager TrackedList[] currentBiomes = new TrackedList[BiomeType.values().length]; List list = new ArrayList(); - list.add(new BiomeEntry(BiomeGenBase.forest, 10)); - list.add(new BiomeEntry(BiomeGenBase.roofedForest, 10)); - list.add(new BiomeEntry(BiomeGenBase.extremeHills, 10)); - list.add(new BiomeEntry(BiomeGenBase.plains, 10)); - list.add(new BiomeEntry(BiomeGenBase.birchForest, 10)); - list.add(new BiomeEntry(BiomeGenBase.swampland, 10)); + list.add(new BiomeEntry(Biomes.forest, 10)); + list.add(new BiomeEntry(Biomes.roofedForest, 10)); + list.add(new BiomeEntry(Biomes.extremeHills, 10)); + list.add(new BiomeEntry(Biomes.plains, 10)); + list.add(new BiomeEntry(Biomes.birchForest, 10)); + list.add(new BiomeEntry(Biomes.swampland, 10)); currentBiomes[BiomeType.WARM.ordinal()] = new TrackedList(list); list.clear(); - list.add(new BiomeEntry(BiomeGenBase.forest, 10)); - list.add(new BiomeEntry(BiomeGenBase.extremeHills, 10)); - list.add(new BiomeEntry(BiomeGenBase.taiga, 10)); - list.add(new BiomeEntry(BiomeGenBase.plains, 10)); + list.add(new BiomeEntry(Biomes.forest, 10)); + list.add(new BiomeEntry(Biomes.extremeHills, 10)); + list.add(new BiomeEntry(Biomes.taiga, 10)); + list.add(new BiomeEntry(Biomes.plains, 10)); currentBiomes[BiomeType.COOL.ordinal()] = new TrackedList(list); list.clear(); - list.add(new BiomeEntry(BiomeGenBase.icePlains, 30)); - list.add(new BiomeEntry(BiomeGenBase.coldTaiga, 10)); + list.add(new BiomeEntry(Biomes.icePlains, 30)); + list.add(new BiomeEntry(Biomes.coldTaiga, 10)); currentBiomes[BiomeType.ICY.ordinal()] = new TrackedList(list); list.clear(); @@ -102,17 +103,17 @@ public class BiomeManager public static void addSpawnBiome(BiomeGenBase biome) { - if (!WorldChunkManager.allowedBiomes.contains(biome)) + if (!BiomeProvider.allowedBiomes.contains(biome)) { - WorldChunkManager.allowedBiomes.add(biome); + BiomeProvider.allowedBiomes.add(biome); } } public static void removeSpawnBiome(BiomeGenBase biome) { - if (WorldChunkManager.allowedBiomes.contains(biome)) + if (BiomeProvider.allowedBiomes.contains(biome)) { - WorldChunkManager.allowedBiomes.remove(biome); + BiomeProvider.allowedBiomes.remove(biome); } } diff --git a/src/main/java/net/minecraftforge/common/ChestGenHooks.java b/src/main/java/net/minecraftforge/common/ChestGenHooks.java deleted file mode 100644 index 61c024423d..0000000000 --- a/src/main/java/net/minecraftforge/common/ChestGenHooks.java +++ /dev/null @@ -1,246 +0,0 @@ -package net.minecraftforge.common; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; -import net.minecraft.util.WeightedRandomChestContent; -import net.minecraft.world.WorldServer; -import net.minecraft.world.gen.feature.WorldGenDungeons; -import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.DesertPyramid; -import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.JunglePyramid; -import net.minecraft.world.gen.structure.StructureMineshaftPieces; -import net.minecraft.world.gen.structure.StructureNetherBridgePieces; -import net.minecraft.world.gen.structure.StructureOceanMonument; -import net.minecraft.world.gen.structure.StructureStrongholdPieces; -import net.minecraft.world.gen.structure.StructureVillagePieces; -import net.minecraftforge.oredict.OreDictionary; - -public class ChestGenHooks -{ - //Currently implemented categories for chests/dispensers, Dungeon loot is still in DungeonHooks - public static final String MINESHAFT_CORRIDOR = "mineshaftCorridor"; - public static final String PYRAMID_DESERT_CHEST = "pyramidDesertyChest"; - public static final String PYRAMID_JUNGLE_CHEST = "pyramidJungleChest"; - public static final String PYRAMID_JUNGLE_DISPENSER = "pyramidJungleDispenser"; - public static final String STRONGHOLD_CORRIDOR = "strongholdCorridor"; - public static final String STRONGHOLD_LIBRARY = "strongholdLibrary"; - public static final String STRONGHOLD_CROSSING = "strongholdCrossing"; - public static final String VILLAGE_BLACKSMITH = "villageBlacksmith"; - public static final String BONUS_CHEST = "bonusChest"; - public static final String DUNGEON_CHEST = "dungeonChest"; - public static final String NETHER_FORTRESS = "netherFortress"; - - private static final HashMap chestInfo = new HashMap(); - private static boolean hasInit = false; - static - { - init(); - } - - private static void init() - { - if (hasInit) - { - return; - } - - hasInit = true; - // This causes the classes static initializers to run - new WorldGenDungeons(); - new DesertPyramid(); - new JunglePyramid(); - new StructureMineshaftPieces(); - new StructureOceanMonument(); - new StructureStrongholdPieces.ChestCorridor(); - new StructureStrongholdPieces.Library(); - new StructureStrongholdPieces.RoomCrossing(); - new StructureVillagePieces.House2(); - new StructureNetherBridgePieces.Corridor(); - WorldServer.fillChestHook(); - } - - // INTERNAL DO NO USE - public static void init(String category, List items, int min, int max) - { - chestInfo.put(category, new ChestGenHooks(category, items, min, max)); - } - - static void addDungeonLoot(ChestGenHooks dungeon, ItemStack item, int weight, int min, int max) - { - dungeon.addItem(new WeightedRandomChestContent(item, min, max, weight)); - } - - /** - * Retrieves, or creates the info class for the specified category. - * - * @param category The category name - * @return A instance of ChestGenHooks for the specified category. - */ - public static ChestGenHooks getInfo(String category) - { - if (!chestInfo.containsKey(category)) - { - chestInfo.put(category, new ChestGenHooks(category)); - } - return chestInfo.get(category); - } - - /** - * Generates an array of items based on the input min/max count. - * If the stack can not hold the total amount, it will be split into - * stacks of size 1. - * - * @param rand A random number generator - * @param source Source item stack - * @param min Minimum number of items - * @param max Maximum number of items - * @return An array containing the generated item stacks - */ - public static ItemStack[] generateStacks(Random rand, ItemStack source, int min, int max) - { - int count = min + (rand.nextInt(max - min + 1)); - - ItemStack[] ret; - if (source.getItem() == null) - { - ret = new ItemStack[0]; - } - else if (count > source.getMaxStackSize()) - { - ret = new ItemStack[count]; - for (int x = 0; x < count; x++) - { - ret[x] = source.copy(); - ret[x].stackSize = 1; - } - } - else - { - ret = new ItemStack[1]; - ret[0] = source.copy(); - ret[0].stackSize = count; - } - return ret; - } - - //shortcut functions, See the non-static versions below - public static List getItems(String category, Random rnd){ return getInfo(category).getItems(rnd); } - public static int getCount(String category, Random rand){ return getInfo(category).getCount(rand); } - public static void addItem(String category, WeightedRandomChestContent item){ getInfo(category).addItem(item); } - public static void removeItem(String category, ItemStack item){ getInfo(category).removeItem(item); } - public static ItemStack getOneItem(String category, Random rand){ return getInfo(category).getOneItem(rand); } - - @SuppressWarnings("unused") - private String category; - private int countMin = 0; - private int countMax = 0; - private ArrayList contents = new ArrayList(); - - public ChestGenHooks(String category) - { - this.category = category; - } - - public ChestGenHooks(String category, List items, int min, int max) - { - this(category); - for (WeightedRandomChestContent item : items) - { - contents.add(item); - } - countMin = min; - countMax = max; - } - - /** - * Adds a new entry into the possible items to generate. - * - * @param item The item to add. - */ - public void addItem(WeightedRandomChestContent item) - { - contents.add(item); - } - - /** - * Removes all items that match the input item stack, Only metadata and item ID are checked. - * If the input item has a metadata of -1, all metadatas will match. - * - * @param item The item to check - */ - public void removeItem(ItemStack item) - { - Iterator itr = contents.iterator(); - while(itr.hasNext()) - { - WeightedRandomChestContent cont = itr.next(); - if (item.isItemEqual(cont.theItemId) || (item.getItemDamage() == OreDictionary.WILDCARD_VALUE && item.getItem() == cont.theItemId.getItem())) - { - itr.remove(); - } - } - } - - /** - * Gets an array of all random objects that are associated with this category. - * - * @return The random objects - */ - public List getItems(Random rnd) - { - ArrayList ret = new ArrayList(); - - for (WeightedRandomChestContent orig : contents) - { - Item item = orig.theItemId.getItem(); - - if (item != null) - { - WeightedRandomChestContent n = item.getChestGenBase(this, rnd, orig); - if (n != null) - { - ret.add(n); - } - } - } - - return ret; - } - - /** - * Gets a random number between countMin and countMax. - * - * @param rand A RNG - * @return A random number where countMin <= num <= countMax - */ - public int getCount(Random rand) - { - return countMin < countMax ? countMin + rand.nextInt(countMax - countMin) : countMin; - } - - /** - * Returns a single ItemStack from the possible items in this registry, - * Useful if you just want a quick and dirty random Item. - * - * @param rand A Random Number gen - * @return A single ItemStack, or null if it could not get one. - */ - public ItemStack getOneItem(Random rand) - { - WeightedRandomChestContent item = (WeightedRandomChestContent)WeightedRandom.getRandomItem(rand, getItems(rand)); - ItemStack[] stacks = ChestGenHooks.generateStacks(rand, item.theItemId, item.minStackSize, item.maxStackSize); - return (stacks.length > 0 ? stacks[0] : null); - } - - //Accessors - public int getMin(){ return countMin; } - public int getMax(){ return countMax; } - public void setMin(int value){ countMin = value; } - public void setMax(int value){ countMax = value; } -} diff --git a/src/main/java/net/minecraftforge/common/DimensionManager.java b/src/main/java/net/minecraftforge/common/DimensionManager.java index 096457fc31..4d788ef5d6 100644 --- a/src/main/java/net/minecraftforge/common/DimensionManager.java +++ b/src/main/java/net/minecraftforge/common/DimensionManager.java @@ -20,13 +20,11 @@ import com.google.common.collect.Multiset; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; +import net.minecraft.world.DimensionType; import net.minecraft.world.MinecraftException; import net.minecraft.world.World; import net.minecraft.world.WorldManager; import net.minecraft.world.WorldProvider; -import net.minecraft.world.WorldProviderEnd; -import net.minecraft.world.WorldProviderHell; -import net.minecraft.world.WorldProviderSurface; import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServerMulti; import net.minecraft.world.storage.ISaveHandler; @@ -37,51 +35,24 @@ import net.minecraftforge.fml.common.FMLLog; public class DimensionManager { - private static Hashtable> providers = new Hashtable>(); - private static Hashtable spawnSettings = new Hashtable(); private static Hashtable worlds = new Hashtable(); private static boolean hasInit = false; - private static Hashtable dimensions = new Hashtable(); + private static Hashtable dimensions = new Hashtable(); private static ArrayList unloadQueue = new ArrayList(); private static BitSet dimensionMap = new BitSet(Long.SIZE << 4); private static ConcurrentMap weakWorldMap = new MapMaker().weakKeys().weakValues().makeMap(); private static Multiset leakedWorlds = HashMultiset.create(); - public static boolean registerProviderType(int id, Class provider, boolean keepLoaded) - { - if (providers.containsKey(id)) - { - return false; - } - providers.put(id, provider); - spawnSettings.put(id, keepLoaded); - return true; - } - /** - * Unregisters a Provider type, and returns a array of all dimensions that are - * registered to this provider type. - * If the return size is greater then 0, it is required that the caller either - * change those dimensions's registered type, or replace this type before the - * world is attempted to load, else the loader will throw an exception. - * - * @param id The provider type ID to unreigster - * @return An array containing all dimension IDs still registered to this provider type. + * Returns a list of dimensions associated with this DimensionType. */ - public static int[] unregisterProviderType(int id) + public static int[] getDimensions(DimensionType type) { - if (!providers.containsKey(id)) - { - return new int[0]; - } - providers.remove(id); - spawnSettings.remove(id); - int[] ret = new int[dimensions.size()]; int x = 0; - for (Map.Entry ent : dimensions.entrySet()) + for (Map.Entry ent : dimensions.entrySet()) { - if (ent.getValue() == id) + if (ent.getValue() == type) { ret[x++] = ent.getKey(); } @@ -99,25 +70,19 @@ public class DimensionManager hasInit = true; - registerProviderType( 0, WorldProviderSurface.class, true); - registerProviderType(-1, WorldProviderHell.class, true); - registerProviderType( 1, WorldProviderEnd.class, false); - registerDimension( 0, 0); - registerDimension(-1, -1); - registerDimension( 1, 1); + registerDimension( 0, DimensionType.OVERWORLD); + registerDimension(-1, DimensionType.NETHER); + registerDimension( 1, DimensionType.THE_END); } - public static void registerDimension(int id, int providerType) + public static void registerDimension(int id, DimensionType type) { - if (!providers.containsKey(providerType)) - { - throw new IllegalArgumentException(String.format("Failed to register dimension for id %d, provider type %d does not exist", id, providerType)); - } + DimensionType.getById(type.getId()); //Check if type is invalid {will throw an error} No clue how it would be invalid tho... if (dimensions.containsKey(id)) { throw new IllegalArgumentException(String.format("Failed to register dimension for id %d, One is already registered", id)); } - dimensions.put(id, providerType); + dimensions.put(id, type); if (id >= 0) { dimensionMap.set(id); @@ -141,7 +106,7 @@ public class DimensionManager return dimensions.containsKey(dim); } - public static int getProviderType(int dim) + public static DimensionType getProviderType(int dim) { if (!dimensions.containsKey(dim)) { @@ -171,7 +136,7 @@ public class DimensionManager int leakCount = leakedWorlds.count(System.identityHashCode(w)); if (leakCount == 5) { - FMLLog.fine("The world %x (%s) may have leaked: first encounter (5 occurences).\n", System.identityHashCode(w), w.getWorldInfo().getWorldName()); + FMLLog.fine("The world %x (%s) may have leaked: first encounter (5 occurrences).\n", System.identityHashCode(w), w.getWorldInfo().getWorldName()); } else if (leakCount % 5 == 0) { @@ -186,19 +151,19 @@ public class DimensionManager return worlds.keySet().toArray(new Integer[worlds.size()]); //Only loaded dims, since usually used to cycle through loaded worlds } - public static void setWorld(int id, WorldServer world) + public static void setWorld(int id, WorldServer world, MinecraftServer server) { if (world != null) { worlds.put(id, world); weakWorldMap.put(world, world); - MinecraftServer.getServer().worldTickTimes.put(id, new long[100]); + server.worldTickTimes.put(id, new long[100]); FMLLog.info("Loading dimension %d (%s) (%s)", id, world.getWorldInfo().getWorldName(), world.getMinecraftServer()); } else { worlds.remove(id); - MinecraftServer.getServer().worldTickTimes.remove(id); + server.worldTickTimes.remove(id); FMLLog.info("Unloading dimension %d", id); } @@ -220,7 +185,7 @@ public class DimensionManager tmp.add(entry.getValue()); } - MinecraftServer.getServer().worldServers = tmp.toArray(new WorldServer[tmp.size()]); + server.worldServers = tmp.toArray(new WorldServer[tmp.size()]); } public static void initDimension(int dim) @@ -244,7 +209,7 @@ public class DimensionManager //WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo()); WorldServer world = (dim == 0 ? overworld : (WorldServer)(new WorldServerMulti(mcServer, savehandler, dim, overworld, mcServer.theProfiler).init())); - world.addWorldAccess(new WorldManager(mcServer, world)); + world.addEventListener(new WorldManager(mcServer, world)); MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world)); if (!mcServer.isSinglePlayer()) { @@ -264,12 +229,6 @@ public class DimensionManager return worlds.values().toArray(new WorldServer[worlds.size()]); } - public static boolean shouldLoadSpawn(int dim) - { - int id = getProviderType(dim); - return spawnSettings.containsKey(id) && spawnSettings.get(id); - } - static { init(); @@ -289,9 +248,9 @@ public class DimensionManager { if (dimensions.containsKey(dim)) { - WorldProvider provider = providers.get(getProviderType(dim)).newInstance(); - provider.setDimension(dim); - return provider; + WorldProvider ret = getProviderType(dim).createDimension(); + ret.setDimension(dim); + return ret; } else { @@ -300,8 +259,8 @@ public class DimensionManager } catch (Exception e) { - FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR, String.format("An error occured trying to create an instance of WorldProvider %d (%s)", - dim, providers.get(getProviderType(dim)).getSimpleName()),e); + FMLCommonHandler.instance().getFMLLogger().log(Level.ERROR, String.format("An error occurred trying to create an instance of WorldProvider %d (%s)", + dim, getProviderType(dim)),e); throw new RuntimeException(e); } } @@ -334,7 +293,7 @@ public class DimensionManager { MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(w)); w.flush(); - setWorld(id, null); + setWorld(id, null, w.getMinecraftServer()); } } } @@ -413,17 +372,17 @@ public class DimensionManager { if (DimensionManager.getWorld(0) != null) { - return ((SaveHandler)DimensionManager.getWorld(0).getSaveHandler()).getWorldDirectory(); - } + return DimensionManager.getWorld(0).getSaveHandler().getWorldDirectory(); + }/* else if (MinecraftServer.getServer() != null) { MinecraftServer srv = MinecraftServer.getServer(); SaveHandler saveHandler = (SaveHandler) srv.getActiveAnvilConverter().getSaveLoader(srv.getFolderName(), false); return saveHandler.getWorldDirectory(); - } + }*/ else { return null; } } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraftforge/common/DungeonHooks.java b/src/main/java/net/minecraftforge/common/DungeonHooks.java index 211ff296b3..2a2f178b2a 100644 --- a/src/main/java/net/minecraftforge/common/DungeonHooks.java +++ b/src/main/java/net/minecraftforge/common/DungeonHooks.java @@ -68,7 +68,7 @@ public class DungeonHooks */ public static String getRandomDungeonMob(Random rand) { - DungeonMob mob = (DungeonMob)WeightedRandom.getRandomItem(rand, dungeonMobs); + DungeonMob mob = WeightedRandom.getRandomItem(rand, dungeonMobs); if (mob == null) { return ""; diff --git a/src/main/java/net/minecraftforge/common/FishingHooks.java b/src/main/java/net/minecraftforge/common/FishingHooks.java deleted file mode 100644 index 70c10185ad..0000000000 --- a/src/main/java/net/minecraftforge/common/FishingHooks.java +++ /dev/null @@ -1,113 +0,0 @@ -package net.minecraftforge.common; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Random; - -import com.google.common.base.Predicate; - -import net.minecraft.entity.projectile.EntityFishHook; -import net.minecraft.item.ItemStack; -import net.minecraft.stats.StatBase; -import net.minecraft.stats.StatList; -import net.minecraft.util.MathHelper; -import net.minecraft.util.WeightedRandom; -import net.minecraft.util.WeightedRandomFishable; - -public class FishingHooks -{ - private static ArrayList fish = new ArrayList(); - private static ArrayList junk = new ArrayList(); - private static ArrayList treasure = new ArrayList(); - - public static void addFish(WeightedRandomFishable item) { fish.add(item); } - public static void addJunk(WeightedRandomFishable item) { junk.add(item); } - public static void addTreasure(WeightedRandomFishable item) { treasure.add(item); } - - public static void removeFish(Predicate test) { remove(fish.iterator(), test); } - public static void removeJunk(Predicate test) { remove(junk.iterator(), test); } - public static void removeTreasure(Predicate test) { remove(treasure.iterator(), test); } - - public static ItemStack getRandomFishable(Random rand, float chance) - { - return getRandomFishable(rand, chance, 0, 0); - } - - public static ItemStack getRandomFishable(Random rand, float chance, int luck, int speed) - { - float junkChance = 0.1F - luck * 0.025F - speed * 0.01F; - float treasureChance = 0.05F + luck * 0.01F - speed * 0.01F; - junkChance = MathHelper.clamp_float(junkChance, 0.0F, 1.0F); - treasureChance = MathHelper.clamp_float(treasureChance, 0.0F, 1.0F); - - if (chance < junkChance) - { - return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, junk)).getItemStack(rand); - } - - chance -= junkChance; - if (chance < treasureChance) - { - return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, treasure)).getItemStack(rand); - } - - chance -= treasureChance; - // this is done in EntityFishHook.func_146033_f. more loot types expected? - { - return ((WeightedRandomFishable)WeightedRandom.getRandomItem(rand, fish)).getItemStack(rand); - } - } - - public static FishableCategory getFishableCategory(float chance, int luck, int speed) - { - float junkChance = 0.1F - luck * 0.025F - speed * 0.01F; - float treasureChance = 0.05F + luck * 0.01F - speed * 0.01F; - junkChance = MathHelper.clamp_float(junkChance, 0.0F, 1.0F); - treasureChance = MathHelper.clamp_float(treasureChance, 0.0F, 1.0F); - - if (chance < junkChance) - { - return FishableCategory.JUNK; - } - - chance -= junkChance; - if (chance < treasureChance) - { - return FishableCategory.TREASURE; - } - - chance -= treasureChance; - // this is done in EntityFishHook.func_146033_f. more loot types expected? - { - return FishableCategory.FISH; - } - } - - private static void remove(Iterator iter, Predicate test) - { - while (iter.hasNext()) - if (!test.apply(iter.next())) - iter.remove(); - } - - static - { - fish.addAll(EntityFishHook.FISH); - junk.addAll(EntityFishHook.JUNK); - treasure.addAll(EntityFishHook.TREASURE); - } - - public static enum FishableCategory - { - JUNK(StatList.junkFishedStat), - TREASURE(StatList.treasureFishedStat), - FISH(StatList.fishCaughtStat); - - public final StatBase stat; - - FishableCategory(StatBase stat) - { - this.stat = stat; - } - } -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java index e60af5ed2a..3f34aad5e7 100644 --- a/src/main/java/net/minecraftforge/common/ForgeChunkManager.java +++ b/src/main/java/net/minecraftforge/common/ForgeChunkManager.java @@ -14,7 +14,32 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; + +import javax.annotation.Nullable; + +import net.minecraft.entity.Entity; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ClassInheritanceMultiMap; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.FMLLog; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.eventhandler.Event; + import org.apache.logging.log4j.Level; + +import com.google.common.base.Function; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.collect.ArrayListMultimap; @@ -25,6 +50,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; +import com.google.common.collect.Iterators; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.ListMultimap; import com.google.common.collect.MapMaker; @@ -32,25 +58,6 @@ import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.SetMultimap; import com.google.common.collect.Sets; -import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.ChunkCoordIntPair; -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.entity.Entity; -import net.minecraft.util.ClassInheritanceMultiMap; -import net.minecraft.util.MathHelper; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.config.ConfigCategory; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; -import net.minecraftforge.common.util.Constants; /** * Manages chunkloading for mods. @@ -103,6 +110,25 @@ public class ForgeChunkManager MOD_PROP_ORDER.add("maximumChunksPerTicket"); } + public static Iterator getPersistentChunksIterableFor(final World world, Iterator chunkIterator) + { + final ImmutableSetMultimap persistentChunksFor = getPersistentChunksFor(world); + final ImmutableSet.Builder builder = ImmutableSet.builder(); + world.theProfiler.startSection("forcedChunkLoading"); + builder.addAll(Iterators.transform(persistentChunksFor.keys().iterator(), new Function() { + @Nullable + @Override + public Chunk apply(@Nullable ChunkCoordIntPair input) + { + return world.getChunkFromChunkCoords(input.chunkXPos, input.chunkZPos); + } + })); + world.theProfiler.endStartSection("regularChunkLoading"); + builder.addAll(chunkIterator); + world.theProfiler.endSection(); + return builder.build().iterator(); + } + /** * All mods requiring chunkloading need to implement this to handle the * re-registration of chunk tickets at world loading time @@ -344,25 +370,45 @@ public class ForgeChunkManager } public static class ForceChunkEvent extends Event { - public final Ticket ticket; - public final ChunkCoordIntPair location; + private final Ticket ticket; + private final ChunkCoordIntPair location; public ForceChunkEvent(Ticket ticket, ChunkCoordIntPair location) { this.ticket = ticket; this.location = location; } + + public Ticket getTicket() + { + return ticket; + } + + public ChunkCoordIntPair getLocation() + { + return location; + } } public static class UnforceChunkEvent extends Event { - public final Ticket ticket; - public final ChunkCoordIntPair location; + private final Ticket ticket; + private final ChunkCoordIntPair location; public UnforceChunkEvent(Ticket ticket, ChunkCoordIntPair location) { this.ticket = ticket; this.location = location; } + + public Ticket getTicket() + { + return ticket; + } + + public ChunkCoordIntPair getLocation() + { + return location; + } } @@ -395,7 +441,7 @@ public class ForgeChunkManager static void loadWorld(World world) { - ArrayListMultimap newTickets = ArrayListMultimap.create(); + ArrayListMultimap newTickets = ArrayListMultimap.create(); tickets.put(world, newTickets); forcedChunks.put(world, ImmutableSetMultimap.of()); @@ -412,7 +458,7 @@ public class ForgeChunkManager if (chunkLoaderData.exists() && chunkLoaderData.isFile()) { - ArrayListMultimap loadedTickets = ArrayListMultimap.create(); + ArrayListMultimap loadedTickets = ArrayListMultimap.create(); Map> playerLoadedTickets = Maps.newHashMap(); NBTTagCompound forcedChunkData; try @@ -427,7 +473,7 @@ public class ForgeChunkManager NBTTagList ticketList = forcedChunkData.getTagList("TicketList", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < ticketList.tagCount(); i++) { - NBTTagCompound ticketHolder = (NBTTagCompound)ticketList.getCompoundTagAt(i); + NBTTagCompound ticketHolder = ticketList.getCompoundTagAt(i); String modId = ticketHolder.getString("Owner"); boolean isPlayer = "Forge".equals(modId); @@ -446,7 +492,7 @@ public class ForgeChunkManager NBTTagList tickets = ticketHolder.getTagList("Tickets", Constants.NBT.TAG_COMPOUND); for (int j = 0; j < tickets.tagCount(); j++) { - NBTTagCompound ticket = (NBTTagCompound) tickets.getCompoundTagAt(j); + NBTTagCompound ticket = tickets.getCompoundTagAt(j); modId = ticket.hasKey("ModId") ? ticket.getString("ModId") : modId; Type type = Type.values()[ticket.getByte("Type")]; //byte ticketChunkDepth = ticket.getByte("ChunkListDepth"); @@ -551,8 +597,8 @@ public class ForgeChunkManager forcedChunks.remove(world); dormantChunkCache.remove(world); - // integrated server is shutting down - if (!MinecraftServer.getServer().isServerRunning()) + // integrated server is shutting down + if (!FMLCommonHandler.instance().getMinecraftServerInstance().isServerRunning()) { playerTickets.clear(); tickets.clear(); @@ -913,7 +959,7 @@ public class ForgeChunkManager { for (ClassInheritanceMultiMap eList : chunk.getEntityLists()) { - Iterator itr = (Iterator)eList.iterator(); + Iterator itr = eList.iterator(); while (itr.hasNext()) { (itr.next()).resetEntityId(); @@ -939,7 +985,7 @@ public class ForgeChunkManager dest.delete(); } cfgFile.renameTo(dest); - FMLLog.log(Level.ERROR, e, "A critical error occured reading the forgeChunkLoading.cfg file, defaults will be used - the invalid file is backed up at forgeChunkLoading.cfg.bak"); + FMLLog.log(Level.ERROR, e, "A critical error occurred reading the forgeChunkLoading.cfg file, defaults will be used - the invalid file is backed up at forgeChunkLoading.cfg.bak"); } syncConfigDefaults(); } @@ -957,37 +1003,37 @@ public class ForgeChunkManager .setCategoryRequiresWorldRestart("defaults", true); Property temp = config.get("defaults", "enabled", true); - temp.comment = "Are mod overrides enabled?"; + temp.setComment("Are mod overrides enabled?"); temp.setLanguageKey("forge.configgui.enableModOverrides"); overridesEnabled = temp.getBoolean(true); propOrder.add("enabled"); temp = config.get("defaults", "maximumChunksPerTicket", 25); - temp.comment = "The default maximum number of chunks a mod can force, per ticket, \n" + - "for a mod without an override. This is the maximum number of chunks a single ticket can force."; + temp.setComment("The default maximum number of chunks a mod can force, per ticket, \n" + + "for a mod without an override. This is the maximum number of chunks a single ticket can force."); temp.setLanguageKey("forge.configgui.maximumChunksPerTicket"); temp.setMinValue(0); defaultMaxChunks = temp.getInt(25); propOrder.add("maximumChunksPerTicket"); temp = config.get("defaults", "maximumTicketCount", 200); - temp.comment = "The default maximum ticket count for a mod which does not have an override\n" + - "in this file. This is the number of chunk loading requests a mod is allowed to make."; + temp.setComment("The default maximum ticket count for a mod which does not have an override\n" + + "in this file. This is the number of chunk loading requests a mod is allowed to make."); temp.setLanguageKey("forge.configgui.maximumTicketCount"); temp.setMinValue(0); defaultMaxCount = temp.getInt(200); propOrder.add("maximumTicketCount"); temp = config.get("defaults", "playerTicketCount", 500); - temp.comment = "The number of tickets a player can be assigned instead of a mod. This is shared across all mods and it is up to the mods to use it."; + temp.setComment("The number of tickets a player can be assigned instead of a mod. This is shared across all mods and it is up to the mods to use it."); temp.setLanguageKey("forge.configgui.playerTicketCount"); temp.setMinValue(0); playerTicketLength = temp.getInt(500); propOrder.add("playerTicketCount"); temp = config.get("defaults", "dormantChunkCacheSize", 0); - temp.comment = "Unloaded chunks can first be kept in a dormant cache for quicker\n" + - "loading times. Specify the size (in chunks) of that cache here"; + temp.setComment("Unloaded chunks can first be kept in a dormant cache for quicker\n" + + "loading times. Specify the size (in chunks) of that cache here"); temp.setLanguageKey("forge.configgui.dormantChunkCacheSize"); temp.setMinValue(0); dormantChunkCacheSize = temp.getInt(0); @@ -1002,9 +1048,9 @@ public class ForgeChunkManager "for that mod"); temp = config.get("Forge", "maximumTicketCount", 200); - temp.comment = "Maximum ticket count for the mod. Zero disables chunkloading capabilities."; + temp.setComment("Maximum ticket count for the mod. Zero disables chunkloading capabilities."); temp = config.get("Forge", "maximumChunksPerTicket", 25); - temp.comment = "Maximum chunks per ticket for the mod."; + temp.setComment("Maximum chunks per ticket for the mod."); for (String mod : config.getCategoryNames()) { if (mod.equals("Forge") || mod.equals("defaults")) diff --git a/src/main/java/net/minecraftforge/common/ForgeHooks.java b/src/main/java/net/minecraftforge/common/ForgeHooks.java index 398ef3ee9d..8d60ecf1fc 100644 --- a/src/main/java/net/minecraftforge/common/ForgeHooks.java +++ b/src/main/java/net/minecraftforge/common/ForgeHooks.java @@ -1,14 +1,5 @@ package net.minecraftforge.common; -import static net.minecraft.init.Blocks.diamond_block; -import static net.minecraft.init.Blocks.diamond_ore; -import static net.minecraft.init.Blocks.emerald_block; -import static net.minecraft.init.Blocks.emerald_ore; -import static net.minecraft.init.Blocks.gold_block; -import static net.minecraft.init.Blocks.gold_ore; -import static net.minecraft.init.Blocks.lit_redstone_ore; -import static net.minecraft.init.Blocks.redstone_ore; - import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; @@ -22,21 +13,22 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityMinecartContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.event.ClickEvent; +import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerRepair; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemBucket; @@ -45,32 +37,30 @@ import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagString; import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.Packet; -import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.network.play.server.SPacketBlockChange; import net.minecraft.stats.StatList; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityNote; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.MathHelper; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.MovingObjectPosition.MovingObjectType; -import net.minecraft.util.Vec3; +import net.minecraft.util.EnumHand; import net.minecraft.util.WeightedRandom; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.WorldSettings; import net.minecraft.world.WorldSettings.GameType; -import net.minecraft.world.gen.feature.WorldGeneratorBonusChest; import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.event.AnvilUpdateEvent; import net.minecraftforge.event.ForgeEventFactory; @@ -87,16 +77,18 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.event.entity.player.AnvilRepairEvent; import net.minecraftforge.event.entity.player.AttackEntityEvent; -import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent; import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.NoteBlockEvent; import net.minecraftforge.fluids.IFluidBlock; +import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.relauncher.ReflectionHelper; public class ForgeHooks { + //TODO: Loot tables? static class SeedEntry extends WeightedRandom.Item { public final ItemStack seed; @@ -105,17 +97,21 @@ public class ForgeHooks super(weight); this.seed = seed; } + public ItemStack getStack(Random rand, int fortune) + { + return seed.copy(); + } } static final List seedList = new ArrayList(); - public static ItemStack getGrassSeed(Random rand) + public static ItemStack getGrassSeed(Random rand, int fortune) { - SeedEntry entry = (SeedEntry)WeightedRandom.getRandomItem(rand, seedList); + SeedEntry entry = WeightedRandom.getRandomItem(rand, seedList); if (entry == null || entry.seed == null) { return null; } - return entry.seed.copy(); + return entry.getStack(rand, fortune); } private static boolean toolInit = false; @@ -123,24 +119,24 @@ public class ForgeHooks public static boolean canHarvestBlock(Block block, EntityPlayer player, IBlockAccess world, BlockPos pos) { - if (block.getMaterial().isToolNotRequired()) + IBlockState state = world.getBlockState(pos); + state = state.getBlock().getActualState(state, world, pos); + if (state.getMaterial().isToolNotRequired()) { return true; } ItemStack stack = player.inventory.getCurrentItem(); - IBlockState state = world.getBlockState(pos); - state = state.getBlock().getActualState(state, world, pos); String tool = block.getHarvestTool(state); if (stack == null || tool == null) { - return player.canHarvestBlock(block); + return player.canHarvestBlock(state); } int toolLevel = stack.getItem().getHarvestLevel(stack, tool); if (toolLevel < 0) { - return player.canHarvestBlock(block); + return player.canHarvestBlock(state); } return toolLevel >= block.getHarvestLevel(state); @@ -157,7 +153,7 @@ public class ForgeHooks public static float blockStrength(IBlockState state, EntityPlayer player, World world, BlockPos pos) { - float hardness = state.getBlock().getBlockHardness(world, pos); + float hardness = state.getBlockHardness(world, pos); if (hardness < 0.0F) { return 0.0F; @@ -212,7 +208,11 @@ public class ForgeHooks } Blocks.obsidian.setHarvestLevel("pickaxe", 3); - for (Block block : new Block[]{emerald_ore, emerald_block, diamond_ore, diamond_block, gold_ore, gold_block, redstone_ore, lit_redstone_ore}) + Block[] oreBlocks = new Block[] { + Blocks.emerald_ore, Blocks.emerald_block, Blocks.diamond_ore, Blocks.diamond_block, + Blocks.gold_ore, Blocks.gold_block, Blocks.redstone_ore, Blocks.lit_redstone_ore + }; + for (Block block : oreBlocks) { block.setHarvestLevel("pickaxe", 2); } @@ -243,83 +243,83 @@ public class ForgeHooks static { - seedList.add(new SeedEntry(new ItemStack(Items.wheat_seeds), 10)); + seedList.add(new SeedEntry(new ItemStack(Items.wheat_seeds), 10) + { + public ItemStack getStack(Random rand, int fortune) + { + return new ItemStack(Items.wheat_seeds, 1 + rand.nextInt(fortune * 2 + 1)); + } + }); initTools(); } /** * Called when a player uses 'pick block', calls new Entity and Block hooks. */ - public static boolean onPickBlock(MovingObjectPosition target, EntityPlayer player, World world) + public static boolean onPickBlock(RayTraceResult target, EntityPlayer player, World world) { /* - int i = 0; - boolean flag1 = false; TileEntity tileentity = null; - Item item; + ItemStack itemstack; - if (this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + if (this.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos blockpos = this.objectMouseOver.getBlockPos(); - Block block = this.theWorld.getBlockState(blockpos).getBlock(); + IBlockState iblockstate = this.theWorld.getBlockState(blockpos); + Block block = iblockstate.getBlock(); - if (block.getMaterial() == Material.air) + if (iblockstate.getMaterial() == Material.air) { return; } - item = block.getItem(this.theWorld, blockpos); + itemstack = block.func_185473_a(this.theWorld, blockpos, iblockstate); - if (item == null) + if (itemstack == null) { return; } - if (flag && GuiScreen.isCtrlKeyDown()) + if (flag && GuiScreen.isCtrlKeyDown() && block.hasTileEntity()) { tileentity = this.theWorld.getTileEntity(blockpos); } - - Block block1 = item instanceof ItemBlock && !block.isFlowerPot() ? Block.getBlockFromItem(item) : block; - i = block1.getDamageValue(this.theWorld, blockpos); - flag1 = item.getHasSubtypes(); } else { - if (this.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY || this.objectMouseOver.entityHit == null || !flag) + if (this.objectMouseOver.typeOfHit != RayTraceResult.Type.ENTITY || this.objectMouseOver.entityHit == null || !flag) { return; } if (this.objectMouseOver.entityHit instanceof EntityPainting) { - item = Items.painting; + itemstack = new ItemStack(Items.painting); } else if (this.objectMouseOver.entityHit instanceof EntityLeashKnot) { - item = Items.lead; + itemstack = new ItemStack(Items.lead); } else if (this.objectMouseOver.entityHit instanceof EntityItemFrame) { EntityItemFrame entityitemframe = (EntityItemFrame)this.objectMouseOver.entityHit; - ItemStack itemstack = entityitemframe.getDisplayedItem(); + ItemStack itemstack1 = entityitemframe.getDisplayedItem(); - if (itemstack == null) + if (itemstack1 == null) { - item = Items.item_frame; + itemstack = new ItemStack(Items.item_frame); } else { - item = itemstack.getItem(); - i = itemstack.getMetadata(); - flag1 = true; + itemstack = ItemStack.copyItemStack(itemstack1); } } else if (this.objectMouseOver.entityHit instanceof EntityMinecart) { EntityMinecart entityminecart = (EntityMinecart)this.objectMouseOver.entityHit; + Item item; - switch (entityminecart.getMinecartType()) + switch (entityminecart.func_184264_v()) { case FURNACE: item = Items.furnace_minecart; @@ -339,61 +339,56 @@ public class ForgeHooks default: item = Items.minecart; } + + itemstack = new ItemStack(item); } else if (this.objectMouseOver.entityHit instanceof EntityBoat) { - item = Items.boat; + itemstack = new ItemStack(((EntityBoat)this.objectMouseOver.entityHit).func_184455_j()); } else if (this.objectMouseOver.entityHit instanceof EntityArmorStand) { - item = Items.armor_stand; + itemstack = new ItemStack(Items.armor_stand); + } + else if (this.objectMouseOver.entityHit instanceof EntityEnderCrystal) + { + itemstack = new ItemStack(Items.field_185158_cP); } else { - item = Items.spawn_egg; - i = EntityList.getEntityID(this.objectMouseOver.entityHit); - flag1 = true; + String s = EntityList.getEntityString(this.objectMouseOver.entityHit); - if (!EntityList.entityEggs.containsKey(Integer.valueOf(i))) + if (!EntityList.entityEggs.containsKey(s)) { return; } + + itemstack = new ItemStack(Items.spawn_egg); + ItemMonsterPlacer.func_185078_a(itemstack, s); } } - - InventoryPlayer inventoryplayer = this.thePlayer.inventory; - - if (tileentity == null) - { - inventoryplayer.setCurrentItem(item, i, flag1, flag); - } - else - { - ItemStack itemstack1 = this.func_181036_a(item, i, tileentity); - inventoryplayer.setInventorySlotContents(inventoryplayer.currentItem, itemstack1); - } */ ItemStack result = null; boolean isCreative = player.capabilities.isCreativeMode; TileEntity te = null; - if (target.typeOfHit == MovingObjectType.BLOCK) + if (target.typeOfHit == RayTraceResult.Type.BLOCK) { IBlockState state = world.getBlockState(target.getBlockPos()); - if (state.getBlock().isAir(world, target.getBlockPos())) + if (state.getBlock().isAir(state, world, target.getBlockPos())) { return false; } - if (isCreative && GuiScreen.isCtrlKeyDown()) + if (isCreative && GuiScreen.isCtrlKeyDown() && state.getBlock().hasTileEntity(state)) te = world.getTileEntity(target.getBlockPos()); - result = state.getBlock().getPickBlock(target, world, target.getBlockPos(), player); + result = state.getBlock().getPickBlock(state, target, world, target.getBlockPos(), player); } else { - if (target.typeOfHit != MovingObjectType.ENTITY || target.entityHit == null || !isCreative) + if (target.typeOfHit != RayTraceResult.Type.ENTITY || target.entityHit == null || !isCreative) { return false; } @@ -406,48 +401,48 @@ public class ForgeHooks return false; } + if (result.getItem() == null) + { + String s1 = ""; + + if (target.typeOfHit == RayTraceResult.Type.BLOCK) + { + s1 = Block.blockRegistry.getNameForObject(world.getBlockState(target.getBlockPos()).getBlock()).toString(); + } + else if (target.typeOfHit == RayTraceResult.Type.ENTITY) + { + s1 = EntityList.getEntityString(target.entityHit); + } + + FMLLog.warning("Picking on: [%s] %s gave null item", target.typeOfHit, s1); + return true; + } + if (te != null) { - NBTTagCompound nbt = new NBTTagCompound(); - te.writeToNBT(nbt); - result.setTagInfo("BlockEntityTag", nbt); - - NBTTagCompound display = new NBTTagCompound(); - result.setTagInfo("display", display); - - NBTTagList lore = new NBTTagList(); - display.setTag("Lore", lore); - lore.appendTag(new NBTTagString("(+NBT)")); + Minecraft.getMinecraft().storeTEInStack(result, te); } - for (int x = 0; x < 9; x++) + if (isCreative) { - ItemStack stack = player.inventory.getStackInSlot(x); - if (stack != null && stack.isItemEqual(result) && ItemStack.areItemStackTagsEqual(stack, result)) - { - player.inventory.currentItem = x; - return true; - } + player.inventory.func_184434_a(result); + Minecraft.getMinecraft().playerController.sendSlotPacket(player.getHeldItem(EnumHand.MAIN_HAND), 36 + player.inventory.currentItem); + return true; } - - if (!isCreative) + int slot = player.inventory.getSlotFor(result); + if (slot != -1) { - return false; + if (InventoryPlayer.isHotbar(slot)) + player.inventory.currentItem = slot; + else + Minecraft.getMinecraft().playerController.pickItem(slot); + return true; } - - int slot = player.inventory.getFirstEmptyStack(); - if (slot < 0 || slot >= 9) - { - slot = player.inventory.currentItem; - } - - player.inventory.setInventorySlotContents(slot, result); - player.inventory.currentItem = slot; - return true; + return false; } //Optifine Helper Functions u.u, these are here specifically for Optifine - //Note: When using Optfine, these methods are invoked using reflection, which + //Note: When using Optifine, these methods are invoked using reflection, which //incurs a major performance penalty. public static void onLivingSetAttackTarget(EntityLivingBase entity, EntityLivingBase target) { @@ -467,7 +462,7 @@ public class ForgeHooks public static float onLivingHurt(EntityLivingBase entity, DamageSource src, float amount) { LivingHurtEvent event = new LivingHurtEvent(entity, src, amount); - return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.ammount); + return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount()); } public static boolean onLivingDeath(EntityLivingBase entity, DamageSource src) @@ -483,16 +478,16 @@ public class ForgeHooks public static float[] onLivingFall(EntityLivingBase entity, float distance, float damageMultiplier) { LivingFallEvent event = new LivingFallEvent(entity, distance, damageMultiplier); - return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.distance, event.damageMultiplier}); + return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.getDistance(), event.getDamageMultiplier()}); } - public static boolean isLivingOnLadder(Block block, World world, BlockPos pos, EntityLivingBase entity) + public static boolean isLivingOnLadder(IBlockState state, World world, BlockPos pos, EntityLivingBase entity) { boolean isSpectator = (entity instanceof EntityPlayer && ((EntityPlayer)entity).isSpectator()); if (isSpectator) return false; if (!ForgeModContainer.fullBoundingBoxLadders) { - return block != null && block.isLadder(world, pos, entity); + return state != null && state.getBlock().isLadder(state, world, pos, entity); } else { @@ -507,7 +502,8 @@ public class ForgeHooks for (int z2 = mZ; z2 < bb.maxZ; z2++) { BlockPos tmp = new BlockPos(x2, y2, z2); - if (world.getBlockState(tmp).getBlock().isLadder(world, tmp, entity)) + state = world.getBlockState(tmp); + if (state.getBlock().isLadder(state, world, tmp, entity)) { return true; } @@ -541,8 +537,11 @@ public class ForgeHooks return null; } - player.joinEntityItemWithWorld(event.entityItem); - return event.entityItem; + if (!player.worldObj.isRemote) + { + player.getEntityWorld().spawnEntityInWorld(event.getEntityItem()); + } + return event.getEntityItem(); } public static float getEnchantPower(World world, BlockPos pos) @@ -550,15 +549,14 @@ public class ForgeHooks return world.getBlockState(pos).getBlock().getEnchantPowerBonus(world, pos); } - @SuppressWarnings("deprecation") - public static ChatComponentTranslation onServerChatEvent(NetHandlerPlayServer net, String raw, ChatComponentTranslation comp) + public static ITextComponent onServerChatEvent(NetHandlerPlayServer net, String raw, ITextComponent comp) { ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp); if (MinecraftForge.EVENT_BUS.post(event)) { return null; } - return event.component; + return event.getComponent(); } @@ -568,13 +566,13 @@ public class ForgeHooks "((?:[a-z0-9]{2,}:\\/\\/)?(?:(?:[0-9]{1,3}\\.){3}[0-9]{1,3}|(?:[-\\w_\\.]{1,}\\.[a-z]{2,}?))(?::[0-9]{1,5})?.*?(?=[!\"\u00A7 \n]|$))", Pattern.CASE_INSENSITIVE); - public static IChatComponent newChatWithLinks(String string){ return newChatWithLinks(string, true); } - public static IChatComponent newChatWithLinks(String string, boolean allowMissingHeader) + public static ITextComponent newChatWithLinks(String string){ return newChatWithLinks(string, true); } + public static ITextComponent newChatWithLinks(String string, boolean allowMissingHeader) { // Includes ipv4 and domain pattern // Matches an ip (xx.xxx.xx.xxx) or a domain (something.com) with or // without a protocol or path. - IChatComponent ichat = null; + ITextComponent ichat = null; Matcher matcher = URL_PATTERN.matcher(string); int lastEnd = 0; @@ -589,13 +587,13 @@ public class ForgeHooks if (part.length() > 0) { if (ichat == null) - ichat = new ChatComponentText(part); + ichat = new TextComponentString(part); else ichat.appendText(part); } lastEnd = end; String url = string.substring(start, end); - IChatComponent link = new ChatComponentText(url); + ITextComponent link = new TextComponentString(url); try { @@ -605,7 +603,7 @@ public class ForgeHooks if (!allowMissingHeader) { if (ichat == null) - ichat = new ChatComponentText(url); + ichat = new TextComponentString(url); else ichat.appendText(url); continue; @@ -616,7 +614,7 @@ public class ForgeHooks catch (URISyntaxException e) { // Bad syntax bail out! - if (ichat == null) ichat = new ChatComponentText(url); + if (ichat == null) ichat = new TextComponentString(url); else ichat.appendText(url); continue; } @@ -625,7 +623,7 @@ public class ForgeHooks ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_URL, url); link.getChatStyle().setChatClickEvent(click); link.getChatStyle().setUnderlined(true); - link.getChatStyle().setColor(EnumChatFormatting.BLUE); + link.getChatStyle().setColor(TextFormatting.BLUE); if (ichat == null) ichat = link; else @@ -635,7 +633,7 @@ public class ForgeHooks // Append the rest of the message. String end = string.substring(lastEnd); if (ichat == null) - ichat = new ChatComponentText(end); + ichat = new TextComponentString(end); else if (end.length() > 0) ichat.appendText(string.substring(lastEnd)); return ichat; @@ -645,14 +643,14 @@ public class ForgeHooks { PlayerOpenContainerEvent event = new PlayerOpenContainerEvent(player, openContainer); MinecraftForge.EVENT_BUS.post(event); - return event.getResult() == Event.Result.DEFAULT ? event.canInteractWith : event.getResult() == Event.Result.ALLOW ? true : false; + return event.getResult() == Event.Result.DEFAULT ? event.isCanInteractWith() : event.getResult() == Event.Result.ALLOW ? true : false; } public static int onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, BlockPos pos) { // Logic from tryHarvestBlock for pre-canceling the event boolean preCancelEvent = false; - if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword) + if (gameType.isCreative() && entityPlayer.getHeldItemMainhand() != null && entityPlayer.getHeldItemMainhand().getItem() instanceof ItemSword) preCancelEvent = true; if (gameType.isAdventure()) @@ -662,7 +660,7 @@ public class ForgeHooks if (!entityPlayer.isAllowEdit()) { - ItemStack itemstack = entityPlayer.getCurrentEquippedItem(); + ItemStack itemstack = entityPlayer.getHeldItemMainhand(); if (itemstack == null || !itemstack.canDestroy(world.getBlockState(pos).getBlock())) preCancelEvent = true; } @@ -671,7 +669,7 @@ public class ForgeHooks // Tell client the block is gone immediately then process events if (world.getTileEntity(pos) == null) { - S23PacketBlockChange packet = new S23PacketBlockChange(world, pos); + SPacketBlockChange packet = new SPacketBlockChange(world, pos); packet.blockState = Blocks.air.getDefaultState(); entityPlayer.playerNetServerHandler.sendPacket(packet); } @@ -686,7 +684,7 @@ public class ForgeHooks if (event.isCanceled()) { // Let the client know the block still exists - entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(world, pos)); + entityPlayer.playerNetServerHandler.sendPacket(new SPacketBlockChange(world, pos)); // Update any tile entity data for this block TileEntity tileentity = world.getTileEntity(pos); @@ -702,7 +700,7 @@ public class ForgeHooks return event.isCanceled() ? -1 : event.getExpToDrop(); } - public static boolean onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) + public static EnumActionResult onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { // handle all placement events here int meta = itemstack.getItemDamage(); @@ -718,10 +716,10 @@ public class ForgeHooks world.captureBlockSnapshots = true; } - boolean flag = itemstack.getItem().onItemUse(itemstack, player, world, pos, side, hitX, hitY, hitZ); + EnumActionResult ret = itemstack.getItem().onItemUse(itemstack, player, world, pos, hand, side, hitX, hitY, hitZ); world.captureBlockSnapshots = false; - if (flag) + if (ret == EnumActionResult.SUCCESS) { // save new item data int newMeta = itemstack.getItemDamage(); @@ -754,7 +752,7 @@ public class ForgeHooks if (placeEvent != null && (placeEvent.isCanceled())) { - flag = false; // cancel placement + ret = EnumActionResult.FAIL; // cancel placement // revert back all captured blocks for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots) { @@ -775,33 +773,33 @@ public class ForgeHooks for (BlockSnapshot snap : blockSnapshots) { - int updateFlag = snap.flag; - IBlockState oldBlock = snap.replacedBlock; - IBlockState newBlock = world.getBlockState(snap.pos); + int updateFlag = snap.getFlag(); + IBlockState oldBlock = snap.getReplacedBlock(); + IBlockState newBlock = world.getBlockState(snap.getPos()); if (newBlock != null && !(newBlock.getBlock().hasTileEntity(newBlock))) // Containers get placed automatically { - newBlock.getBlock().onBlockAdded(world, snap.pos, newBlock); + newBlock.getBlock().onBlockAdded(world, snap.getPos(), newBlock); } - world.markAndNotifyBlock(snap.pos, null, oldBlock, newBlock, updateFlag); + world.markAndNotifyBlock(snap.getPos(), null, oldBlock, newBlock, updateFlag); } - player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1); + player.addStat(StatList.func_188060_a(itemstack.getItem())); } } world.capturedBlockSnapshots.clear(); - return flag; + return ret; } public static boolean onAnvilChange(ContainerRepair container, ItemStack left, ItemStack right, IInventory outputSlot, String name, int baseCost) { AnvilUpdateEvent e = new AnvilUpdateEvent(left, right, name, baseCost); if (MinecraftForge.EVENT_BUS.post(e)) return false; - if (e.output == null) return true; + if (e.getOutput() == null) return true; - outputSlot.setInventorySlotContents(0, e.output); - container.maximumCost = e.cost; - container.materialCost = e.materialCost; + outputSlot.setInventorySlotContents(0, e.getOutput()); + container.maximumCost = e.getCost(); + container.materialCost = e.getMaterialCost(); return false; } @@ -809,7 +807,7 @@ public class ForgeHooks { AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output); MinecraftForge.EVENT_BUS.post(e); - return e.breakChance; + return e.getBreakChance(); } public static boolean onNoteChange(TileEntityNote te, byte old) @@ -861,7 +859,7 @@ public class ForgeHooks stack = stack.getItem().getContainerItem(stack); if (stack != null && stack.isItemStackDamageable() && stack.getMetadata() > stack.getMaxDamage()) { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(craftingPlayer.get(), stack)); + ForgeEventFactory.onPlayerDestroyItem(craftingPlayer.get(), stack, null); return null; } return stack; @@ -869,11 +867,6 @@ public class ForgeHooks return null; } - public static WorldGeneratorBonusChest getBonusChest(Random rand) - { - return new WorldGeneratorBonusChest(ChestGenHooks.getItems(ChestGenHooks.BONUS_CHEST, rand), ChestGenHooks.getCount(ChestGenHooks.BONUS_CHEST, rand)); - } - public static boolean isInsideOfMaterial(Material material, Entity entity, BlockPos pos) { IBlockState state = entity.worldObj.getBlockState(pos); @@ -894,18 +887,18 @@ public class ForgeHooks { filled *= -1; //filled -= 0.11111111F; //Why this is needed.. not sure... - return eyes > (double)(pos.getY() + 1 + (1 - filled)); + return eyes > pos.getY() + 1 + (1 - filled); } else { - return eyes < (double)(pos.getY() + 1 + filled); + return eyes < pos.getY() + 1 + filled; } } public static boolean onPlayerAttackTarget(EntityPlayer player, Entity target) { if (MinecraftForge.EVENT_BUS.post(new AttackEntityEvent(player, target))) return false; - ItemStack stack = player.getCurrentEquippedItem(); + ItemStack stack = player.getHeldItemMainhand(); if (stack != null && stack.getItem().onLeftClickEntity(stack, player, target)) return false; return true; } @@ -925,16 +918,56 @@ public class ForgeHooks return !event.isCanceled(); } - public static MovingObjectPosition rayTraceEyes(EntityLivingBase entity, double length) + public static RayTraceResult rayTraceEyes(EntityLivingBase entity, double length) { - Vec3 startPos = new Vec3(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ); - Vec3 endPos = startPos.add(new Vec3(entity.getLookVec().xCoord * length, entity.getLookVec().yCoord * length, entity.getLookVec().zCoord * length)); + Vec3d startPos = new Vec3d(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ); + Vec3d endPos = startPos.add(new Vec3d(entity.getLookVec().xCoord * length, entity.getLookVec().yCoord * length, entity.getLookVec().zCoord * length)); return entity.worldObj.rayTraceBlocks(startPos, endPos); } - public static Vec3 rayTraceEyeHitVec(EntityLivingBase entity, double length) + public static Vec3d rayTraceEyeHitVec(EntityLivingBase entity, double length) { - MovingObjectPosition movingObjectPosition = rayTraceEyes(entity, length); - return movingObjectPosition == null ? null : movingObjectPosition.hitVec; + RayTraceResult git = rayTraceEyes(entity, length); + return git == null ? null : git.hitVec; } -} \ No newline at end of file + + public static boolean onInteractEntityAt(EntityPlayer player, Entity entity, RayTraceResult ray, ItemStack stack, EnumHand hand) + { + Vec3d vec3d = new Vec3d(ray.hitVec.xCoord - entity.posX, ray.hitVec.yCoord - entity.posY, ray.hitVec.zCoord - entity.posZ); + return onInteractEntityAt(player, entity, vec3d, stack, hand); + } + + public static boolean onInteractEntityAt(EntityPlayer player, Entity entity, Vec3d vec3d, ItemStack stack, EnumHand hand) + { + return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.EntityInteractSpecific(player, hand, stack, entity, vec3d)); + } + + public static boolean onInteractEntity(EntityPlayer player, Entity entity, ItemStack item, EnumHand hand) + { + return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.EntityInteract(player, hand, item, entity)); + } + + public static boolean onItemRightClick(EntityPlayer player, EnumHand hand, ItemStack stack) + { + return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.RightClickItem(player, hand, stack)); + } + + public static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(EntityPlayer player, BlockPos pos, EnumFacing face, Vec3d hitVec) + { + PlayerInteractEvent.LeftClickBlock evt = new PlayerInteractEvent.LeftClickBlock(player, pos, face, hitVec); + MinecraftForge.EVENT_BUS.post(evt); + return evt; + } + + public static PlayerInteractEvent.RightClickBlock onRightClickBlock(EntityPlayer player, EnumHand hand, ItemStack stack, BlockPos pos, EnumFacing face, Vec3d hitVec) + { + PlayerInteractEvent.RightClickBlock evt = new PlayerInteractEvent.RightClickBlock(player, hand, stack, pos, face, hitVec); + MinecraftForge.EVENT_BUS.post(evt); + return evt; + } + + public static void onEmptyClick(EntityPlayer player, EnumHand hand) + { + MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.RightClickEmpty(player, hand)); + } +} diff --git a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java index f1a0f243da..7d5d5ad209 100644 --- a/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java +++ b/src/main/java/net/minecraftforge/common/ForgeInternalHandler.java @@ -1,31 +1,31 @@ package net.minecraftforge.common; -import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.common.eventhandler.EventPriority; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.FakePlayerFactory; -import net.minecraftforge.event.entity.*; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.fml.common.FMLLog; +import net.minecraftforge.fml.common.eventhandler.EventPriority; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ForgeInternalHandler { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onEntityJoinWorld(EntityJoinWorldEvent event) { - if (!event.world.isRemote) + if (!event.getWorld().isRemote) { - ForgeChunkManager.loadEntity(event.entity); + ForgeChunkManager.loadEntity(event.getEntity()); } - Entity entity = event.entity; + Entity entity = event.getEntity(); if (entity.getClass().equals(EntityItem.class)) { - ItemStack stack = entity.getDataWatcher().getWatchableObjectItemStack(10); + ItemStack stack = ((EntityItem)entity).getEntityItem(); if (stack == null) { @@ -47,12 +47,12 @@ public class ForgeInternalHandler if (item.hasCustomEntity(stack)) { - Entity newEntity = item.createEntity(event.world, entity, stack); + Entity newEntity = item.createEntity(event.getWorld(), entity, stack); if (newEntity != null) { entity.setDead(); event.setCanceled(true); - event.world.spawnEntityInWorld(newEntity); + event.getWorld().spawnEntityInWorld(newEntity); } } } @@ -61,20 +61,20 @@ public class ForgeInternalHandler @SubscribeEvent(priority = EventPriority.HIGHEST) public void onDimensionLoad(WorldEvent.Load event) { - ForgeChunkManager.loadWorld(event.world); + ForgeChunkManager.loadWorld(event.getWorld()); } @SubscribeEvent(priority = EventPriority.HIGHEST) public void onDimensionSave(WorldEvent.Save event) { - ForgeChunkManager.saveWorld(event.world); + ForgeChunkManager.saveWorld(event.getWorld()); } @SubscribeEvent(priority = EventPriority.HIGHEST) public void onDimensionUnload(WorldEvent.Unload event) { - ForgeChunkManager.unloadWorld(event.world); - if (event.world instanceof WorldServer) - FakePlayerFactory.unloadWorld((WorldServer)event.world); + ForgeChunkManager.unloadWorld(event.getWorld()); + if (event.getWorld() instanceof WorldServer) + FakePlayerFactory.unloadWorld((WorldServer) event.getWorld()); } } diff --git a/src/main/java/net/minecraftforge/common/ForgeModContainer.java b/src/main/java/net/minecraftforge/common/ForgeModContainer.java index dfe2346f5b..b18562cdf4 100644 --- a/src/main/java/net/minecraftforge/common/ForgeModContainer.java +++ b/src/main/java/net/minecraftforge/common/ForgeModContainer.java @@ -14,6 +14,7 @@ import java.net.URL; import java.security.cert.Certificate; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; @@ -24,6 +25,7 @@ import net.minecraft.world.storage.WorldInfo; import net.minecraftforge.classloading.FMLForgePlugin; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; +import net.minecraftforge.common.model.animation.CapabilityAnimation; import net.minecraftforge.common.network.ForgeNetworkHandler; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.items.CapabilityItemHandler; @@ -73,6 +75,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC public static boolean defaultHasSpawnFuzz = true; public static boolean forgeLightPipelineEnabled = true; public static boolean replaceVanillaBucketModel = true; + public static long java8Reminder = 0; private static Configuration config; private static ForgeModContainer INSTANCE; @@ -148,7 +151,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC Property prop; prop = config.get(CATEGORY_GENERAL, "disableVersionCheck", false); - prop.comment = "Set to true to disable Forge's version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github."; + prop.setComment("Set to true to disable Forge's version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github."); // Language keys are a good idea to implement if you are using config GUIs. This allows you to use a .lang file that will hold the // "pretty" version of the property name as well as allow others to provide their own localizations. // This language key is also used to get the tooltip for a property. The tooltip language key is langKey + ".tooltip". @@ -169,13 +172,13 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC propOrder.add(prop.getName()); prop = config.get(CATEGORY_GENERAL, "sortRecipies", true); - prop.comment = "Set to true to enable the post initialization sorting of crafting recipes using Forge's sorter. May cause desyncing on conflicting recipies. MUST RESTART MINECRAFT IF CHANGED FROM THE CONFIG GUI."; + prop.setComment("Set to true to enable the post initialization sorting of crafting recipes using Forge's sorter. May cause desyncing on conflicting recipes. MUST RESTART MINECRAFT IF CHANGED FROM THE CONFIG GUI."); prop.setLanguageKey("forge.configgui.sortRecipies").setRequiresMcRestart(true); shouldSortRecipies = prop.getBoolean(shouldSortRecipies); propOrder.add(prop.getName()); prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringEntities", false); - prop.comment = "Set this to true to remove any Entity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."; + prop.setComment("Set this to true to remove any Entity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."); prop.setLanguageKey("forge.configgui.removeErroringEntities").setRequiresWorldRestart(true); removeErroringEntities = prop.getBoolean(false); propOrder.add(prop.getName()); @@ -186,7 +189,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC } prop = config.get(Configuration.CATEGORY_GENERAL, "removeErroringTileEntities", false); - prop.comment = "Set this to true to remove any TileEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."; + prop.setComment("Set this to true to remove any TileEntity that throws an error in its update method instead of closing the server and reporting a crash log. BE WARNED THIS COULD SCREW UP EVERYTHING USE SPARINGLY WE ARE NOT RESPONSIBLE FOR DAMAGES."); prop.setLanguageKey("forge.configgui.removeErroringTileEntities").setRequiresWorldRestart(true); removeErroringTileEntities = prop.getBoolean(false); propOrder.add(prop.getName()); @@ -197,17 +200,17 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC } prop = config.get(Configuration.CATEGORY_GENERAL, "disableStitchedFileSaving", true); - prop.comment = "Set this to just disable the texture stitcher from writing the '{name}_{mipmap}.png files to disc. Just a small performance tweak. Default: true"; + prop.setComment("Set this to just disable the texture stitcher from writing the '{name}_{mipmap}.png files to disc. Just a small performance tweak. Default: true"); disableStitchedFileSaving = prop.getBoolean(true); prop = config.get(Configuration.CATEGORY_GENERAL, "fullBoundingBoxLadders", false); - prop.comment = "Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticable differences in mechanics so default is vanilla behavior. Default: false"; + prop.setComment("Set this to true to check the entire entity's collision bounding box for ladders instead of just the block they are in. Causes noticeable differences in mechanics so default is vanilla behavior. Default: false"); prop.setLanguageKey("forge.configgui.fullBoundingBoxLadders").setRequiresWorldRestart(true); fullBoundingBoxLadders = prop.getBoolean(false); propOrder.add(prop.getName()); prop = config.get(Configuration.CATEGORY_GENERAL, "biomeSkyBlendRange", new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 }); - prop.comment = "Control the range of sky blending for colored skies in biomes."; + prop.setComment("Control the range of sky blending for colored skies in biomes."); prop.setLanguageKey("forge.configgui.biomeSkyBlendRange"); blendRanges = prop.getIntList(); propOrder.add(prop.getName()); @@ -225,7 +228,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC propOrder.add(prop.getName()); prop = config.get(Configuration.CATEGORY_GENERAL, "defaultSpawnFuzz", 20, - "The spawn fuzz when a player respawns in the world, this is controlable by WorldType, this config option is for the default overworld.", + "The spawn fuzz when a player respawns in the world, this is controllable by WorldType, this config option is for the default overworld.", 1, Integer.MAX_VALUE); prop.setLanguageKey("forge.configgui.spawnfuzz").setRequiresWorldRestart(false); defaultSpawnFuzz = prop.getInt(20); @@ -258,6 +261,11 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC replaceVanillaBucketModel = prop.getBoolean(Boolean.FALSE); propOrder.add(prop.getName()); + prop = config.get(Configuration.CATEGORY_CLIENT, "java8Reminder", java8Reminder, + "The timestamp of the last reminder to update to Java 8 in number of milliseconds since January 1, 1970, 00:00:00 GMT. Nag will show only once every 24 hours. To disable it set this to some really high number."); + java8Reminder = prop.getLong(java8Reminder); + propOrder.add(prop.getName()); + config.setCategoryPropertyOrder(CATEGORY_CLIENT, propOrder); if (config.hasChanged()) @@ -266,6 +274,13 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC } } + public static void updateNag() + { + Property prop = config.get(Configuration.CATEGORY_CLIENT, "java8Reminder", java8Reminder); + prop.set((new Date()).getTime()); + config.save(); + } + /** * By subscribing to the OnConfigChangedEvent we are able to execute code when our config screens are closed. * This implementation uses the optional configID string to handle multiple Configurations using one event handler. @@ -273,18 +288,18 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC @SubscribeEvent public void onConfigChanged(OnConfigChangedEvent event) { - if (getMetadata().modId.equals(event.modID) && !event.isWorldRunning) + if (getMetadata().modId.equals(event.getModID()) && !event.isWorldRunning()) { - if (Configuration.CATEGORY_GENERAL.equals(event.configID)) + if (Configuration.CATEGORY_GENERAL.equals(event.getConfigID())) { syncConfig(false); } - else if ("chunkLoader".equals(event.configID)) + else if ("chunkLoader".equals(event.getConfigID())) { ForgeChunkManager.syncConfigDefaults(); ForgeChunkManager.loadConfiguration(); } - else if (VERSION_CHECK_CAT.equals(event.configID)) + else if (VERSION_CHECK_CAT.equals(event.getConfigID())) { syncConfig(false); } @@ -315,6 +330,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC public void preInit(FMLPreInitializationEvent evt) { CapabilityItemHandler.register(); + CapabilityAnimation.register(); MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER); ForgeChunkManager.captureConfig(evt.getModConfigurationDirectory()); MinecraftForge.EVENT_BUS.register(this); @@ -354,7 +370,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC @Subscribe public void serverStarting(FMLServerStartingEvent evt) { - evt.registerServerCommand(new ForgeCommand(evt.getServer())); + evt.registerServerCommand(new ForgeCommand()); } @Override public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) diff --git a/src/main/java/net/minecraftforge/common/ForgeVersion.java b/src/main/java/net/minecraftforge/common/ForgeVersion.java index 35ee2385d3..72d2792ef0 100644 --- a/src/main/java/net/minecraftforge/common/ForgeVersion.java +++ b/src/main/java/net/minecraftforge/common/ForgeVersion.java @@ -31,17 +31,17 @@ import net.minecraftforge.fml.common.versioning.ComparableVersion; public class ForgeVersion { //This number is incremented every time we remove deprecated code/major API changes, never reset - public static final int majorVersion = 11; + public static final int majorVersion = 12; //This number is incremented every minecraft release, never reset - public static final int minorVersion = 15; + public static final int minorVersion = 16; //This number is incremented every time a interface changes or new major feature is added, and reset every Minecraft version - public static final int revisionVersion = 1; + public static final int revisionVersion = 0; //This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code. public static final int buildVersion = 0; // This is the minecraft version we're building for - used in various places in Forge/FML code - public static final String mcVersion = "1.8.9"; + public static final String mcVersion = "1.9"; // This is the MCP data version we're using - public static final String mcpVersion = "9.19"; + public static final String mcpVersion = "9.23"; @SuppressWarnings("unused") private static Status status = PENDING; @SuppressWarnings("unused") @@ -85,13 +85,54 @@ public class ForgeVersion public static enum Status { - PENDING, - FAILED, - UP_TO_DATE, - OUTDATED, - AHEAD, - BETA, - BETA_OUTDATED + PENDING(), + FAILED(), + UP_TO_DATE(), + OUTDATED(3, true), + AHEAD(), + BETA(), + BETA_OUTDATED(6, true); + + final int sheetOffset; + final boolean draw, animated; + + Status() + { + this(0, false, false); + } + + Status(int sheetOffset) + { + this(sheetOffset, true, false); + } + + Status(int sheetOffset, boolean animated) + { + this(sheetOffset, true, animated); + } + + Status(int sheetOffset, boolean draw, boolean animated) + { + this.sheetOffset = sheetOffset; + this.draw = draw; + this.animated = animated; + } + + public int getSheetOffset() + { + return sheetOffset; + } + + public boolean shouldDraw() + { + return draw; + } + + public boolean isAnimated() + { + return animated; + } + } public static class CheckResult @@ -119,7 +160,7 @@ public class ForgeVersion { if (!ForgeModContainer.getConfig().get(ForgeModContainer.VERSION_CHECK_CAT, "Global", true).getBoolean()) { - FMLLog.log("ForgeVersionCheck", Level.INFO, "Global Forge version check system disabeld, no futher processing."); + FMLLog.log("ForgeVersionCheck", Level.INFO, "Global Forge version check system disabled, no further processing."); return; } @@ -239,16 +280,12 @@ public class ForgeVersion } // Gather a list of mods that have opted in to this update system by providing a URL. - // Small hack needed to support a interface change until we force a recompile. public static Map gatherMods() { Map ret = new HashMap(); for (ModContainer mod : Loader.instance().getActiveModList()) { - URL url = null; - try { - url = mod.getUpdateUrl(); - } catch (AbstractMethodError abs) { } //TODO: Remove this in 1.8.8+? + URL url = mod.getUpdateUrl(); if (url != null) ret.put(mod, url); } diff --git a/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java b/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java deleted file mode 100644 index 87ea4da8ce..0000000000 --- a/src/main/java/net/minecraftforge/common/IExtendedEntityProperties.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.minecraftforge.common; - -import net.minecraft.entity.Entity; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - -/** - * Allows for custom entity data and logic to be hooked to existing entity classes. - * - * @author cpw, mithion - * - */ -public interface IExtendedEntityProperties { - /** - * Called when the entity that this class is attached to is saved. - * Any custom entity data that needs saving should be saved here. - * @param compound The compound to save to. - */ - public void saveNBTData(NBTTagCompound compound); - - /** - * Called when the entity that this class is attached to is loaded. - * In order to hook into this, you will need to subscribe to the EntityConstructing event. - * Otherwise, you will need to initialize manually. - * @param compound The compound to load from. - */ - public void loadNBTData(NBTTagCompound compound); - - /** - * Used to initialize the extended properties with the entity that this is attached to, as well - * as the world object. - * Called automatically if you register with the EntityConstructing event. - * May be called multiple times if the extended properties is moved over to a new entity. - * Such as when a player switches dimension {Minecraft re-creates the player entity} - * @param entity The entity that this extended properties is attached to - * @param world The world in which the entity exists - */ - public void init(Entity entity, World world); -} diff --git a/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java b/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java index 2346273d02..35b99d39af 100644 --- a/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java +++ b/src/main/java/net/minecraftforge/common/IMinecartCollisionHandler.java @@ -1,6 +1,6 @@ package net.minecraftforge.common; -import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityMinecart; @@ -14,7 +14,7 @@ public interface IMinecartCollisionHandler { /** - * This basically replaces the function of the same name in EnityMinecart. + * This basically replaces the function of the same name in EntityMinecart. * Code in IMinecartHooks.applyEntityCollisionHook is still run. * @param cart The cart that called the collision. * @param other The object it collided with. diff --git a/src/main/java/net/minecraftforge/common/IPlantable.java b/src/main/java/net/minecraftforge/common/IPlantable.java index d3e40d451d..e8bfabbfba 100644 --- a/src/main/java/net/minecraftforge/common/IPlantable.java +++ b/src/main/java/net/minecraftforge/common/IPlantable.java @@ -1,7 +1,7 @@ package net.minecraftforge.common; import net.minecraft.block.state.IBlockState; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; public interface IPlantable diff --git a/src/main/java/net/minecraftforge/common/IShearable.java b/src/main/java/net/minecraftforge/common/IShearable.java index acd0be858d..429ed9ed58 100644 --- a/src/main/java/net/minecraftforge/common/IShearable.java +++ b/src/main/java/net/minecraftforge/common/IShearable.java @@ -3,7 +3,7 @@ package net.minecraftforge.common; import java.util.List; import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; /** diff --git a/src/main/java/net/minecraftforge/common/ISpecialArmor.java b/src/main/java/net/minecraftforge/common/ISpecialArmor.java index 27bf880369..a6e08d6050 100644 --- a/src/main/java/net/minecraftforge/common/ISpecialArmor.java +++ b/src/main/java/net/minecraftforge/common/ISpecialArmor.java @@ -23,6 +23,7 @@ import net.minecraft.item.ItemStack; */ public interface ISpecialArmor { + //TODO: Change 'int slot' to EnumArmorType /** * Retrieves the modifiers to be used when calculating armor damage. * @@ -71,7 +72,7 @@ public interface ISpecialArmor public int AbsorbMax = Integer.MAX_VALUE; public double AbsorbRatio = 0; public int Slot = 0; - private static final boolean DEBUG = false; //Only enable this if you wish to be spamed with debugging information. + private static final boolean DEBUG = false; //Only enable this if you wish to be spammed with debugging information. //Left it in because I figured it'd be useful for modders developing custom armor. public ArmorProperties(int priority, double ratio, int max) diff --git a/src/main/java/net/minecraftforge/common/MinecraftForge.java b/src/main/java/net/minecraftforge/common/MinecraftForge.java index 625e29a887..c386dcd8e0 100644 --- a/src/main/java/net/minecraftforge/common/MinecraftForge.java +++ b/src/main/java/net/minecraftforge/common/MinecraftForge.java @@ -38,10 +38,16 @@ public class MinecraftForge * @param seed The item to drop as a seed. * @param weight The relative probability of the seeds, * where wheat seeds are 10. + * + * Note: These functions may be going away soon, we're looking into loot tables.... */ public static void addGrassSeed(ItemStack seed, int weight) { - ForgeHooks.seedList.add(new SeedEntry(seed, weight)); + addGrassSeed(new SeedEntry(seed, weight)); + } + public static void addGrassSeed(SeedEntry seed) + { + ForgeHooks.seedList.add(seed); } /** diff --git a/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java b/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java index 50064f3627..d71840509b 100644 --- a/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java +++ b/src/main/java/net/minecraftforge/common/WorldSpecificSaveHandler.java @@ -3,6 +3,7 @@ package net.minecraftforge.common; import java.io.File; import java.io.IOException; +import net.minecraft.world.gen.structure.template.TemplateManager; import org.apache.logging.log4j.Level; import com.google.common.io.Files; @@ -38,34 +39,52 @@ public class WorldSpecificSaveHandler implements ISaveHandler @Override public void saveWorldInfo(WorldInfo var1){ parent.saveWorldInfo(var1); } @Override public IPlayerFileData getPlayerNBTManager() { return parent.getPlayerNBTManager(); } @Override public void flush() { parent.flush(); } - @Override public String getWorldDirectoryName() { return parent.getWorldDirectoryName(); } @Override public File getWorldDirectory() { return parent.getWorldDirectory(); } @Override public File getMapFileFromName(String name) { - if (dataDir == null) //Delayed down here do that world has time to be initalized first. + if (dataDir == null) //Delayed down here do that world has time to be initialized first. { dataDir = new File(world.getChunkSaveLocation(), "data"); dataDir.mkdirs(); } File file = new File(dataDir, name + ".dat"); - if (!file.exists() && name.equalsIgnoreCase("FORTRESS") && world.provider.getDimensionId() == -1) //Only copy over the fortress.dat for the vanilla nether. + if (!file.exists()) { - File parentFile = parent.getMapFileFromName(name); - if (parentFile.exists()) + switch (world.provider.getDimension()) { - try - { - Files.copy(parentFile, file); - } - catch (IOException e) - { - FMLLog.log(Level.ERROR, e, "A critical error occured copying fortress.dat to world specific dat folder - new file will be created."); - } + case -1: + if (name.equalsIgnoreCase("FORTRESS")) copyFile(name, file); + break; + case 1: + if (name.equalsIgnoreCase("VILLAGES_END")) copyFile(name, file); + break; } } return file; } + private void copyFile(String name, File to) + { + File parentFile = parent.getMapFileFromName(name); + if (parentFile.exists()) + { + try + { + Files.copy(parentFile, to); + } + catch (IOException e) + { + FMLLog.log(Level.ERROR, e, "A critical error occurred copying %s to world specific dat folder - new file will be created.", parentFile.getName()); + } + } + } + + @Override + public TemplateManager getStructureTemplateManager() + { + return parent.getStructureTemplateManager(); + } + } diff --git a/src/main/java/net/minecraftforge/client/model/animation/Event.java b/src/main/java/net/minecraftforge/common/animation/Event.java similarity index 94% rename from src/main/java/net/minecraftforge/client/model/animation/Event.java rename to src/main/java/net/minecraftforge/common/animation/Event.java index 96135d2d3f..aabe3e6300 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/Event.java +++ b/src/main/java/net/minecraftforge/common/animation/Event.java @@ -1,4 +1,4 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.animation; import com.google.common.base.Objects; diff --git a/src/main/java/net/minecraftforge/client/model/animation/IEventHandler.java b/src/main/java/net/minecraftforge/common/animation/IEventHandler.java similarity index 75% rename from src/main/java/net/minecraftforge/client/model/animation/IEventHandler.java rename to src/main/java/net/minecraftforge/common/animation/IEventHandler.java index 81c7f38927..1133737384 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/IEventHandler.java +++ b/src/main/java/net/minecraftforge/common/animation/IEventHandler.java @@ -1,4 +1,5 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.animation; + /** diff --git a/src/main/java/net/minecraftforge/client/model/animation/ITimeValue.java b/src/main/java/net/minecraftforge/common/animation/ITimeValue.java similarity index 87% rename from src/main/java/net/minecraftforge/client/model/animation/ITimeValue.java rename to src/main/java/net/minecraftforge/common/animation/ITimeValue.java index 88770b1250..dfb7fc8ec1 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/ITimeValue.java +++ b/src/main/java/net/minecraftforge/common/animation/ITimeValue.java @@ -1,4 +1,4 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.animation; /** * Time-varying value associated with the animation. diff --git a/src/main/java/net/minecraftforge/client/model/animation/TimeValues.java b/src/main/java/net/minecraftforge/common/animation/TimeValues.java similarity index 98% rename from src/main/java/net/minecraftforge/client/model/animation/TimeValues.java rename to src/main/java/net/minecraftforge/common/animation/TimeValues.java index a612685787..74811384be 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/TimeValues.java +++ b/src/main/java/net/minecraftforge/common/animation/TimeValues.java @@ -1,4 +1,4 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.animation; import java.io.IOException; import java.util.regex.Pattern; @@ -23,7 +23,7 @@ public final class TimeValues { public static enum IdentityValue implements ITimeValue, IStringSerializable { - instance; + INSTANCE; public float apply(float input) { @@ -352,7 +352,7 @@ public final class TimeValues String string = in.nextString(); if(string.equals("#identity")) { - return IdentityValue.instance; + return IdentityValue.INSTANCE; } if(!string.startsWith("#")) { diff --git a/src/main/java/net/minecraftforge/common/brewing/AbstractBrewingRecipe.java b/src/main/java/net/minecraftforge/common/brewing/AbstractBrewingRecipe.java index ceb3dd15af..278abffbbb 100644 --- a/src/main/java/net/minecraftforge/common/brewing/AbstractBrewingRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/AbstractBrewingRecipe.java @@ -5,9 +5,9 @@ import net.minecraftforge.oredict.OreDictionary; public abstract class AbstractBrewingRecipe implements IBrewingRecipe { - public final ItemStack input; - public final T ingredient; - public final ItemStack output; + private final ItemStack input; + private final T ingredient; + private final ItemStack output; protected AbstractBrewingRecipe(ItemStack input, T ingredient, ItemStack output) { @@ -15,12 +15,12 @@ public abstract class AbstractBrewingRecipe implements IBrewingRecipe { this.ingredient = ingredient; this.output = output; - if (this.input == null || this.ingredient == null || this.output == null) + if (this.getInput() == null || this.getIngredient() == null || this.getOutput() == null) { throw new IllegalArgumentException("A brewing recipe cannot have a null parameter."); } - if (this.input.getMaxStackSize() != 1) + if (this.getInput().getMaxStackSize() != 1) { throw new IllegalArgumentException("Inputs must have a max size of 1 just like water bottles. Brewing Stands override the input with the output when the brewing is done, items that stack would end up getting lost."); } @@ -29,12 +29,27 @@ public abstract class AbstractBrewingRecipe implements IBrewingRecipe { @Override public boolean isInput(ItemStack stack) { - return OreDictionary.itemMatches(this.input, stack, false); + return OreDictionary.itemMatches(this.getInput(), stack, false); } @Override public ItemStack getOutput(ItemStack input, ItemStack ingredient) { - return isInput(input) && isIngredient(ingredient) ? ItemStack.copyItemStack(output) : null; + return isInput(input) && isIngredient(ingredient) ? ItemStack.copyItemStack(getOutput()) : null; + } + + public ItemStack getInput() + { + return input; + } + + public T getIngredient() + { + return ingredient; + } + + public ItemStack getOutput() + { + return output; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/brewing/BrewingOreRecipe.java b/src/main/java/net/minecraftforge/common/brewing/BrewingOreRecipe.java index 8ac625cb94..57bd51128d 100644 --- a/src/main/java/net/minecraftforge/common/brewing/BrewingOreRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/BrewingOreRecipe.java @@ -19,7 +19,7 @@ public class BrewingOreRecipe extends AbstractBrewingRecipe> { @Override public boolean isIngredient(ItemStack stack) { - for (ItemStack target : this.ingredient) + for (ItemStack target : this.getIngredient()) { if (OreDictionary.itemMatches(target, stack, false)) { diff --git a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java index e2b6ce9068..1ce78812ad 100644 --- a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipe.java @@ -13,6 +13,6 @@ public class BrewingRecipe extends AbstractBrewingRecipe { @Override public boolean isIngredient(ItemStack stack) { - return OreDictionary.itemMatches(this.ingredient, stack, false); + return OreDictionary.itemMatches(this.getIngredient(), stack, false); } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java index 07ea61ce77..7905ff03a9 100644 --- a/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java +++ b/src/main/java/net/minecraftforge/common/brewing/BrewingRecipeRegistry.java @@ -17,7 +17,7 @@ public class BrewingRecipeRegistry { /** * Adds a recipe to the registry. Due to the nature of the brewing stand * inputs that stack (a.k.a max stack size > 1) are not allowed. - * + * * @param input * The ItemStack that goes in same slots as the water bottles * would. @@ -36,7 +36,7 @@ public class BrewingRecipeRegistry { /** * Adds a recipe to the registry. Due to the nature of the brewing stand * inputs that stack (a.k.a max stack size > 1) are not allowed. - * + * * @param input * The ItemStack that goes in same slots as the water bottles * would. @@ -84,7 +84,7 @@ public class BrewingRecipeRegistry { /** * Returns true if the passed input and ingredient have an output */ - public static boolean hasOuput(ItemStack input, ItemStack ingredient) + public static boolean hasOutput(ItemStack input, ItemStack ingredient) { return getOutput(input, ingredient) != null; } @@ -100,7 +100,7 @@ public class BrewingRecipeRegistry { for (int i : inputIndexes) { - if (hasOuput(inputs[i], ingredient)) + if (hasOutput(inputs[i], ingredient)) { return true; } @@ -168,4 +168,4 @@ public class BrewingRecipeRegistry { { return Collections.unmodifiableList(recipes); } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraftforge/common/brewing/VanillaBrewingRecipe.java b/src/main/java/net/minecraftforge/common/brewing/VanillaBrewingRecipe.java index bf00b6fe33..f11f4584fa 100644 --- a/src/main/java/net/minecraftforge/common/brewing/VanillaBrewingRecipe.java +++ b/src/main/java/net/minecraftforge/common/brewing/VanillaBrewingRecipe.java @@ -1,11 +1,8 @@ package net.minecraftforge.common.brewing; -import java.util.List; - import net.minecraft.init.Items; -import net.minecraft.item.ItemPotion; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionHelper; /** @@ -21,7 +18,8 @@ public class VanillaBrewingRecipe implements IBrewingRecipe { @Override public boolean isInput(ItemStack stack) { - return stack.getItem() instanceof ItemPotion || stack.getItem() == Items.glass_bottle; + Item item = stack.getItem(); + return item == Items.potionitem || item == Items.splash_potion || item == Items.lingering_potion || item == Items.glass_bottle; } /** @@ -30,7 +28,7 @@ public class VanillaBrewingRecipe implements IBrewingRecipe { @Override public boolean isIngredient(ItemStack stack) { - return stack.getItem().isPotionIngredient(stack); + return PotionHelper.isReagent(stack); } /** @@ -41,34 +39,14 @@ public class VanillaBrewingRecipe implements IBrewingRecipe { @Override public ItemStack getOutput(ItemStack input, ItemStack ingredient) { - if (ingredient != null && input != null && input.getItem() instanceof ItemPotion && isIngredient(ingredient)) + if (ingredient != null && input != null && isIngredient(ingredient)) { - int inputMeta = input.getMetadata(); - int outputMeta = PotionHelper.applyIngredient(inputMeta, ingredient.getItem().getPotionEffect(ingredient)); - if (inputMeta == outputMeta) + ItemStack result = PotionHelper.doReaction(ingredient, input); + if (result != input) { - return null; - } - - List oldEffects = Items.potionitem.getEffects(inputMeta); - List newEffects = Items.potionitem.getEffects(outputMeta); - - boolean hasResult = false; - if ((inputMeta <= 0 || oldEffects != newEffects) && (oldEffects == null || !oldEffects.equals(newEffects) && newEffects != null)) - { - hasResult = true; - } - else if (!ItemPotion.isSplash(inputMeta) && ItemPotion.isSplash(outputMeta)) - { - hasResult = true; - } - - if (hasResult) - { - ItemStack output = input.copy(); - output.setItemDamage(outputMeta); - return output; + return result; } + return null; } return null; diff --git a/src/main/java/net/minecraftforge/common/capabilities/Capability.java b/src/main/java/net/minecraftforge/common/capabilities/Capability.java index 94627012a0..0e3a0fb5c2 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/Capability.java +++ b/src/main/java/net/minecraftforge/common/capabilities/Capability.java @@ -65,10 +65,29 @@ public class Capability * the fully qualified class name for the target interface. */ public String getName() { return name; } + /** * @return An instance of the default storage handler. You can safely use this store your default implementation in NBT. */ public IStorage getStorage() { return storage; } + + /** + * Quick access to the IStorage's readNBT. + * See {@link IStorage#readNBT(Capability, Object, EnumFacing, NBTBase)} for documentation. + */ + public void readNBT(T instance, EnumFacing side, NBTBase nbt) + { + storage.readNBT(this, instance, side, nbt); + } + + /** + * Quick access to the IStorage's writeNBT. + * See {@link IStorage#writeNBT(Capability, Object, EnumFacing)} for documentation. + */ + public NBTBase writeNBT(T instance, EnumFacing side) + { + return storage.writeNBT(this, instance, side); + } /** * A NEW instance of the default implementation. @@ -92,6 +111,17 @@ public class Capability return null; } + /** + * Use this inside ICapabilityProvider.getCapability to avoid unchecked cast warnings. + * Example: return SOME_CAPABILITY.cast(instance); + * Use with caution; + */ + @SuppressWarnings("unchecked") + public R cast(T instance) + { + return (R)instance; + } + // INTERNAL private final String name; private final IStorage storage; diff --git a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java index 5e319e1734..9c9f08ade8 100644 --- a/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java +++ b/src/main/java/net/minecraftforge/common/capabilities/CapabilityManager.java @@ -42,7 +42,7 @@ public enum CapabilityManager public T call() throws Exception { try { - return (T)implementation.newInstance(); + return implementation.newInstance(); } catch (InstantiationException e) { Throwables.propagate(e); } catch (IllegalAccessException e) { diff --git a/src/main/java/net/minecraftforge/common/chunkio/ChunkIOExecutor.java b/src/main/java/net/minecraftforge/common/chunkio/ChunkIOExecutor.java index e4cda1d766..3b8fccbf27 100644 --- a/src/main/java/net/minecraftforge/common/chunkio/ChunkIOExecutor.java +++ b/src/main/java/net/minecraftforge/common/chunkio/ChunkIOExecutor.java @@ -1,32 +1,130 @@ package net.minecraftforge.common.chunkio; -import net.minecraftforge.common.util.AsynchronousExecutor; +import java.util.Iterator; +import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; -public class ChunkIOExecutor { +import com.google.common.collect.Maps; + +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.storage.AnvilChunkLoader; +import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraftforge.fml.common.FMLLog; + +public class ChunkIOExecutor +{ static final int BASE_THREADS = 1; static final int PLAYERS_PER_THREAD = 50; - private static final AsynchronousExecutor instance = new AsynchronousExecutor(new ChunkIOProvider(), BASE_THREADS); + private static final Map tasks = Maps.newConcurrentMap(); + private static final ThreadPoolExecutor pool = new ThreadPoolExecutor(BASE_THREADS, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, + new LinkedBlockingQueue(), + new ThreadFactory() + { + private AtomicInteger count = new AtomicInteger(1); + @Override + public Thread newThread(Runnable r) + { + Thread thread = new Thread(r, "Chunk I/O Executor Thread-" + count.getAndIncrement()); + thread.setDaemon(true); + return thread; + } + } + ); - public static net.minecraft.world.chunk.Chunk syncChunkLoad(net.minecraft.world.World world, net.minecraft.world.chunk.storage.AnvilChunkLoader loader, net.minecraft.world.gen.ChunkProviderServer provider, int x, int z) { - return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider)); + //Load the chunk completely in this thread. Dequeue as needed... + public static Chunk syncChunkLoad(World world, AnvilChunkLoader loader, ChunkProviderServer provider, int x, int z) + { + QueuedChunk key = new QueuedChunk(x, z, loader, world, provider); + ChunkIOProvider task = tasks.get(key); + if (task != null) + { + if (!pool.remove(task) && !task.runFinished()) // If it wasn't in the pool, and run hasn't finished, then wait for the async thread. + { + synchronized(task) + { + try + { + task.wait(); + } + catch (InterruptedException e) + { + e.printStackTrace(); // Something happened? Log it? + } + } + } + } + else + { + task = new ChunkIOProvider(key); + task.run(); + } + task.syncCallback(); + return task.getChunk(); } - public static void queueChunkLoad(net.minecraft.world.World world, net.minecraft.world.chunk.storage.AnvilChunkLoader loader, net.minecraft.world.gen.ChunkProviderServer provider, int x, int z, Runnable runnable) { - instance.add(new QueuedChunk(x, z, loader, world, provider), runnable); + //Queue the chunk to be loaded, and call the runnable when finished + public static void queueChunkLoad(World world, AnvilChunkLoader loader, ChunkProviderServer provider, int x, int z, Runnable runnable) + { + QueuedChunk key = new QueuedChunk(x, z, loader, world, provider); + ChunkIOProvider task = tasks.get(key); + if (task == null) + { + task = new ChunkIOProvider(key); + task.addCallback(runnable); // Add before calling execute for thread safety + tasks.put(key, task); + pool.execute(task); + } + else + { + task.addCallback(runnable); + } } // Abuses the fact that hashCode and equals for QueuedChunk only use world and coords - public static void dropQueuedChunkLoad(net.minecraft.world.World world, int x, int z, Runnable runnable) { - instance.drop(new QueuedChunk(x, z, null, world, null), runnable); + // Remove the chunk from the queue if it's in the list. + public static void dropQueuedChunkLoad(World world, int x, int z, Runnable runnable) + { + QueuedChunk key = new QueuedChunk(x, z, null, world, null); + ChunkIOProvider task = tasks.get(key); + if (task == null) + { + FMLLog.warning("Attempted to dequeue chunk that wasn't queued? %d @ (%d, %d)", world.provider.getDimension(), x, z); + return; + } + + task.removeCallback(runnable); + + if (!task.hasCallback()) + { + tasks.remove(key); + pool.remove(task); + } } - public static void adjustPoolSize(int players) { + public static void adjustPoolSize(int players) + { int size = Math.max(BASE_THREADS, (int) Math.ceil(players / PLAYERS_PER_THREAD)); - instance.setActiveThreads(size); + pool.setCorePoolSize(size); } - public static void tick() { - instance.finishActive(); + public static void tick() + { + Iterator itr = tasks.values().iterator(); + while (itr.hasNext()) + { + ChunkIOProvider task = itr.next(); + if (task.runFinished() && task.hasCallback()) + { + task.syncCallback(); + } + itr.remove(); + } } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/chunkio/ChunkIOProvider.java b/src/main/java/net/minecraftforge/common/chunkio/ChunkIOProvider.java index 8e7c904fdb..b76a7cfd67 100644 --- a/src/main/java/net/minecraftforge/common/chunkio/ChunkIOProvider.java +++ b/src/main/java/net/minecraftforge/common/chunkio/ChunkIOProvider.java @@ -1,64 +1,113 @@ package net.minecraftforge.common.chunkio; - import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.storage.AnvilChunkLoader; +import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.AsynchronousExecutor; import net.minecraftforge.event.world.ChunkDataEvent; import java.io.IOException; -import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentLinkedQueue; -class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider { - private final AtomicInteger threadNumber = new AtomicInteger(1); +class ChunkIOProvider implements Runnable +{ + private QueuedChunk chunkInfo; + private Chunk chunk; + private NBTTagCompound nbt; + private ConcurrentLinkedQueue callbacks = new ConcurrentLinkedQueue(); + private boolean ran = false; - // async stuff - public net.minecraft.world.chunk.Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException { - net.minecraft.world.chunk.storage.AnvilChunkLoader loader = queuedChunk.loader; - Object[] data = null; - try { - data = loader.loadChunk__Async(queuedChunk.world, queuedChunk.x, queuedChunk.z); - } catch (IOException e) { - e.printStackTrace(); + ChunkIOProvider(QueuedChunk chunk) + { + this.chunkInfo = chunk; + } + + public void addCallback(Runnable callback) + { + this.callbacks.add(callback); + } + public void removeCallback(Runnable callback) + { + this.callbacks.remove(callback); + } + + @Override + public void run() // async stuff + { + synchronized(this) + { + AnvilChunkLoader loader = chunkInfo.loader; + Object[] data = null; + try + { + data = loader.loadChunk__Async(chunkInfo.world, chunkInfo.x, chunkInfo.z); + } + catch (IOException e) + { + e.printStackTrace(); + } + + if (data != null) + { + this.nbt = (NBTTagCompound)data[1]; + this.chunk = (Chunk)data[0]; + } + + this.ran = true; + this.notifyAll(); } - - if (data != null) { - queuedChunk.compound = (net.minecraft.nbt.NBTTagCompound) data[1]; - return (net.minecraft.world.chunk.Chunk) data[0]; - } - - return null; } // sync stuff - public void callStage2(QueuedChunk queuedChunk, net.minecraft.world.chunk.Chunk chunk) throws RuntimeException { - if(chunk == null) { + public void syncCallback() + { + ChunkProviderServer provider = this.chunkInfo.provider; + if (chunk == null) + { // If the chunk loading failed just do it synchronously (may generate) - queuedChunk.provider.originalLoadChunk(queuedChunk.x, queuedChunk.z); + provider.originalLoadChunk(this.chunkInfo.x, this.chunkInfo.z); return; } - queuedChunk.loader.loadEntities(queuedChunk.world, queuedChunk.compound.getCompoundTag("Level"), chunk); - MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(chunk, queuedChunk.compound)); // Don't call ChunkDataEvent.Load async - chunk.setLastSaveTime(queuedChunk.provider.worldObj.getTotalWorldTime()); - queuedChunk.provider.id2ChunkMap.add(ChunkCoordIntPair.chunkXZ2Int(queuedChunk.x, queuedChunk.z), chunk); - queuedChunk.provider.loadedChunks.add(chunk); - chunk.onChunkLoad(); + // Load Entities + this.chunkInfo.loader.loadEntities(this.chunkInfo.world, this.nbt.getCompoundTag("Level"), this.chunk); - if (queuedChunk.provider.serverChunkGenerator != null) { - queuedChunk.provider.serverChunkGenerator.recreateStructures(chunk, queuedChunk.x, queuedChunk.z); + MinecraftForge.EVENT_BUS.post(new ChunkDataEvent.Load(this.chunk, this.nbt)); // Don't call ChunkDataEvent.Load async + + this.chunk.setLastSaveTime(provider.worldObj.getTotalWorldTime()); + provider.id2ChunkMap.add(ChunkCoordIntPair.chunkXZ2Int(this.chunkInfo.x, this.chunkInfo.z), this.chunk); + provider.loadedChunks.add(this.chunk); + this.chunk.onChunkLoad(); + + if (provider.chunkGenerator != null) + { + provider.chunkGenerator.recreateStructures(this.chunk, this.chunkInfo.x, this.chunkInfo.z); } - chunk.populateChunk(queuedChunk.provider, queuedChunk.provider, queuedChunk.x, queuedChunk.z); + this.chunk.populateChunk(provider, provider.chunkGenerator); + + for (Runnable r : this.callbacks) + { + r.run(); + } + + this.callbacks.clear(); } - public void callStage3(QueuedChunk queuedChunk, net.minecraft.world.chunk.Chunk chunk, Runnable runnable) throws RuntimeException { - runnable.run(); + public Chunk getChunk() + { + return this.chunk; } - public Thread newThread(Runnable runnable) { - Thread thread = new Thread(runnable, "Chunk I/O Executor Thread-" + threadNumber.getAndIncrement()); - thread.setDaemon(true); - return thread; + public boolean runFinished() + { + return this.ran; + } + + public boolean hasCallback() + { + return this.callbacks.size() > 0; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/chunkio/QueuedChunk.java b/src/main/java/net/minecraftforge/common/chunkio/QueuedChunk.java index f093b996bc..d813242e64 100644 --- a/src/main/java/net/minecraftforge/common/chunkio/QueuedChunk.java +++ b/src/main/java/net/minecraftforge/common/chunkio/QueuedChunk.java @@ -7,7 +7,6 @@ class QueuedChunk { final net.minecraft.world.chunk.storage.AnvilChunkLoader loader; final net.minecraft.world.World world; final net.minecraft.world.gen.ChunkProviderServer provider; - net.minecraft.nbt.NBTTagCompound compound; public QueuedChunk(int x, int z, net.minecraft.world.chunk.storage.AnvilChunkLoader loader, net.minecraft.world.World world, net.minecraft.world.gen.ChunkProviderServer provider) { this.x = x; @@ -43,7 +42,7 @@ class QueuedChunk { result.append(" z: " + z + NEW_LINE); result.append(" loader: " + loader + NEW_LINE ); result.append(" world: " + world.getWorldInfo().getWorldName() + NEW_LINE); - result.append(" dimension: " + world.provider.getDimensionId() + NEW_LINE); + result.append(" dimension: " + world.provider.getDimension() + NEW_LINE); result.append(" provider: " + world.provider.getClass().getName() + NEW_LINE); result.append("}"); diff --git a/src/main/java/net/minecraftforge/common/config/ConfigCategory.java b/src/main/java/net/minecraftforge/common/config/ConfigCategory.java index f90938a10d..a98b194afd 100644 --- a/src/main/java/net/minecraftforge/common/config/ConfigCategory.java +++ b/src/main/java/net/minecraftforge/common/config/ConfigCategory.java @@ -286,7 +286,7 @@ public class ConfigCategory implements Map { Property prop = props[x]; - if (prop.comment != null && !prop.comment.isEmpty()) + if (prop.getComment() != null && !prop.getComment().isEmpty()) { if (x != 0) { @@ -294,7 +294,7 @@ public class ConfigCategory implements Map } Splitter splitter = Splitter.onPattern("\r?\n"); - for (String commentLine : splitter.split(prop.comment)) + for (String commentLine : splitter.split(prop.getComment())) { write(out, pad1, "# ", commentLine); } diff --git a/src/main/java/net/minecraftforge/common/config/ConfigElement.java b/src/main/java/net/minecraftforge/common/config/ConfigElement.java index 77b4155ff8..d09689d05d 100644 --- a/src/main/java/net/minecraftforge/common/config/ConfigElement.java +++ b/src/main/java/net/minecraftforge/common/config/ConfigElement.java @@ -23,12 +23,12 @@ public class ConfigElement implements IConfigElement private Property prop; private Property.Type type; private boolean isProperty; - private ConfigCategory ctgy; + private ConfigCategory category; private boolean categoriesFirst = true; - public ConfigElement(ConfigCategory ctgy) + public ConfigElement(ConfigCategory category) { - this.ctgy = ctgy; + this.category = category; isProperty = false; } @@ -51,8 +51,8 @@ public class ConfigElement implements IConfigElement if (!isProperty) { List elements = new ArrayList(); - Iterator ccI = ctgy.getChildren().iterator(); - Iterator pI = ctgy.getOrderedValues().iterator(); + Iterator ccI = category.getChildren().iterator(); + Iterator pI = category.getOrderedValues().iterator(); @SuppressWarnings("unused") int index = 0; @@ -87,7 +87,7 @@ public class ConfigElement implements IConfigElement @Override public String getName() { - return isProperty ? prop.getName() : ctgy.getName(); + return isProperty ? prop.getName() : category.getName(); } @Override @@ -99,7 +99,7 @@ public class ConfigElement implements IConfigElement @Override public Class getConfigEntryClass() { - return isProperty ? prop.getConfigEntryClass() : ctgy.getConfigEntryClass(); + return isProperty ? prop.getConfigEntryClass() : category.getConfigEntryClass(); } @Override @@ -111,7 +111,7 @@ public class ConfigElement implements IConfigElement @Override public String getQualifiedName() { - return isProperty ? prop.getName() : ctgy.getQualifiedName(); + return isProperty ? prop.getName() : category.getQualifiedName(); } @Override @@ -148,7 +148,7 @@ public class ConfigElement implements IConfigElement @Override public String getComment() { - return isProperty ? prop.comment : ctgy.getComment(); + return isProperty ? prop.getComment() : category.getComment(); } @Override @@ -167,19 +167,19 @@ public class ConfigElement implements IConfigElement @Override public boolean requiresWorldRestart() { - return isProperty ? prop.requiresWorldRestart() : ctgy.requiresWorldRestart(); + return isProperty ? prop.requiresWorldRestart() : category.requiresWorldRestart(); } @Override public boolean showInGui() { - return isProperty ? prop.showInGui() : ctgy.showInGui(); + return isProperty ? prop.showInGui() : category.showInGui(); } @Override public boolean requiresMcRestart() { - return isProperty ? prop.requiresMcRestart() : ctgy.requiresMcRestart(); + return isProperty ? prop.requiresMcRestart() : category.requiresMcRestart(); } @Override @@ -191,7 +191,7 @@ public class ConfigElement implements IConfigElement @Override public String getLanguageKey() { - return isProperty ? prop.getLanguageKey() : ctgy.getLanguagekey(); + return isProperty ? prop.getLanguageKey() : category.getLanguagekey(); } @Override diff --git a/src/main/java/net/minecraftforge/common/config/Configuration.java b/src/main/java/net/minecraftforge/common/config/Configuration.java index 16aac45b5e..13c34e06c8 100644 --- a/src/main/java/net/minecraftforge/common/config/Configuration.java +++ b/src/main/java/net/minecraftforge/common/config/Configuration.java @@ -166,7 +166,7 @@ public class Configuration */ public Property get(String category, String key, boolean defaultValue) { - return get(category, key, defaultValue, (String) null); + return get(category, key, defaultValue, null); } /** @@ -201,7 +201,7 @@ public class Configuration */ public Property get(String category, String key, boolean[] defaultValues) { - return get(category, key, defaultValues, (String) null); + return get(category, key, defaultValues, null); } /** @@ -268,7 +268,7 @@ public class Configuration */ public Property get(String category, String key, int defaultValue) { - return get(category, key, defaultValue, (String) null, Integer.MIN_VALUE, Integer.MAX_VALUE); + return get(category, key, defaultValue, null, Integer.MIN_VALUE, Integer.MAX_VALUE); } /** @@ -321,7 +321,7 @@ public class Configuration */ public Property get(String category, String key, int[] defaultValues) { - return get(category, key, defaultValues, (String) null); + return get(category, key, defaultValues, null); } /** @@ -410,7 +410,7 @@ public class Configuration */ public Property get(String category, String key, double defaultValue) { - return get(category, key, defaultValue, (String) null); + return get(category, key, defaultValue, null); } /** @@ -553,7 +553,7 @@ public class Configuration */ public Property get(String category, String key, String defaultValue) { - return get(category, key, defaultValue, (String) null); + return get(category, key, defaultValue, null); } /** @@ -615,7 +615,7 @@ public class Configuration */ public Property get(String category, String key, String[] defaultValues) { - return get(category, key, defaultValues, (String) null, false, -1, (Pattern) null); + return get(category, key, defaultValues, null, false, -1, null); } /** @@ -629,7 +629,7 @@ public class Configuration */ public Property get(String category, String key, String[] defaultValues, String comment) { - return get(category, key, defaultValues, comment, false, -1, (Pattern) null); + return get(category, key, defaultValues, comment, false, -1, null); } /** @@ -706,7 +706,7 @@ public class Configuration } prop.setDefaultValue(defaultValue); - prop.comment = comment; + prop.setComment(comment); return prop; } else if (defaultValue != null) @@ -715,7 +715,7 @@ public class Configuration prop.setValue(defaultValue); //Set and mark as dirty to signify it should save cat.put(key, prop); prop.setDefaultValue(defaultValue); - prop.comment = comment; + prop.setComment(comment); return prop; } else @@ -754,7 +754,7 @@ public class Configuration } prop.setDefaultValues(defaultValues); - prop.comment = comment; + prop.setComment(comment); return prop; } @@ -762,7 +762,7 @@ public class Configuration { Property prop = new Property(key, defaultValues, type); prop.setDefaultValues(defaultValues); - prop.comment = comment; + prop.setComment(comment); cat.put(key, prop); return prop; } @@ -877,7 +877,7 @@ public class Configuration } else if (Character.isWhitespace(line.charAt(i))) { - // ignore space charaters + // ignore space characters } else { @@ -927,7 +927,7 @@ public class Configuration break; if (currentCat == null) { - throw new RuntimeException(String.format("Config file corrupt, attepted to close to many categories '%s:%d'", fileName, lineNum)); + throw new RuntimeException(String.format("Config file corrupt, attempted to close to many categories '%s:%d'", fileName, lineNum)); } currentCat = currentCat.parent; break; @@ -1330,7 +1330,7 @@ public class Configuration size = 4; } else if (bom32 == 0xFFFE0000) //This will never happen as it'll be caught by UTF-16LE, - { //but if anyone ever runs across a 32LE file, i'd like to disect it. + { //but if anyone ever runs across a 32LE file, i'd like to dissect it. enc = "UTF-32LE"; size = 4; } @@ -1517,7 +1517,7 @@ public class Configuration Property prop = this.get(category, name, defaultValue); prop.setLanguageKey(langKey); prop.setValidationPattern(pattern); - prop.comment = comment + " [default: " + defaultValue + "]"; + prop.setComment(comment + " [default: " + defaultValue + "]"); return prop.getString(); } @@ -1552,7 +1552,7 @@ public class Configuration Property prop = this.get(category, name, defaultValue); prop.setValidValues(validValues); prop.setLanguageKey(langKey); - prop.comment = comment + " [default: " + defaultValue + "]"; + prop.setComment(comment + " [default: " + defaultValue + "]"); return prop.getString(); } @@ -1567,7 +1567,7 @@ public class Configuration */ public String[] getStringList(String name, String category, String[] defaultValues, String comment) { - return getStringList(name, category, defaultValues, comment, (String[]) null, name); + return getStringList(name, category, defaultValues, comment, null, name); } /** @@ -1598,7 +1598,7 @@ public class Configuration Property prop = this.get(category, name, defaultValue); prop.setLanguageKey(langKey); prop.setValidValues(validValues); - prop.comment = comment + " [default: " + prop.getDefault() + "]"; + prop.setComment(comment + " [default: " + prop.getDefault() + "]"); return prop.getStringList(); } @@ -1630,7 +1630,7 @@ public class Configuration { Property prop = this.get(category, name, defaultValue); prop.setLanguageKey(langKey); - prop.comment = comment + " [default: " + defaultValue + "]"; + prop.setComment(comment + " [default: " + defaultValue + "]"); return prop.getBoolean(defaultValue); } @@ -1666,7 +1666,7 @@ public class Configuration { Property prop = this.get(category, name, defaultValue); prop.setLanguageKey(langKey); - prop.comment = comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"; + prop.setComment(comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"); prop.setMinValue(minValue); prop.setMaxValue(maxValue); return prop.getInt(defaultValue) < minValue ? minValue : (prop.getInt(defaultValue) > maxValue ? maxValue : prop.getInt(defaultValue)); @@ -1704,7 +1704,7 @@ public class Configuration { Property prop = this.get(category, name, Float.toString(defaultValue), name); prop.setLanguageKey(langKey); - prop.comment = comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"; + prop.setComment(comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + defaultValue + "]"); prop.setMinValue(minValue); prop.setMaxValue(maxValue); try diff --git a/src/main/java/net/minecraftforge/common/config/Property.java b/src/main/java/net/minecraftforge/common/config/Property.java index 094ad0c49a..d42bbad48a 100644 --- a/src/main/java/net/minecraftforge/common/config/Property.java +++ b/src/main/java/net/minecraftforge/common/config/Property.java @@ -14,6 +14,16 @@ import net.minecraftforge.fml.client.config.GuiEditArrayEntries.IArrayEntry; public class Property { + public String getComment() + { + return comment; + } + + public void setComment(String comment) + { + this.comment = comment; + } + public enum Type { STRING, @@ -45,7 +55,7 @@ public class Property private String name; private String value; private String defaultValue; - public String comment; + private String comment; private String[] values; private String[] defaultValues; private String[] validValues; @@ -113,7 +123,7 @@ public class Property this.minValue = String.valueOf(Integer.MIN_VALUE); this.maxValue = String.valueOf(Integer.MAX_VALUE); this.langKey = langKey; - this.comment = ""; + this.setComment(""); } public Property(String name, String[] values, Type type) @@ -155,7 +165,7 @@ public class Property this.minValue = String.valueOf(Integer.MIN_VALUE); this.maxValue = String.valueOf(Integer.MAX_VALUE); this.langKey = langKey; - this.comment = ""; + this.setComment(""); } /** @@ -670,14 +680,7 @@ public class Property */ public int getInt() { - try - { - return Integer.parseInt(value); - } - catch (NumberFormatException e) - { - return Integer.parseInt(defaultValue); - } + return getInt(Integer.parseInt(defaultValue)); } /** @@ -717,6 +720,54 @@ public class Property } } + /** + * Returns the value in this property as a long, + * if the value is not a valid long, it will return the initially provided default. + * + * @return The value + */ + public long getLong() + { + return getLong(Long.parseLong(defaultValue)); + } + + /** + * Returns the value in this property as a long, + * if the value is not a valid long, it will return the + * provided default. + * + * @param _default The default to provide if the current value is not a validlong + * @return The value + */ + public long getLong(long _default) + { + try + { + return Long.parseLong(value); + } + catch (NumberFormatException e) + { + return _default; + } + } + + /** + * Checks if the current value stored in this property can be converted to a long. + * @return True if the type of the Property is an Long + */ + public boolean isLongValue() + { + try + { + Long.parseLong(value); + return true; + } + catch (NumberFormatException e) + { + return false; + } + } + /** * Returns the value in this property as a boolean, * if the value is not a valid boolean, it will return the @@ -1138,6 +1189,7 @@ public class Property this.setValues(values); } public void set(int value){ set(Integer.toString(value)); } + public void set(long value){ set(Long.toString(value)); } public void set(boolean value){ set(Boolean.toString(value)); } public void set(double value){ set(Double.toString(value)); } } diff --git a/src/main/java/net/minecraftforge/client/model/IModelPart.java b/src/main/java/net/minecraftforge/common/model/IModelPart.java similarity index 85% rename from src/main/java/net/minecraftforge/client/model/IModelPart.java rename to src/main/java/net/minecraftforge/common/model/IModelPart.java index e8fe6bedd9..48fdb4752b 100644 --- a/src/main/java/net/minecraftforge/client/model/IModelPart.java +++ b/src/main/java/net/minecraftforge/common/model/IModelPart.java @@ -1,4 +1,4 @@ -package net.minecraftforge.client.model; +package net.minecraftforge.common.model; /* * Represents the part of the model you can refer to, for example: mesh, diff --git a/src/main/java/net/minecraftforge/client/model/IModelState.java b/src/main/java/net/minecraftforge/common/model/IModelState.java similarity index 92% rename from src/main/java/net/minecraftforge/client/model/IModelState.java rename to src/main/java/net/minecraftforge/common/model/IModelState.java index dff153de36..d53fd234ab 100644 --- a/src/main/java/net/minecraftforge/client/model/IModelState.java +++ b/src/main/java/net/minecraftforge/common/model/IModelState.java @@ -1,4 +1,4 @@ -package net.minecraftforge.client.model; +package net.minecraftforge.common.model; import com.google.common.base.Optional; diff --git a/src/main/java/net/minecraftforge/client/model/ITransformation.java b/src/main/java/net/minecraftforge/common/model/ITransformation.java similarity index 90% rename from src/main/java/net/minecraftforge/client/model/ITransformation.java rename to src/main/java/net/minecraftforge/common/model/ITransformation.java index 36f22b03f0..f57604c89f 100644 --- a/src/main/java/net/minecraftforge/client/model/ITransformation.java +++ b/src/main/java/net/minecraftforge/common/model/ITransformation.java @@ -1,4 +1,4 @@ -package net.minecraftforge.client.model; +package net.minecraftforge.common.model; import javax.vecmath.Matrix4f; diff --git a/src/main/java/net/minecraftforge/client/model/TRSRTransformation.java b/src/main/java/net/minecraftforge/common/model/TRSRTransformation.java similarity index 77% rename from src/main/java/net/minecraftforge/client/model/TRSRTransformation.java rename to src/main/java/net/minecraftforge/common/model/TRSRTransformation.java index 83167e84f4..6e77ce716d 100644 --- a/src/main/java/net/minecraftforge/client/model/TRSRTransformation.java +++ b/src/main/java/net/minecraftforge/common/model/TRSRTransformation.java @@ -1,38 +1,43 @@ -package net.minecraftforge.client.model; +package net.minecraftforge.common.model; +import java.util.EnumMap; + +import javax.vecmath.AxisAngle4f; import javax.vecmath.Matrix3f; import javax.vecmath.Matrix4f; import javax.vecmath.Quat4f; +import javax.vecmath.SingularMatrixException; import javax.vecmath.Tuple3f; import javax.vecmath.Tuple4f; import javax.vecmath.Vector3f; import javax.vecmath.Vector4f; -import net.minecraft.client.renderer.block.model.ItemTransformVec3f; -import net.minecraft.client.resources.model.ModelRotation; +import net.minecraft.client.renderer.block.model.ModelRotation; import net.minecraft.util.EnumFacing; -import net.minecraft.util.Vec3i; +import net.minecraft.util.math.Vec3i; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; import com.google.common.base.Objects; import com.google.common.base.Optional; +import com.google.common.collect.Maps; /* * Interpolation-friendly affine transformation. * If created with matrix, should successfully decompose it to a composition * of easily interpolatable transformations (translation, first rotation, scale * (with generally speaking different factors for each axis) and second rotation. - * If the inpit matrix is a composition of translation, rotation and scale (in + * If the input matrix is a composition of translation, rotation and scale (in * any order), then the interpolation of the derived primitive transformations * should result in the same transformation as the interpolation of the originals. * Decomposition happens lazily (and is hopefully fast enough), so performance * should be comparable to using Matrix4f directly. * Immutable. */ -@SuppressWarnings("deprecation") -public class TRSRTransformation implements IModelState, ITransformation +public final class TRSRTransformation implements IModelState, ITransformation { private final Matrix4f matrix; @@ -64,27 +69,26 @@ public class TRSRTransformation implements IModelState, ITransformation full = true; } - public TRSRTransformation(ItemTransformVec3f transform) + @Deprecated + @SideOnly(Side.CLIENT) + public TRSRTransformation(net.minecraft.client.renderer.block.model.ItemTransformVec3f transform) { - this(getMatrix(transform)); - } - - public static Matrix4f getMatrix(ItemTransformVec3f transform) - { - TRSRTransformation ret = new TRSRTransformation(toVecmath(transform.translation), quatFromYXZDegrees(toVecmath(transform.rotation)), toVecmath(transform.scale), null); - return blockCenterToCorner(ret).getMatrix(); + this(toVecmath(transform.translation), quatFromXYZDegrees(toVecmath(transform.rotation)), toVecmath(transform.scale), null); } + @SideOnly(Side.CLIENT) public TRSRTransformation(ModelRotation rotation) { this(rotation.getMatrix()); } - + + @SideOnly(Side.CLIENT) public TRSRTransformation(EnumFacing facing) { this(getMatrix(facing)); } - + + @SideOnly(Side.CLIENT) public static Matrix4f getMatrix(EnumFacing facing) { switch(facing) @@ -121,6 +125,14 @@ public class TRSRTransformation implements IModelState, ITransformation return new TRSRTransformation(m); } + public TRSRTransformation inverse() + { + if(this == identity) return this; + Matrix4f m = getMatrix(); + m.invert(); + return new TRSRTransformation(m); + } + private void genCheck() { if(!full) @@ -135,16 +147,6 @@ public class TRSRTransformation implements IModelState, ITransformation } } - public static Quat4f quatFromYXZDegrees(Vector3f yxz) - { - return quatFromYXZ((float)Math.toRadians(yxz.y), (float)Math.toRadians(yxz.x), (float)Math.toRadians(yxz.z)); - } - - public static Quat4f quatFromYXZ(Vector3f yxz) - { - return quatFromYXZ(yxz.y, yxz.x, yxz.z); - } - public static Quat4f quatFromYXZ(float y, float x, float z) { Quat4f ret = new Quat4f(0, 0, 0, 1), t = new Quat4f(); @@ -157,6 +159,28 @@ public class TRSRTransformation implements IModelState, ITransformation return ret; } + public static Quat4f quatFromXYZDegrees(Vector3f xyz) + { + return quatFromXYZ((float)Math.toRadians(xyz.x), (float)Math.toRadians(xyz.y), (float)Math.toRadians(xyz.z)); + } + + public static Quat4f quatFromXYZ(Vector3f xyz) + { + return quatFromXYZ(xyz.x, xyz.y, xyz.z); + } + + public static Quat4f quatFromXYZ(float x, float y, float z) + { + Quat4f ret = new Quat4f(0, 0, 0, 1), t = new Quat4f(); + t.set((float)Math.sin(x/2), 0, 0, (float)Math.cos(x/2)); + ret.mul(t); + t.set(0, (float)Math.sin(y/2), 0, (float)Math.cos(y/2)); + ret.mul(t); + t.set(0, 0, (float)Math.sin(z/2), (float)Math.cos(z/2)); + ret.mul(t); + return ret; + } + public static Vector3f toYXZDegrees(Quat4f q) { Vector3f yxz = toYXZ(q); @@ -187,6 +211,36 @@ public class TRSRTransformation implements IModelState, ITransformation ); } + public static Vector3f toXYZDegrees(Quat4f q) + { + Vector3f xyz = toXYZ(q); + return new Vector3f((float)Math.toDegrees(xyz.x), (float)Math.toDegrees(xyz.y), (float)Math.toDegrees(xyz.z)); + } + + public static Vector3f toXYZ(Quat4f q) + { + float w2 = q.w * q.w; + float x2 = q.x * q.x; + float y2 = q.y * q.y; + float z2 = q.z * q.z; + float l = w2 + x2 + y2 + z2; + float sy = 2 * q.w * q.x - 2 * q.y * q.z; + float y = (float)Math.asin(sy / l); + if(Math.abs(sy) > .999f * l) + { + return new Vector3f( + 2 * (float)Math.atan2(q.x, q.w), + y, + 0 + ); + } + return new Vector3f( + (float)Math.atan2(2 * q.y * q.z + 2 * q.x * q.w, w2 - x2 - y2 + z2), + y, + (float)Math.atan2(2 * q.x * q.y + 2 * q.w * q.z, w2 + x2 - y2 - z2) + ); + } + public static Matrix4f mul(Vector3f translation, Quat4f leftRot, Vector3f scale, Quat4f rightRot) { Matrix4f res = new Matrix4f(), t = new Matrix4f(); @@ -447,9 +501,11 @@ public class TRSRTransformation implements IModelState, ITransformation /* * Don't use this if you don't need to, conversion is lossy (second rotation component is lost). */ - public ItemTransformVec3f toItemTransform() + @Deprecated + @SideOnly(Side.CLIENT) + public net.minecraft.client.renderer.block.model.ItemTransformVec3f toItemTransform() { - return new ItemTransformVec3f(toLwjgl(toYXZDegrees(getLeftRot())), toLwjgl(getTranslation()), toLwjgl(getScale())); + return new net.minecraft.client.renderer.block.model.ItemTransformVec3f(toLwjgl(toXYZDegrees(getLeftRot())), toLwjgl(getTranslation()), toLwjgl(getScale())); } public Matrix4f getMatrix() @@ -592,16 +648,19 @@ public class TRSRTransformation implements IModelState, ITransformation return true; } + @SideOnly(Side.CLIENT) public static Vector3f toVecmath(org.lwjgl.util.vector.Vector3f vec) { return new Vector3f(vec.x, vec.y, vec.z); } + @SideOnly(Side.CLIENT) public static Vector4f toVecmath(org.lwjgl.util.vector.Vector4f vec) { return new Vector4f(vec.x, vec.y, vec.z, vec.w); } + @SideOnly(Side.CLIENT) public static Matrix4f toVecmath(org.lwjgl.util.vector.Matrix4f m) { return new Matrix4f( @@ -611,16 +670,19 @@ public class TRSRTransformation implements IModelState, ITransformation m.m03, m.m13, m.m23, m.m33); } + @SideOnly(Side.CLIENT) public static org.lwjgl.util.vector.Vector3f toLwjgl(Vector3f vec) { return new org.lwjgl.util.vector.Vector3f(vec.x, vec.y, vec.z); } + @SideOnly(Side.CLIENT) public static org.lwjgl.util.vector.Vector4f toLwjgl(Vector4f vec) { return new org.lwjgl.util.vector.Vector4f(vec.x, vec.y, vec.z, vec.w); } + @SideOnly(Side.CLIENT) public static org.lwjgl.util.vector.Matrix4f toLwjgl(Matrix4f m) { org.lwjgl.util.vector.Matrix4f r = new org.lwjgl.util.vector.Matrix4f(); @@ -673,4 +735,51 @@ public class TRSRTransformation implements IModelState, ITransformation slerp(this.getRightRot(), that.getRightRot(), progress) ); } + + private static final EnumMap vanillaUvTransformLocalToGlobal = Maps.newEnumMap(EnumFacing.class); + private static final EnumMap vanillaUvTransformGlobalToLocal = Maps.newEnumMap(EnumFacing.class); + + static + { + vanillaUvTransformLocalToGlobal.put(EnumFacing.SOUTH, identity); + Quat4f tmp = new Quat4f(); + tmp.set(new AxisAngle4f(0, 1, 0, (float)Math.toRadians(90))); + vanillaUvTransformLocalToGlobal.put(EnumFacing.EAST, new TRSRTransformation(null, new Quat4f(tmp), null, null)); + tmp.set(new AxisAngle4f(0, 1, 0, (float)Math.toRadians(-90))); + vanillaUvTransformLocalToGlobal.put(EnumFacing.WEST, new TRSRTransformation(null, new Quat4f(tmp), null, null)); + tmp.set(new AxisAngle4f(0, 1, 0, (float)Math.toRadians(180))); + vanillaUvTransformLocalToGlobal.put(EnumFacing.NORTH, new TRSRTransformation(null, new Quat4f(tmp), null, null)); + tmp.set(new AxisAngle4f(1, 0, 0, (float)Math.toRadians(-90))); + vanillaUvTransformLocalToGlobal.put(EnumFacing.UP, new TRSRTransformation(null, new Quat4f(tmp), null, null)); + tmp.set(new AxisAngle4f(1, 0, 0, (float)Math.toRadians(90))); + vanillaUvTransformLocalToGlobal.put(EnumFacing.DOWN, new TRSRTransformation(null, new Quat4f(tmp), null, null)); + + for(EnumFacing side : EnumFacing.values()) + { + vanillaUvTransformGlobalToLocal.put(side, vanillaUvTransformLocalToGlobal.get(side).inverse()); + } + } + + public static TRSRTransformation getVanillaUvTransformLocalToGlobal(EnumFacing side) + { + return vanillaUvTransformLocalToGlobal.get(side); + } + + public static TRSRTransformation getVanillaUvTransformGlobalToLocal(EnumFacing side) + { + return vanillaUvTransformGlobalToLocal.get(side); + } + + public TRSRTransformation getUVLockTransform(EnumFacing originalSide) + { + EnumFacing newSide = rotate(originalSide); + try + { + return blockCenterToCorner(vanillaUvTransformGlobalToLocal.get(originalSide).compose(blockCornerToCenter(this.inverse())).compose(vanillaUvTransformLocalToGlobal.get(newSide))); + } + catch(SingularMatrixException e) + { + return new TRSRTransformation(null, null, new Vector3f(0, 0, 0), null); + } + } } diff --git a/src/main/java/net/minecraftforge/client/model/animation/AnimationStateMachine.java b/src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java similarity index 54% rename from src/main/java/net/minecraftforge/client/model/animation/AnimationStateMachine.java rename to src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java index d2a7c8f371..6418b0c5c3 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/AnimationStateMachine.java +++ b/src/main/java/net/minecraftforge/common/model/animation/AnimationStateMachine.java @@ -1,13 +1,26 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.model.animation; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.concurrent.TimeUnit; -import net.minecraftforge.client.model.IModelState; -import net.minecraftforge.common.model.animation.IAnimationStateMachine; +import net.minecraft.client.resources.IResource; +import net.minecraft.client.resources.IResourceManager; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.animation.Event; +import net.minecraftforge.common.animation.ITimeValue; +import net.minecraftforge.common.animation.TimeValues; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.util.JsonUtils; +import net.minecraftforge.fml.common.FMLLog; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Triple; +import org.apache.logging.log4j.Level; +import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; @@ -15,10 +28,12 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.JsonParseException; import com.google.gson.annotations.SerializedName; -class AnimationStateMachine implements IAnimationStateMachine +public final class AnimationStateMachine implements IAnimationStateMachine { private final ImmutableMap parameters; private final ImmutableMap clips; @@ -52,22 +67,6 @@ class AnimationStateMachine implements IAnimationStateMachine this.startState = startState; } - /** - * Used during resolution of parameter references. - */ - ImmutableMap getParameters() - { - return parameters; - } - - /** - * Used during resolution of clip references. - */ - ImmutableMap getClips() - { - return clips; - } - /** * post-loading initialization hook. */ @@ -166,4 +165,100 @@ class AnimationStateMachine implements IAnimationStateMachine { shouldHandleSpecialEvents = true; } + + /** + * Load a new instance if AnimationStateMachine at specified location, with specified custom parameters. + */ + @SideOnly(Side.CLIENT) + public static IAnimationStateMachine load(IResourceManager manager, ResourceLocation location, ImmutableMap customParameters) + { + try + { + ClipResolver clipResolver = new ClipResolver(); + ParameterResolver parameterResolver = new ParameterResolver(customParameters); + Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver); + TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver); + IResource resource = manager.getResource(location); + AnimationStateMachine asm = asmGson.fromJson(new InputStreamReader(resource.getInputStream(), "UTF-8"), AnimationStateMachine.class); + clipResolver.asm = asm; + parameterResolver.asm = asm; + asm.initialize(); + //String json = asmGson.toJson(asm); + //System.out.println(location + ": " + json); + return asm; + } + catch(IOException e) + { + FMLLog.log(Level.ERROR, e, "Exception loading Animation State Machine %s, skipping", location); + return missing; + } + catch(JsonParseException e) + { + FMLLog.log(Level.ERROR, e, "Exception loading Animation State Machine %s, skipping", location); + return missing; + } + finally + { + Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(null); + TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(null); + } + } + + private static final AnimationStateMachine missing = new AnimationStateMachine( + ImmutableMap.of(), + ImmutableMap.of("missingno", (IClip)Clips.IdentityClip.INSTANCE), + ImmutableList.of("missingno"), + ImmutableMap.of(), + "missingno"); + + static + { + missing.initialize(); + } + + public static final AnimationStateMachine getMissing() + { + return missing; + } + + private static final class ClipResolver implements Function + { + private AnimationStateMachine asm; + + public IClip apply(String name) + { + return asm.clips.get(name); + } + } + + private static final class ParameterResolver implements Function + { + private final ImmutableMap customParameters; + private AnimationStateMachine asm; + + public ParameterResolver(ImmutableMap customParameters) + { + this.customParameters = customParameters; + } + + public ITimeValue apply(String name) + { + if(asm.parameters.containsKey(name)) + { + return asm.parameters.get(name); + } + return customParameters.get(name); + } + } + + private static final Gson asmGson = new GsonBuilder() + .registerTypeAdapter(ImmutableList.class, JsonUtils.ImmutableListTypeAdapter.INSTANCE) + .registerTypeAdapter(ImmutableMap.class, JsonUtils.ImmutableMapTypeAdapter.INSTANCE) + .registerTypeAdapterFactory(Clips.CommonClipTypeAdapterFactory.INSTANCE) + //.registerTypeAdapterFactory(ClipProviders.CommonClipProviderTypeAdapterFactory.INSTANCE) + .registerTypeAdapterFactory(TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE) + .setPrettyPrinting() + .enableComplexMapKeySerialization() + .disableHtmlEscaping() + .create(); } diff --git a/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java b/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java new file mode 100644 index 0000000000..9dde0aa0c4 --- /dev/null +++ b/src/main/java/net/minecraftforge/common/model/animation/CapabilityAnimation.java @@ -0,0 +1,59 @@ +package net.minecraftforge.common.model.animation; + +import java.util.concurrent.Callable; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.common.capabilities.ICapabilityProvider; + +public class CapabilityAnimation +{ + @CapabilityInject(IAnimationStateMachine.class) + public static Capability ANIMATION_CAPABILITY = null; + + public static void register() + { + CapabilityManager.INSTANCE.register(IAnimationStateMachine.class, new Capability.IStorage() + { + public NBTBase writeNBT(Capability capability, IAnimationStateMachine instance, EnumFacing side) + { + return null; + } + + public void readNBT(Capability capability, IAnimationStateMachine instance, EnumFacing side, NBTBase nbt) {} + }, new Callable() + { + public IAnimationStateMachine call() throws Exception + { + return AnimationStateMachine.getMissing(); + } + }); + } + + public static class DefaultItemAnimationCapabilityProvider implements ICapabilityProvider + { + private final IAnimationStateMachine asm; + + public DefaultItemAnimationCapabilityProvider(IAnimationStateMachine asm) + { + this.asm = asm; + } + + public boolean hasCapability(Capability capability, EnumFacing facing) + { + return capability == ANIMATION_CAPABILITY; + } + + public T getCapability(Capability capability, EnumFacing facing) + { + if(capability == ANIMATION_CAPABILITY) + { + return ANIMATION_CAPABILITY.cast(asm); + } + return null; + } + } +} diff --git a/src/main/java/net/minecraftforge/client/model/animation/Clips.java b/src/main/java/net/minecraftforge/common/model/animation/Clips.java similarity index 93% rename from src/main/java/net/minecraftforge/client/model/animation/Clips.java rename to src/main/java/net/minecraftforge/common/model/animation/Clips.java index c673ff60bb..7f588db040 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/Clips.java +++ b/src/main/java/net/minecraftforge/common/model/animation/Clips.java @@ -1,17 +1,22 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.model.animation; import java.io.IOException; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.util.IStringSerializable; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IModel; -import net.minecraftforge.client.model.IModelPart; -import net.minecraftforge.client.model.IModelState; import net.minecraftforge.client.model.ModelLoaderRegistry; -import net.minecraftforge.client.model.TRSRTransformation; +import net.minecraftforge.client.model.animation.IAnimatedModel; +import net.minecraftforge.common.animation.Event; +import net.minecraftforge.common.animation.ITimeValue; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.fml.common.FMLLog; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.tuple.Pair; @@ -39,11 +44,11 @@ public final class Clips */ public static enum IdentityClip implements IClip, IStringSerializable { - instance; + INSTANCE; public IJointClip apply(IJoint joint) { - return JointClips.IdentityJointClip.instance; + return JointClips.IdentityJointClip.INSTANCE; } public Iterable pastEvents(float lastPollTime, float time) @@ -60,28 +65,21 @@ public final class Clips /** * Retrieves the clip from the model. */ + @SideOnly(Side.CLIENT) public static IClip getModelClipNode(ResourceLocation modelLocation, String clipName) { - IModel model; - try + IModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation); + if(model instanceof IAnimatedModel) { - model = ModelLoaderRegistry.getModel(modelLocation); - if(model instanceof IAnimatedModel) + Optional clip = ((IAnimatedModel)model).getClip(clipName); + if(clip.isPresent()) { - Optional clip = ((IAnimatedModel)model).getClip(clipName); - if(clip.isPresent()) - { - return new ModelClip(clip.get(), modelLocation, clipName); - } - FMLLog.getLogger().error("Unable to find clip " + clipName + " in the model " + modelLocation); + return new ModelClip(clip.get(), modelLocation, clipName); } - } - catch (IOException e) - { - FMLLog.getLogger().error("Unable to load model" + modelLocation + " while loading clip " + clipName, e); + FMLLog.getLogger().error("Unable to find clip " + clipName + " in the model " + modelLocation); } // FIXME: missing clip? - return new ModelClip(IdentityClip.instance, modelLocation, clipName); + return new ModelClip(IdentityClip.INSTANCE, modelLocation, clipName); } /** @@ -504,7 +502,7 @@ public final class Clips // IdentityClip if(string.equals("#identity")) { - return IdentityClip.instance; + return IdentityClip.INSTANCE; } // Clip reference if(string.startsWith("#")) diff --git a/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java b/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java index 53b640c21d..bb84e244c9 100644 --- a/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java +++ b/src/main/java/net/minecraftforge/common/model/animation/IAnimationStateMachine.java @@ -1,7 +1,7 @@ package net.minecraftforge.common.model.animation; -import net.minecraftforge.client.model.IModelState; -import net.minecraftforge.client.model.animation.Event; +import net.minecraftforge.common.animation.Event; +import net.minecraftforge.common.model.IModelState; import org.apache.commons.lang3.tuple.Pair; diff --git a/src/main/java/net/minecraftforge/client/model/animation/IClip.java b/src/main/java/net/minecraftforge/common/model/animation/IClip.java similarity index 61% rename from src/main/java/net/minecraftforge/client/model/animation/IClip.java rename to src/main/java/net/minecraftforge/common/model/animation/IClip.java index 714322a01b..4e0ff222a8 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/IClip.java +++ b/src/main/java/net/minecraftforge/common/model/animation/IClip.java @@ -1,4 +1,6 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.model.animation; + +import net.minecraftforge.common.animation.Event; /** diff --git a/src/main/java/net/minecraftforge/client/model/animation/IJoint.java b/src/main/java/net/minecraftforge/common/model/animation/IJoint.java similarity index 60% rename from src/main/java/net/minecraftforge/client/model/animation/IJoint.java rename to src/main/java/net/minecraftforge/common/model/animation/IJoint.java index 288a0cc4e4..4afde21554 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/IJoint.java +++ b/src/main/java/net/minecraftforge/common/model/animation/IJoint.java @@ -1,9 +1,9 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.model.animation; import com.google.common.base.Optional; -import net.minecraftforge.client.model.IModelPart; -import net.minecraftforge.client.model.TRSRTransformation; +import net.minecraftforge.common.model.IModelPart; +import net.minecraftforge.common.model.TRSRTransformation; /** * Model part that's a part of the hierarchical skeleton. diff --git a/src/main/java/net/minecraftforge/client/model/animation/IJointClip.java b/src/main/java/net/minecraftforge/common/model/animation/IJointClip.java similarity index 58% rename from src/main/java/net/minecraftforge/client/model/animation/IJointClip.java rename to src/main/java/net/minecraftforge/common/model/animation/IJointClip.java index 27edea0e5b..09dc177d58 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/IJointClip.java +++ b/src/main/java/net/minecraftforge/common/model/animation/IJointClip.java @@ -1,6 +1,6 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.model.animation; -import net.minecraftforge.client.model.TRSRTransformation; +import net.minecraftforge.common.model.TRSRTransformation; /** * Returns Local joint pose; animation clip for specific model part. diff --git a/src/main/java/net/minecraftforge/client/model/animation/JointClips.java b/src/main/java/net/minecraftforge/common/model/animation/JointClips.java similarity index 84% rename from src/main/java/net/minecraftforge/client/model/animation/JointClips.java rename to src/main/java/net/minecraftforge/common/model/animation/JointClips.java index 945c54f466..df64bec1e5 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/JointClips.java +++ b/src/main/java/net/minecraftforge/common/model/animation/JointClips.java @@ -1,6 +1,6 @@ -package net.minecraftforge.client.model.animation; +package net.minecraftforge.common.model.animation; -import net.minecraftforge.client.model.TRSRTransformation; +import net.minecraftforge.common.model.TRSRTransformation; /** * Various implementations of IJointClip. @@ -9,7 +9,7 @@ public final class JointClips { public static enum IdentityJointClip implements IJointClip { - instance; + INSTANCE; public TRSRTransformation apply(float time) { diff --git a/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java b/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java index 010f6ee9d6..232d39a558 100644 --- a/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java +++ b/src/main/java/net/minecraftforge/common/network/DimensionMessageHandler.java @@ -2,6 +2,7 @@ package net.minecraftforge.common.network; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; +import net.minecraft.world.DimensionType; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.network.ForgeMessage.DimensionRegisterMessage; import org.apache.logging.log4j.Level; @@ -13,7 +14,7 @@ public class DimensionMessageHandler extends SimpleChannelInboundHandler> unlistedProperties; - public ExtendedBlockState(Block blockIn, @SuppressWarnings("rawtypes") IProperty[] properties, IUnlistedProperty[] unlistedProperties) + public ExtendedBlockState(Block blockIn, IProperty[] properties, IUnlistedProperty[] unlistedProperties) { super(blockIn, properties, buildUnlistedMap(unlistedProperties)); - ImmutableSet.Builder> builder = ImmutableSet.>builder(); + ImmutableSet.Builder> builder = ImmutableSet.builder(); for(IUnlistedProperty property : unlistedProperties) { builder.add(property); } this.unlistedProperties = builder.build(); } - + public Collection> getUnlistedProperties() { return unlistedProperties; @@ -40,7 +40,7 @@ public class ExtendedBlockState extends BlockState private static ImmutableMap, Optional> buildUnlistedMap(IUnlistedProperty[] unlistedProperties) { - ImmutableMap.Builder, Optional> builder = ImmutableMap., Optional>builder(); + ImmutableMap.Builder, Optional> builder = ImmutableMap.builder(); for(IUnlistedProperty p : unlistedProperties) { builder.put(p, Optional.absent()); @@ -49,7 +49,7 @@ public class ExtendedBlockState extends BlockState } @Override - protected StateImplementation createState(Block block, @SuppressWarnings("rawtypes") ImmutableMap properties, ImmutableMap, Optional> unlistedProperties) + protected StateImplementation createState(Block block, ImmutableMap, Comparable> properties, ImmutableMap, Optional> unlistedProperties) { if (unlistedProperties == null || unlistedProperties.isEmpty()) return super.createState(block, properties, unlistedProperties); return new ExtendedStateImplementation(block, properties, unlistedProperties, null); @@ -58,10 +58,9 @@ public class ExtendedBlockState extends BlockState protected static class ExtendedStateImplementation extends StateImplementation implements IExtendedBlockState { private final ImmutableMap, Optional> unlistedProperties; - @SuppressWarnings("rawtypes") - private Map, BlockState.StateImplementation> normalMap; + private Map, Comparable>, BlockStateContainer.StateImplementation> normalMap; - protected ExtendedStateImplementation(Block block, @SuppressWarnings("rawtypes") ImmutableMap properties, ImmutableMap, Optional> unlistedProperties, @SuppressWarnings("rawtypes") ImmutableTable table) + protected ExtendedStateImplementation(Block block, ImmutableMap, Comparable> properties, ImmutableMap, Optional> unlistedProperties, ImmutableTable, Comparable, IBlockState> table) { super(block, properties); this.unlistedProperties = unlistedProperties; @@ -75,27 +74,27 @@ public class ExtendedBlockState extends BlockState { throw new IllegalArgumentException("Cannot set property " + property + " as it does not exist in " + getBlock().getBlockState()); } - else if (!property.getAllowedValues().contains(value)) - { - throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on block " + Block.blockRegistry.getNameForObject(getBlock()) + ", it is not an allowed value"); - } else { - if(this.getProperties().get(property) == value) + if (!property.getAllowedValues().contains(value)) { - return this; + throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on block " + Block.blockRegistry.getNameForObject(getBlock()) + ", it is not an allowed value"); + } else + { + if (this.getProperties().get(property) == value) + { + return this; + } + Map, Comparable> map = Maps.newHashMap(getProperties()); + map.put(property, value); + if (Iterables.all(unlistedProperties.values(), Predicates.>equalTo(Optional.absent()))) + { // no dynamic properties present, looking up in the normal table + return normalMap.get(map); + } + ImmutableTable, Comparable, IBlockState> table = propertyValueTable; + table = ((StateImplementation) table.get(property, value)).getPropertyValueTable(); + return new ExtendedStateImplementation(getBlock(), ImmutableMap.copyOf(map), unlistedProperties, table).setMap(this.normalMap); } - @SuppressWarnings("rawtypes") - Map map = Maps.newHashMap(getProperties()); - map.put(property, value); - if(Iterables.all(unlistedProperties.values(), Predicates.>equalTo(Optional.absent()))) - { // no dynamic properties present, looking up in the normal table - return (IExtendedBlockState) normalMap.get(map); - } - @SuppressWarnings("rawtypes") - ImmutableTable table = propertyValueTable; - table = ((StateImplementation)table.get(property, value)).getPropertyValueTable(); - return new ExtendedStateImplementation(getBlock(), ImmutableMap.copyOf(map), unlistedProperties, table).setMap(this.normalMap); } } @@ -138,18 +137,18 @@ public class ExtendedBlockState extends BlockState } @Override - public void buildPropertyValueTable(@SuppressWarnings("rawtypes") Map, BlockState.StateImplementation> map) + public void buildPropertyValueTable(Map, Comparable>, BlockStateContainer.StateImplementation> map) { this.normalMap = map; super.buildPropertyValueTable(map); } - - private ExtendedStateImplementation setMap(@SuppressWarnings("rawtypes") Map, BlockState.StateImplementation> map) + + private ExtendedStateImplementation setMap(Map, Comparable>, BlockStateContainer.StateImplementation> map) { this.normalMap = map; return this; } - + public IBlockState getClean() { return this.normalMap.get(getProperties()); diff --git a/src/main/java/net/minecraftforge/common/property/Properties.java b/src/main/java/net/minecraftforge/common/property/Properties.java index 243109cc06..1bc1d4f6c2 100644 --- a/src/main/java/net/minecraftforge/common/property/Properties.java +++ b/src/main/java/net/minecraftforge/common/property/Properties.java @@ -2,7 +2,7 @@ package net.minecraftforge.common.property; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; -import net.minecraftforge.client.model.IModelState; +import net.minecraftforge.common.model.IModelState; public class Properties { diff --git a/src/main/java/net/minecraftforge/common/util/AsynchronousExecutor.java b/src/main/java/net/minecraftforge/common/util/AsynchronousExecutor.java deleted file mode 100644 index 9fa2656ecc..0000000000 --- a/src/main/java/net/minecraftforge/common/util/AsynchronousExecutor.java +++ /dev/null @@ -1,361 +0,0 @@ -package net.minecraftforge.common.util; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; - -import net.minecraftforge.fml.common.FMLLog; - - -/** - * Executes tasks using a multi-stage process executor. Synchronous executions are via {@link AsynchronousExecutor#finishActive()} or the {@link AsynchronousExecutor#get(Object)} methods. - *
  • Stage 1 creates the object from a parameter, and is usually called asynchronously. - *
  • Stage 2 takes the parameter and object from stage 1 and does any synchronous processing to prepare it. - *
  • Stage 3 takes the parameter and object from stage 1, as well as a callback that was registered, and performs any synchronous calculations. - * - * @param

    The type of parameter you provide to make the object that will be created. It should implement {@link Object#hashCode()} and {@link Object#equals(Object)} if you want to get the value early. - * @param The type of object you provide. This is created in stage 1, and passed to stage 2, 3, and returned if get() is called. - * @param The type of callback you provide. You may register many of these to be passed to the provider in stage 3, one at a time. - * @param A type of exception you may throw and expect to be handled by the main thread - * @author Wesley Wolfe (c) 2012, 2014 - */ -public final class AsynchronousExecutor { - - public static interface CallBackProvider extends ThreadFactory { - - /** - * Normally an asynchronous call, but can be synchronous - * - * @param parameter parameter object provided - * @return the created object - */ - T callStage1(P parameter) throws E; - - /** - * Synchronous call - * - * @param parameter parameter object provided - * @param object the previously created object - */ - void callStage2(P parameter, T object) throws E; - - /** - * Synchronous call, called multiple times, once per registered callback - * - * @param parameter parameter object provided - * @param object the previously created object - * @param callback the current callback to execute - */ - void callStage3(P parameter, T object, C callback) throws E; - } - - @SuppressWarnings("rawtypes") - static final AtomicIntegerFieldUpdater STATE_FIELD = AtomicIntegerFieldUpdater.newUpdater(AsynchronousExecutor.Task.class, "state"); - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private static boolean set(AsynchronousExecutor.Task $this, int expected, int value) { - return STATE_FIELD.compareAndSet($this, expected, value); - } - - class Task implements Runnable { - static final int PENDING = 0x0; - static final int STAGE_1_ASYNC = PENDING + 1; - static final int STAGE_1_SYNC = STAGE_1_ASYNC + 1; - static final int STAGE_1_COMPLETE = STAGE_1_SYNC + 1; - static final int FINISHED = STAGE_1_COMPLETE + 1; - - volatile int state = PENDING; - final P parameter; - T object; - final List callbacks = new LinkedList(); - E t = null; - - Task(final P parameter) { - this.parameter = parameter; - } - - public void run() { - if (initAsync()) { - finished.add(this); - } - } - - boolean initAsync() { - if (set(this, PENDING, STAGE_1_ASYNC)) { - boolean ret = true; - - try { - init(); - } finally { - if (set(this, STAGE_1_ASYNC, STAGE_1_COMPLETE)) { - // No one is/will be waiting - } else { - // We know that the sync thread will be waiting - synchronized (this) { - if (state != STAGE_1_SYNC) { - // They beat us to the synchronized block - this.notifyAll(); - } else { - // We beat them to the synchronized block - } - state = STAGE_1_COMPLETE; // They're already synchronized, atomic locks are not needed - } - // We want to return false, because we know a synchronous task already handled the finish() - ret = false; // Don't return inside finally; VERY bad practice. - } - } - - return ret; - } else { - return false; - } - } - - void initSync() { - if (set(this, PENDING, STAGE_1_COMPLETE)) { - // If we succeed that variable switch, good as done - init(); - } else if (set(this, STAGE_1_ASYNC, STAGE_1_SYNC)) { - // Async thread is running, but this shouldn't be likely; we need to sync to wait on them because of it. - synchronized (this) { - if (set(this, STAGE_1_SYNC, PENDING)) { // They might NOT synchronized yet, atomic lock IS needed - // We are the first into the lock - while (state != STAGE_1_COMPLETE) { - try { - this.wait(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new RuntimeException("Unable to handle interruption on " + parameter, e); - } - } - } else { - // They beat us to the synchronized block - } - } - } else { - // Async thread is not pending, the more likely situation for a task not pending - } - } - - @SuppressWarnings("unchecked") - void init() { - try { - object = provider.callStage1(parameter); - } catch (final Throwable t) { - this.t = (E) t; - } - } - - @SuppressWarnings("unchecked") - T get() throws E { - initSync(); - if (callbacks.isEmpty()) { - // 'this' is a placeholder to prevent callbacks from being empty during finish call - // See get method below - callbacks.add((C) this); - } - finish(); - return object; - } - - void finish() throws E { - switch (state) { - default: - case PENDING: - case STAGE_1_ASYNC: - case STAGE_1_SYNC: - throw new IllegalStateException("Attempting to finish unprepared(" + state + ") task(" + parameter + ")"); - case STAGE_1_COMPLETE: - try { - if (t != null) { - throw t; - } - if (callbacks.isEmpty()) { - return; - } - - final CallBackProvider provider = AsynchronousExecutor.this.provider; - final P parameter = this.parameter; - final T object = this.object; - - provider.callStage2(parameter, object); - for (C callback : callbacks) { - if (callback == this) { - // 'this' is a placeholder to prevent callbacks from being empty on a get() call - // See get method above - continue; - } - provider.callStage3(parameter, object, callback); - } - } finally { - tasks.remove(parameter); - state = FINISHED; - } - case FINISHED: - } - } - - boolean drop() { - if (set(this, PENDING, FINISHED)) { - // If we succeed that variable switch, good as forgotten - tasks.remove(parameter); - return true; - } else { - // We need the async thread to finish normally to properly dispose of the task - return false; - } - } - } - - final CallBackProvider provider; - final Queue finished = new ConcurrentLinkedQueue(); - final Map tasks = new HashMap(); - final ThreadPoolExecutor pool; - - /** - * Uses a thread pool to pass executions to the provider. - * @see AsynchronousExecutor - */ - public AsynchronousExecutor(final CallBackProvider provider, final int coreSize) { - if (provider == null) { - throw new IllegalArgumentException("Provider cannot be null"); - } - this.provider = provider; - - // We have an unbound queue size so do not need a max thread size - pool = new ThreadPoolExecutor(coreSize, Integer.MAX_VALUE, 60l, TimeUnit.SECONDS, new LinkedBlockingQueue(), provider); - } - - /** - * Adds a callback to the parameter provided, adding parameter to the queue if needed. - *

    - * This should always be synchronous. - */ - public void add(P parameter, C callback) { - Task task = tasks.get(parameter); - if (task == null) { - tasks.put(parameter, task = new Task(parameter)); - pool.execute(task); - } - task.callbacks.add(callback); - } - - /** - * This removes a particular callback from the specified parameter. - *

    - * If no callbacks remain for a given parameter, then the {@link CallBackProvider CallBackProvider's} stages may be omitted from execution. - * Stage 3 will have no callbacks, stage 2 will be skipped unless a {@link #get(Object)} is used, and stage 1 will be avoided on a best-effort basis. - *

    - * Subsequent calls to {@link #getSkipQueue(Object)} will always work. - *

    - * Subsequent calls to {@link #get(Object)} might work. - *

    - * This should always be synchronous - * @return true if no further execution for the parameter is possible, such that, no exceptions will be thrown in {@link #finishActive()} for the parameter, and {@link #get(Object)} will throw an {@link IllegalStateException}, false otherwise - * @throws IllegalStateException if parameter is not in the queue anymore - * @throws IllegalStateException if the callback was not specified for given parameter - */ - public boolean drop(P parameter, C callback) throws IllegalStateException { - final Task task = tasks.get(parameter); - if (task == null) { - // Print debug info for QueuedChunk and avoid crash - //throw new IllegalStateException("Unknown " + parameter); - FMLLog.info("Unknown %s", parameter); - FMLLog.info("This should not happen. Please report this error to Forge."); - return false; - } - if (!task.callbacks.remove(callback)) { - throw new IllegalStateException("Unknown " + callback + " for " + parameter); - } - if (task.callbacks.isEmpty()) { - return task.drop(); - } - return false; - } - - /** - * This method attempts to skip the waiting period for said parameter. - *

    - * This should always be synchronous. - * @throws IllegalStateException if the parameter is not in the queue anymore, or sometimes if called from asynchronous thread - */ - public T get(P parameter) throws E, IllegalStateException { - final Task task = tasks.get(parameter); - if (task == null) { - throw new IllegalStateException("Unknown " + parameter); - } - return task.get(); - } - - /** - * Processes a parameter as if it was in the queue, without ever passing to another thread. - */ - public T getSkipQueue(P parameter) throws E { - return skipQueue(parameter); - } - - /** - * Processes a parameter as if it was in the queue, without ever passing to another thread. - */ - public T getSkipQueue(P parameter, C callback) throws E { - final T object = skipQueue(parameter); - provider.callStage3(parameter, object, callback); - return object; - } - - /** - * Processes a parameter as if it was in the queue, without ever passing to another thread. - */ - public T getSkipQueue(P parameter, @SuppressWarnings("unchecked")C... callbacks) throws E { - final CallBackProvider provider = this.provider; - final T object = skipQueue(parameter); - for (C callback : callbacks) { - provider.callStage3(parameter, object, callback); - } - return object; - } - - /** - * Processes a parameter as if it was in the queue, without ever passing to another thread. - */ - public T getSkipQueue(P parameter, Iterable callbacks) throws E { - final CallBackProvider provider = this.provider; - final T object = skipQueue(parameter); - for (C callback : callbacks) { - provider.callStage3(parameter, object, callback); - } - return object; - } - - private T skipQueue(P parameter) throws E { - Task task = tasks.get(parameter); - if (task != null) { - return task.get(); - } - T object = provider.callStage1(parameter); - provider.callStage2(parameter, object); - return object; - } - - /** - * This is the 'heartbeat' that should be called synchronously to finish any pending tasks - */ - public void finishActive() throws E { - final Queue finished = this.finished; - while (!finished.isEmpty()) { - finished.poll().finish(); - } - } - - public void setActiveThreads(final int coreSize) { - pool.setCorePoolSize(coreSize); - } -} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java index a249adaf74..6df3e7d310 100644 --- a/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java +++ b/src/main/java/net/minecraftforge/common/util/BlockSnapshot.java @@ -5,11 +5,11 @@ import java.io.Serializable; import net.minecraft.block.state.IBlockState; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.common.registry.GameRegistry.UniqueIdentifier; /** * Represents a captured snapshot of a block which will not change @@ -23,68 +23,68 @@ public class BlockSnapshot implements Serializable { private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockSnapshot", "false")); - public final BlockPos pos; - public final int dimId; - public transient IBlockState replacedBlock; - public int flag; + private final BlockPos pos; + private final int dimId; + private transient IBlockState replacedBlock; + private int flag; private final NBTTagCompound nbt; - public transient World world; - public final UniqueIdentifier blockIdentifier; - public final int meta; + private transient World world; + private final ResourceLocation registryName; + private final int meta; public BlockSnapshot(World world, BlockPos pos, IBlockState state) { - this.world = world; - this.dimId = world.provider.getDimensionId(); + this.setWorld(world); + this.dimId = world.provider.getDimension(); this.pos = pos; - this.replacedBlock = state; - this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock()); + this.setReplacedBlock(state); + this.registryName = state.getBlock().getRegistryName(); this.meta = state.getBlock().getMetaFromState(state); - this.flag = 3; + this.setFlag(3); TileEntity te = world.getTileEntity(pos); if (te != null) { nbt = new NBTTagCompound(); - te.writeToNBT(nbt); + te.writeToNBT(getNbt()); } else nbt = null; if (DEBUG) { - System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), blockIdentifier, meta); + System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), getRegistryName(), getMeta()); } } public BlockSnapshot(World world, BlockPos pos, IBlockState state, NBTTagCompound nbt) { - this.world = world; - this.dimId = world.provider.getDimensionId(); - this.pos = pos.getImmutable(); - this.replacedBlock = state; - this.blockIdentifier = GameRegistry.findUniqueIdentifierFor(state.getBlock()); + this.setWorld(world); + this.dimId = world.provider.getDimension(); + this.pos = pos.toImmutable(); + this.setReplacedBlock(state); + this.registryName = state.getBlock().getRegistryName(); this.meta = state.getBlock().getMetaFromState(state); - this.flag = 3; + this.setFlag(3); this.nbt = nbt; if (DEBUG) { - System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), blockIdentifier, meta); + System.out.printf("Created BlockSnapshot - [World: %s ][Location: %d,%d,%d ][Block: %s ][Meta: %d ]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), getRegistryName(), getMeta()); } } public BlockSnapshot(World world, BlockPos pos, IBlockState state, int flag) { this(world, pos, state); - this.flag = flag; + this.setFlag(flag); } /** * Raw constructor designed for serialization usages. */ - public BlockSnapshot(int dimension, BlockPos pos, String modid, String blockName, int meta, int flag, NBTTagCompound nbt) + public BlockSnapshot(int dimension, BlockPos pos, String modId, String blockName, int meta, int flag, NBTTagCompound nbt) { this.dimId = dimension; - this.pos = pos.getImmutable(); - this.flag = flag; - this.blockIdentifier = new UniqueIdentifier(modid + ":" + blockName); + this.pos = pos.toImmutable(); + this.setFlag(flag); + this.registryName = new ResourceLocation(modId, blockName); this.meta = meta; this.nbt = nbt; } @@ -115,14 +115,14 @@ public class BlockSnapshot implements Serializable public IBlockState getCurrentBlock() { - return world.getBlockState(pos); + return getWorld().getBlockState(getPos()); } public World getWorld() { if (this.world == null) { - this.world = DimensionManager.getWorld(dimId); + this.world = DimensionManager.getWorld(getDimId()); } return this.world; } @@ -131,15 +131,15 @@ public class BlockSnapshot implements Serializable { if (this.replacedBlock == null) { - this.replacedBlock = GameRegistry.findBlock(this.blockIdentifier.modId, this.blockIdentifier.name).getStateFromMeta(meta); + this.replacedBlock = GameRegistry.findBlock(this.getRegistryName().getResourceDomain(), this.getRegistryName().getResourcePath()).getStateFromMeta(getMeta()); } return this.replacedBlock; } public TileEntity getTileEntity() { - if (nbt != null) - return TileEntity.createAndLoadEntity(nbt); + if (getNbt() != null) + return TileEntity.createTileEntity(getWorld().getMinecraftServer(), getNbt()); else return null; } @@ -161,7 +161,7 @@ public class BlockSnapshot implements Serializable { if (force) { - world.setBlockState(pos, replaced, applyPhysics ? 3 : 2); + getWorld().setBlockState(getPos(), replaced, applyPhysics ? 3 : 2); } else { @@ -169,22 +169,22 @@ public class BlockSnapshot implements Serializable } } - world.setBlockState(pos, replaced, applyPhysics ? 3 : 2); - world.markBlockForUpdate(pos); + getWorld().setBlockState(getPos(), replaced, applyPhysics ? 3 : 2); + getWorld().notifyBlockUpdate(getPos(), current, replaced, applyPhysics ? 3 : 2); TileEntity te = null; - if (nbt != null) + if (getNbt() != null) { - te = world.getTileEntity(pos); + te = getWorld().getTileEntity(getPos()); if (te != null) { - te.readFromNBT(nbt); + te.readFromNBT(getNbt()); te.markDirty(); } } if (DEBUG) { - System.out.printf("Restored BlockSnapshot with data [World: %s ][Location: %d,%d,%d ][Meta: %d ][Block: %s ][TileEntity: %s ][force: %s ][applyPhysics: %s]", world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ(), replaced.getBlock().getMetaFromState(replaced), replaced.getBlock().delegate.name(), te, force, applyPhysics); + System.out.printf("Restored BlockSnapshot with data [World: %s ][Location: %d,%d,%d ][Meta: %d ][Block: %s ][TileEntity: %s ][force: %s ][applyPhysics: %s]", getWorld().getWorldInfo().getWorldName(), getPos().getX(), getPos().getY(), getPos().getZ(), replaced.getBlock().getMetaFromState(replaced), replaced.getBlock().delegate.name(), te, force, applyPhysics); } return true; } @@ -206,14 +206,14 @@ public class BlockSnapshot implements Serializable } world.setBlockState(pos, replaced, applyPhysics ? 3 : 2); - world.markBlockForUpdate(pos); + world.notifyBlockUpdate(pos, current, replaced, applyPhysics ? 3 : 2); TileEntity te = null; - if (nbt != null) + if (getNbt() != null) { te = world.getTileEntity(pos); if (te != null) { - te.readFromNBT(nbt); + te.readFromNBT(getNbt()); te.markDirty(); } } @@ -227,20 +227,20 @@ public class BlockSnapshot implements Serializable public void writeToNBT(NBTTagCompound compound) { - compound.setString("blockMod", blockIdentifier.modId); - compound.setString("blockName", blockIdentifier.name); - compound.setInteger("posX", pos.getX()); - compound.setInteger("posY", pos.getY()); - compound.setInteger("posZ", pos.getZ()); - compound.setInteger("flag", flag); - compound.setInteger("dimension", dimId); - compound.setInteger("metadata", meta); + compound.setString("blockMod", getRegistryName().getResourceDomain()); + compound.setString("blockName", getRegistryName().getResourcePath()); + compound.setInteger("posX", getPos().getX()); + compound.setInteger("posY", getPos().getY()); + compound.setInteger("posZ", getPos().getZ()); + compound.setInteger("flag", getFlag()); + compound.setInteger("dimension", getDimId()); + compound.setInteger("metadata", getMeta()); - compound.setBoolean("hasTE", nbt != null); + compound.setBoolean("hasTE", getNbt() != null); - if (nbt != null) + if (getNbt() != null) { - compound.setTag("tileEntity", nbt); + compound.setTag("tileEntity", getNbt()); } } @@ -256,27 +256,27 @@ public class BlockSnapshot implements Serializable return false; } final BlockSnapshot other = (BlockSnapshot) obj; - if (!this.pos.equals(other.pos)) + if (!this.getPos().equals(other.getPos())) { return false; } - if (this.meta != other.meta) + if (this.getMeta() != other.getMeta()) { return false; } - if (this.dimId != other.dimId) + if (this.getDimId() != other.getDimId()) { return false; } - if (this.nbt != other.nbt && (this.nbt == null || !this.nbt.equals(other.nbt))) + if (this.getNbt() != other.getNbt() && (this.getNbt() == null || !this.getNbt().equals(other.getNbt()))) { return false; } - if (this.world != other.world && (this.world == null || !this.world.equals(other.world))) + if (this.getWorld() != other.getWorld() && (this.getWorld() == null || !this.getWorld().equals(other.getWorld()))) { return false; } - if (this.blockIdentifier != other.blockIdentifier && (this.blockIdentifier == null || !this.blockIdentifier.equals(other.blockIdentifier))) + if (this.getRegistryName() != other.getRegistryName() && (this.getRegistryName() == null || !this.getRegistryName().equals(other.getRegistryName()))) { return false; } @@ -287,14 +287,24 @@ public class BlockSnapshot implements Serializable public int hashCode() { int hash = 7; - hash = 73 * hash + this.pos.getX(); - hash = 73 * hash + this.pos.getY(); - hash = 73 * hash + this.pos.getZ(); - hash = 73 * hash + this.meta; - hash = 73 * hash + this.dimId; - hash = 73 * hash + (this.nbt != null ? this.nbt.hashCode() : 0); - hash = 73 * hash + (this.world != null ? this.world.hashCode() : 0); - hash = 73 * hash + (this.blockIdentifier != null ? this.blockIdentifier.hashCode() : 0); + hash = 73 * hash + this.getPos().getX(); + hash = 73 * hash + this.getPos().getY(); + hash = 73 * hash + this.getPos().getZ(); + hash = 73 * hash + this.getMeta(); + hash = 73 * hash + this.getDimId(); + hash = 73 * hash + (this.getNbt() != null ? this.getNbt().hashCode() : 0); + hash = 73 * hash + (this.getWorld() != null ? this.getWorld().hashCode() : 0); + hash = 73 * hash + (this.getRegistryName() != null ? this.getRegistryName().hashCode() : 0); return hash; } + + public BlockPos getPos() { return pos; } + public int getDimId() { return dimId; } + public void setReplacedBlock(IBlockState replacedBlock) { this.replacedBlock = replacedBlock; } + public int getFlag() { return flag; } + public void setFlag(int flag) { this.flag = flag; } + public NBTTagCompound getNbt() { return nbt; } + public void setWorld(World world) { this.world = world; } + public ResourceLocation getRegistryName() { return registryName; } + public int getMeta() { return meta; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/util/EnumHelper.java b/src/main/java/net/minecraftforge/common/util/EnumHelper.java index 066d0a8ceb..147377690e 100644 --- a/src/main/java/net/minecraftforge/common/util/EnumHelper.java +++ b/src/main/java/net/minecraftforge/common/util/EnumHelper.java @@ -3,6 +3,9 @@ package net.minecraftforge.common.util; import java.lang.reflect.*; import java.util.*; +import com.google.common.collect.Lists; + +import net.minecraftforge.fml.common.EnhancedRuntimeException; import net.minecraftforge.fml.common.FMLLog; import net.minecraft.block.BlockPressurePlate.Sensitivity; import net.minecraft.block.material.Material; @@ -15,8 +18,9 @@ import net.minecraft.item.EnumAction; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MovingObjectPosition.MovingObjectType; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.text.TextFormatting; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.gen.structure.StructureStrongholdPieces.Stronghold.Door; import net.minecraftforge.classloading.FMLForgePlugin; @@ -31,31 +35,30 @@ public class EnumHelper private static boolean isSetup = false; //Some enums are decompiled with extra arguments, so lets check for that - @SuppressWarnings("rawtypes") - private static Class[][] commonTypes = + private static Class[][] commonTypes = { {EnumAction.class}, - {ArmorMaterial.class, String.class, int.class, int[].class, int.class}, + {ArmorMaterial.class, String.class, int.class, int[].class, int.class, SoundEvent.class}, {EnumArt.class, String.class, int.class, int.class, int.class, int.class}, {EnumCreatureAttribute.class}, {EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class, boolean.class}, {Door.class}, {EnumEnchantmentType.class}, {Sensitivity.class}, - {MovingObjectType.class}, + {RayTraceResult.Type.class}, {EnumSkyBlock.class, int.class}, {EnumStatus.class}, {ToolMaterial.class, int.class, int.class, float.class, float.class, int.class}, - {EnumRarity.class, EnumChatFormatting.class, String.class} + {EnumRarity.class, TextFormatting.class, String.class} }; public static EnumAction addAction(String name) { return addEnum(EnumAction.class, name); } - public static ArmorMaterial addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability) + public static ArmorMaterial addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability, SoundEvent soundOnEquip) { - return addEnum(ArmorMaterial.class, name, textureName, durability, reductionAmounts, enchantability); + return addEnum(ArmorMaterial.class, name, textureName, durability, reductionAmounts, enchantability, soundOnEquip); } public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY) { @@ -65,8 +68,7 @@ public class EnumHelper { return addEnum(EnumCreatureAttribute.class, name); } - @SuppressWarnings("rawtypes") - public static EnumCreatureType addCreatureType(String name, Class typeClass, int maxNumber, Material material, boolean peaceful, boolean animal) + public static EnumCreatureType addCreatureType(String name, Class typeClass, int maxNumber, Material material, boolean peaceful, boolean animal) { return addEnum(EnumCreatureType.class, name, typeClass, maxNumber, material, peaceful, animal); } @@ -82,9 +84,9 @@ public class EnumHelper { return addEnum(Sensitivity.class, name); } - public static MovingObjectType addMovingObjectType(String name) + public static RayTraceResult.Type addMovingObjectType(String name) { - return addEnum(MovingObjectType.class, name); + return addEnum(RayTraceResult.Type.class, name); } public static EnumSkyBlock addSkyBlock(String name, int lightValue) { @@ -98,7 +100,7 @@ public class EnumHelper { return addEnum(ToolMaterial.class, name, harvestLevel, maxUses, efficiency, damage, enchantability); } - public static EnumRarity addRarity(String name, EnumChatFormatting color, String displayName) + public static EnumRarity addRarity(String name, TextFormatting color, String displayName) { return addEnum(EnumRarity.class, name, color, displayName); } @@ -143,11 +145,11 @@ public class EnumHelper private static < T extends Enum> T makeEnum(Class enumClass, String value, int ordinal, Class[] additionalTypes, Object[] additionalValues) throws Exception { - Object[] parms = new Object[additionalValues.length + 2]; - parms[0] = value; - parms[1] = Integer.valueOf(ordinal); - System.arraycopy(additionalValues, 0, parms, 2, additionalValues.length); - return enumClass.cast(newInstance.invoke(getConstructorAccessor(enumClass, additionalTypes), new Object[] {parms})); + Object[] params = new Object[additionalValues.length + 2]; + params[0] = value; + params[1] = ordinal; + System.arraycopy(additionalValues, 0, params, 2, additionalValues.length); + return enumClass.cast(newInstance.invoke(getConstructorAccessor(enumClass, additionalTypes), new Object[] {params})); } public static void setFailsafeFieldValue(Field field, Object target, Object value) throws Exception @@ -185,10 +187,9 @@ public class EnumHelper return addEnum(commonTypes, enumType, enumName, paramValues); } - @SuppressWarnings("rawtypes") - public static > T addEnum(Class[][] map, Class enumType, String enumName, Object... paramValues) + public static > T addEnum(Class[][] map, Class enumType, String enumName, Object... paramValues) { - for (Class[] lookup : map) + for (Class[] lookup : map) { if (lookup[0] == enumType) { @@ -203,8 +204,19 @@ public class EnumHelper return null; } - @SuppressWarnings("unchecked") - public static > T addEnum(Class enumType, String enumName, Class[] paramTypes, Object[] paramValues) + //Tests an enum is compatible with these args, throws an error if not. + public static void testEnum(Class> enumType, Class[] paramTypes) + { + addEnum(true, enumType, null, paramTypes, (Object[])null); + } + + public static > T addEnum(Class enumType, String enumName, Class[] paramTypes, Object... paramValues) + { + return addEnum(false, enumType, enumName, paramTypes, paramValues); + } + + @SuppressWarnings({ "unchecked", "serial" }) + private static > T addEnum(boolean test, final Class enumType, String enumName, final Class[] paramTypes, Object[] paramValues) { if (!isSetup) { @@ -242,14 +254,74 @@ public class EnumHelper if (valuesField == null) { - FMLLog.severe("Could not find $VALUES field for enum: %s", enumType.getName()); - FMLLog.severe("Runtime Deobf: %s", FMLForgePlugin.RUNTIME_DEOBF); - FMLLog.severe("Flags: %s", String.format("%16s", Integer.toBinaryString(flags)).replace(' ', '0')); - FMLLog.severe("Fields:"); + final List lines = Lists.newArrayList(); + lines.add(String.format("Could not find $VALUES field for enum: %s", enumType.getName())); + lines.add(String.format("Runtime Deobf: %s", FMLForgePlugin.RUNTIME_DEOBF)); + lines.add(String.format("Flags: %s", String.format("%16s", Integer.toBinaryString(flags)).replace(' ', '0'))); + lines.add( "Fields:"); for (Field field : fields) { String mods = String.format("%16s", Integer.toBinaryString(field.getModifiers())).replace(' ', '0'); - FMLLog.severe(" %s %s: %s", mods, field.getName(), field.getType().getName()); + lines.add(String.format(" %s %s: %s", mods, field.getName(), field.getType().getName())); + } + + for (String line : lines) + FMLLog.severe(line); + + if (test) + { + throw new EnhancedRuntimeException("Could not find $VALUES field for enum: " + enumType.getName()) + { + @Override + protected void printStackTrace(WrappedPrintStream stream) + { + for (String line : lines) + stream.println(line); + } + }; + } + return null; + } + + if (test) + { + Object ctr = null; + Exception ex = null; + try + { + ctr = getConstructorAccessor(enumType, paramTypes); + } + catch (Exception e) + { + ex = e; + } + if (ctr == null || ex != null) + { + throw new EnhancedRuntimeException(String.format("Could not find constructor for Enum %s", enumType.getName()), ex) + { + private String toString(Class[] cls) + { + StringBuilder b = new StringBuilder(); + for (int x = 0; x < cls.length; x++) + { + b.append(cls[x].getName()); + if (x != cls.length - 1) + b.append(", "); + } + return b.toString(); + } + @Override + protected void printStackTrace(WrappedPrintStream stream) + { + stream.println("Target Arguments:"); + stream.println(" java.lang.String, int, " + toString(paramTypes)); + stream.println("Found Constructors:"); + for (Constructor ctr : enumType.getDeclaredConstructors()) + { + stream.println(" " + toString(ctr.getParameterTypes())); + } + } + }; } return null; } @@ -260,7 +332,7 @@ public class EnumHelper { T[] previousValues = (T[])valuesField.get(enumType); List values = new ArrayList(Arrays.asList(previousValues)); - T newValue = (T)makeEnum(enumType, enumName, values.size(), paramTypes, paramValues); + T newValue = makeEnum(enumType, enumName, values.size(), paramTypes, paramValues); values.add(newValue); setFailsafeFieldValue(valuesField, null, values.toArray((T[]) Array.newInstance(enumType, 0))); cleanEnumCache(enumType); @@ -281,4 +353,4 @@ public class EnumHelper setup(); } } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraftforge/common/util/FakePlayer.java b/src/main/java/net/minecraftforge/common/util/FakePlayer.java index 3cbb21eb21..71467cd30b 100644 --- a/src/main/java/net/minecraftforge/common/util/FakePlayer.java +++ b/src/main/java/net/minecraftforge/common/util/FakePlayer.java @@ -2,15 +2,16 @@ package net.minecraftforge.common.util; import com.mojang.authlib.GameProfile; +import net.minecraft.entity.Entity; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.play.client.C15PacketClientSettings; -import net.minecraft.server.management.ItemInWorldManager; +import net.minecraft.network.play.client.CPacketClientSettings; +import net.minecraft.server.management.PlayerInteractionManager; import net.minecraft.stats.StatBase; import net.minecraft.util.DamageSource; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.Vec3; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraft.world.WorldServer; @@ -19,18 +20,18 @@ public class FakePlayer extends EntityPlayerMP { public FakePlayer(WorldServer world, GameProfile name) { - super(FMLCommonHandler.instance().getMinecraftServerInstance(), world, name, new ItemInWorldManager(world)); + super(FMLCommonHandler.instance().getMinecraftServerInstance(), world, name, new PlayerInteractionManager(world)); } - @Override public Vec3 getPositionVector(){ return new Vec3(0, 0, 0); } + @Override public Vec3d getPositionVector(){ return new Vec3d(0, 0, 0); } @Override public boolean canCommandSenderUseCommand(int i, String s){ return false; } - @Override public void addChatComponentMessage(IChatComponent chatmessagecomponent){} + @Override public void addChatComponentMessage(ITextComponent chatmessagecomponent){} @Override public void addStat(StatBase par1StatBase, int par2){} @Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){} @Override public boolean isEntityInvulnerable(DamageSource source){ return true; } @Override public boolean canAttackPlayer(EntityPlayer player){ return false; } @Override public void onDeath(DamageSource source){ return; } @Override public void onUpdate(){ return; } - @Override public void travelToDimension(int dim){ return; } - @Override public void handleClientSettings(C15PacketClientSettings pkt){ return; } + @Override public Entity changeDimension(int dim){ return this; } + @Override public void handleClientSettings(CPacketClientSettings pkt){ return; } } diff --git a/src/main/java/net/minecraftforge/common/util/JsonUtils.java b/src/main/java/net/minecraftforge/common/util/JsonUtils.java index 68d2d34eef..bae684ea2c 100644 --- a/src/main/java/net/minecraftforge/common/util/JsonUtils.java +++ b/src/main/java/net/minecraftforge/common/util/JsonUtils.java @@ -26,16 +26,16 @@ public class JsonUtils public ImmutableList deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { final Type[] typeArguments = ((ParameterizedType) type).getActualTypeArguments(); - final Type parameterizedType = listOf(typeArguments[0]).getType(); - final List list = context.deserialize(json, parameterizedType); + final Type parametrizedType = listOf(typeArguments[0]).getType(); + final List list = context.deserialize(json, parametrizedType); return ImmutableList.copyOf(list); } public JsonElement serialize(ImmutableList src, Type type, JsonSerializationContext context) { final Type[] typeArguments = ((ParameterizedType) type).getActualTypeArguments(); - final Type parameterizedType = listOf(typeArguments[0]).getType(); - return context.serialize(src, parameterizedType); + final Type parametrizedType = listOf(typeArguments[0]).getType(); + return context.serialize(src, parametrizedType); } } diff --git a/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java b/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java index 585c5a715d..94baabc085 100644 --- a/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java +++ b/src/main/java/net/minecraftforge/event/AnvilUpdateEvent.java @@ -14,19 +14,29 @@ import net.minecraft.item.ItemStack; @Cancelable public class AnvilUpdateEvent extends Event { - public final ItemStack left; // The left side of the input - public final ItemStack right; // The right side of the input - public final String name; // The name to set the item, if the user specified one. - public ItemStack output; // Set this to set the output stack - public int cost; // The base cost, set this to change it if output != null - public int materialCost; // The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack. + private final ItemStack left; // The left side of the input + private final ItemStack right; // The right side of the input + private final String name; // The name to set the item, if the user specified one. + private ItemStack output; // Set this to set the output stack + private int cost; // The base cost, set this to change it if output != null + private int materialCost; // The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack. public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost) { this.left = left; this.right = right; this.name = name; - this.cost = cost; - this.materialCost = 0; + this.setCost(cost); + this.setMaterialCost(0); } + + public ItemStack getLeft() { return left; } + public ItemStack getRight() { return right; } + public String getName() { return name; } + public ItemStack getOutput() { return output; } + public void setOutput(ItemStack output) { this.output = output; } + public int getCost() { return cost; } + public void setCost(int cost) { this.cost = cost; } + public int getMaterialCost() { return materialCost; } + public void setMaterialCost(int materialCost) { this.materialCost = materialCost; } } diff --git a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java index a05b6780cb..fe13a88edb 100644 --- a/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java +++ b/src/main/java/net/minecraftforge/event/AttachCapabilitiesEvent.java @@ -37,7 +37,7 @@ public class AttachCapabilitiesEvent extends Event /** * Adds a capability to be attached to this object. * Keys MUST be unique, it is suggested that you set the domain to your mod ID. - * If the capability is an instance of INBTSerializeable, this key will be used when serializing this capability. + * If the capability is an instance of INBTSerializable, this key will be used when serializing this capability. * * @param key The name of owner of this capability provider. * @param cap The capability provider diff --git a/src/main/java/net/minecraftforge/event/CommandEvent.java b/src/main/java/net/minecraftforge/event/CommandEvent.java index 5c316b5148..58f2943082 100644 --- a/src/main/java/net/minecraftforge/event/CommandEvent.java +++ b/src/main/java/net/minecraftforge/event/CommandEvent.java @@ -26,15 +26,22 @@ import net.minecraft.command.ICommandSender; public class CommandEvent extends Event { - public final ICommand command; - public final ICommandSender sender; - public String[] parameters; - public Throwable exception; + private final ICommand command; + private final ICommandSender sender; + private String[] parameters; + private Throwable exception; public CommandEvent(ICommand command, ICommandSender sender, String[] parameters) { this.command = command; this.sender = sender; - this.parameters = parameters; + this.setParameters(parameters); } + + public ICommand getCommand() { return command; } + public ICommandSender getSender() { return sender; } + public String[] getParameters() { return parameters; } + public void setParameters(String[] parameters) { this.parameters = parameters; } + public Throwable getException() { return exception; } + public void setException(Throwable exception) { this.exception = exception; } } diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index 46d6f1acb6..9bbdfceb50 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -4,7 +4,6 @@ import java.io.File; import java.util.EnumSet; import java.util.List; -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; @@ -19,17 +18,24 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; +import net.minecraft.util.ActionResult; import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; +import net.minecraft.util.EnumHand; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.text.ITextComponent; import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.WorldSettings; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.storage.IPlayerFileData; import net.minecraft.world.storage.SaveHandler; import net.minecraftforge.client.event.ClientChatReceivedEvent; @@ -45,14 +51,16 @@ import net.minecraftforge.event.entity.EntityMountEvent; import net.minecraftforge.event.entity.EntityStruckByLightningEvent; import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; import net.minecraftforge.event.entity.item.ItemExpireEvent; +import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent; import net.minecraftforge.event.entity.living.LivingExperienceDropEvent; import net.minecraftforge.event.entity.living.LivingHealEvent; import net.minecraftforge.event.entity.living.LivingPackSizeEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent; import net.minecraftforge.event.entity.living.LivingSpawnEvent.AllowDespawn; import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent; +import net.minecraftforge.event.entity.player.ArrowLooseEvent; +import net.minecraftforge.event.entity.player.ArrowNockEvent; import net.minecraftforge.event.entity.player.BonemealEvent; -import net.minecraftforge.event.entity.player.EntityInteractEvent; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.event.entity.player.FillBucketEvent; import net.minecraftforge.event.entity.player.ItemTooltipEvent; @@ -60,17 +68,16 @@ import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent; import net.minecraftforge.event.entity.player.PlayerDropsEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerFlyableFallEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; import net.minecraftforge.event.entity.player.PlayerSetSpawnEvent; import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; -import net.minecraftforge.event.entity.player.PlayerUseItemEvent; import net.minecraftforge.event.entity.player.PlayerWakeUpEvent; import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent; import net.minecraftforge.event.entity.player.UseHoeEvent; +import net.minecraftforge.event.terraingen.ChunkGeneratorEvent; +import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.world.BlockEvent; -import net.minecraftforge.event.world.BlockEvent.NeighborNotifyEvent; import net.minecraftforge.event.world.BlockEvent.MultiPlaceEvent; +import net.minecraftforge.event.world.BlockEvent.NeighborNotifyEvent; import net.minecraftforge.event.world.BlockEvent.PlaceEvent; import net.minecraftforge.event.world.ExplosionEvent; import net.minecraftforge.event.world.WorldEvent; @@ -84,7 +91,7 @@ public class ForgeEventFactory public static MultiPlaceEvent onPlayerMultiBlockPlace(EntityPlayer player, List blockSnapshots, EnumFacing direction) { BlockSnapshot snap = blockSnapshots.get(0); - IBlockState placedAgainst = snap.world.getBlockState(snap.pos.offset(direction.getOpposite())); + IBlockState placedAgainst = snap.getWorld().getBlockState(snap.getPos().offset(direction.getOpposite())); MultiPlaceEvent event = new MultiPlaceEvent(blockSnapshots, placedAgainst, player); MinecraftForge.EVENT_BUS.post(event); return event; @@ -92,7 +99,7 @@ public class ForgeEventFactory public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, EnumFacing direction) { - IBlockState placedAgainst = blockSnapshot.world.getBlockState(blockSnapshot.pos.offset(direction.getOpposite())); + IBlockState placedAgainst = blockSnapshot.getWorld().getBlockState(blockSnapshot.getPos().offset(direction.getOpposite())); PlaceEvent event = new PlaceEvent(blockSnapshot, placedAgainst, player); MinecraftForge.EVENT_BUS.post(event); return event; @@ -105,35 +112,22 @@ public class ForgeEventFactory return event; } - public static boolean doPlayerHarvestCheck(EntityPlayer player, Block block, boolean success) + public static boolean doPlayerHarvestCheck(EntityPlayer player, IBlockState state, boolean success) { - PlayerEvent.HarvestCheck event = new PlayerEvent.HarvestCheck(player, block, success); + PlayerEvent.HarvestCheck event = new PlayerEvent.HarvestCheck(player, state, success); MinecraftForge.EVENT_BUS.post(event); - return event.success; + return event.canHarvest(); } public static float getBreakSpeed(EntityPlayer player, IBlockState state, float original, BlockPos pos) { PlayerEvent.BreakSpeed event = new PlayerEvent.BreakSpeed(player, state, original, pos); - return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.newSpeed); + return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getNewSpeed()); } - @Deprecated - public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, World world, BlockPos pos, EnumFacing face) + public static void onPlayerDestroyItem(EntityPlayer player, ItemStack stack, EnumHand hand) { - return onPlayerInteract(player, action, world, pos, face, null); - } - - public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, World world, BlockPos pos, EnumFacing face, Vec3 localPos) - { - PlayerInteractEvent event = new PlayerInteractEvent(player, action, pos, face, world, localPos); - MinecraftForge.EVENT_BUS.post(event); - return event; - } - - public static void onPlayerDestroyItem(EntityPlayer player, ItemStack stack) - { - MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack)); + MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack, hand)); } public static Result canEntitySpawn(EntityLiving entity, World world, float x, float y, float z) @@ -172,28 +166,28 @@ public class ForgeEventFactory { return null; } - return event.list; + return event.getList(); } public static int getMaxSpawnPackSize(EntityLiving entity) { LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity); MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent); - return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.getMaxSpawnedInChunk(); + return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.getMaxPackSize() : entity.getMaxSpawnedInChunk(); } public static String getPlayerDisplayName(EntityPlayer player, String username) { PlayerEvent.NameFormat event = new PlayerEvent.NameFormat(player, username); MinecraftForge.EVENT_BUS.post(event); - return event.displayname; + return event.getDisplayname(); } public static float fireBlockHarvesting(List drops, World world, BlockPos pos, IBlockState state, int fortune, float dropChance, boolean silkTouch, EntityPlayer player) { BlockEvent.HarvestDropsEvent event = new BlockEvent.HarvestDropsEvent(world, pos, state, fortune, dropChance, drops, player, silkTouch); MinecraftForge.EVENT_BUS.post(event); - return event.dropChance; + return event.getDropChance(); } public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, EntityPlayer entityPlayer, List toolTip, boolean showAdvancedItemTooltips) @@ -215,28 +209,28 @@ public class ForgeEventFactory return MinecraftForge.EVENT_BUS.post(new EntityStruckByLightningEvent(entity, bolt)); } - public static int onItemUseStart(EntityPlayer player, ItemStack item, int duration) + public static int onItemUseStart(EntityLivingBase entity, ItemStack item, int duration) { - PlayerUseItemEvent event = new PlayerUseItemEvent.Start(player, item, duration); - return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.duration; + LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Start(entity, item, duration); + return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration(); } - public static int onItemUseTick(EntityPlayer player, ItemStack item, int duration) + public static int onItemUseTick(EntityLivingBase entity, ItemStack item, int duration) { - PlayerUseItemEvent event = new PlayerUseItemEvent.Tick(player, item, duration); - return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.duration; + LivingEntityUseItemEvent event = new LivingEntityUseItemEvent.Tick(entity, item, duration); + return MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getDuration(); } - public static boolean onUseItemStop(EntityPlayer player, ItemStack item, int duration) + public static boolean onUseItemStop(EntityLivingBase entity, ItemStack item, int duration) { - return MinecraftForge.EVENT_BUS.post(new PlayerUseItemEvent.Stop(player, item, duration)); + return MinecraftForge.EVENT_BUS.post(new LivingEntityUseItemEvent.Stop(entity, item, duration)); } - public static ItemStack onItemUseFinish(EntityPlayer player, ItemStack item, int duration, ItemStack result) + public static ItemStack onItemUseFinish(EntityLivingBase entity, ItemStack item, int duration, ItemStack result) { - PlayerUseItemEvent.Finish event = new PlayerUseItemEvent.Finish(player, item, duration, result); + LivingEntityUseItemEvent.Finish event = new LivingEntityUseItemEvent.Finish(entity, item, duration, result); MinecraftForge.EVENT_BUS.post(event); - return event.result; + return event.getResultStack(); } public static void onStartEntityTracking(Entity entity, EntityPlayer player) @@ -266,10 +260,10 @@ public class ForgeEventFactory MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, dir, uuidString)); } - public static IChatComponent onClientChat(byte type, IChatComponent message) + public static ITextComponent onClientChat(byte type, ITextComponent message) { ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message); - return MinecraftForge.EVENT_BUS.post(event) ? null : event.message; + return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage(); } public static int onHoeUse(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos) @@ -297,23 +291,23 @@ public class ForgeEventFactory return 0; } - public static ItemStack onBucketUse(EntityPlayer player, World world, ItemStack stack, MovingObjectPosition target) + public static ActionResult onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target) { FillBucketEvent event = new FillBucketEvent(player, stack, world, target); - if (MinecraftForge.EVENT_BUS.post(event)) return stack; + if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult(EnumActionResult.FAIL, stack); if (event.getResult() == Result.ALLOW) { if (player.capabilities.isCreativeMode) - return stack; + return new ActionResult(EnumActionResult.SUCCESS, stack); if (--stack.stackSize <= 0) - return event.result; + return new ActionResult(EnumActionResult.SUCCESS, event.getFilledBucket()); - if (!player.inventory.addItemStackToInventory(event.result)) - player.dropPlayerItemWithRandomChoice(event.result, false); + if (!player.inventory.addItemStackToInventory(event.getFilledBucket())) + player.dropPlayerItemWithRandomChoice(event.getFilledBucket(), false); - return stack; + return new ActionResult(EnumActionResult.SUCCESS, stack); } return null; } @@ -322,23 +316,12 @@ public class ForgeEventFactory { EntityEvent.CanUpdate event = new EntityEvent.CanUpdate(entity); MinecraftForge.EVENT_BUS.post(event); - return event.canUpdate; + return event.getCanUpdate(); } - /** - * Use {@link #onPlaySoundAtEntity(Entity,String,float,float)} - */ - @Deprecated - public static String onPlaySoundAt(Entity entity, String name, float volume, float pitch) + public static PlaySoundAtEntityEvent onPlaySoundAtEntity(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch) { - PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(entity, name, volume, pitch); - MinecraftForge.EVENT_BUS.post(event); - return event.name; - } - - public static PlaySoundAtEntityEvent onPlaySoundAtEntity(Entity entity, String name, float volume, float pitch) - { - PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(entity, name, volume, pitch); + PlaySoundAtEntityEvent event = new PlaySoundAtEntityEvent(entity, name, category, volume, pitch); MinecraftForge.EVENT_BUS.post(event); return event; } @@ -348,7 +331,7 @@ public class ForgeEventFactory if (item == null) return -1; ItemExpireEvent event = new ItemExpireEvent(entity, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, entity.worldObj))); if (!MinecraftForge.EVENT_BUS.post(event)) return -1; - return event.extraLife; + return event.getExtraLife(); } public static int onItemPickup(EntityItem entityItem, EntityPlayer entityIn, ItemStack itemstack) @@ -365,16 +348,11 @@ public class ForgeEventFactory { for (EntityItem item : capturedDrops) { - player.joinEntityItemWithWorld(item); + player.dropItemAndGetStack(item); } } } - public static boolean canInteractWith(EntityPlayer player, Entity entity) - { - return !MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(player, entity)); - } - public static boolean canMountEntity(Entity entityMounting, Entity entityBeingMounted, boolean isMounting) { boolean isCanceled = MinecraftForge.EVENT_BUS.post(new EntityMountEvent(entityMounting, entityBeingMounted, entityMounting.worldObj, isMounting)); @@ -392,12 +370,12 @@ public class ForgeEventFactory { PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos); MinecraftForge.EVENT_BUS.post(event); - return event.result; + return event.getResultStatus(); } - public static void onPlayerWakeup(EntityPlayer player, boolean wakeImmediatly, boolean updateWorldFlag, boolean setSpawn) + public static void onPlayerWakeup(EntityPlayer player, boolean wakeImmediately, boolean updateWorldFlag, boolean setSpawn) { - MinecraftForge.EVENT_BUS.post(new PlayerWakeUpEvent(player, wakeImmediatly, updateWorldFlag, setSpawn)); + MinecraftForge.EVENT_BUS.post(new PlayerWakeUpEvent(player, wakeImmediately, updateWorldFlag, setSpawn)); } public static void onPlayerFall(EntityPlayer player, float distance, float multiplier) @@ -443,10 +421,10 @@ public class ForgeEventFactory public static float onLivingHeal(EntityLivingBase entity, float amount) { LivingHealEvent event = new LivingHealEvent(entity, amount); - return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.amount); + return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount()); } - public static boolean onPotionAttemptBreaw(ItemStack[] stacks) + public static boolean onPotionAttemptBrew(ItemStack[] stacks) { ItemStack[] tmp = new ItemStack[stacks.length]; for (int x = 0; x < tmp.length; x++) @@ -516,9 +494,40 @@ public class ForgeEventFactory Result canContinueSleep = evt.getResult(); if (canContinueSleep == Result.DEFAULT) - return player.worldObj.getBlockState(player.playerLocation).getBlock().isBed(player.worldObj, player.playerLocation, player); + { + IBlockState state = player.worldObj.getBlockState(player.playerLocation); + return state.getBlock().isBed(state, player.worldObj, player.playerLocation, player); + } else return canContinueSleep == Result.ALLOW; } + public static ActionResult onArrowNock(ItemStack item, World world, EntityPlayer player, EnumHand hand, boolean hasAmmo) + { + ArrowNockEvent event = new ArrowNockEvent(player, item, hand, world, hasAmmo); + if (MinecraftForge.EVENT_BUS.post(event)) + return new ActionResult(EnumActionResult.FAIL, item); + return event.getAction(); + } + + public static int onArrowLoose(ItemStack stack, World world, EntityPlayer player, int charge, boolean hasAmmo) + { + ArrowLooseEvent event = new ArrowLooseEvent(player, stack, world, charge, hasAmmo); + if (MinecraftForge.EVENT_BUS.post(event)) + return -1; + return event.getCharge(); + } + + public static boolean onReplaceBiomeBlocks(IChunkGenerator gen, int x, int z, ChunkPrimer primer, World world) + { + ChunkGeneratorEvent.ReplaceBiomeBlocks event = new ChunkGeneratorEvent.ReplaceBiomeBlocks(gen, x, z, primer, world); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); + return event.getResult() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY; + } + + public static void onChunkPopulate(boolean pre, IChunkGenerator gen, World world, int x, int z, boolean hasVillageGenerated) + { + MinecraftForge.EVENT_BUS.post(pre ? new PopulateChunkEvent.Pre(gen, world, world.rand, x, z, hasVillageGenerated) : new PopulateChunkEvent.Post(gen, world, world.rand, x, z, hasVillageGenerated)); + } + } diff --git a/src/main/java/net/minecraftforge/event/ServerChatEvent.java b/src/main/java/net/minecraftforge/event/ServerChatEvent.java index 69f9ce56c5..af326955c7 100644 --- a/src/main/java/net/minecraftforge/event/ServerChatEvent.java +++ b/src/main/java/net/minecraftforge/event/ServerChatEvent.java @@ -3,8 +3,7 @@ package net.minecraftforge.event; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; /** * ServerChatEvent is fired whenever a C01PacketChatMessage is processed.
    @@ -26,11 +25,10 @@ import net.minecraft.util.IChatComponent; @Cancelable public class ServerChatEvent extends Event { - public final String message, username; - public final EntityPlayerMP player; - @Deprecated //Use methods below - public ChatComponentTranslation component; - public ServerChatEvent(EntityPlayerMP player, String message, ChatComponentTranslation component) + private final String message, username; + private final EntityPlayerMP player; + private ITextComponent component; + public ServerChatEvent(EntityPlayerMP player, String message, ITextComponent component) { super(); this.message = message; @@ -39,16 +37,17 @@ public class ServerChatEvent extends Event this.component = component; } - public void setComponent(IChatComponent e) + public void setComponent(ITextComponent e) { - if (e instanceof ChatComponentTranslation) - this.component = (ChatComponentTranslation)e; - else - this.component = new ChatComponentTranslation("%s", e); + this.component = e; } - public IChatComponent getComponent() + public ITextComponent getComponent() { return this.component; } + + public String getMessage() { return this.message; } + public String getUsername() { return this.username; } + public EntityPlayerMP getPlayer() { return this.player; } } diff --git a/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java b/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java index 8ec9d6724c..b3c194d80c 100644 --- a/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java +++ b/src/main/java/net/minecraftforge/event/brewing/PotionBrewEvent.java @@ -73,8 +73,7 @@ public class PotionBrewEvent extends Event *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
    **/ - @SuppressWarnings("deprecation") - public static class Post extends PotionBrewedEvent + public static class Post extends PotionBrewEvent { public Post(ItemStack[] stacks) { diff --git a/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java b/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java deleted file mode 100644 index 59bf94d614..0000000000 --- a/src/main/java/net/minecraftforge/event/brewing/PotionBrewedEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.minecraftforge.event.brewing; - -import net.minecraft.item.ItemStack; - -/** - * PotionBrewedEvent is fired when a potion is brewed in the brewing stand. - *
    - * The event is fired during the TileEntityBrewingStand#brewPotions() method invocation.
    - *
    - * {@link #brewingStacks} contains the itemstack array from the TileEntityBrewer holding all items in Brewer.
    - *
    - * This event is not {@link Cancelable}.
    - *
    - * This event does not have a result. {@link HasResult}
    - *
    - * This event is fired on the {@link MinecraftForge#EVENT_BUS}.
    - **/ -@Deprecated // remove in 1.9 -public class PotionBrewedEvent extends PotionBrewEvent -{ - /** - * The brewing stacks in the brewing stand. Each index has the possibility to be null, so make sure you check. - * Changing this array to another one has no effect. - */ - @Deprecated - public ItemStack[] brewingStacks; - public PotionBrewedEvent(ItemStack[] brewingStacks) - { - super(brewingStacks); - this.brewingStacks = brewingStacks; - } -} diff --git a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java index 76c0415818..462de61a3d 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityEvent.java @@ -14,13 +14,18 @@ import net.minecraft.entity.Entity; **/ public class EntityEvent extends Event { - public final Entity entity; + private final Entity entity; public EntityEvent(Entity entity) { this.entity = entity; } - + + public Entity getEntity() + { + return entity; + } + /** * EntityConstructing is fired when an Entity is being created.
    * This event is fired within the constructor of the Entity.
    @@ -54,11 +59,21 @@ public class EntityEvent extends Event **/ public static class CanUpdate extends EntityEvent { - public boolean canUpdate = false; + private boolean canUpdate = false; public CanUpdate(Entity entity) { super(entity); } + + public boolean getCanUpdate() + { + return canUpdate; + } + + public void setCanUpdate(boolean canUpdate) + { + this.canUpdate = canUpdate; + } } /** @@ -74,18 +89,27 @@ public class EntityEvent extends Event **/ public static class EnteringChunk extends EntityEvent { - public int newChunkX; - public int newChunkZ; - public int oldChunkX; - public int oldChunkZ; + private int newChunkX; + private int newChunkZ; + private int oldChunkX; + private int oldChunkZ; public EnteringChunk(Entity entity, int newChunkX, int newChunkZ, int oldChunkX, int oldChunkZ) { super(entity); - this.newChunkX = newChunkX; - this.newChunkZ = newChunkZ; - this.oldChunkX = oldChunkX; - this.oldChunkZ = oldChunkZ; + this.setNewChunkX(newChunkX); + this.setNewChunkZ(newChunkZ); + this.setOldChunkX(oldChunkX); + this.setOldChunkZ(oldChunkZ); } + + public int getNewChunkX() { return newChunkX; } + public void setNewChunkX(int newChunkX) { this.newChunkX = newChunkX; } + public int getNewChunkZ() { return newChunkZ; } + public void setNewChunkZ(int newChunkZ) { this.newChunkZ = newChunkZ; } + public int getOldChunkX() { return oldChunkX; } + public void setOldChunkX(int oldChunkX) { this.oldChunkX = oldChunkX; } + public int getOldChunkZ() { return oldChunkZ; } + public void setOldChunkZ(int oldChunkZ) { this.oldChunkZ = oldChunkZ; } } } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java index 9882373b17..a7ac552448 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityJoinWorldEvent.java @@ -22,11 +22,16 @@ import net.minecraft.world.World; public class EntityJoinWorldEvent extends EntityEvent { - public final World world; + private final World world; public EntityJoinWorldEvent(Entity entity, World world) { super(entity); this.world = world; } + + public World getWorld() + { + return world; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java index c849e4792c..921917eb69 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityMountEvent.java @@ -23,9 +23,9 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult; public class EntityMountEvent extends EntityEvent { - public final Entity entityMounting; - public final Entity entityBeingMounted; - public final World worldObj; + private final Entity entityMounting; + private final Entity entityBeingMounted; + private final World worldObj; private final boolean isMounting; @@ -48,4 +48,18 @@ public class EntityMountEvent extends EntityEvent return !isMounting; } + public Entity getEntityMounting() + { + return entityMounting; + } + + public Entity getEntityBeingMounted() + { + return entityBeingMounted; + } + + public World getWorldObj() + { + return worldObj; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java index b9fdd3f02a..24e3cc2f17 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityStruckByLightningEvent.java @@ -21,11 +21,16 @@ import net.minecraft.entity.effect.EntityLightningBolt; @Cancelable public class EntityStruckByLightningEvent extends EntityEvent { - public final EntityLightningBolt lightning; + private final EntityLightningBolt lightning; public EntityStruckByLightningEvent(Entity entity, EntityLightningBolt lightning) { super(entity); this.lightning = lightning; } + + public EntityLightningBolt getLightning() + { + return lightning; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java b/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java index d62c2765bd..ebfc21a153 100644 --- a/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/EntityTravelToDimensionEvent.java @@ -19,11 +19,16 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult; @Cancelable public class EntityTravelToDimensionEvent extends EntityEvent { - public final int dimension; + private final int dimension; public EntityTravelToDimensionEvent(Entity entity, int dimension) { super(entity); this.dimension = dimension; } + + public int getDimension() + { + return dimension; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java index 5b933ebd87..7ca05f304d 100644 --- a/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/PlaySoundAtEntityEvent.java @@ -2,6 +2,8 @@ package net.minecraftforge.event.entity; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraft.entity.Entity; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvent; /** * PlaySoundAtEntityEvent is fired a sound is to be played at an Entity
    @@ -25,20 +27,33 @@ import net.minecraft.entity.Entity; **/ @Cancelable public class PlaySoundAtEntityEvent extends EntityEvent -{ - public String name; - public final float volume; - public final float pitch; - public float newVolume; - public float newPitch; - - public PlaySoundAtEntityEvent(Entity entity, String name, float volume, float pitch) +{ + private SoundEvent name; + private SoundCategory category; + private final float volume; + private final float pitch; + private float newVolume; + private float newPitch; + + public PlaySoundAtEntityEvent(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch) { super(entity); this.name = name; + this.category = category; this.volume = volume; this.pitch = pitch; this.newVolume = volume; this.newPitch = pitch; } + + public SoundEvent getSound() { return this.name; } + public SoundCategory getCategory() { return this.category; } + public float getDefaultVolume() { return this.volume; } + public float getDefaultPitch() { return this.pitch; } + public float getVolume() { return this.newVolume; } + public float getPitch() { return this.newPitch; } + public void setSound(SoundEvent value) { this.name = value; } + public void setCategory(SoundCategory category) { this.category = category; } + public void setVolume(float value) { this.newVolume = value; } + public void setPitch(float value) { this.newPitch = value; } } diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java index e9667a2e98..c41a247187 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemEvent.java @@ -11,10 +11,7 @@ import net.minecraftforge.event.entity.EntityEvent; */ public class ItemEvent extends EntityEvent { - /** - * The relevant EntityItem for this event, already cast for you. - */ - public final EntityItem entityItem; + private final EntityItem entityItem; /** * Creates a new event for an EntityItem. @@ -26,4 +23,12 @@ public class ItemEvent extends EntityEvent super(itemEntity); this.entityItem = itemEntity; } + + /** + * The relevant EntityItem for this event, already cast for you. + */ + public EntityItem getEntityItem() + { + return entityItem; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java index db7b79db10..8d4de1e9e9 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemExpireEvent.java @@ -7,13 +7,13 @@ import net.minecraft.entity.item.EntityItem; * Event that is fired when an EntityItem's age has reached its maximum * lifespan. Canceling this event will prevent the EntityItem from being * flagged as dead, thus staying it's removal from the world. If canceled - * it will add more time to the entitie's life equal to extraLife. + * it will add more time to the entities life equal to extraLife. */ @Cancelable public class ItemExpireEvent extends ItemEvent { - public int extraLife; + private int extraLife; /** * Creates a new event for an expiring EntityItem. @@ -24,6 +24,16 @@ public class ItemExpireEvent extends ItemEvent public ItemExpireEvent(EntityItem entityItem, int extraLife) { super(entityItem); + this.setExtraLife(extraLife); + } + + public int getExtraLife() + { + return extraLife; + } + + public void setExtraLife(int extraLife) + { this.extraLife = extraLife; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java index c167ce8d0b..090a7140e4 100644 --- a/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/item/ItemTossEvent.java @@ -14,10 +14,7 @@ import net.minecraft.entity.player.EntityPlayer; public class ItemTossEvent extends ItemEvent { - /** - * The player tossing the item. - */ - public final EntityPlayer player; + private final EntityPlayer player; /** * Creates a new event for EntityItems tossed by a player. @@ -30,4 +27,12 @@ public class ItemTossEvent extends ItemEvent super(entityItem); this.player = player; } + + /** + * The player tossing the item. + */ + public EntityPlayer getPlayer() + { + return player; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java b/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java index d03b071a44..bc9190f4c1 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/EnderTeleportEvent.java @@ -12,17 +12,26 @@ import net.minecraft.entity.EntityLivingBase; public class EnderTeleportEvent extends LivingEvent { - public double targetX; - public double targetY; - public double targetZ; - public float attackDamage; + private double targetX; + private double targetY; + private double targetZ; + private float attackDamage; public EnderTeleportEvent(EntityLivingBase entity, double targetX, double targetY, double targetZ, float attackDamage) { super(entity); - this.targetX = targetX; - this.targetY = targetY; - this.targetZ = targetZ; - this.attackDamage = attackDamage; + this.setTargetX(targetX); + this.setTargetY(targetY); + this.setTargetZ(targetZ); + this.setAttackDamage(attackDamage); } + + public double getTargetX() { return targetX; } + public void setTargetX(double targetX) { this.targetX = targetX; } + public double getTargetY() { return targetY; } + public void setTargetY(double targetY) { this.targetY = targetY; } + public double getTargetZ() { return targetZ; } + public void setTargetZ(double targetZ) { this.targetZ = targetZ; } + public float getAttackDamage() { return attackDamage; } + public void setAttackDamage(float attackDamage) { this.attackDamage = attackDamage; } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java index 5e4ae66a27..ec99b75a64 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingAttackEvent.java @@ -25,12 +25,15 @@ import net.minecraft.entity.EntityLivingBase; @Cancelable public class LivingAttackEvent extends LivingEvent { - public final DamageSource source; - public final float ammount; - public LivingAttackEvent(EntityLivingBase entity, DamageSource source, float ammount) + private final DamageSource source; + private final float amount; + public LivingAttackEvent(EntityLivingBase entity, DamageSource source, float amount) { super(entity); this.source = source; - this.ammount = ammount; + this.amount = amount; } + + public DamageSource getSource() { return source; } + public float getAmount() { return amount; } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java index 307434232a..3287374798 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDeathEvent.java @@ -25,10 +25,15 @@ import net.minecraft.entity.EntityLivingBase; @Cancelable public class LivingDeathEvent extends LivingEvent { - public final DamageSource source; + private final DamageSource source; public LivingDeathEvent(EntityLivingBase entity, DamageSource source) { super(entity); this.source = source; } + + public DamageSource getSource() + { + return source; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java index 787e51192b..4f2a82a29b 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingDropsEvent.java @@ -29,10 +29,10 @@ import net.minecraft.entity.EntityLivingBase; @Cancelable public class LivingDropsEvent extends LivingEvent { - public final DamageSource source; - public final List drops; - public final int lootingLevel; - public final boolean recentlyHit; + private final DamageSource source; + private final List drops; + private final int lootingLevel; + private final boolean recentlyHit; public LivingDropsEvent(EntityLivingBase entity, DamageSource source, List drops, int lootingLevel, boolean recentlyHit) { @@ -42,4 +42,24 @@ public class LivingDropsEvent extends LivingEvent this.lootingLevel = lootingLevel; this.recentlyHit = recentlyHit; } + + public DamageSource getSource() + { + return source; + } + + public List getDrops() + { + return drops; + } + + public int getLootingLevel() + { + return lootingLevel; + } + + public boolean isRecentlyHit() + { + return recentlyHit; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerUseItemEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java similarity index 54% rename from src/main/java/net/minecraftforge/event/entity/player/PlayerUseItemEvent.java rename to src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java index 2387de5d7f..6047e79d7b 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerUseItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEntityUseItemEvent.java @@ -1,18 +1,33 @@ -package net.minecraftforge.event.entity.player; +package net.minecraftforge.event.entity.living; -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.eventhandler.Cancelable; -public abstract class PlayerUseItemEvent extends PlayerEvent +public abstract class LivingEntityUseItemEvent extends LivingEvent { - public final ItemStack item; - public int duration; + private final ItemStack item; + private int duration; - private PlayerUseItemEvent(EntityPlayer player, ItemStack item, int duration) + private LivingEntityUseItemEvent(EntityLivingBase entity, ItemStack item, int duration) { - super(player); + super(entity); this.item = item; + this.setDuration(duration); + } + + public ItemStack getItem() + { + return item; + } + + public int getDuration() + { + return duration; + } + + public void setDuration(int duration) + { this.duration = duration; } @@ -28,11 +43,11 @@ public abstract class PlayerUseItemEvent extends PlayerEvent * */ @Cancelable - public static class Start extends PlayerUseItemEvent + public static class Start extends LivingEntityUseItemEvent { - public Start(EntityPlayer player, ItemStack item, int duration) + public Start(EntityLivingBase entity, ItemStack item, int duration) { - super(player, item, duration); + super(entity, item, duration); } } @@ -43,32 +58,32 @@ public abstract class PlayerUseItemEvent extends PlayerEvent * */ @Cancelable - public static class Tick extends PlayerUseItemEvent + public static class Tick extends LivingEntityUseItemEvent { - public Tick(EntityPlayer player, ItemStack item, int duration) + public Tick(EntityLivingBase entity, ItemStack item, int duration) { - super(player, item, duration); + super(entity, item, duration); } } /** - * Fired when a player stops using an item without the use duration timing out. + * Fired when a player stops using an item without the use duration timing out. * Example: * Stop eating 1/2 way through * Stop defending with sword * Stop drawing bow. This case would fire the arrow - * + * * Duration on this event is how long the item had left in it's count down before 'finishing' * - * Canceling this event will prevent the Item from being notified that it has stopped being used, + * Canceling this event will prevent the Item from being notified that it has stopped being used, * The only vanilla item this would effect are bows, and it would cause them NOT to fire there arrow. */ @Cancelable - public static class Stop extends PlayerUseItemEvent + public static class Stop extends LivingEntityUseItemEvent { - public Stop(EntityPlayer player, ItemStack item, int duration) + public Stop(EntityLivingBase entity, ItemStack item, int duration) { - super(player, item, duration); + super(entity, item, duration); } } @@ -76,18 +91,28 @@ public abstract class PlayerUseItemEvent extends PlayerEvent * Fired after an item has fully finished being used. * The item has been notified that it was used, and the item/result stacks reflect after that state. * This means that when this is fired for a Potion, the potion effect has already been applied. - * + * * If you wish to cancel those effects, you should cancel one of the above events. - * + * * The result item stack is the stack that is placed in the player's inventory in replacement of the stack that is currently being used. * */ - public static class Finish extends PlayerUseItemEvent + public static class Finish extends LivingEntityUseItemEvent { - public ItemStack result; - public Finish(EntityPlayer player, ItemStack item, int duration, ItemStack result) + private ItemStack result; + public Finish(EntityLivingBase entity, ItemStack item, int duration, ItemStack result) + { + super(entity, item, duration); + this.setResultStack(result); + } + + public ItemStack getResultStack() + { + return result; + } + + public void setResultStack(ItemStack result) { - super(player, item, duration); this.result = result; } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java index b0002ce22e..0f899e6392 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingEvent.java @@ -13,13 +13,18 @@ import net.minecraftforge.event.entity.EntityEvent; **/ public class LivingEvent extends EntityEvent { - public final EntityLivingBase entityLiving; + private final EntityLivingBase entityLiving; public LivingEvent(EntityLivingBase entity) { super(entity); entityLiving = entity; } - + + public EntityLivingBase getEntityLiving() + { + return entityLiving; + } + /** * LivingUpdateEvent is fired when an Entity is updated.
    * This event is fired whenever an Entity is updated in diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java index 8c96c0cbc5..a65cd6fdd2 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingExperienceDropEvent.java @@ -12,10 +12,10 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; @Cancelable public class LivingExperienceDropEvent extends LivingEvent { - final EntityPlayer attackingPlayer; - final int originalExperiencePoints; + private final EntityPlayer attackingPlayer; + private final int originalExperiencePoints; - int droppedExperiencePoints; + private int droppedExperiencePoints; public LivingExperienceDropEvent(EntityLivingBase entity, EntityPlayer attackingPlayer, int originalExperience) { diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java index 322325292b..0cc1d0e826 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingFallEvent.java @@ -22,12 +22,17 @@ import net.minecraft.entity.EntityLivingBase; @Cancelable public class LivingFallEvent extends LivingEvent { - public float distance; - public float damageMultiplier; + private float distance; + private float damageMultiplier; public LivingFallEvent(EntityLivingBase entity, float distance, float damageMultiplier) { super(entity); - this.distance = distance; - this.damageMultiplier = damageMultiplier; + this.setDistance(distance); + this.setDamageMultiplier(damageMultiplier); } + + public float getDistance() { return distance; } + public void setDistance(float distance) { this.distance = distance; } + public float getDamageMultiplier() { return damageMultiplier; } + public void setDamageMultiplier(float damageMultiplier) { this.damageMultiplier = damageMultiplier; } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java index 516f708b06..04be4cc15a 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHealEvent.java @@ -21,10 +21,20 @@ import net.minecraft.entity.EntityLivingBase; @Cancelable public class LivingHealEvent extends LivingEvent { - public float amount; + private float amount; public LivingHealEvent(EntityLivingBase entity, float amount) { super(entity); + this.setAmount(amount); + } + + public float getAmount() + { + return amount; + } + + public void setAmount(float amount) + { this.amount = amount; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java index 4bdea7c8a4..0c17934cf8 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingHurtEvent.java @@ -25,13 +25,18 @@ import net.minecraft.entity.EntityLivingBase; @Cancelable public class LivingHurtEvent extends LivingEvent { - public final DamageSource source; - public float ammount; - public LivingHurtEvent(EntityLivingBase entity, DamageSource source, float ammount) + private final DamageSource source; + private float amount; + public LivingHurtEvent(EntityLivingBase entity, DamageSource source, float amount) { super(entity); this.source = source; - this.ammount = ammount; + this.amount = amount; } + public DamageSource getSource() { return source; } + + public float getAmount() { return amount; } + + public void setAmount(float amount) { this.amount = amount; } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java index cd196a87ce..b4219a6dfd 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingPackSizeEvent.java @@ -6,18 +6,28 @@ import net.minecraft.entity.EntityLiving; @HasResult public class LivingPackSizeEvent extends LivingEvent { - /** - * This event is fired when the spawning system determines the - * maximum amount of the selected entity that can spawn at the same - * time. - * - * If you set the result to 'ALLOW', it means that you want to return - * the value of maxPackSize as the maximum pack size for current entity. - */ - public int maxPackSize; + private int maxPackSize; public LivingPackSizeEvent(EntityLiving entity) { super(entity); } + + /** + * This event is fired when the spawning system determines the + * maximum amount of the selected entity that can spawn at the same + * time. + * + * If you set the result to 'ALLOW', it means that you want to return + * the value of maxPackSize as the maximum pack size for current entity. + */ + public int getMaxPackSize() + { + return maxPackSize; + } + + public void setMaxPackSize(int maxPackSize) + { + this.maxPackSize = maxPackSize; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java index ec73c406e3..ef1a29458e 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSetAttackTargetEvent.java @@ -21,11 +21,15 @@ import net.minecraft.entity.EntityLivingBase; public class LivingSetAttackTargetEvent extends LivingEvent { - public final EntityLivingBase target; + private final EntityLivingBase target; public LivingSetAttackTargetEvent(EntityLivingBase entity, EntityLivingBase target) { super(entity); this.target = target; } + public EntityLivingBase getTarget() + { + return target; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java index 2979e4341b..6a538b21b0 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/LivingSpawnEvent.java @@ -19,10 +19,10 @@ import net.minecraft.world.World; **/ public class LivingSpawnEvent extends LivingEvent { - public final World world; - public final float x; - public final float y; - public final float z; + private final World world; + private final float x; + private final float y; + private final float z; public LivingSpawnEvent(EntityLiving entity, World world, float x, float y, float z) { @@ -33,6 +33,10 @@ public class LivingSpawnEvent extends LivingEvent this.z = z; } + public World getWorld() { return world; } + public float getX() { return x; } + public float getY() { return y; } + public float getZ() { return z; } /** * Fires before mob spawn events. * diff --git a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java index 07002ddd25..f5d2ec9b76 100644 --- a/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/living/ZombieEvent.java @@ -1,6 +1,5 @@ package net.minecraftforge.event.entity.living; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.world.World; @@ -22,7 +21,7 @@ public class ZombieEvent extends EntityEvent { public EntityZombie getSummoner() { - return (EntityZombie) entity; + return (EntityZombie) getEntity(); } /** @@ -50,17 +49,14 @@ public class ZombieEvent extends EntityEvent { **/ @HasResult public static class SummonAidEvent extends ZombieEvent { - /** - * Populate this field to have a custom zombie instead of a normal zombie summoned - */ - public EntityZombie customSummonedAid; + private EntityZombie customSummonedAid; - public final World world; - public final int x; - public final int y; - public final int z; - public final EntityLivingBase attacker; - public final double summonChance; + private final World world; + private final int x; + private final int y; + private final int z; + private final EntityLivingBase attacker; + private final double summonChance; public SummonAidEvent(EntityZombie entity, World world, int x, int y, int z, EntityLivingBase attacker, double summonChance) { @@ -72,6 +68,17 @@ public class ZombieEvent extends EntityEvent { this.attacker = attacker; this.summonChance = summonChance; } - + + /** + * Populate this field to have a custom zombie instead of a normal zombie summoned + */ + public EntityZombie getCustomSummonedAid() { return customSummonedAid; } + public void setCustomSummonedAid(EntityZombie customSummonedAid) { this.customSummonedAid = customSummonedAid; } + public World getWorld() { return world; } + public int getX() { return x; } + public int getY() { return y; } + public int getZ() { return z; } + public EntityLivingBase getAttacker() { return attacker; } + public double getSummonChance() { return summonChance; } } } diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java index 76e7cbfb58..94664fe117 100644 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartCollisionEvent.java @@ -18,11 +18,16 @@ import net.minecraft.entity.item.EntityMinecart; **/ public class MinecartCollisionEvent extends MinecartEvent { - public final Entity collider; + private final Entity collider; public MinecartCollisionEvent(EntityMinecart minecart, Entity collider) { super(minecart); this.collider = collider; } + + public Entity getCollider() + { + return collider; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java index 7d445fcde5..0479a067cb 100644 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartEvent.java @@ -14,11 +14,16 @@ import net.minecraftforge.event.entity.EntityEvent; **/ public class MinecartEvent extends EntityEvent { - public final EntityMinecart minecart; + private final EntityMinecart minecart; public MinecartEvent(EntityMinecart minecart) { super(minecart); this.minecart = minecart; } + + public EntityMinecart getMinecart() + { + return minecart; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java index ea56b9964a..819cb7823b 100644 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartInteractEvent.java @@ -3,11 +3,13 @@ package net.minecraftforge.event.entity.minecart; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; /** * MinecartInteractEvent is fired when a player interacts with a minecart.
    * This event is fired whenever a player interacts with a minecart in - * EntityMinecartContainer#interactFirst(EntityPlayer), + * EntityMinecartContainer#interactFirst(EntityPlayer), * EntityMinecartEmpty#interactFirst(EntityPlayer) * EntityMinecartFurnace#interactFirst(EntityPlayer) * EntityMinecartHopper#interactFirst(EntityPlayer).
    @@ -24,11 +26,19 @@ import net.minecraft.entity.player.EntityPlayer; @Cancelable public class MinecartInteractEvent extends MinecartEvent { - public final EntityPlayer player; + private final EntityPlayer player; + private final ItemStack item; + private final EnumHand hand; - public MinecartInteractEvent(EntityMinecart minecart, EntityPlayer player) + public MinecartInteractEvent(EntityMinecart minecart, EntityPlayer player, ItemStack item, EnumHand hand) { super(minecart); this.player = player; + this.item = item; + this.hand = hand; } + + public EntityPlayer getPlayer() { return player; } + public ItemStack getItem() { return item; } + public EnumHand getHand() { return hand; } } diff --git a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java index 23d247f1b1..6ba3f4bdf2 100644 --- a/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/minecart/MinecartUpdateEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.entity.minecart; import net.minecraft.entity.item.EntityMinecart; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; /** * MinecartUpdateEvent is fired when a minecart is updated.
    @@ -18,11 +18,16 @@ import net.minecraft.util.BlockPos; **/ public class MinecartUpdateEvent extends MinecartEvent { - public final BlockPos pos; + private final BlockPos pos; public MinecartUpdateEvent(EntityMinecart minecart, BlockPos pos) { super(minecart); this.pos = pos; } + + public BlockPos getPos() + { + return pos; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/AchievementEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AchievementEvent.java index 5a8e5c15d0..7fee0f4a42 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AchievementEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AchievementEvent.java @@ -10,10 +10,15 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; @Cancelable public class AchievementEvent extends PlayerEvent { - public final Achievement achievement; + private final Achievement achievement; public AchievementEvent(EntityPlayer player, Achievement achievement) { super(player); this.achievement = achievement; } + + public Achievement getAchievement() + { + return achievement; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java index c158a5b69d..360f2e5bc5 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AnvilRepairEvent.java @@ -5,18 +5,11 @@ import net.minecraft.item.ItemStack; public class AnvilRepairEvent extends PlayerEvent { - /** - * Fired when the player removes a "repaired" item from the Anvil's Output slot. - * - * breakChance specifies as a percentage the chance that the anvil will be "damaged" when used. - * - * ItemStacks are the inputs/output from the anvil. They cannot be edited. - */ - - public final ItemStack left; // The left side of the input - public final ItemStack right; // The right side of the input - public final ItemStack output; // Set this to set the output stack - public float breakChance; // Anvil's chance to break (reduced by 1 durability) when this is complete. Default is 12% (0.12f) + + private final ItemStack left; // The left side of the input + private final ItemStack right; // The right side of the input + private final ItemStack output; // Set this to set the output stack + private float breakChance; // Anvil's chance to break (reduced by 1 durability) when this is complete. Default is 12% (0.12f) public AnvilRepairEvent(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right) { @@ -24,6 +17,19 @@ public class AnvilRepairEvent extends PlayerEvent this.output = output; this.left = left; this.right = right; - this.breakChance = 0.12f; + this.setBreakChance(0.12f); } + + /** + * Fired when the player removes a "repaired" item from the Anvil's Output slot. + * + * breakChance specifies as a percentage the chance that the anvil will be "damaged" when used. + * + * ItemStacks are the inputs/output from the anvil. They cannot be edited. + */ + public ItemStack getLeft() { return left; } + public ItemStack getRight() { return right; } + public ItemStack getOutput() { return output; } + public float getBreakChance() { return breakChance; } + public void setBreakChance(float breakChance) { this.breakChance = breakChance; } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java index 9d3e4e9b25..6250e3d7a8 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowLooseEvent.java @@ -3,6 +3,7 @@ package net.minecraftforge.event.entity.player; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.world.World; /** * ArrowLooseEvent is fired when a player stops using a bow.
    @@ -22,13 +23,23 @@ import net.minecraft.item.ItemStack; @Cancelable public class ArrowLooseEvent extends PlayerEvent { - public final ItemStack bow; - public int charge; - - public ArrowLooseEvent(EntityPlayer player, ItemStack bow, int charge) + private final ItemStack bow; + private final World world; + private final boolean hasAmmo; + private int charge; + + public ArrowLooseEvent(EntityPlayer player, ItemStack bow, World world, int charge, boolean hasAmmo) { super(player); this.bow = bow; + this.world = world; this.charge = charge; + this.hasAmmo = hasAmmo; } + + public ItemStack getBow() { return this.bow; } + public World getWorld() { return this.world; } + public boolean hasAmmo() { return this.hasAmmo; } + public int getCharge() { return this.charge; } + public void setCharge(int charge) { this.charge = charge; } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java index 1ff04fa732..888f0e3dba 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java @@ -1,31 +1,46 @@ package net.minecraftforge.event.entity.player; -import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumHand; +import net.minecraft.world.World; /** * ArrowNockEvent is fired when a player begins using a bow.
    * This event is fired whenever a player begins using a bow in * ItemBow#onItemRightClick(ItemStack, World, EntityPlayer).
    *
    - * {@link #result} contains the resulting ItemStack due to the use of the bow.
    - *
    - * This event is {@link Cancelable}.
    - * If this event is canceled, the player does not begin using the bow.
    - *
    - * This event does not have a result. {@link HasResult}
    - *
    * This event is fired on the {@link MinecraftForge#EVENT_BUS}. **/ -@Cancelable public class ArrowNockEvent extends PlayerEvent { - public ItemStack result; - - public ArrowNockEvent(EntityPlayer player, ItemStack result) + private final ItemStack bow; + private final EnumHand hand; + private final World world; + private final boolean hasAmmo; + private ActionResult action; + + public ArrowNockEvent(EntityPlayer player, ItemStack item, EnumHand hand, World world, boolean hasAmmo) { super(player); - this.result = result; + this.bow = item; + this.hand = hand; + this.world = world; + this.hasAmmo = hasAmmo; + } + + public ItemStack getBow() { return this.bow; } + public World getWorld() { return this.world; } + public EnumHand getHand() { return this.hand; } + public boolean hasAmmo() { return this.hasAmmo; } + public ActionResult getAction() + { + return this.action; + } + + public void setAction(ActionResult action) + { + this.action = action; } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java index f053ed9b41..f81f10cd7d 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/AttackEntityEvent.java @@ -21,10 +21,15 @@ import net.minecraft.entity.player.EntityPlayer; @Cancelable public class AttackEntityEvent extends PlayerEvent { - public final Entity target; + private final Entity target; public AttackEntityEvent(EntityPlayer player, Entity target) { super(player); this.target = target; } + + public Entity getTarget() + { + return target; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java index efd23ace5c..bdfe08ef4a 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/BonemealEvent.java @@ -4,26 +4,26 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +/** + * This event is called when a player attempts to use Bonemeal on a block. + * It can be canceled to completely prevent any further processing. + * + * You can also set the result to ALLOW to mark the event as processed + * and use up a bonemeal from the stack but do no further processing. + * + * setResult(ALLOW) is the same as the old setHandled() + */ @Cancelable @Event.HasResult public class BonemealEvent extends PlayerEvent { - /** - * This event is called when a player attempts to use Bonemeal on a block. - * It can be canceled to completely prevent any further processing. - * - * You can also set the result to ALLOW to mark the event as processed - * and use up a bonemeal from the stack but do no further processing. - * - * setResult(ALLOW) is the same as the old setHandeled() - */ - public final World world; - public final BlockPos pos; - public final IBlockState block; + private final World world; + private final BlockPos pos; + private final IBlockState block; public BonemealEvent(EntityPlayer player, World world, BlockPos pos, IBlockState block) { @@ -32,4 +32,19 @@ public class BonemealEvent extends PlayerEvent this.pos = pos; this.block = block; } + + public World getWorld() + { + return world; + } + + public BlockPos getPos() + { + return pos; + } + + public IBlockState getBlock() + { + return block; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java deleted file mode 100644 index 0a4bcf42d9..0000000000 --- a/src/main/java/net/minecraftforge/event/entity/player/EntityInteractEvent.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.minecraftforge.event.entity.player; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; - -/** - * EntityInteractEvent is fired when a player interacts with an Entity.
    - * This event is fired whenever a player interacts with an Entity in - * EntityPlayer#interactWith(Entity).
    - *
    - * {@link #target} contains the Entity the player interacted with.
    - *
    - * This event is {@link Cancelable}.
    - * If this event is canceled, the player does not interact with the Entity.
    - *
    - * This event does not have a result. {@link HasResult}
    - *
    - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. - **/ -@Cancelable -public class EntityInteractEvent extends PlayerEvent -{ - public final Entity target; - public EntityInteractEvent(EntityPlayer player, Entity target) - { - super(player); - this.target = target; - } -} diff --git a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java index b22f7d56ca..0e9ed47346 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/EntityItemPickupEvent.java @@ -5,25 +5,30 @@ import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +/** + * This event is called when a player collides with a EntityItem on the ground. + * The event can be canceled, and no further processing will be done. + * + * You can set the result of this event to ALLOW which will trigger the + * processing of achievements, FML's event, play the sound, and kill the + * entity if all the items are picked up. + * + * setResult(ALLOW) is the same as the old setHandled() + */ @Cancelable @Event.HasResult public class EntityItemPickupEvent extends PlayerEvent { - /** - * This event is called when a player collides with a EntityItem on the ground. - * The event can be canceled, and no further processing will be done. - * - * You can set the result of this event to ALLOW which will trigger the - * processing of achievements, FML's event, play the sound, and kill the - * entity if all the items are picked up. - * - * setResult(ALLOW) is the same as the old setHandled() - */ - public final EntityItem item; + private final EntityItem item; public EntityItemPickupEvent(EntityPlayer player, EntityItem item) { super(player); this.item = item; } + + public EntityItem getItem() + { + return item; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java index 5e1f71ab5c..77819d7ba2 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/FillBucketEvent.java @@ -4,34 +4,40 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; +/** + * This event is fired when a player attempts to use a Empty bucket, it + * can be canceled to completely prevent any further processing. + * + * If you set the result to 'ALLOW', it means that you have processed + * the event and wants the basic functionality of adding the new + * ItemStack to your inventory and reducing the stack size to process. + * setResult(ALLOW) is the same as the old setHandled(); + */ @Cancelable @Event.HasResult public class FillBucketEvent extends PlayerEvent { - /** - * This event is fired when a player attempts to use a Empty bucket, it - * can be canceled to completely prevent any further processing. - * - * If you set the result to 'ALLOW', it means that you have processed - * the event and wants the basic functionality of adding the new - * ItemStack to your inventory and reducing the stack size to process. - * setResult(ALLOW) is the same as the old setHandeled(); - */ - public final ItemStack current; - public final World world; - public final MovingObjectPosition target; + private final ItemStack current; + private final World world; + private final RayTraceResult target; - public ItemStack result; + private ItemStack result; - public FillBucketEvent(EntityPlayer player, ItemStack current, World world, MovingObjectPosition target) + public FillBucketEvent(EntityPlayer player, ItemStack current, World world, RayTraceResult target) { super(player); this.current = current; this.world = world; this.target = target; } + + public ItemStack getEmptyBucket() { return this.current; } + public World getWorld(){ return this.world; } + public RayTraceResult getTarget() { return this.target; } + public ItemStack getFilledBucket() { return this.result; } + public void setFilledBucket(ItemStack bucket) { this.result = bucket; } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java b/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java index 7194abad51..f9fd61ca27 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/ItemTooltipEvent.java @@ -6,18 +6,9 @@ import net.minecraft.item.ItemStack; public class ItemTooltipEvent extends PlayerEvent { - /** - * Whether the advanced information on item tooltips is being shown, toggled by F3+H. - */ - public final boolean showAdvancedItemTooltips; - /** - * The {@link ItemStack} with the tooltip. - */ - public final ItemStack itemStack; - /** - * The {@link ItemStack} tooltip. - */ - public final List toolTip; + private final boolean showAdvancedItemTooltips; + private final ItemStack itemStack; + private final List toolTip; /** * This event is fired in {@link ItemStack#getTooltip(EntityPlayer, boolean)}, which in turn is called from it's respective GUIContainer. @@ -29,4 +20,28 @@ public class ItemTooltipEvent extends PlayerEvent this.toolTip = toolTip; this.showAdvancedItemTooltips = showAdvancedItemTooltips; } + + /** + * Whether the advanced information on item tooltips is being shown, toggled by F3+H. + */ + public boolean isShowAdvancedItemTooltips() + { + return showAdvancedItemTooltips; + } + + /** + * The {@link ItemStack} with the tooltip. + */ + public ItemStack getItemStack() + { + return itemStack; + } + + /** + * The {@link ItemStack} tooltip. + */ + public List getToolTip() + { + return toolTip; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java index e8d7a20c12..35d2d3357b 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDestroyItemEvent.java @@ -3,6 +3,7 @@ package net.minecraftforge.event.entity.player; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHand; /** * PlayerDestroyItemEvent is fired when a player destroys an item.
    @@ -15,6 +16,7 @@ import net.minecraft.item.ItemStack; * and ItemInWorldManager#activateBlockOrUseItem(EntityPlayer, World, ItemStack, int, int, int, int, float, float, float).
    *
    * {@link #original} contains the original ItemStack before the item was destroyed.
    + * (@link #hand) contains the hand that the current item was held in.
    *
    * This event is not {@link Cancelable}.
    *
    @@ -24,11 +26,16 @@ import net.minecraft.item.ItemStack; **/ public class PlayerDestroyItemEvent extends PlayerEvent { - public final ItemStack original; - public PlayerDestroyItemEvent(EntityPlayer player, ItemStack original) + private final ItemStack original; + private final EnumHand hand; // May be null if this player destroys the item by any use besides holding it. + public PlayerDestroyItemEvent(EntityPlayer player, ItemStack original, EnumHand hand) { super(player); this.original = original; + this.hand = hand; } + public ItemStack getOriginal() { return this.original; } + public EnumHand getHand() { return this.hand; } + } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java index d3f5246806..9fb1a4a590 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerDropsEvent.java @@ -18,7 +18,7 @@ import net.minecraftforge.event.entity.living.LivingDropsEvent; @Cancelable public class PlayerDropsEvent extends LivingDropsEvent { - public final EntityPlayer entityPlayer; + private final EntityPlayer entityPlayer; /** * Creates a new event containing all the items that will drop into the @@ -36,4 +36,9 @@ public class PlayerDropsEvent extends LivingDropsEvent this.entityPlayer = entity; } + + public EntityPlayer getEntityPlayer() + { + return entityPlayer; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java index 50b3857834..864242dd9c 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerEvent.java @@ -6,7 +6,7 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraftforge.event.entity.living.LivingEvent; /** @@ -18,13 +18,18 @@ import net.minecraftforge.event.entity.living.LivingEvent; **/ public class PlayerEvent extends LivingEvent { - public final EntityPlayer entityPlayer; + private final EntityPlayer entityPlayer; public PlayerEvent(EntityPlayer player) { super(player); entityPlayer = player; } + public EntityPlayer getEntityPlayer() + { + return entityPlayer; + } + /** * HarvestCheck is fired when a player attempts to harvest a block.
    * This event is fired whenever a player attempts to harvest a block in @@ -43,15 +48,19 @@ public class PlayerEvent extends LivingEvent **/ public static class HarvestCheck extends PlayerEvent { - public final Block block; - public boolean success; + private final IBlockState state; + private boolean success; - public HarvestCheck(EntityPlayer player, Block block, boolean success) + public HarvestCheck(EntityPlayer player, IBlockState state, boolean success) { super(player); - this.block = block; + this.state = state; this.success = success; } + + public IBlockState getTargetBlock() { return this.state; } + public boolean canHarvest() { return this.success; } + public void setCanHarvest(boolean success){ this.success = success; } } /** @@ -76,19 +85,25 @@ public class PlayerEvent extends LivingEvent @Cancelable public static class BreakSpeed extends PlayerEvent { - public final IBlockState state; - public final float originalSpeed; - public float newSpeed = 0.0f; - public final BlockPos pos; // Y position of -1 notes unknown location + private final IBlockState state; + private final float originalSpeed; + private float newSpeed = 0.0f; + private final BlockPos pos; // Y position of -1 notes unknown location public BreakSpeed(EntityPlayer player, IBlockState state, float original, BlockPos pos) { super(player); this.state = state; this.originalSpeed = original; - this.newSpeed = original; + this.setNewSpeed(original); this.pos = pos; } + + public IBlockState getState() { return state; } + public float getOriginalSpeed() { return originalSpeed; } + public float getNewSpeed() { return newSpeed; } + public void setNewSpeed(float newSpeed) { this.newSpeed = newSpeed; } + public BlockPos getPos() { return pos; } } /** @@ -109,13 +124,28 @@ public class PlayerEvent extends LivingEvent **/ public static class NameFormat extends PlayerEvent { - public final String username; - public String displayname; + private final String username; + private String displayname; public NameFormat(EntityPlayer player, String username) { super(player); this.username = username; - this.displayname = username; + this.setDisplayname(username); + } + + public String getUsername() + { + return username; + } + + public String getDisplayname() + { + return displayname; + } + + public void setDisplayname(String displayname) + { + this.displayname = displayname; } } @@ -125,15 +155,8 @@ public class PlayerEvent extends LivingEvent */ public static class Clone extends PlayerEvent { - /** - * The old EntityPlayer that this new entity is a clone of. - */ - public final EntityPlayer original; - /** - * True if this event was fired because the player died. - * False if it was fired because the entity switched dimensions. - */ - public final boolean wasDeath; + private final EntityPlayer original; + private final boolean wasDeath; public Clone(EntityPlayer _new, EntityPlayer oldPlayer, boolean wasDeath) { @@ -141,6 +164,23 @@ public class PlayerEvent extends LivingEvent this.original = oldPlayer; this.wasDeath = wasDeath; } + + /** + * The old EntityPlayer that this new entity is a clone of. + */ + public EntityPlayer getOriginal() + { + return original; + } + + /** + * True if this event was fired because the player died. + * False if it was fired because the entity switched dimensions. + */ + public boolean isWasDeath() + { + return wasDeath; + } } /** @@ -149,10 +189,7 @@ public class PlayerEvent extends LivingEvent */ public static class StartTracking extends PlayerEvent { - /** - * The Entity now being tracked. - */ - public final Entity target; + private final Entity target; public StartTracking(EntityPlayer player, Entity target) { @@ -160,6 +197,13 @@ public class PlayerEvent extends LivingEvent this.target = target; } + /** + * The Entity now being tracked. + */ + public Entity getTarget() + { + return target; + } } /** @@ -168,10 +212,7 @@ public class PlayerEvent extends LivingEvent */ public static class StopTracking extends PlayerEvent { - /** - * The Entity no longer being tracked. - */ - public final Entity target; + private final Entity target; public StopTracking(EntityPlayer player, Entity target) { @@ -179,6 +220,13 @@ public class PlayerEvent extends LivingEvent this.target = target; } + /** + * The Entity no longer being tracked. + */ + public Entity getTarget() + { + return target; + } } /** @@ -188,16 +236,8 @@ public class PlayerEvent extends LivingEvent * containing additional mod related player data. */ public static class LoadFromFile extends PlayerEvent { - /** - * The directory where player data is being stored. Use this - * to locate your mod additional file. - */ - public final File playerDirectory; - /** - * The UUID is the standard for player related file storage. - * It is broken out here for convenience for quick file generation. - */ - public final String playerUUID; + private final File playerDirectory; + private final String playerUUID; public LoadFromFile(EntityPlayer player, File originDirectory, String playerUUID) { @@ -214,7 +254,25 @@ public class PlayerEvent extends LivingEvent public File getPlayerFile(String suffix) { if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved"); - return new File(this.playerDirectory, this.playerUUID+"."+suffix); + return new File(this.getPlayerDirectory(), this.getPlayerUUID() +"."+suffix); + } + + /** + * The directory where player data is being stored. Use this + * to locate your mod additional file. + */ + public File getPlayerDirectory() + { + return playerDirectory; + } + + /** + * The UUID is the standard for player related file storage. + * It is broken out here for convenience for quick file generation. + */ + public String getPlayerUUID() + { + return playerUUID; } } /** @@ -231,16 +289,8 @@ public class PlayerEvent extends LivingEvent * corrupt the world state. */ public static class SaveToFile extends PlayerEvent { - /** - * The directory where player data is being stored. Use this - * to locate your mod additional file. - */ - public final File playerDirectory; - /** - * The UUID is the standard for player related file storage. - * It is broken out here for convenience for quick file generation. - */ - public final String playerUUID; + private final File playerDirectory; + private final String playerUUID; public SaveToFile(EntityPlayer player, File originDirectory, String playerUUID) { @@ -257,7 +307,25 @@ public class PlayerEvent extends LivingEvent public File getPlayerFile(String suffix) { if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved"); - return new File(this.playerDirectory, this.playerUUID+"."+suffix); + return new File(this.getPlayerDirectory(), this.getPlayerUUID() +"."+suffix); + } + + /** + * The directory where player data is being stored. Use this + * to locate your mod additional file. + */ + public File getPlayerDirectory() + { + return playerDirectory; + } + + /** + * The UUID is the standard for player related file storage. + * It is broken out here for convenience for quick file generation. + */ + public String getPlayerUUID() + { + return playerUUID; } } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java index 931e84d888..8a469f0dd2 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerFlyableFallEvent.java @@ -9,13 +9,18 @@ import net.minecraft.entity.player.EntityPlayer; */ public class PlayerFlyableFallEvent extends PlayerEvent { - public float distance; - public float multipler; + private float distance; + private float multiplier; public PlayerFlyableFallEvent(EntityPlayer player, float distance, float multiplier) { super(player); this.distance = distance; - this.multipler = multiplier; + this.multiplier = multiplier; } + + public float getDistance() { return distance;} + public void setDistance(float distance) { this.distance = distance; } + public float getMultiplier() { return multiplier; } + public void setMultiplier(float multiplier) { this.multiplier = multiplier; } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java index 3eb8d28d61..90325e3eea 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerInteractEvent.java @@ -1,78 +1,336 @@ package net.minecraftforge.event.entity.player; +import com.google.common.base.Preconditions; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.relauncher.Side; + +import javax.annotation.Nullable; + import static net.minecraftforge.fml.common.eventhandler.Event.Result.DEFAULT; import static net.minecraftforge.fml.common.eventhandler.Event.Result.DENY; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.eventhandler.Cancelable; /** * PlayerInteractEvent is fired when a player interacts in some way. - *
    - * This event is fired whenever a player interacts in - * Minecraft#func_147121_ag(), - * NetHandlerPlayServer#processPlayerBlockPlacement(C08PacketPlayerBlockPlacement), - * ItemInWorldManager#activateBlockOrUseItem(EntityPlayer, World, ItemStack, int, int, int, int, float, float, float), - * ItemInWorldManager#onBlockClicked(int, int, int, int).
    - *
    - * This event is fired via the {@link ForgeEventFactory#onPlayerInteract(EntityPlayer, Action, BlockPos, EnumFacing)}. - *
    - * {@link #action} contains the Action the player performed durin this interaction.
    - * {@link #pos} contains the coordinate of where this event occurred.
    - * {@link #face} contains the face of the block that was interacted with. May be null if unknown.
    - * {@link #world} contains the world in which this event is occurring.
    - *
    - * This event is {@link Cancelable}.
    - * If this event is canceled, the player does not interact.
    - *
    - * This event does not have a result. {@link HasResult}
    - *
    - * This event is fired on the {@link MinecraftForge#EVENT_BUS}. + * All subclasses are fired on {@link MinecraftForge#EVENT_BUS}. + * See the individual documentation on each subevent for more details. **/ -@Cancelable public class PlayerInteractEvent extends PlayerEvent { - public static enum Action + private final EnumHand hand; + private final ItemStack stack; + private final BlockPos pos; + private final EnumFacing face; + + private PlayerInteractEvent(EntityPlayer player, EnumHand hand, ItemStack stack, BlockPos pos, EnumFacing face) { - RIGHT_CLICK_AIR, - RIGHT_CLICK_BLOCK, - LEFT_CLICK_BLOCK - } - - public final Action action; - public final World world; - public final BlockPos pos; - public final EnumFacing face; // Can be null if unknown - public final Vec3 localPos; // Can be null if unknown - - public Result useBlock = DEFAULT; - public Result useItem = DEFAULT; - - @Deprecated - public PlayerInteractEvent(EntityPlayer player, Action action, BlockPos pos, EnumFacing face, World world) - { - this(player, action, pos, face, world, null); - } - - public PlayerInteractEvent(EntityPlayer player, Action action, BlockPos pos, EnumFacing face, World world, Vec3 localPos) - { - super(player); - this.action = action; - this.pos = pos; + super(Preconditions.checkNotNull(player, "Null player in PlayerInteractEvent!")); + this.hand = Preconditions.checkNotNull(hand, "Null hand in PlayerInteractEvent!"); + this.stack = stack; + this.pos = Preconditions.checkNotNull(pos, "Null position in PlayerInteractEvent!"); this.face = face; - if (face == null) useBlock = DENY; - this.world = world; - this.localPos = localPos; } - @Override - public void setCanceled(boolean cancel) + /** + * This event is fired on both sides whenever a player right clicks an entity. + * + * "Interact at" is an interact where the local vector (which part of the entity you clicked) is known. + * The state of this event affects whether {@link Entity#applyPlayerInteraction} is called. + * If {@link Entity#applyPlayerInteraction} returns {@link net.minecraft.util.EnumActionResult#SUCCESS}, then processing ends. + * Otherwise processing will continue to {@link EntityInteract} + * + * Canceling the event clientside will cause processing to continue to {@link EntityInteract}, + * while canceling serverside will simply do no further processing. + */ + @Cancelable + public static class EntityInteractSpecific extends PlayerInteractEvent { - super.setCanceled(cancel); - useBlock = (cancel ? DENY : useBlock == DENY ? DEFAULT : useBlock); - useItem = (cancel ? DENY : useItem == DENY ? DEFAULT : useItem); + private final Vec3d localPos; + private final Entity target; + + public EntityInteractSpecific(EntityPlayer player, EnumHand hand, ItemStack stack, Entity target, Vec3d localPos) + { + super(player, hand, stack, new BlockPos(target), null); + this.localPos = localPos; + this.target = target; + } + + /** + * Returns the local interaction position. This is a 3D vector, where (0, 0, 0) is centered exactly at the + * center of the entity's bounding box at their feet. This means the X and Z values will be in the range + * [-width / 2, width / 2] while Y values will be in the range [0, height] + * @return The local position + */ + public Vec3d getLocalPos() + { + return localPos; + } + + public Entity getTarget() + { + return target; + } } + + /** + * This event is fired on both sides when the player right clicks an entity. + * It is responsible for all general entity interactions. + * + * This event is fired completely independently of the above {@link EntityInteractSpecific}, except for the case + * where the above call to {@link Entity#applyPlayerInteraction} returns {@link net.minecraft.util.EnumActionResult#SUCCESS}. + * In that case, general entity interactions, and hence this event, will not be called. See the above javadoc for more details. + * + * This event's state affects whether {@link Entity#processInitialInteract} and {@link net.minecraft.item.Item#itemInteractionForEntity} are called. + * + * Canceling the event clientside will cause processing to continue to {@link RightClickItem}, + * while canceling serverside will simply do no further processing. + */ + @Cancelable + public static class EntityInteract extends PlayerInteractEvent + { + private final Entity target; + + public EntityInteract(EntityPlayer player, EnumHand hand, ItemStack stack, Entity target) + { + super(player, hand, stack, new BlockPos(target), null); + this.target = target; + } + + public Entity getTarget() + { + return target; + } + } + + /** + * This event is fired on both sides whenever the player right clicks while targeting a block. + * This event controls which of {@link net.minecraft.block.Block#onBlockActivated} and/or {@link net.minecraft.item.Item#onItemUse} + * will be called after {@link net.minecraft.item.Item#onItemUseFirst} is called. + * Canceling the event will cause none of the above three to be called. + * There are various results to this event, see the getters below. + * Note that handling things differently on the client vs server may cause desynchronizations! + */ + @Cancelable + public static class RightClickBlock extends PlayerInteractEvent + { + private Result useBlock = DEFAULT; + private Result useItem = DEFAULT; + private final Vec3d hitVec; + + public RightClickBlock(EntityPlayer player, EnumHand hand, ItemStack stack, + BlockPos pos, EnumFacing face, Vec3d hitVec) { + super(player, hand, stack, pos, face); + this.hitVec = hitVec; + } + + /** + * @return The hit vector of this click + */ + public Vec3d getHitVec() + { + return hitVec; + } + + /** + * @return If {@link net.minecraft.block.Block#onBlockActivated} should be called + */ + public Result getUseBlock() + { + return useBlock; + } + + /** + * @return If {@link net.minecraft.item.Item#onItemUse} should be called + */ + public Result getUseItem() + { + return useItem; + } + + /** + * DENY: Block will never be used. + * DEFAULT: Default behaviour (sneak will not use block, unless all items return true in {@link net.minecraft.item.Item#doesSneakBypassUse}). + * ALLOW: Block will always be used, regardless of sneaking and doesSneakBypassUse. + */ + public void setUseBlock(Result triggerBlock) + { + this.useBlock = triggerBlock; + } + + /** + * DENY: The item will never be used. + * DEFAULT: The item will be used if the block fails. + * ALLOW: The item will always be used. + */ + public void setUseItem(Result triggerItem) + { + this.useItem = triggerItem; + } + + @Override + public void setCanceled(boolean canceled) + { + super.setCanceled(canceled); + useBlock = DENY; + useItem = DENY; + } + } + + /** + * This event is fired on both sides before the player triggers {@link net.minecraft.item.Item#onItemRightClick}. + * Note that this is NOT fired if the player is targeting a block. For that case, see {@link RightClickBlock}. + * Canceling the event clientside causes processing to continue to the other hands, + * while canceling serverside will simply do no further processing. + */ + @Cancelable + public static class RightClickItem extends PlayerInteractEvent + { + public RightClickItem(EntityPlayer player, EnumHand hand, ItemStack stack) + { + super(player, hand, stack, new BlockPos(player), null); + } + } + + /** + * This event is fired on the client side when the player right clicks empty space with an empty hand. + * The server is not aware of when the client right clicks empty space with an empty hand, you will need to tell the server yourself. + * This event cannot be canceled. + */ + public static class RightClickEmpty extends PlayerInteractEvent + { + public RightClickEmpty(EntityPlayer player, EnumHand hand) + { + super(player, hand, null, new BlockPos(player), null); + } + } + + /** + * This event is fired when a player left clicks while targeting a block. + * This event controls which of {@link net.minecraft.block.Block#onBlockClicked} and/or the item harvesting methods will be called + * Canceling the event will cause none of the above noted methods to be called. + * There are various results to this event, see the getters below. + * Note that if the event is canceled and the player holds down left mouse, the event will continue to fire. + * This is due to how vanilla calls the left click handler methods. + */ + @Cancelable + public static class LeftClickBlock extends PlayerInteractEvent + { + private Result useBlock = DEFAULT; + private Result useItem = DEFAULT; + private final Vec3d hitVec; + + public LeftClickBlock(EntityPlayer player, BlockPos pos, EnumFacing face, Vec3d hitVec) + { + super(player, EnumHand.MAIN_HAND, player.getHeldItem(EnumHand.MAIN_HAND), pos, face); + this.hitVec = hitVec; + } + + /** + * @return The local hit vector of this click + */ + public Vec3d getHitVec() + { + return hitVec; + } + + /** + * @return If {@link net.minecraft.block.Block#onBlockClicked} should be called + */ + public Result getUseBlock() + { + return useBlock; + } + + /** + * @return If the block should be attempted to be mined with the current item + */ + public Result getUseItem() + { + return useItem; + } + + public void setUseBlock(Result triggerBlock) + { + this.useBlock = triggerBlock; + } + + public void setUseItem(Result triggerItem) + { + this.useItem = triggerItem; + } + + @Override + public void setCanceled(boolean canceled) + { + super.setCanceled(canceled); + useBlock = DENY; + useItem = DENY; + } + } + + /** + * @return The hand involved in this interaction. Will never be null. + */ + public EnumHand getHand() + { + return hand; + } + + /** + * @return The itemstack involved in this interaction, or null if the hand was empty. + */ + @Nullable + public ItemStack getItemStack() + { + return stack; + } + + /** + * If the interaction was on an entity, will be a BlockPos centered on the entity. + * If the interaction was on a block, will be the position of that block. + * Otherwise, will be a BlockPos centered on the player. + * Will never be null. + * @return The position involved in this interaction. + */ + public BlockPos getPos() + { + return pos; + } + + /** + * @return The face involved in this interaction. For all non-block interactions, this will return null. + */ + @Nullable + public EnumFacing getFace() + { + return face; + } + + /** + * @return Convenience method to get the world of this interaction. + */ + public World getWorld() + { + return getEntityPlayer().getEntityWorld(); + } + + /** + * @return The effective, i.e. logical, side of this interaction. This will be {@link Side#CLIENT} on the client thread, and {@link Side#SERVER} on the server thread. + */ + public Side getSide() + { + return getWorld().isRemote ? Side.CLIENT : Side.SERVER; + } + } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java index 52358ace7c..0f39360d3b 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerOpenContainerEvent.java @@ -4,26 +4,30 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +/** + * This event is fired when a player attempts to view a container during + * player tick. + * + * setResult ALLOW to allow the container to stay open + * setResult DENY to force close the container (denying access) + * + * DEFAULT is vanilla behavior + * + */ @HasResult public class PlayerOpenContainerEvent extends PlayerEvent { - public final boolean canInteractWith; - - /** - * This event is fired when a player attempts to view a container during - * player tick. - * - * setResult ALLOW to allow the container to stay open - * setResult DENY to force close the container (denying access) - * - * DEFAULT is vanilla behavior - * - */ + private final boolean canInteractWith; public PlayerOpenContainerEvent(EntityPlayer player, Container openContainer) { super(player); this.canInteractWith = openContainer.canInteractWith(player); } + + public boolean isCanInteractWith() + { + return canInteractWith; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java index fedb6c038e..44755c4cba 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerPickupXpEvent.java @@ -11,11 +11,16 @@ import net.minecraft.entity.player.EntityPlayer; @Cancelable public class PlayerPickupXpEvent extends PlayerEvent { - public final EntityXPOrb orb; + private final EntityXPOrb orb; public PlayerPickupXpEvent(EntityPlayer player, EntityXPOrb orb) { super(player); this.orb = orb; } + + public EntityXPOrb getOrb() + { + return orb; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java index e2d059a25b..bca18deca6 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSetSpawnEvent.java @@ -2,17 +2,13 @@ package net.minecraftforge.event.entity.player; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; @Cancelable public class PlayerSetSpawnEvent extends PlayerEvent { - /** - * This event is called before a player's spawn point is changed. - * The event can be canceled, and no further processing will be done. - */ - public final boolean forced; - public final BlockPos newSpawn; + private final boolean forced; + private final BlockPos newSpawn; public PlayerSetSpawnEvent(EntityPlayer player, BlockPos newSpawn, boolean forced) { super(player); @@ -20,4 +16,17 @@ public class PlayerSetSpawnEvent extends PlayerEvent this.forced = forced; } + /** + * This event is called before a player's spawn point is changed. + * The event can be canceled, and no further processing will be done. + */ + public boolean isForced() + { + return forced; + } + + public BlockPos getNewSpawn() + { + return newSpawn; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java index 0d256b6ac3..29aa31a4ad 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerSleepInBedEvent.java @@ -2,7 +2,7 @@ package net.minecraftforge.event.entity.player; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer.EnumStatus; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; /** * PlayerSleepInBedEvent is fired when a player sleeps in a bed. @@ -20,8 +20,8 @@ import net.minecraft.util.BlockPos; **/ public class PlayerSleepInBedEvent extends PlayerEvent { - public EnumStatus result = null; - public final BlockPos pos; + private EnumStatus result = null; + private final BlockPos pos; public PlayerSleepInBedEvent(EntityPlayer player, BlockPos pos) { @@ -29,4 +29,18 @@ public class PlayerSleepInBedEvent extends PlayerEvent this.pos = pos; } + public EnumStatus getResultStatus() + { + return result; + } + + public void setResult(EnumStatus result) + { + this.result = result; + } + + public BlockPos getPos() + { + return pos; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java b/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java index e278c90adb..6b161fdb8a 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/PlayerWakeUpEvent.java @@ -9,29 +9,35 @@ import net.minecraft.entity.player.EntityPlayer; */ public class PlayerWakeUpEvent extends PlayerEvent { + private final boolean wakeImmediately; + + private final boolean updateWorld; + + private final boolean setSpawn; + + public PlayerWakeUpEvent(EntityPlayer player, boolean wakeImmediately, boolean updateWorld, boolean setSpawn) + { + super(player); + this.wakeImmediately = wakeImmediately; + this.updateWorld = updateWorld; + this.setSpawn = setSpawn; + } + /** * Used for the 'wake up animation'. * This is false if the player is considered 'sleepy' and the overlay should slowly fade away. */ - public final boolean wakeImmediatly; + public boolean wakeImmediately() { return wakeImmediately; } /** * Indicates if the server should be notified of sleeping changes. * This will only be false if the server is considered 'up to date' already, because, for example, it initiated the call. */ - public final boolean updateWorld; + public boolean updateWorld() { return updateWorld; } /** * Indicates if the player's sleep was considered successful. * In vanilla, this is used to determine if the spawn chunk is to be set to the bed's position. */ - public final boolean setSpawn; - - public PlayerWakeUpEvent(EntityPlayer player, boolean wakeImmediatly, boolean updateWorld, boolean setSpawn) - { - super(player); - this.wakeImmediatly = wakeImmediatly; - this.updateWorld = updateWorld; - this.setSpawn = setSpawn; - } + public boolean shouldSetSpawn() { return setSpawn; } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java b/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java index 0dbd832e19..148a5f2765 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/SleepingLocationCheckEvent.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.entity.player; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.common.eventhandler.Event.HasResult; /** @@ -17,7 +17,7 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult; public class SleepingLocationCheckEvent extends PlayerEvent { - public final BlockPos sleepingLocation; + private final BlockPos sleepingLocation; public SleepingLocationCheckEvent(EntityPlayer player, BlockPos sleepingLocation) { @@ -25,4 +25,8 @@ public class SleepingLocationCheckEvent extends PlayerEvent this.sleepingLocation = sleepingLocation; } + public BlockPos getSleepingLocation() + { + return sleepingLocation; + } } diff --git a/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java b/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java index bc9f50f053..55fba10aac 100644 --- a/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java +++ b/src/main/java/net/minecraftforge/event/entity/player/UseHoeEvent.java @@ -2,28 +2,28 @@ package net.minecraftforge.event.entity.player; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; +/** + * This event is fired when a player attempts to use a Hoe on a block, it + * can be canceled to completely prevent any further processing. + * + * You can also set the result to ALLOW to mark the event as processed + * and damage the hoe. + * + * setResult(ALLOW) is the same as the old setHandled(); + */ @Cancelable @Event.HasResult public class UseHoeEvent extends PlayerEvent { - /** - * This event is fired when a player attempts to use a Hoe on a block, it - * can be canceled to completely prevent any further processing. - * - * You can also set the result to ALLOW to mark the event as processed - * and damage the hoe. - * - * setResult(ALLOW) is the same as the old setHandeled(); - */ - public final ItemStack current; - public final World world; - public final BlockPos pos; + private final ItemStack current; + private final World world; + private final BlockPos pos; public UseHoeEvent(EntityPlayer player, ItemStack current, World world, BlockPos pos) { @@ -32,4 +32,19 @@ public class UseHoeEvent extends PlayerEvent this.world = world; this.pos = pos; } + + public ItemStack getCurrent() + { + return current; + } + + public World getWorld() + { + return world; + } + + public BlockPos getPos() + { + return pos; + } } diff --git a/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java index 5ee2cc5973..acf68c04a5 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/BiomeEvent.java @@ -1,7 +1,6 @@ package net.minecraftforge.event.terraingen; import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; import net.minecraft.block.state.IBlockState; import net.minecraft.world.biome.BiomeDecorator; import net.minecraft.world.biome.BiomeGenBase; @@ -15,13 +14,18 @@ import net.minecraft.world.biome.BiomeGenBase; **/ public class BiomeEvent extends Event { - public final BiomeGenBase biome; + private final BiomeGenBase biome; public BiomeEvent(BiomeGenBase biome) { this.biome = biome; } + public BiomeGenBase getBiome() + { + return biome; + } + /** * CreateDecorator is fired when a BiomeDecorator is created.
    * This event is fired whenever a BiomeDecorator is created in @@ -38,14 +42,29 @@ public class BiomeEvent extends Event **/ public static class CreateDecorator extends BiomeEvent { - public final BiomeDecorator originalBiomeDecorator; - public BiomeDecorator newBiomeDecorator; + private final BiomeDecorator originalBiomeDecorator; + private BiomeDecorator newBiomeDecorator; public CreateDecorator(BiomeGenBase biome, BiomeDecorator original) { super(biome); originalBiomeDecorator = original; - newBiomeDecorator = original; + setNewBiomeDecorator(original); + } + + public BiomeDecorator getOriginalBiomeDecorator() + { + return originalBiomeDecorator; + } + + public BiomeDecorator getNewBiomeDecorator() + { + return newBiomeDecorator; + } + + public void setNewBiomeDecorator(BiomeDecorator newBiomeDecorator) + { + this.newBiomeDecorator = newBiomeDecorator; } } @@ -58,14 +77,29 @@ public class BiomeEvent extends Event **/ public static class BiomeColor extends BiomeEvent { - public final int originalColor; - public int newColor; + private final int originalColor; + private int newColor; public BiomeColor(BiomeGenBase biome, int original) { super(biome); originalColor = original; - newColor = original; + setNewColor(original); + } + + public int getOriginalColor() + { + return originalColor; + } + + public int getNewColor() + { + return newColor; + } + + public void setNewColor(int newColor) + { + this.newColor = newColor; } } @@ -78,14 +112,29 @@ public class BiomeEvent extends Event @HasResult public static class GetVillageBlockID extends BiomeEvent { - public final IBlockState original; - public IBlockState replacement; + private final IBlockState original; + private IBlockState replacement; public GetVillageBlockID(BiomeGenBase biome, IBlockState original) { super(biome); this.original = original; } + + public IBlockState getOriginal() + { + return original; + } + + public IBlockState getReplacement() + { + return replacement; + } + + public void setReplacement(IBlockState replacement) + { + this.replacement = replacement; + } } /** diff --git a/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java b/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java new file mode 100644 index 0000000000..96551ebbec --- /dev/null +++ b/src/main/java/net/minecraftforge/event/terraingen/ChunkGeneratorEvent.java @@ -0,0 +1,90 @@ +package net.minecraftforge.event.terraingen; + +import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraft.world.World; +import net.minecraft.world.chunk.ChunkPrimer; +import net.minecraft.world.chunk.IChunkGenerator; + +public class ChunkGeneratorEvent extends Event +{ + private final IChunkGenerator gen; + + public ChunkGeneratorEvent(IChunkGenerator gen) + { + this.gen = gen; + } + + public IChunkGenerator getGenerator() { return this.getGen(); } + + public IChunkGenerator getGen() + { + return gen; + } + + /** + * This event is fired when a chunks blocks are replaced by a biomes top and + * filler blocks. + * + * You can set the result to DENY to prevent the default replacement. + */ + @HasResult + public static class ReplaceBiomeBlocks extends ChunkGeneratorEvent + { + private final int x; + private final int z; + private final ChunkPrimer primer; + private final World world; // CAN BE NULL + + public ReplaceBiomeBlocks(IChunkGenerator chunkProvider, int x, int z, ChunkPrimer primer, World world) + { + super(chunkProvider); + this.x = x; + this.z = z; + this.primer = primer; + this.world = world; + } + + public int getX() { return x; } + public int getZ() { return z; } + public ChunkPrimer getPrimer() { return primer; } + public World getWorld() { return world; } + } + + /** + * This event is fired before a chunks terrain noise field is initialized. + * + * You can set the result to DENY to substitute your own noise field. + */ + @HasResult + public static class InitNoiseField extends ChunkGeneratorEvent + { + private double[] noisefield; + private final int posX; + private final int posY; + private final int posZ; + private final int sizeX; + private final int sizeY; + private final int sizeZ; + + public InitNoiseField(IChunkGenerator chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ) + { + super(chunkProvider); + this.setNoisefield(noisefield); + this.posX = posX; + this.posY = posY; + this.posZ = posZ; + this.sizeX = sizeX; + this.sizeY = sizeY; + this.sizeZ = sizeZ; + } + + public double[] getNoisefield() { return noisefield; } + public void setNoisefield(double[] noisefield) { this.noisefield = noisefield; } + public int getPosX() { return posX; } + public int getPosY() { return posY; } + public int getPosZ() { return posZ; } + public int getSizeX() { return sizeX; } + public int getSizeY() { return sizeY; } + public int getSizeZ() { return sizeZ; } + } +} diff --git a/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java b/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java deleted file mode 100644 index d9374346a0..0000000000 --- a/src/main/java/net/minecraftforge/event/terraingen/ChunkProviderEvent.java +++ /dev/null @@ -1,72 +0,0 @@ -package net.minecraftforge.event.terraingen; - -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraft.world.World; -import net.minecraft.world.chunk.ChunkPrimer; -import net.minecraft.world.chunk.IChunkProvider; - -public class ChunkProviderEvent extends Event -{ - - public final IChunkProvider chunkProvider; - - public ChunkProviderEvent(IChunkProvider chunkProvider) - { - this.chunkProvider = chunkProvider; - } - - /** - * This event is fired when a chunks blocks are replaced by a biomes top and - * filler blocks. - * - * You can set the result to DENY to prevent the default replacement. - */ - @HasResult - public static class ReplaceBiomeBlocks extends ChunkProviderEvent - { - public final int x; - public final int z; - public final ChunkPrimer primer; - public final World world; // CAN BE NULL - - public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int x, int z, ChunkPrimer primer, World world) - { - super(chunkProvider); - this.x = x; - this.z = z; - this.primer = primer; - this.world = world; - } - - } - - /** - * This event is fired before a chunks terrain noise field is initialized. - * - * You can set the result to DENY to substitute your own noise field. - */ - @HasResult - public static class InitNoiseField extends ChunkProviderEvent - { - public double[] noisefield; - public final int posX; - public final int posY; - public final int posZ; - public final int sizeX; - public final int sizeY; - public final int sizeZ; - - public InitNoiseField(IChunkProvider chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ) - { - super(chunkProvider); - this.noisefield = noisefield; - this.posX = posX; - this.posY = posY; - this.posZ = posZ; - this.sizeX = sizeX; - this.sizeY = sizeY; - this.sizeZ = sizeZ; - } - - } -} diff --git a/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java index 1e6f0a1cf7..ff4c0c6b75 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/DecorateBiomeEvent.java @@ -3,7 +3,7 @@ package net.minecraftforge.event.terraingen; import java.util.Random; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.Event.HasResult; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; /**DecorateBiomeEvent is fired when a BiomeDecorator is created. @@ -23,9 +23,9 @@ import net.minecraft.world.World; **/ public class DecorateBiomeEvent extends Event { - public final World world; - public final Random rand; - public final BlockPos pos; + private final World world; + private final Random rand; + private final BlockPos pos; public DecorateBiomeEvent(World world, Random rand, BlockPos pos) { @@ -34,6 +34,21 @@ public class DecorateBiomeEvent extends Event this.pos = pos; } + public World getWorld() + { + return world; + } + + public Random getRand() + { + return rand; + } + + public BlockPos getPos() + { + return pos; + } + /** * This event is fired before a chunk is decorated with a biome feature. */ @@ -64,11 +79,16 @@ public class DecorateBiomeEvent extends Event @HasResult public static class Decorate extends DecorateBiomeEvent { + public EventType getType() + { + return type; + } + /** Use CUSTOM to filter custom event types */ public static enum EventType { BIG_SHROOM, CACTUS, CLAY, DEAD_BUSH, LILYPAD, FLOWERS, GRASS, LAKE_WATER, LAKE_LAVA, PUMPKIN, REED, SAND, SAND_PASS2, SHROOM, TREE, CUSTOM } - public final EventType type; + private final EventType type; public Decorate(World world, Random rand, BlockPos pos, EventType type) { diff --git a/src/main/java/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java b/src/main/java/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java index 67974e3f9e..d41dde420a 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java +++ b/src/main/java/net/minecraftforge/event/terraingen/DeferredBiomeDecorator.java @@ -1,7 +1,7 @@ package net.minecraftforge.event.terraingen; import java.util.Random; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeDecorator; import net.minecraft.world.biome.BiomeGenBase; @@ -41,6 +41,6 @@ public class DeferredBiomeDecorator extends BiomeDecorator { BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(biome, wrapped); MinecraftForge.TERRAIN_GEN_BUS.post(event); - biome.theBiomeDecorator = event.newBiomeDecorator; + biome.theBiomeDecorator = event.getNewBiomeDecorator(); } } diff --git a/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java b/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java index 914ffe208e..9113db4059 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/InitMapGenEvent.java @@ -9,14 +9,18 @@ public class InitMapGenEvent extends Event */ public static enum EventType { CAVE, MINESHAFT, NETHER_BRIDGE, NETHER_CAVE, RAVINE, SCATTERED_FEATURE, STRONGHOLD, VILLAGE, OCEAN_MONUMENT, CUSTOM } - public final EventType type; - public final MapGenBase originalGen; - public MapGenBase newGen; + private final EventType type; + private final MapGenBase originalGen; + private MapGenBase newGen; InitMapGenEvent(EventType type, MapGenBase original) { this.type = type; this.originalGen = original; - this.newGen = original; + this.setNewGen(original); } + public EventType getType() { return type; } + public MapGenBase getOriginalGen() { return originalGen; } + public MapGenBase getNewGen() { return newGen; } + public void setNewGen(MapGenBase newGen) { this.newGen = newGen; } } diff --git a/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java b/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java index ae4af86c13..9c31596f84 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/InitNoiseGensEvent.java @@ -3,20 +3,110 @@ package net.minecraftforge.event.terraingen; import java.util.Random; import net.minecraft.world.World; -import net.minecraft.world.gen.NoiseGenerator; -import net.minecraftforge.event.world.*; +import net.minecraft.world.gen.NoiseGeneratorOctaves; +import net.minecraft.world.gen.NoiseGeneratorPerlin; +import net.minecraft.world.gen.NoiseGeneratorSimplex; +import net.minecraftforge.event.world.WorldEvent; -public class InitNoiseGensEvent extends WorldEvent +public class InitNoiseGensEvent extends WorldEvent { - public final Random rand; - public final NoiseGenerator[] originalNoiseGens; - public NoiseGenerator[] newNoiseGens; - - public InitNoiseGensEvent(World world, Random rand, NoiseGenerator[] original) + private final Random rand; + private final T original; + private T newValues; + + @SuppressWarnings("unchecked") + public InitNoiseGensEvent(World world, Random rand, T original) { super(world); this.rand = rand; - originalNoiseGens = original; - newNoiseGens = original.clone(); + this.original = original; + this.newValues = (T)original.clone(); + } + public Random getRandom() { return this.rand; } + public T getOriginal() { return this.original; } + public T getNewValues() { return this.newValues; } + + public static class Context + { + private NoiseGeneratorOctaves lperlin1; + private NoiseGeneratorOctaves lperlin2; + private NoiseGeneratorOctaves perlin; + private NoiseGeneratorOctaves scale; + private NoiseGeneratorOctaves depth; + public Context(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin, + NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth) + { + this.lperlin1 = lperlin1; + this.lperlin2 = lperlin2; + this.perlin = perlin; + this.scale = scale; + this.depth = depth; + } + public NoiseGeneratorOctaves getLPerlin1() { return lperlin1; } + public NoiseGeneratorOctaves getLPerlin2() { return lperlin2; } + public NoiseGeneratorOctaves getPerlin() { return perlin; } + public NoiseGeneratorOctaves getScale() { return scale; } + public NoiseGeneratorOctaves getDepth() { return depth; } + public void setLPerlin1(NoiseGeneratorOctaves value) { this.lperlin1 = value; } + public void getLPerlin2(NoiseGeneratorOctaves value) { this.lperlin2 = value; } + public void getPerlin (NoiseGeneratorOctaves value) { this.perlin = value; } + public void getScale (NoiseGeneratorOctaves value) { this.scale = value; } + public void getDepth (NoiseGeneratorOctaves value) { this.depth = value; } + + public Context clone(){ return new Context(lperlin1, lperlin2, perlin, scale, depth); } + } + + public static class ContextOverworld extends Context + { + private NoiseGeneratorPerlin height; + private NoiseGeneratorOctaves forest; + + public ContextOverworld(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin, + NoiseGeneratorPerlin height, NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth, NoiseGeneratorOctaves forest) + { + super(lperlin1, lperlin2, perlin, scale, depth); + this.height = height; + this.forest = forest; + } + public ContextOverworld clone() { return new ContextOverworld(getLPerlin1(), getLPerlin2(), getPerlin(), height, getScale(), getDepth(), forest); } + public NoiseGeneratorPerlin getHeight() { return height; } + public NoiseGeneratorOctaves getForest() { return forest; } + + public void getHeight (NoiseGeneratorPerlin value) { this.height = value; } + public void getForest (NoiseGeneratorOctaves value) { this.forest = value; } + } + + public static class ContextEnd extends Context + { + private NoiseGeneratorSimplex island; + public ContextEnd(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin, + NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth, NoiseGeneratorSimplex island) + { + super(lperlin1, lperlin2, perlin, scale, depth); + this.island = island; + } + public ContextEnd clone() { return new ContextEnd(getLPerlin1(), getLPerlin2(), getPerlin(), getScale(), getDepth(), island); } + public NoiseGeneratorSimplex getIsland() { return island; } + public void getIsland (NoiseGeneratorSimplex value) { this.island = value; } + } + + + public static class ContextHell extends Context + { + private NoiseGeneratorOctaves perlin2; + private NoiseGeneratorOctaves perlin3; + + public ContextHell(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin, + NoiseGeneratorOctaves perlin2, NoiseGeneratorOctaves perlin3, NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth) + { + super(lperlin1, lperlin2, perlin, scale, depth); + this.perlin2 = perlin2; + this.perlin3 = perlin3; + } + public ContextHell clone() { return new ContextHell(getLPerlin1(), getLPerlin2(), getPerlin(), perlin2, perlin3, getScale(), getDepth()); } + public NoiseGeneratorOctaves getPerlin2() { return perlin2; } + public NoiseGeneratorOctaves getPerlin3() { return perlin3; } + public void getPerlin2 (NoiseGeneratorOctaves value) { this.perlin2 = value; } + public void getPerlin3 (NoiseGeneratorOctaves value) { this.perlin3 = value; } } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java b/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java index de737b9048..0977129f14 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/OreGenEvent.java @@ -3,7 +3,7 @@ package net.minecraftforge.event.terraingen; import java.util.Random; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.Event.HasResult; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; @@ -20,9 +20,9 @@ import net.minecraft.world.gen.feature.WorldGenerator; **/ public class OreGenEvent extends Event { - public final World world; - public final Random rand; - public final BlockPos pos; + private final World world; + private final Random rand; + private final BlockPos pos; public OreGenEvent(World world, Random rand, BlockPos pos) { @@ -31,6 +31,21 @@ public class OreGenEvent extends Event this.pos = pos; } + public World getWorld() + { + return world; + } + + public Random getRand() + { + return rand; + } + + public BlockPos getPos() + { + return pos; + } + /** * OreGenEvent.Pre is fired just before a chunk is populated with ores.
    * This event is fired just before ore generation in @@ -89,8 +104,8 @@ public class OreGenEvent extends Event { public static enum EventType { COAL, DIAMOND, DIRT, GOLD, GRAVEL, IRON, LAPIS, REDSTONE, QUARTZ, DIORITE, GRANITE, ANDESITE, EMERALD, SILVERFISH, CUSTOM } - public final EventType type; - public final WorldGenerator generator; + private final EventType type; + private final WorldGenerator generator; public GenerateMinable(World world, Random rand, WorldGenerator generator, BlockPos pos, EventType type) { @@ -98,5 +113,15 @@ public class OreGenEvent extends Event this.generator = generator; this.type = type; } + + public EventType getType() + { + return type; + } + + public WorldGenerator getGenerator() + { + return generator; + } } } diff --git a/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java b/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java index cfc77547f5..08ece413bf 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/PopulateChunkEvent.java @@ -2,10 +2,11 @@ package net.minecraftforge.event.terraingen; import java.util.Random; -import net.minecraftforge.fml.common.eventhandler.Event; -import net.minecraftforge.fml.common.eventhandler.Event.HasResult; import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.chunk.IChunkGenerator; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.eventhandler.Cancelable; +import net.minecraftforge.fml.common.eventhandler.Event; /** * PopulateChunkEvent is fired when an event involving chunk terrain feature population occurs.
    @@ -20,17 +21,17 @@ import net.minecraft.world.chunk.IChunkProvider; *
    * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}, except {@link Populate}, which fires on the {@link MinecraftForge#TERRAIN_GEN_BUS}.
    **/ -public class PopulateChunkEvent extends ChunkProviderEvent +public class PopulateChunkEvent extends ChunkGeneratorEvent { - public final World world; - public final Random rand; - public final int chunkX; - public final int chunkZ; - public final boolean hasVillageGenerated; + private final World world; + private final Random rand; + private final int chunkX; + private final int chunkZ; + private final boolean hasVillageGenerated; - public PopulateChunkEvent(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) + public PopulateChunkEvent(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { - super(chunkProvider); + super(gen); this.world = world; this.rand = rand; this.chunkX = chunkX; @@ -38,6 +39,11 @@ public class PopulateChunkEvent extends ChunkProviderEvent this.hasVillageGenerated = hasVillageGenerated; } + public World getWorld() { return world; } + public Random getRand() { return rand; } + public int getChunkX() { return chunkX; } + public int getChunkZ() { return chunkZ; } + public boolean isHasVillageGenerated() { return hasVillageGenerated; } /** * PopulateChunkEvent.Pre is fired just before a chunk is populated a terrain feature.
    * This event is fired just before terrain feature generation in @@ -53,9 +59,9 @@ public class PopulateChunkEvent extends ChunkProviderEvent **/ public static class Pre extends PopulateChunkEvent { - public Pre(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) + public Pre(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { - super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated); + super(gen, world, rand, chunkX, chunkZ, hasVillageGenerated); } } @@ -74,7 +80,7 @@ public class PopulateChunkEvent extends ChunkProviderEvent **/ public static class Post extends PopulateChunkEvent { - public Post(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) + public Post(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) { super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated); } @@ -99,15 +105,20 @@ public class PopulateChunkEvent extends ChunkProviderEvent @HasResult public static class Populate extends PopulateChunkEvent { + public EventType getType() + { + return type; + } + /** Use CUSTOM to filter custom event types */ public static enum EventType { DUNGEON, FIRE, GLOWSTONE, ICE, LAKE, LAVA, NETHER_LAVA, NETHER_LAVA2, ANIMALS, CUSTOM } - public final EventType type; + private final EventType type; - public Populate(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, EventType type) + public Populate(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, EventType type) { - super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated); + super(gen, world, rand, chunkX, chunkZ, hasVillageGenerated); this.type = type; } } diff --git a/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java index 5e95749354..e12002b250 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/SaplingGrowTreeEvent.java @@ -2,7 +2,7 @@ package net.minecraftforge.event.terraingen; import java.util.Random; import net.minecraftforge.fml.common.eventhandler.Event.HasResult; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.event.world.WorldEvent; @@ -24,8 +24,8 @@ import net.minecraftforge.event.world.WorldEvent; @HasResult public class SaplingGrowTreeEvent extends WorldEvent { - public final BlockPos pos; - public final Random rand; + private final BlockPos pos; + private final Random rand; public SaplingGrowTreeEvent(World world, Random rand, BlockPos pos) { @@ -33,4 +33,14 @@ public class SaplingGrowTreeEvent extends WorldEvent this.rand = rand; this.pos = pos; } + + public BlockPos getPos() + { + return pos; + } + + public Random getRand() + { + return rand; + } } diff --git a/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java index 881cc63a70..c6f4aa2d4a 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java +++ b/src/main/java/net/minecraftforge/event/terraingen/TerrainGen.java @@ -1,35 +1,35 @@ package net.minecraftforge.event.terraingen; import java.util.Random; -import net.minecraftforge.fml.common.eventhandler.Event.*; -import net.minecraft.util.BlockPos; + +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.gen.MapGenBase; -import net.minecraft.world.gen.NoiseGenerator; import net.minecraft.world.gen.feature.WorldGenerator; -import net.minecraftforge.common.*; -import net.minecraftforge.event.terraingen.DecorateBiomeEvent.*; -import net.minecraftforge.event.terraingen.OreGenEvent.*; -import net.minecraftforge.event.terraingen.PopulateChunkEvent.*; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate; +import net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable; +import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate; +import net.minecraftforge.fml.common.eventhandler.Event.Result; public abstract class TerrainGen { - public static NoiseGenerator[] getModdedNoiseGenerators(World world, Random rand, NoiseGenerator[] original) + public static T getModdedNoiseGenerators(World world, Random rand, T original) { - InitNoiseGensEvent event = new InitNoiseGensEvent(world, rand, original); + InitNoiseGensEvent event = new InitNoiseGensEvent(world, rand, original); MinecraftForge.TERRAIN_GEN_BUS.post(event); - return event.newNoiseGens; + return event.getNewValues(); } public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type) { InitMapGenEvent event = new InitMapGenEvent(type, original); MinecraftForge.TERRAIN_GEN_BUS.post(event); - return event.newGen; + return event.getNewGen(); } - public static boolean populate(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type) + public static boolean populate(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type) { PopulateChunkEvent.Populate event = new PopulateChunkEvent.Populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, type); MinecraftForge.TERRAIN_GEN_BUS.post(event); diff --git a/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java index 463f644cb6..cb3f21daca 100644 --- a/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java +++ b/src/main/java/net/minecraftforge/event/terraingen/WorldTypeEvent.java @@ -15,13 +15,18 @@ import net.minecraft.world.WorldType; **/ public class WorldTypeEvent extends Event { - public final WorldType worldType; + private final WorldType worldType; public WorldTypeEvent(WorldType worldType) { this.worldType = worldType; } + public WorldType getWorldType() + { + return worldType; + } + /** * BiomeSize is fired when vanilla Minecraft attempts to generate biomes.
    * This event is fired during biome generation in @@ -39,14 +44,29 @@ public class WorldTypeEvent extends Event **/ public static class BiomeSize extends WorldTypeEvent { - public final int originalSize; - public int newSize; + private final int originalSize; + private int newSize; public BiomeSize(WorldType worldType, int original) { super(worldType); originalSize = original; - newSize = original; + setNewSize(original); + } + + public int getOriginalSize() + { + return originalSize; + } + + public int getNewSize() + { + return newSize; + } + + public void setNewSize(int newSize) + { + this.newSize = newSize; } } @@ -68,16 +88,36 @@ public class WorldTypeEvent extends Event **/ public static class InitBiomeGens extends WorldTypeEvent { - public final long seed; - public final GenLayer[] originalBiomeGens; - public GenLayer[] newBiomeGens; + private final long seed; + private final GenLayer[] originalBiomeGens; + private GenLayer[] newBiomeGens; public InitBiomeGens(WorldType worldType, long seed, GenLayer[] original) { super(worldType); this.seed = seed; originalBiomeGens = original; - newBiomeGens = original.clone(); + setNewBiomeGens(original.clone()); + } + + public long getSeed() + { + return seed; + } + + public GenLayer[] getOriginalBiomeGens() + { + return originalBiomeGens; + } + + public GenLayer[] getNewBiomeGens() + { + return newBiomeGens; + } + + public void setNewBiomeGens(GenLayer[] newBiomeGens) + { + this.newBiomeGens = newBiomeGens; } } } diff --git a/src/main/java/net/minecraftforge/event/world/BlockEvent.java b/src/main/java/net/minecraftforge/event/world/BlockEvent.java index bd33fe17db..01b90398f3 100644 --- a/src/main/java/net/minecraftforge/event/world/BlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/BlockEvent.java @@ -6,8 +6,9 @@ import java.util.List; import net.minecraft.block.state.IBlockState; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Enchantments; import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; @@ -21,9 +22,9 @@ public class BlockEvent extends Event { private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false")); - public final World world; - public final BlockPos pos; - public final IBlockState state; + private final World world; + private final BlockPos pos; + private final IBlockState state; public BlockEvent(World world, BlockPos pos, IBlockState state) { this.pos = pos; @@ -31,6 +32,21 @@ public class BlockEvent extends Event this.state = state; } + public World getWorld() + { + return world; + } + + public BlockPos getPos() + { + return pos; + } + + public IBlockState getState() + { + return state; + } + /** * Fired when a block is about to drop it's harvested items. The {@link #drops} array can be amended, as can the {@link #dropChance}. * Note well: the {@link #harvester} player field is null in a variety of scenarios. Code expecting null. @@ -44,21 +60,28 @@ public class BlockEvent extends Event */ public static class HarvestDropsEvent extends BlockEvent { - public final int fortuneLevel; - public final List drops; - public final boolean isSilkTouching; - public float dropChance; // Change to e.g. 1.0f, if you manipulate the list and want to guarantee it always drops - public final EntityPlayer harvester; // May be null for non-player harvesting such as explosions or machines + private final int fortuneLevel; + private final List drops; + private final boolean isSilkTouching; + private float dropChance; // Change to e.g. 1.0f, if you manipulate the list and want to guarantee it always drops + private final EntityPlayer harvester; // May be null for non-player harvesting such as explosions or machines public HarvestDropsEvent(World world, BlockPos pos, IBlockState state, int fortuneLevel, float dropChance, List drops, EntityPlayer harvester, boolean isSilkTouching) { super(world, pos, state); this.fortuneLevel = fortuneLevel; - this.dropChance = dropChance; + this.setDropChance(dropChance); this.drops = drops; this.isSilkTouching = isSilkTouching; this.harvester = harvester; } + + public int getFortuneLevel() { return fortuneLevel; } + public List getDrops() { return drops; } + public boolean isSilkTouching() { return isSilkTouching; } + public float getDropChance() { return dropChance; } + public void setDropChance(float dropChance) { this.dropChance = dropChance; } + public EntityPlayer getHarvester() { return harvester; } } /** @@ -78,14 +101,14 @@ public class BlockEvent extends Event this.player = player; if (state == null || !ForgeHooks.canHarvestBlock(state.getBlock(), player, world, pos) || // Handle empty block or player unable to break block scenario - (state.getBlock().canSilkHarvest(world, pos, world.getBlockState(pos), player) && EnchantmentHelper.getSilkTouchModifier(player))) // If the block is being silk harvested, the exp dropped is 0 + (state.getBlock().canSilkHarvest(world, pos, world.getBlockState(pos), player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.silkTouch, player.getHeldItemMainhand()) > 0)) // If the block is being silk harvested, the exp dropped is 0 { this.exp = 0; } else { - int bonusLevel = EnchantmentHelper.getFortuneModifier(player); - this.exp = state.getBlock().getExpDrop(world, pos, bonusLevel); + int bonusLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.fortune, player.getHeldItemMainhand()); + this.exp = state.getBlock().getExpDrop(state, world, pos, bonusLevel); } } @@ -123,25 +146,31 @@ public class BlockEvent extends Event @Cancelable public static class PlaceEvent extends BlockEvent { - public final EntityPlayer player; - public final ItemStack itemInHand; - public final BlockSnapshot blockSnapshot; - public final IBlockState placedBlock; - public final IBlockState placedAgainst; + private final EntityPlayer player; + private final ItemStack itemInHand; + private final BlockSnapshot blockSnapshot; + private final IBlockState placedBlock; + private final IBlockState placedAgainst; public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player) { - super(blockSnapshot.world, blockSnapshot.pos, blockSnapshot.getCurrentBlock()); + super(blockSnapshot.getWorld(), blockSnapshot.getPos(), blockSnapshot.getCurrentBlock()); this.player = player; - this.itemInHand = player.getCurrentEquippedItem(); + this.itemInHand = player.getHeldItemMainhand(); this.blockSnapshot = blockSnapshot; this.placedBlock = blockSnapshot.getCurrentBlock(); this.placedAgainst = placedAgainst; if (DEBUG) { - System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", placedBlock, placedAgainst, player.getCurrentEquippedItem(), player); + System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", getPlacedBlock(), placedAgainst, getItemInHand(), player); } } + + public EntityPlayer getPlayer() { return player; } + public ItemStack getItemInHand() { return itemInHand; } + public BlockSnapshot getBlockSnapshot() { return blockSnapshot; } + public IBlockState getPlacedBlock() { return placedBlock; } + public IBlockState getPlacedAgainst() { return placedAgainst; } } /** @@ -162,12 +191,12 @@ public class BlockEvent extends Event this.blockSnapshots = ImmutableList.copyOf(blockSnapshots); if (DEBUG) { - System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.itemInHand, player); + System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.getItemInHand(), player); } } /** - * Gets a list of blocksnapshots for all blocks which were replaced by the + * Gets a list of BlockSnapshots for all blocks which were replaced by the * placement of the new blocks. Most of these blocks will just be of type AIR. * * @return immutable list of replaced BlockSnapshots @@ -177,29 +206,29 @@ public class BlockEvent extends Event return blockSnapshots; } } - + /** * Fired when a physics update occurs on a block. This event acts as * a way for mods to detect physics updates, in the same way a BUD switch * does. This event is only called on the server. */ @Cancelable - public static class NeighborNotifyEvent extends BlockEvent + public static class NeighborNotifyEvent extends BlockEvent { private final EnumSet notifiedSides; - + public NeighborNotifyEvent(World world, BlockPos pos, IBlockState state, EnumSet notifiedSides) { super(world, pos, state); this.notifiedSides = notifiedSides; } - + /** * Gets a list of directions from the base block that updates will occur upon. - * + * * @return list of notified directions */ - public EnumSet getNotifiedSides() + public EnumSet getNotifiedSides() { return notifiedSides; } diff --git a/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java index e94c57cc32..bc33653b06 100644 --- a/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ChunkWatchEvent.java @@ -16,15 +16,25 @@ import net.minecraft.entity.player.EntityPlayerMP; **/ public class ChunkWatchEvent extends Event { - public final ChunkCoordIntPair chunk; - public final EntityPlayerMP player; + private final ChunkCoordIntPair chunk; + private final EntityPlayerMP player; public ChunkWatchEvent(ChunkCoordIntPair chunk, EntityPlayerMP player) { this.chunk = chunk; this.player = player; } - + + public ChunkCoordIntPair getChunk() + { + return chunk; + } + + public EntityPlayerMP getPlayer() + { + return player; + } + /** * ChunkWatchEvent.Watch is fired when an EntityPlayer begins watching a chunk.
    * This event is fired when a chunk is added to the watched chunks of an EntityPlayer in diff --git a/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java b/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java index 167c09724b..5a93fdb3d9 100644 --- a/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java +++ b/src/main/java/net/minecraftforge/event/world/ExplosionEvent.java @@ -5,7 +5,7 @@ import java.util.List; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.entity.Entity; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.Explosion; import net.minecraft.world.World; @@ -21,8 +21,8 @@ import net.minecraft.world.World; */ public class ExplosionEvent extends Event { - public final World world; - public final Explosion explosion; + private final World world; + private final Explosion explosion; public ExplosionEvent(World world, Explosion explosion) { @@ -30,6 +30,16 @@ public class ExplosionEvent extends Event this.explosion = explosion; } + public World getWorld() + { + return world; + } + + public Explosion getExplosion() + { + return explosion; + } + /** ExplosionEvent.Start is fired before the explosion actually occurs. Canceling this event will stop the explosion.
    *
    * This event is {@link Cancelable}.
    @@ -64,7 +74,7 @@ public class ExplosionEvent extends Event /** return the list of blocks affected by the explosion. */ public List getAffectedBlocks() { - return explosion.getAffectedBlockPositions(); + return getExplosion().getAffectedBlockPositions(); } /** return the list of entities affected by the explosion. */ diff --git a/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java b/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java index 5df225e85d..1c54ff5182 100644 --- a/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java +++ b/src/main/java/net/minecraftforge/event/world/NoteBlockEvent.java @@ -1,26 +1,21 @@ package net.minecraftforge.event.world; -import com.google.common.base.Preconditions; - -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; + +import com.google.common.base.Preconditions; /** * Base class for Noteblock Events * */ -@SuppressWarnings("unused") public class NoteBlockEvent extends BlockEvent { private int noteId; - NoteBlockEvent(World world, BlockPos pos, IBlockState state, int note) + protected NoteBlockEvent(World world, BlockPos pos, IBlockState state, int note) { super(world, pos, state); this.noteId = note; @@ -72,12 +67,22 @@ public class NoteBlockEvent extends BlockEvent @Cancelable public static class Play extends NoteBlockEvent { - public Instrument instrument; + private Instrument instrument; public Play(World world, BlockPos pos, IBlockState state, int note, int instrument) { super(world, pos, state, note); - this.instrument = Instrument.fromId(instrument); + this.setInstrument(Instrument.fromId(instrument)); + } + + public Instrument getInstrument() + { + return instrument; + } + + public void setInstrument(Instrument instrument) + { + this.instrument = instrument; } } @@ -88,8 +93,8 @@ public class NoteBlockEvent extends BlockEvent @Cancelable public static class Change extends NoteBlockEvent { - public final Note oldNote; - public final Octave oldOctave; + private final Note oldNote; + private final Octave oldOctave; public Change(World world, BlockPos pos, IBlockState state, int oldNote, int newNote) { @@ -97,6 +102,16 @@ public class NoteBlockEvent extends BlockEvent this.oldNote = Note.fromId(oldNote); this.oldOctave = Octave.fromId(oldNote); } + + public Note getOldNote() + { + return oldNote; + } + + public Octave getOldOctave() + { + return oldOctave; + } } /** diff --git a/src/main/java/net/minecraftforge/event/world/WorldEvent.java b/src/main/java/net/minecraftforge/event/world/WorldEvent.java index 9e8bc166be..d54bd3b77b 100644 --- a/src/main/java/net/minecraftforge/event/world/WorldEvent.java +++ b/src/main/java/net/minecraftforge/event/world/WorldEvent.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.entity.EnumCreatureType; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldSettings; import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; @@ -16,19 +16,24 @@ import net.minecraftforge.fml.common.eventhandler.Event; * If a method utilizes this {@link Event} as its parameter, the method will * receive every child event of this class.
    *
    - * {@link #world} contains the World this event is occuring in.
    + * {@link #world} contains the World this event is occurring in.
    *
    * All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
    **/ public class WorldEvent extends Event { - public final World world; + private final World world; public WorldEvent(World world) { this.world = world; } + public World getWorld() + { + return world; + } + /** * WorldEvent.Load is fired when Minecraft loads a world.
    * This event is fired when a world is loaded in @@ -96,9 +101,9 @@ public class WorldEvent extends Event @Cancelable public static class PotentialSpawns extends WorldEvent { - public final EnumCreatureType type; - public final BlockPos pos; - public final List list; + private final EnumCreatureType type; + private final BlockPos pos; + private final List list; public PotentialSpawns(World world, EnumCreatureType type, BlockPos pos, List oldList) { @@ -114,6 +119,21 @@ public class WorldEvent extends Event this.list = new ArrayList(); } } + + public EnumCreatureType getType() + { + return type; + } + + public BlockPos getPos() + { + return pos; + } + + public List getList() + { + return list; + } } /** @@ -123,11 +143,16 @@ public class WorldEvent extends Event @Cancelable public static class CreateSpawnPosition extends WorldEvent { - public final WorldSettings settings; + private final WorldSettings settings; public CreateSpawnPosition(World world, WorldSettings settings) { super(world); this.settings = settings; } + + public WorldSettings getSettings() + { + return settings; + } } } diff --git a/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java b/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java index b5828a447f..fcde08de64 100644 --- a/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java +++ b/src/main/java/net/minecraftforge/fluids/BlockFluidBase.java @@ -7,16 +7,16 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.item.Item; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumWorldBlockLayer; -import net.minecraft.util.Vec3; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.property.ExtendedBlockState; @@ -34,10 +34,7 @@ import com.google.common.collect.Maps; * * It is highly recommended that you extend this class or one of the Forge-provided child classes. * - * @author King Lemming, OvermindDL1 - * */ -@SuppressWarnings("unchecked") public abstract class BlockFluidBase extends Block implements IFluidBlock { protected final static Map defaultDisplacements = Maps.newHashMap(); @@ -91,29 +88,28 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 15); public static final PropertyFloat[] LEVEL_CORNERS = new PropertyFloat[4]; public static final PropertyFloat FLOW_DIRECTION = new PropertyFloat("flow_direction"); - public static final IUnlistedProperty[] FLUID_RENDER_PROPS; + public static final ImmutableList> FLUID_RENDER_PROPS; static { - @SuppressWarnings("rawtypes") - ImmutableList.Builder builder = ImmutableList.builder(); + ImmutableList.Builder> builder = ImmutableList.builder(); builder.add(FLOW_DIRECTION); for(int i = 0; i < 4; i++) { LEVEL_CORNERS[i] = new PropertyFloat("level_corner_" + i); builder.add(LEVEL_CORNERS[i]); } - FLUID_RENDER_PROPS = builder.build().toArray(new IUnlistedProperty[0]); + FLUID_RENDER_PROPS = builder.build(); } protected int quantaPerBlock = 8; protected float quantaPerBlockFloat = 8F; protected int density = 1; protected int densityDir = -1; - protected int temperature = 295; + protected int temperature = 295; protected int tickRate = 20; - protected EnumWorldBlockLayer renderLayer = EnumWorldBlockLayer.TRANSLUCENT; + protected BlockRenderLayer renderLayer = BlockRenderLayer.TRANSLUCENT; protected int maxScaledLight = 0; protected final String fluidName; @@ -128,7 +124,6 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock public BlockFluidBase(Fluid fluid, Material material) { super(material); - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.setTickRandomly(true); this.disableStats(); @@ -146,15 +141,15 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock } @Override - protected BlockState createBlockState() + protected BlockStateContainer createBlockState() { - return new ExtendedBlockState(this, new IProperty[] { LEVEL }, FLUID_RENDER_PROPS); + return new ExtendedBlockState(this, new IProperty[] { LEVEL }, FLUID_RENDER_PROPS.toArray(new IUnlistedProperty[0])); } @Override public int getMetaFromState(IBlockState state) { - return ((Integer)state.getValue(LEVEL)).intValue(); + return state.getValue(LEVEL); } public BlockFluidBase setQuantaPerBlock(int quantaPerBlock) { @@ -185,7 +180,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock return this; } - public BlockFluidBase setRenderLayer(EnumWorldBlockLayer renderLayer) + public BlockFluidBase setRenderLayer(BlockRenderLayer renderLayer) { this.renderLayer = renderLayer; return this; @@ -204,19 +199,19 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock { if (world.isAirBlock(pos)) return true; - Block block = world.getBlockState(pos).getBlock(); + IBlockState state = world.getBlockState(pos); - if (block == this) + if (state.getBlock() == this) { return false; } - if (displacements.containsKey(block)) + if (displacements.containsKey(state.getBlock())) { - return displacements.get(block); + return displacements.get(state.getBlock()); } - Material material = block.getMaterial(); + Material material = state.getMaterial(); if (material.blocksMovement() || material == Material.portal) { return false; @@ -225,16 +220,16 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock int density = getDensity(world, pos); if (density == Integer.MAX_VALUE) { - return true; + return true; } if (this.density > density) { - return true; + return true; } else { - return false; + return false; } } @@ -265,7 +260,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock return false; } - Material material = block.getMaterial(); + Material material = state.getMaterial(); if (material.blocksMovement() || material == Material.portal) { return false; @@ -274,17 +269,17 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock int density = getDensity(world, pos); if (density == Integer.MAX_VALUE) { - block.dropBlockAsItem(world, pos, state, 0); - return true; + block.dropBlockAsItem(world, pos, state, 0); + return true; } if (this.density > density) { - return true; + return true; } else { - return false; + return false; } } @@ -321,12 +316,6 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock return true; } - @Override - public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state) - { - return null; - } - @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { @@ -346,10 +335,10 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock } @Override - public Vec3 modifyAcceleration(World world, BlockPos pos, Entity entity, Vec3 vec) + public Vec3d modifyAcceleration(World world, BlockPos pos, Entity entity, Vec3d vec) { if (densityDir > 0) return vec; - Vec3 vec_flow = this.getFlowVector(world, pos); + Vec3d vec_flow = this.getFlowVector(world, pos); return vec.addVector( vec_flow.xCoord * (quantaPerBlock * 4), vec_flow.yCoord * (quantaPerBlock * 4), @@ -357,24 +346,24 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock } @Override - public int getLightValue(IBlockAccess world, BlockPos pos) + public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { if (maxScaledLight == 0) { - return super.getLightValue(world, pos); + return super.getLightValue(state, world, pos); } - int data = ((Integer)world.getBlockState(pos).getValue(LEVEL)).intValue(); + int data = state.getValue(LEVEL); return (int) (data / quantaPerBlockFloat * maxScaledLight); } @Override - public boolean isOpaqueCube() + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube() + public boolean isFullCube(IBlockState state) { return false; } @@ -390,7 +379,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock */ @Override - public int getMixedBrightnessForBlock(IBlockAccess world, BlockPos pos) + public int getPackedLightmapCoords(IBlockState state, IBlockAccess world, BlockPos pos) { int lightThis = world.getCombinedLight(pos, 0); int lightUp = world.getCombinedLight(pos.up(), 0); @@ -404,16 +393,16 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock @Override @SideOnly(Side.CLIENT) - public EnumWorldBlockLayer getBlockLayer() + public BlockRenderLayer getBlockLayer() { return this.renderLayer; } @Override - public boolean shouldSideBeRendered(IBlockAccess world, BlockPos pos, EnumFacing side) + public boolean shouldSideBeRendered(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - Block block = world.getBlockState(pos).getBlock(); - if (block.getMaterial() == this.blockMaterial) + IBlockState neighbor = world.getBlockState(pos.offset(side)); + if (neighbor.getMaterial() == state.getMaterial()) { return false; } @@ -425,7 +414,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock { return true; } - return super.shouldSideBeRendered(world, pos, side); + return super.shouldSideBeRendered(state, world, pos, side); } @Override @@ -496,12 +485,12 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock public static double getFlowDirection(IBlockAccess world, BlockPos pos) { - Block block = world.getBlockState(pos).getBlock(); - if (!block.getMaterial().isLiquid()) + IBlockState state = world.getBlockState(pos); + if (!state.getMaterial().isLiquid()) { return -1000.0; } - Vec3 vec = ((BlockFluidBase) block).getFlowVector(world, pos); + Vec3d vec = ((BlockFluidBase)state.getBlock()).getFlowVector(world, pos); return vec.xCoord == 0.0D && vec.zCoord == 0.0D ? -1000.0D : Math.atan2(vec.zCoord, vec.xCoord) - Math.PI / 2D; } @@ -564,7 +553,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock IBlockState up = world.getBlockState(pos.down(densityDir)); if (here.getBlock() == this) { - if (up.getBlock().getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock) + if (up.getMaterial().isLiquid() || up.getBlock() instanceof IFluidBlock) { return 1; } @@ -574,12 +563,12 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock return 0.875F; } } - return !here.getBlock().getMaterial().isSolid() && up.getBlock() == this ? 1 : this.getQuantaPercentage(world, pos) * 0.875F; + return !here.getMaterial().isSolid() && up.getBlock() == this ? 1 : this.getQuantaPercentage(world, pos) * 0.875F; } - public Vec3 getFlowVector(IBlockAccess world, BlockPos pos) + public Vec3d getFlowVector(IBlockAccess world, BlockPos pos) { - Vec3 vec = new Vec3(0.0D, 0.0D, 0.0D); + Vec3d vec = new Vec3d(0.0D, 0.0D, 0.0D); int decay = quantaPerBlock - getQuantaValue(world, pos); for (int side = 0; side < 4; ++side) @@ -599,7 +588,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock int otherDecay = quantaPerBlock - getQuantaValue(world, pos2); if (otherDecay >= quantaPerBlock) { - if (!world.getBlockState(pos2).getBlock().getMaterial().blocksMovement()) + if (!world.getBlockState(pos2).getMaterial().blocksMovement()) { otherDecay = quantaPerBlock - getQuantaValue(world, pos2.down()); if (otherDecay >= 0) @@ -652,4 +641,10 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock if (remaining > 1) remaining = 1.0f; return remaining * (density > 0 ? 1 : -1); } -} \ No newline at end of file + + @Override + public AxisAlignedBB getSelectedBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) + { + return null; + } +} diff --git a/src/main/java/net/minecraftforge/fluids/BlockFluidClassic.java b/src/main/java/net/minecraftforge/fluids/BlockFluidClassic.java index 3cd307bfe8..449a9c0342 100644 --- a/src/main/java/net/minecraftforge/fluids/BlockFluidClassic.java +++ b/src/main/java/net/minecraftforge/fluids/BlockFluidClassic.java @@ -2,11 +2,10 @@ package net.minecraftforge.fluids; import java.util.Random; -import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -15,8 +14,6 @@ import net.minecraft.world.World; * * It is highly recommended that you use/extend this class for "classic" fluid blocks. * - * @author King Lemming - * */ public class BlockFluidClassic extends BlockFluidBase { @@ -56,14 +53,14 @@ public class BlockFluidClassic extends BlockFluidBase return -1; } - int quantaRemaining = quantaPerBlock - ((Integer)state.getValue(LEVEL)).intValue(); + int quantaRemaining = quantaPerBlock - state.getValue(LEVEL); return quantaRemaining; } @Override public boolean canCollideCheck(IBlockState state, boolean fullHit) { - return fullHit && ((Integer)state.getValue(LEVEL)).intValue() == 0; + return fullHit && state.getValue(LEVEL) == 0; } @Override @@ -73,20 +70,20 @@ public class BlockFluidClassic extends BlockFluidBase } @Override - public int getLightValue(IBlockAccess world, BlockPos pos) + public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { if (maxScaledLight == 0) { - return super.getLightValue(world, pos); + return super.getLightValue(state, world, pos); } - int data = quantaPerBlock - ((Integer)world.getBlockState(pos).getValue(LEVEL)).intValue() - 1; + int data = quantaPerBlock - state.getValue(LEVEL) - 1; return (int) (data / quantaPerBlockFloat * maxScaledLight); } @Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { - int quantaRemaining = quantaPerBlock - ((Integer)state.getValue(LEVEL)).intValue(); + int quantaRemaining = quantaPerBlock - state.getValue(LEVEL); int expQuanta = -101; // check adjacent block levels if non-source @@ -171,7 +168,8 @@ public class BlockFluidClassic extends BlockFluidBase public boolean isSourceBlock(IBlockAccess world, BlockPos pos) { - return world.getBlockState(pos).getBlock() == this && ((Integer)world.getBlockState(pos).getValue(LEVEL)).intValue() == 0; + IBlockState state = world.getBlockState(pos); + return state.getBlock() == this && state.getValue(LEVEL) == 0; } protected boolean[] getOptimalFlowDirections(World world, BlockPos pos) @@ -280,18 +278,18 @@ public class BlockFluidClassic extends BlockFluidBase { if (world.isAirBlock(pos)) return true; - Block block = world.getBlockState(pos).getBlock(); - if (block == this) + IBlockState state = world.getBlockState(pos); + if (state.getBlock() == this) { return true; } - if (displacements.containsKey(block)) + if (displacements.containsKey(state.getBlock())) { - return displacements.get(block); + return displacements.get(state.getBlock()); } - Material material = block.getMaterial(); + Material material = state.getMaterial(); if (material.blocksMovement() || material == Material.water || material == Material.lava || @@ -312,7 +310,7 @@ public class BlockFluidClassic extends BlockFluidBase } else { - return false; + return false; } } diff --git a/src/main/java/net/minecraftforge/fluids/BlockFluidFinite.java b/src/main/java/net/minecraftforge/fluids/BlockFluidFinite.java index 05f767fbbf..285899e9b8 100644 --- a/src/main/java/net/minecraftforge/fluids/BlockFluidFinite.java +++ b/src/main/java/net/minecraftforge/fluids/BlockFluidFinite.java @@ -5,9 +5,9 @@ import java.util.Random; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.EnumFacing; -import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -16,8 +16,6 @@ import net.minecraft.world.World; * * It is highly recommended that you use/extend this class for finite fluid blocks. * - * @author OvermindDL1, KingLemming - * */ public class BlockFluidFinite extends BlockFluidBase { @@ -30,7 +28,7 @@ public class BlockFluidFinite extends BlockFluidBase public int getQuantaValue(IBlockAccess world, BlockPos pos) { IBlockState state = world.getBlockState(pos); - if (state.getBlock().isAir(world, pos)) + if (state.getBlock().isAir(state, world, pos)) { return 0; } @@ -39,13 +37,13 @@ public class BlockFluidFinite extends BlockFluidBase { return -1; } - return ((Integer)state.getValue(LEVEL)) + 1; + return state.getValue(LEVEL) + 1; } @Override public boolean canCollideCheck(IBlockState state, boolean fullHit) { - return fullHit && ((Integer)state.getValue(LEVEL)) == quantaPerBlock - 1; + return fullHit && state.getValue(LEVEL) == quantaPerBlock - 1; } @Override @@ -58,7 +56,7 @@ public class BlockFluidFinite extends BlockFluidBase public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { boolean changed = false; - int quantaRemaining = ((Integer)state.getValue(LEVEL)) + 1; + int quantaRemaining = state.getValue(LEVEL) + 1; // Flow vertically if possible int prevRemaining = quantaRemaining; @@ -83,7 +81,7 @@ public class BlockFluidFinite extends BlockFluidBase } // Flow out if possible - int lowerthan = quantaRemaining - 1; + int lowerThan = quantaRemaining - 1; int total = quantaRemaining; int count = 1; @@ -93,7 +91,7 @@ public class BlockFluidFinite extends BlockFluidBase if (displaceIfPossible(world, off)) world.setBlockToAir(off); - int quanta = getQuantaValueBelow(world, off, lowerthan); + int quanta = getQuantaValueBelow(world, off, lowerThan); if (quanta >= 0) { count++; @@ -116,25 +114,25 @@ public class BlockFluidFinite extends BlockFluidBase for (EnumFacing side : EnumFacing.Plane.HORIZONTAL) { BlockPos off = pos.offset(side); - int quanta = getQuantaValueBelow(world, off, lowerthan); + int quanta = getQuantaValueBelow(world, off, lowerThan); if (quanta >= 0) { - int newquanta = each; + int newQuanta = each; if (rem == count || rem > 1 && rand.nextInt(count - rem) != 0) { - ++newquanta; + ++newQuanta; --rem; } - if (newquanta != quanta) + if (newQuanta != quanta) { - if (newquanta == 0) + if (newQuanta == 0) { world.setBlockToAir(off); } else { - world.setBlockState(off, getDefaultState().withProperty(LEVEL, newquanta - 1), 2); + world.setBlockState(off, getDefaultState().withProperty(LEVEL, newQuanta - 1), 2); } world.scheduleUpdate(off, this, tickRate); } @@ -228,8 +226,7 @@ public class BlockFluidFinite extends BlockFluidBase @Override public FluidStack drain(World world, BlockPos pos, boolean doDrain) { - final FluidStack fluidStack = new FluidStack(getFluid(), - MathHelper.floor_float(getQuantaPercentage(world, pos) * FluidContainerRegistry.BUCKET_VOLUME)); + final FluidStack fluidStack = new FluidStack(getFluid(), MathHelper.floor_float(getQuantaPercentage(world, pos) * FluidContainerRegistry.BUCKET_VOLUME)); if (doDrain) { @@ -244,4 +241,4 @@ public class BlockFluidFinite extends BlockFluidBase { return true; } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraftforge/fluids/Fluid.java b/src/main/java/net/minecraftforge/fluids/Fluid.java index c533506fa5..8ed8477f14 100644 --- a/src/main/java/net/minecraftforge/fluids/Fluid.java +++ b/src/main/java/net/minecraftforge/fluids/Fluid.java @@ -2,9 +2,9 @@ package net.minecraftforge.fluids; import java.util.Locale; import net.minecraft.block.Block; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.translation.I18n; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLLog; import net.minecraft.item.EnumRarity; @@ -24,8 +24,6 @@ import net.minecraft.item.EnumRarity; * The default values can be used as a reference point for mods adding fluids such as oil or heavy * water. * - * @author King Lemming - * */ public class Fluid { @@ -165,12 +163,6 @@ public class Fluid return this.fluidName; } - @Deprecated // Modders should never actually use int ID, use String - public final int getID() - { - return FluidRegistry.getFluidID(this.fluidName); - } - public final Block getBlock() { return block; @@ -187,7 +179,7 @@ public class Fluid public String getLocalizedName(FluidStack stack) { String s = this.getUnlocalizedName(); - return s == null ? "" : StatCollector.translateToLocal(s); + return s == null ? "" : I18n.translateToLocal(s); } /** diff --git a/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java index da4d535047..0b2c3d49cf 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java +++ b/src/main/java/net/minecraftforge/fluids/FluidContainerRegistry.java @@ -19,9 +19,10 @@ import net.minecraftforge.common.MinecraftForge; * * For more complex items, use {@link IFluidContainerItem} instead. * - * @author King Lemming - * + * Deprecated: We will eventually be moving this ALL away from a registry and instead EVERYTHING will use IFluidContainerItem. + * We need to decide a way of swapping Items/Stacks. */ +@Deprecated public abstract class FluidContainerRegistry { // Holder object that implements HashCode for an ItemStack, @@ -168,8 +169,8 @@ public abstract class FluidContainerRegistry } if (data.fluid == null || data.fluid.getFluid() == null) { - FMLLog.bigWarning("Invalid registration attempt for a fluid container item %s has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this.", data.filledContainer.getItem().getUnlocalizedName(data.filledContainer)); - return false; + FMLLog.bigWarning("Invalid registration attempt for a fluid container item %s has occurred. The registration has been denied to prevent crashes. The mod responsible for the registration needs to correct this.", data.filledContainer.getItem().getUnlocalizedName(data.filledContainer)); + return false; } containerFluidMap.put(new ContainerKey(data.filledContainer), data); @@ -388,11 +389,16 @@ public abstract class FluidContainerRegistry public static class FluidContainerRegisterEvent extends Event { - public final FluidContainerData data; + private final FluidContainerData data; public FluidContainerRegisterEvent(FluidContainerData data) { this.data = data.copy(); } + + public FluidContainerData getData() + { + return data; + } } } diff --git a/src/main/java/net/minecraftforge/fluids/FluidEvent.java b/src/main/java/net/minecraftforge/fluids/FluidEvent.java index 9c4a2124ff..73427962c3 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidEvent.java +++ b/src/main/java/net/minecraftforge/fluids/FluidEvent.java @@ -1,16 +1,16 @@ package net.minecraftforge.fluids; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.Event; public class FluidEvent extends Event { - public final FluidStack fluid; - public final World world; - public final BlockPos pos; + private final FluidStack fluid; + private final World world; + private final BlockPos pos; public FluidEvent(FluidStack fluid, World world, BlockPos pos) { @@ -19,6 +19,21 @@ public class FluidEvent extends Event this.pos = pos; } + public FluidStack getFluid() + { + return fluid; + } + + public World getWorld() + { + return world; + } + + public BlockPos getPos() + { + return pos; + } + /** * Mods should fire this event when they move fluids around. * @@ -38,8 +53,8 @@ public class FluidEvent extends Event */ public static class FluidFillingEvent extends FluidEvent { - public final IFluidTank tank; - public final int amount; + private final IFluidTank tank; + private final int amount; public FluidFillingEvent(FluidStack fluid, World world, BlockPos pos, IFluidTank tank, int amount) { @@ -47,6 +62,16 @@ public class FluidEvent extends Event this.tank = tank; this.amount = amount; } + + public IFluidTank getTank() + { + return tank; + } + + public int getAmount() + { + return amount; + } } /** @@ -56,8 +81,8 @@ public class FluidEvent extends Event */ public static class FluidDrainingEvent extends FluidEvent { - public final IFluidTank tank; - public final int amount; + private final IFluidTank tank; + private final int amount; public FluidDrainingEvent(FluidStack fluid, World world, BlockPos pos, IFluidTank tank, int amount) { @@ -65,6 +90,16 @@ public class FluidEvent extends Event this.amount = amount; this.tank = tank; } + + public IFluidTank getTank() + { + return tank; + } + + public int getAmount() + { + return amount; + } } /** diff --git a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java index d04e335821..ec3e6be78a 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java +++ b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java @@ -13,7 +13,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; +import net.minecraft.util.text.translation.I18n; import net.minecraftforge.common.MinecraftForge; import com.google.common.base.Strings; @@ -32,9 +32,6 @@ import net.minecraftforge.fml.common.registry.RegistryDelegate; /** * Handles Fluid registrations. Fluids MUST be registered in order to function. - * - * @author King Lemming, CovertJaguar (LiquidDictionary) - * */ public abstract class FluidRegistry { @@ -56,14 +53,14 @@ public abstract class FluidRegistry public static final Fluid WATER = new Fluid("water", new ResourceLocation("blocks/water_still"), new ResourceLocation("blocks/water_flow")) { @Override public String getLocalizedName(FluidStack fs) { - return StatCollector.translateToLocal("tile.water.name"); + return I18n.translateToLocal("tile.water.name"); } }.setBlock(Blocks.water).setUnlocalizedName(Blocks.water.getUnlocalizedName()); public static final Fluid LAVA = new Fluid("lava", new ResourceLocation("blocks/lava_still"), new ResourceLocation("blocks/lava_flow")) { @Override public String getLocalizedName(FluidStack fs) { - return StatCollector.translateToLocal("tile.lava.name"); + return I18n.translateToLocal("tile.lava.name"); } }.setBlock(Blocks.lava).setLuminosity(15).setDensity(3000).setViscosity(6000).setTemperature(1300).setUnlocalizedName(Blocks.lava.getUnlocalizedName()); @@ -322,14 +319,24 @@ public abstract class FluidRegistry public static class FluidRegisterEvent extends Event { - public final String fluidName; - public final int fluidID; + private final String fluidName; + private final int fluidID; public FluidRegisterEvent(String fluidName, int fluidID) { this.fluidName = fluidName; this.fluidID = fluidID; } + + public String getFluidName() + { + return fluidName; + } + + public int getFluidID() + { + return fluidID; + } } public static int getMaxID() @@ -426,13 +433,7 @@ public abstract class FluidRegistry } @Override - public String name() - { - return name; - } - - @Override - public ResourceLocation getResourceName() { + public ResourceLocation name() { return new ResourceLocation(name); } @@ -447,4 +448,4 @@ public abstract class FluidRegistry fluid = fluids.get(name); } } -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraftforge/fluids/FluidStack.java b/src/main/java/net/minecraftforge/fluids/FluidStack.java index 616b55c49a..fbff1e5e0e 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidStack.java +++ b/src/main/java/net/minecraftforge/fluids/FluidStack.java @@ -13,8 +13,6 @@ import net.minecraftforge.fml.common.registry.RegistryDelegate; * {@link #isFluidStackIdentical(FluidStack)} to determine if FluidID, Amount and NBT Tag are all * equal. * - * @author King Lemming, SirSengir (LiquidStack) - * */ public class FluidStack { @@ -34,7 +32,7 @@ public class FluidStack FMLLog.bigWarning("Failed attempt to create a FluidStack for an unregistered Fluid %s (type %s)", fluid.getName(), fluid.getClass().getName()); throw new IllegalArgumentException("Cannot create a fluidstack from an unregistered fluid"); } - this.fluidDelegate = FluidRegistry.makeDelegate(fluid); + this.fluidDelegate = FluidRegistry.makeDelegate(fluid); this.amount = amount; } @@ -187,12 +185,12 @@ public class FluidStack @Override public final int hashCode() { - int code = 1; - code = 31*code + getFluid().hashCode(); - code = 31*code + amount; - if (tag != null) - code = 31*code + tag.hashCode(); - return code; + int code = 1; + code = 31*code + getFluid().hashCode(); + code = 31*code + amount; + if (tag != null) + code = 31*code + tag.hashCode(); + return code; } /** diff --git a/src/main/java/net/minecraftforge/fluids/FluidTank.java b/src/main/java/net/minecraftforge/fluids/FluidTank.java index 0f7e6e7de0..4969137daf 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidTank.java +++ b/src/main/java/net/minecraftforge/fluids/FluidTank.java @@ -6,9 +6,6 @@ import net.minecraft.tileentity.TileEntity; /** * Reference implementation of {@link IFluidTank}. Use/extend this or implement your own. - * - * @author King Lemming, cpw (LiquidTank) - * */ public class FluidTank implements IFluidTank { diff --git a/src/main/java/net/minecraftforge/fluids/FluidTankInfo.java b/src/main/java/net/minecraftforge/fluids/FluidTankInfo.java index a61ca4e4c8..ad1fba81f2 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidTankInfo.java +++ b/src/main/java/net/minecraftforge/fluids/FluidTankInfo.java @@ -2,9 +2,6 @@ package net.minecraftforge.fluids; /** * Wrapper class used to encapsulate information about an IFluidTank. - * - * @author King Lemming - * */ public final class FluidTankInfo { diff --git a/src/main/java/net/minecraftforge/fluids/FluidUtil.java b/src/main/java/net/minecraftforge/fluids/FluidUtil.java index 7368df3a95..7a374b091a 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidUtil.java +++ b/src/main/java/net/minecraftforge/fluids/FluidUtil.java @@ -5,12 +5,14 @@ import net.minecraft.crash.CrashReportCategory; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.SoundEvents; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.ReportedException; +import net.minecraft.util.SoundCategory; import net.minecraft.world.World; import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.items.IItemHandler; @@ -26,7 +28,7 @@ public class FluidUtil { } - /** Returns true if intercation was successful. */ + /** Returns true if interaction was successful. */ public static boolean interactWithTank(ItemStack stack, EntityPlayer player, IFluidHandler tank, EnumFacing side) { if (stack == null || player.worldObj.isRemote) @@ -191,7 +193,7 @@ public class FluidUtil * @param tank The tank to fill from * @param side Side to access the tank from * @param player The player that tries to fill the bucket. Needed if the input itemstack has a stacksize > 1 to determine where the filled container goes. - * @return True if the IFluidContainerItem was filled successfully, false otherwise. The passed container will have been modified to accomodate for anything done in this method. New Itemstacks might have been added to the players inventory. + * @return True if the IFluidContainerItem was filled successfully, false otherwise. The passed container will have been modified to accommodate for anything done in this method. New Itemstacks might have been added to the players inventory. */ public static boolean tryFillFluidContainerItem(ItemStack container, IFluidHandler tank, EnumFacing side, EntityPlayer player) { @@ -217,7 +219,7 @@ public class FluidUtil * @param inventory An inventory where any additionally created item (filled container if multiple empty are present) are put * @param max Maximum amount to take from the tank. Uses IFluidContainerItem capacity if <= 0 * @param player The player that gets the items the inventory can't take. Can be null, only used if the inventory cannot take the filled stack. - * @return True if the IFluidContainerItem was filled successfully, false otherwise. The passed container will have been modified to accomodate for anything done in this method. New Itemstacks might have been added to the players inventory. + * @return True if the IFluidContainerItem was filled successfully, false otherwise. The passed container will have been modified to accommodate for anything done in this method. New Itemstacks might have been added to the players inventory. */ public static boolean tryFillFluidContainerItem(ItemStack container, IFluidHandler tank, EnumFacing side, IItemHandler inventory, int max, EntityPlayer player) { @@ -390,7 +392,7 @@ public class FluidUtil return false; } - private static boolean insertItemIntoo(ItemStack stack, IInventory inventory, World world, BlockPos pos, boolean isCreative) + private static boolean insertItemInto(ItemStack stack, IInventory inventory, World world, BlockPos pos, boolean isCreative) { if (stack == null) { @@ -402,7 +404,7 @@ public class FluidUtil { if (world != null && pos != null) { - world.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "random.pop", 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.entity_item_pickup, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); } return true; } @@ -543,8 +545,8 @@ public class FluidUtil { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding item to inventory"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added"); - crashreportcategory.addCrashSection("Item ID", Integer.valueOf(Item.getIdFromItem(itemstack.getItem()))); - crashreportcategory.addCrashSection("Item data", Integer.valueOf(itemstack.getMetadata())); + crashreportcategory.addCrashSection("Item ID", Item.getIdFromItem(itemstack.getItem())); + crashreportcategory.addCrashSection("Item data", itemstack.getMetadata()); crashreportcategory.addCrashSectionCallable("Item name", new Callable() { public String call() throws Exception diff --git a/src/main/java/net/minecraftforge/fluids/IFluidBlock.java b/src/main/java/net/minecraftforge/fluids/IFluidBlock.java index da78c9fb80..5bd19dbfdd 100644 --- a/src/main/java/net/minecraftforge/fluids/IFluidBlock.java +++ b/src/main/java/net/minecraftforge/fluids/IFluidBlock.java @@ -1,6 +1,6 @@ package net.minecraftforge.fluids; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; /** @@ -8,8 +8,6 @@ import net.minecraft.world.World; * * NOTE: Using/extending the reference implementations {@link BlockFluidBase} is encouraged. * - * @author King Lemming - * */ public interface IFluidBlock { @@ -49,4 +47,4 @@ public interface IFluidBlock * @return */ float getFilledPercentage(World world, BlockPos pos); -} \ No newline at end of file +} diff --git a/src/main/java/net/minecraftforge/fluids/IFluidContainerItem.java b/src/main/java/net/minecraftforge/fluids/IFluidContainerItem.java index 04957b9cdf..f640403e8e 100644 --- a/src/main/java/net/minecraftforge/fluids/IFluidContainerItem.java +++ b/src/main/java/net/minecraftforge/fluids/IFluidContainerItem.java @@ -5,18 +5,16 @@ import net.minecraft.item.ItemStack; /** * Implement this interface on Item classes that support external manipulation of their internal * fluid storage. - * + * * A reference implementation is provided {@link ItemFluidContainer}. - * + * * NOTE: Use of NBT data on the containing ItemStack is encouraged. - * - * @author King Lemming - * + * */ public interface IFluidContainerItem { /** - * + * * @param container * ItemStack which is the fluid container. * @return FluidStack representing the fluid in the container, null if the container is empty. @@ -24,7 +22,7 @@ public interface IFluidContainerItem FluidStack getFluid(ItemStack container); /** - * + * * @param container * ItemStack which is the fluid container. * @return Capacity of this fluid container. @@ -32,7 +30,7 @@ public interface IFluidContainerItem int getCapacity(ItemStack container); /** - * + * * @param container * ItemStack which is the fluid container. * @param resource @@ -45,7 +43,7 @@ public interface IFluidContainerItem int fill(ItemStack container, FluidStack resource, boolean doFill); /** - * + * * @param container * ItemStack which is the fluid container. * @param maxDrain diff --git a/src/main/java/net/minecraftforge/fluids/IFluidHandler.java b/src/main/java/net/minecraftforge/fluids/IFluidHandler.java index 27880f4a97..a788328a8d 100644 --- a/src/main/java/net/minecraftforge/fluids/IFluidHandler.java +++ b/src/main/java/net/minecraftforge/fluids/IFluidHandler.java @@ -8,8 +8,6 @@ import net.minecraft.util.EnumFacing; * * A reference implementation is provided {@link TileFluidHandler}. * - * @author King Lemming - * */ public interface IFluidHandler { diff --git a/src/main/java/net/minecraftforge/fluids/IFluidTank.java b/src/main/java/net/minecraftforge/fluids/IFluidTank.java index 7416761854..ec64a94759 100644 --- a/src/main/java/net/minecraftforge/fluids/IFluidTank.java +++ b/src/main/java/net/minecraftforge/fluids/IFluidTank.java @@ -2,11 +2,8 @@ package net.minecraftforge.fluids; /** * A tank is the unit of interaction with Fluid inventories. - * + * * A reference implementation can be found at {@link FluidTank}. - * - * @author King Lemming, cpw (ILiquidTank) - * */ public interface IFluidTank { @@ -28,15 +25,15 @@ public interface IFluidTank /** * Returns a wrapper object {@link FluidTankInfo } containing the capacity of the tank and the * FluidStack it holds. - * + * * Should prevent manipulation of the IFluidTank. See {@link FluidTank}. - * + * * @return State information for the IFluidTank. */ FluidTankInfo getInfo(); /** - * + * * @param resource * FluidStack attempting to fill the tank. * @param doFill @@ -46,7 +43,7 @@ public interface IFluidTank int fill(FluidStack resource, boolean doFill); /** - * + * * @param maxDrain * Maximum amount of fluid to be removed from the container. * @param doFill diff --git a/src/main/java/net/minecraftforge/fluids/ItemFluidContainer.java b/src/main/java/net/minecraftforge/fluids/ItemFluidContainer.java index 85e4699412..6127133e2a 100644 --- a/src/main/java/net/minecraftforge/fluids/ItemFluidContainer.java +++ b/src/main/java/net/minecraftforge/fluids/ItemFluidContainer.java @@ -6,9 +6,6 @@ import net.minecraft.nbt.NBTTagCompound; /** * Reference implementation of {@link IFluidContainerItem}. Use/extend this or implement your own. - * - * @author King Lemming - * */ public class ItemFluidContainer extends Item implements IFluidContainerItem { diff --git a/src/main/java/net/minecraftforge/fluids/TileFluidHandler.java b/src/main/java/net/minecraftforge/fluids/TileFluidHandler.java index a48f2ee954..f90247f6aa 100644 --- a/src/main/java/net/minecraftforge/fluids/TileFluidHandler.java +++ b/src/main/java/net/minecraftforge/fluids/TileFluidHandler.java @@ -7,9 +7,6 @@ import net.minecraft.util.EnumFacing; /** * Reference Tile Entity implementation of {@link IFluidHandler}. Use/extend this or write your own. - * - * @author King Lemming - * */ public class TileFluidHandler extends TileEntity implements IFluidHandler { diff --git a/src/main/java/net/minecraftforge/fluids/UniversalBucket.java b/src/main/java/net/minecraftforge/fluids/UniversalBucket.java index c6f51a97a0..751b99b36c 100644 --- a/src/main/java/net/minecraftforge/fluids/UniversalBucket.java +++ b/src/main/java/net/minecraftforge/fluids/UniversalBucket.java @@ -6,15 +6,19 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.stats.StatList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.text.translation.I18n; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.StatCollector; +import net.minecraft.util.SoundCategory; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.FillBucketEvent; import net.minecraftforge.fml.common.eventhandler.Event; @@ -32,9 +36,9 @@ import java.util.List; public class UniversalBucket extends Item implements IFluidContainerItem { - public final int capacity; // how much the bucket holds - public final ItemStack empty; // empty item to return and recognize when filling - public final boolean nbtSensitive; + private final int capacity; // how much the bucket holds + private final ItemStack empty; // empty item to return and recognize when filling + private final boolean nbtSensitive; public UniversalBucket() { @@ -64,7 +68,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { // add all fluids that the bucket can be filled with - FluidStack fs = new FluidStack(fluid, capacity); + FluidStack fs = new FluidStack(fluid, getCapacity()); ItemStack stack = new ItemStack(this); if (fill(stack, fs, true) == fs.amount) { @@ -79,36 +83,36 @@ public class UniversalBucket extends Item implements IFluidContainerItem FluidStack fluidStack = getFluid(stack); if (fluidStack == null) { - if(empty != null) + if(getEmpty() != null) { - return empty.getDisplayName(); + return getEmpty().getDisplayName(); } return super.getItemStackDisplayName(stack); } String unloc = this.getUnlocalizedNameInefficiently(stack); - if (StatCollector.canTranslate(unloc + "." + fluidStack.getFluid().getName())) + if (I18n.canTranslate(unloc + "." + fluidStack.getFluid().getName())) { - return StatCollector.translateToLocal(unloc + "." + fluidStack.getFluid().getName()); + return I18n.translateToLocal(unloc + "." + fluidStack.getFluid().getName()); } - return StatCollector.translateToLocalFormatted(unloc + ".name", fluidStack.getLocalizedName()); + return I18n.translateToLocalFormatted(unloc + ".name", fluidStack.getLocalizedName()); } @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) + public ActionResult onItemRightClick(ItemStack itemstack, World world, EntityPlayer player, EnumHand hand) { FluidStack fluidStack = getFluid(itemstack); // empty bucket shouldn't exist, do nothing since it should be handled by the bucket event if (fluidStack == null) { - return itemstack; + return ActionResult.newResult(EnumActionResult.PASS, itemstack); } // clicked on a block? - MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false); - if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + RayTraceResult mop = this.getMovingObjectPositionFromPlayer(world, player, false); + if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos clickPos = mop.getBlockPos(); // can we place liquid there? @@ -125,21 +129,21 @@ public class UniversalBucket extends Item implements IFluidContainerItem && !player.capabilities.isCreativeMode) { // success! - player.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); + player.addStat(StatList.func_188057_b(this)); itemstack.stackSize--; - ItemStack emptyStack = empty != null ? empty.copy() : new ItemStack(this); + ItemStack emptyStack = getEmpty() != null ? getEmpty().copy() : new ItemStack(this); // check whether we replace the item or add the empty one to the inventory if (itemstack.stackSize <= 0) { - return emptyStack; + return ActionResult.newResult(EnumActionResult.SUCCESS, emptyStack); } else { // add empty bucket to player inventory ItemHandlerHelper.giveItemToPlayer(player, emptyStack); - return itemstack; + return ActionResult.newResult(EnumActionResult.SUCCESS, itemstack); } } } @@ -147,7 +151,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem } // couldn't place liquid there2 - return itemstack; + return ActionResult.newResult(EnumActionResult.FAIL, itemstack); } @@ -158,7 +162,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem return false; } - Material material = worldIn.getBlockState(pos).getBlock().getMaterial(); + Material material = worldIn.getBlockState(pos).getMaterial(); boolean isSolid = material.isSolid(); // can only place in air or non-solid blocks @@ -173,8 +177,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); - worldIn.playSoundEffect((double) ((float) i + 0.5F), (double) ((float) j + 0.5F), (double) ((float) k - + 0.5F), "random.fizz", 0.5F, + worldIn.playSound(null, pos, SoundEvents.block_fire_extinguish, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F); for (int l = 0; l < 8; ++l) @@ -206,21 +209,21 @@ public class UniversalBucket extends Item implements IFluidContainerItem } // not for us to handle - if (event.current == null || - !event.current.isItemEqual(empty) || - (nbtSensitive && ItemStack.areItemStackTagsEqual(event.current, empty))) + if (event.getEmptyBucket() == null || + !event.getEmptyBucket().isItemEqual(getEmpty()) || + (isNbtSensitive() && ItemStack.areItemStackTagsEqual(event.getEmptyBucket(), getEmpty()))) { return; } // needs to target a block - if (event.target == null || event.target.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) + if (event.getTarget() == null || event.getTarget().typeOfHit != RayTraceResult.Type.BLOCK) { return; } - World world = event.world; - BlockPos pos = event.target.getBlockPos(); + World world = event.getWorld(); + BlockPos pos = event.getTarget().getBlockPos(); IBlockState state = world.getBlockState(pos); // Note that water and lava are NOT an instance of IFluidBlock! They are therefore not handled by this code! if (state.getBlock() instanceof IFluidBlock) @@ -230,7 +233,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem { FluidStack drained = fluidBlock.drain(world, pos, false); // check if it fits exactly - if (drained != null && drained.amount == capacity) + if (drained != null && drained.amount == getCapacity()) { // check if the container accepts it ItemStack filledBucket = new ItemStack(this); @@ -243,7 +246,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem // set it as the result event.setResult(Event.Result.ALLOW); - event.result = filledBucket; + event.setFilledBucket(filledBucket); } else { @@ -259,7 +262,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem public static ItemStack getFilledBucket(UniversalBucket item, Fluid fluid) { ItemStack stack = new ItemStack(item); - item.fill(stack, new FluidStack(fluid, item.capacity), true); + item.fill(stack, new FluidStack(fluid, item.getCapacity()), true); return stack; } @@ -274,7 +277,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem @Override public int getCapacity(ItemStack container) { - return capacity; + return getCapacity(); } @Override @@ -287,7 +290,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem } // can only fill exact capacity - if (resource == null || resource.amount != capacity) + if (resource == null || resource.amount != getCapacity()) { return 0; } @@ -307,14 +310,14 @@ public class UniversalBucket extends Item implements IFluidContainerItem resource.writeToNBT(tag); container.setTagCompound(tag); } - return capacity; + return getCapacity(); } @Override public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { // can only drain everything at once - if (maxDrain < capacity) + if (maxDrain < getCapacity()) { return null; } @@ -322,11 +325,11 @@ public class UniversalBucket extends Item implements IFluidContainerItem FluidStack fluidStack = getFluid(container); if (doDrain && fluidStack != null) { - if(empty != null) + if(getEmpty() != null) { - container.setItem(empty.getItem()); - container.setTagCompound(empty.getTagCompound()); - container.setItemDamage(empty.getItemDamage()); + container.setItem(getEmpty().getItem()); + container.setTagCompound(getEmpty().getTagCompound()); + container.setItemDamage(getEmpty().getItemDamage()); } else { container.stackSize = 0; @@ -335,4 +338,19 @@ public class UniversalBucket extends Item implements IFluidContainerItem return fluidStack; } + + public int getCapacity() + { + return capacity; + } + + public ItemStack getEmpty() + { + return empty; + } + + public boolean isNbtSensitive() + { + return nbtSensitive; + } } diff --git a/src/main/java/net/minecraftforge/fml/client/CustomModLoadingErrorDisplayException.java b/src/main/java/net/minecraftforge/fml/client/CustomModLoadingErrorDisplayException.java index 607c3c51d1..fe8d5db8c9 100644 --- a/src/main/java/net/minecraftforge/fml/client/CustomModLoadingErrorDisplayException.java +++ b/src/main/java/net/minecraftforge/fml/client/CustomModLoadingErrorDisplayException.java @@ -43,7 +43,7 @@ public abstract class CustomModLoadingErrorDisplayException extends EnhancedRunt private static final long serialVersionUID = 1L; /** - * Called after the GUI is inited by the parent code. You can do extra stuff here, maybe? + * Called after the GUI is initialized by the parent code. You can do extra stuff here, maybe? * * @param errorScreen The error screen we're painting * @param fontRenderer A font renderer for you diff --git a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java index 3f24d4e62c..87019d1575 100644 --- a/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java +++ b/src/main/java/net/minecraftforge/fml/client/FMLClientHandler.java @@ -19,6 +19,7 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -32,14 +33,14 @@ import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiIngameMenu; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.GuiSelectWorld; +import net.minecraft.client.gui.GuiWorldSelection; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.ServerListEntryNormal; import net.minecraft.client.multiplayer.GuiConnecting; import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.client.network.OldServerPinger; +import net.minecraft.client.network.ServerPinger; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.AbstractResourcePack; import net.minecraft.client.resources.FallbackResourceManager; @@ -67,8 +68,9 @@ import net.minecraft.util.IThreadListener; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; import net.minecraft.world.WorldSettings; +import net.minecraft.world.storage.SaveFormatComparator; import net.minecraft.world.storage.SaveFormatOld; -import net.minecraftforge.client.model.animation.Animation; +import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.DummyModContainer; import net.minecraftforge.fml.common.DuplicateModsFoundException; @@ -76,6 +78,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLContainerHolder; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.IFMLSidedHandler; +import net.minecraftforge.fml.common.Java8VersionException; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.LoaderException; import net.minecraftforge.fml.common.MetadataCollection; @@ -88,7 +91,6 @@ import net.minecraftforge.fml.common.WrongMinecraftVersionException; import net.minecraftforge.fml.common.eventhandler.EventBus; import net.minecraftforge.fml.common.network.FMLNetworkEvent; import net.minecraftforge.fml.common.network.internal.FMLNetworkHandler; -import net.minecraftforge.fml.common.registry.LanguageRegistry; import net.minecraftforge.fml.common.registry.PersistentRegistryManager; import net.minecraftforge.fml.common.toposort.ModSortingException; import net.minecraftforge.fml.relauncher.Side; @@ -123,7 +125,7 @@ import com.google.gson.JsonObject; /** * Handles primary communication from hooked code into the system * - * The FML entry point is {@link #beginMinecraftLoading(Minecraft, List)} called from + * The FML entry point is {@link #beginMinecraftLoading(Minecraft, List, IReloadableResourceManager)} called from * {@link Minecraft} * * Obfuscated code should focus on this class and other members of the "server" @@ -159,6 +161,8 @@ public class FMLClientHandler implements IFMLSidedHandler private boolean loading = true; + private Java8VersionException j8onlymods; + private WrongMinecraftVersionException wrongMC; private CustomModLoadingErrorDisplayException customError; @@ -186,7 +190,7 @@ public class FMLClientHandler implements IFMLSidedHandler * @param resourceManager The resource manager */ @SuppressWarnings("unchecked") - public void beginMinecraftLoading(Minecraft minecraft, @SuppressWarnings("rawtypes") List resourcePackList, IReloadableResourceManager resourceManager) + public void beginMinecraftLoading(Minecraft minecraft, List resourcePackList, IReloadableResourceManager resourceManager) { detectOptifine(); SplashProgress.start(); @@ -200,8 +204,6 @@ public class FMLClientHandler implements IFMLSidedHandler return; } - resourceManager.registerReloadListener(Animation.INSTANCE); - FMLCommonHandler.instance().beginLoading(this); try { @@ -215,6 +217,10 @@ public class FMLClientHandler implements IFMLSidedHandler { dupesFound = dupes; } + catch (Java8VersionException j8mods) + { + j8onlymods = j8mods; + } catch (MissingModsException missing) { modsMissing = missing; @@ -300,7 +306,7 @@ public class FMLClientHandler implements IFMLSidedHandler */ public void finishMinecraftLoading() { - if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null || modSorting!=null) + if (modsMissing != null || wrongMC != null || customError!=null || dupesFound!=null || modSorting!=null || j8onlymods!=null) { SplashProgress.finish(); return; @@ -347,6 +353,8 @@ public class FMLClientHandler implements IFMLSidedHandler } loading = false; client.gameSettings.loadOptions(); //Reload options to load any mod added keybindings. + Loader.instance().loadingComplete(); + SplashProgress.finish(); } public void extendModList() @@ -386,6 +394,10 @@ public class FMLClientHandler implements IFMLSidedHandler { showGuiScreen(new GuiWrongMinecraft(wrongMC)); } + else if (j8onlymods != null) + { + showGuiScreen(new GuiJava8Error(j8onlymods)); + } else if (modsMissing != null) { showGuiScreen(new GuiModsMissing(modsMissing)); @@ -404,10 +416,16 @@ public class FMLClientHandler implements IFMLSidedHandler } else { - Loader.instance().loadingComplete(); - SplashProgress.finish(); + logMissingTextureErrors(); + if (!Loader.instance().java8) + { + if ((new Date()).getTime() >= ForgeModContainer.java8Reminder + (1000 * 60 * 60 * 24)) + { + showGuiScreen(new GuiJava8Error(new Java8VersionException(Collections.emptyList()))); + ForgeModContainer.updateNag(); + } + } } - logMissingTextureErrors(); } /** * Get the server instance @@ -591,7 +609,6 @@ public class FMLClientHandler implements IFMLSidedHandler @Override public void addModAsResource(ModContainer container) { - LanguageRegistry.instance().loadLanguagesFor(container, Side.CLIENT); Class resourcePackType = container.getCustomResourcePackClass(); if (resourcePackType != null) { @@ -628,7 +645,7 @@ public class FMLClientHandler implements IFMLSidedHandler @Override public void serverStopped() { - // If the server crashes during startup, it might hang the client- reset the client so it can abend properly. + // If the server crashes during startup, it might hang the client - reset the client so it can abend properly. MinecraftServer server = getServer(); if (server != null && !server.serverIsInRunLoop()) @@ -666,9 +683,9 @@ public class FMLClientHandler implements IFMLSidedHandler { return new File(client.mcDataDir, "saves"); } - public void tryLoadExistingWorld(GuiSelectWorld selectWorldGUI, String dirName, String saveName) + public void tryLoadExistingWorld(GuiWorldSelection selectWorldGUI, SaveFormatComparator comparator) { - File dir = new File(getSavesDir(), dirName); + File dir = new File(getSavesDir(), comparator.getFileName()); NBTTagCompound leveldat; try { @@ -682,20 +699,20 @@ public class FMLClientHandler implements IFMLSidedHandler } catch (Exception e1) { - FMLLog.warning("There appears to be a problem loading the save %s, both level files are unreadable.", dirName); + FMLLog.warning("There appears to be a problem loading the save %s, both level files are unreadable.", comparator.getFileName()); return; } } NBTTagCompound fmlData = leveldat.getCompoundTag("FML"); if (fmlData.hasKey("ModItemData")) { - showGuiScreen(new GuiOldSaveLoadConfirm(dirName, saveName, selectWorldGUI)); + showGuiScreen(new GuiOldSaveLoadConfirm(comparator.getFileName(), comparator.getDisplayName(), selectWorldGUI)); } else { try { - client.launchIntegratedServer(dirName, saveName, (WorldSettings)null); + client.launchIntegratedServer(comparator.getFileName(), comparator.getDisplayName(), null); } catch (StartupQuery.AbortedException e) { @@ -737,7 +754,7 @@ public class FMLClientHandler implements IFMLSidedHandler String type = jsonData.get("type").getAsString(); JsonArray modDataArray = jsonData.get("modList").getAsJsonArray(); boolean moddedClientAllowed = jsonData.has("clientModsAllowed") ? jsonData.get("clientModsAllowed").getAsBoolean() : true; - Builder modListBldr = ImmutableMap.builder(); + Builder modListBldr = ImmutableMap.builder(); for (JsonElement obj : modDataArray) { JsonObject modObj = obj.getAsJsonObject(); @@ -820,7 +837,7 @@ public class FMLClientHandler implements IFMLSidedHandler public void connectToServerAtStartup(String host, int port) { setupServerList(); - OldServerPinger osp = new OldServerPinger(); + ServerPinger osp = new ServerPinger(); ServerData serverData = new ServerData("Command Line", host+":"+port,false); try { diff --git a/src/main/java/net/minecraftforge/fml/client/GuiJava8Error.java b/src/main/java/net/minecraftforge/fml/client/GuiJava8Error.java new file mode 100644 index 0000000000..af3071d4fc --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/client/GuiJava8Error.java @@ -0,0 +1,140 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package net.minecraftforge.fml.client; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiErrorScreen; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.FMLLog; +import net.minecraftforge.fml.common.Java8VersionException; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import org.apache.logging.log4j.Level; + +import com.google.common.collect.Lists; + +import java.awt.*; +import java.io.IOException; +import java.net.URI; +import java.util.List; + +public class GuiJava8Error extends GuiErrorScreen +{ + private Java8VersionException java8VersionException; + public GuiJava8Error(Java8VersionException java8VersionException) + { + super(null,null); + this.java8VersionException = java8VersionException; + } + + @Override + public void initGui() + { + this.buttonList.clear(); + this.buttonList.add(new GuiButton(1, 50, this.height - 38, this.width/2 -55, 20, I18n.format("fml.button.visitjavadownloads"))); + if (java8VersionException.getMods().isEmpty()) + { + this.buttonList.add(new GuiButton(3, this.width / 2 + 5, this.height - 38, this.width / 2 - 55, 20, I18n.format("fml.button.continue"))); + } + else + { + this.buttonList.add(new GuiButton(2, this.width / 2 + 5, this.height - 38, this.width / 2 - 55, 20, I18n.format("menu.quit"))); + } + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException + { + if (button.id == 1) + { + try + { + Desktop.getDesktop().browse(new URI("http://www.oracle.com/technetwork/java/javase/downloads/index.html")); + } + catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "Problem launching browser"); + } + } + else if (button.id == 2) + { + FMLCommonHandler.instance().exitJava(1,true); + } + else if (button.id == 3) + { + FMLClientHandler.instance().showGuiScreen(null); + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) + { + this.drawDefaultBackground(); + int offset = 25; + if (!java8VersionException.getMods().isEmpty()) + { + this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.java8problem", TextFormatting.RED, TextFormatting.BOLD, TextFormatting.RESET), this.width / 2, offset, 0xFFFFFF); + } + else + { + this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.java8recommended", TextFormatting.RED, TextFormatting.BOLD, TextFormatting.RESET), this.width / 2, offset, 0xFFFFFF); + } + offset+=15; + this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.javaversion", System.getProperty("java.version").split("\\.")[1], System.getProperty("java.version")), this.width / 2, offset, 0xFFFFFF); + offset += 10; + if (!java8VersionException.getMods().isEmpty()) + { + this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.upgradejavaorremove", TextFormatting.RED,TextFormatting.BOLD, TextFormatting.RESET), this.width / 2, offset, 0xFFFFFF); + offset += 15; + this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.modslistedbelow", I18n.format("fml.messages.requirejava8")), this.width / 2, offset, 0xFFFFFF); + offset += 10; + this.drawCenteredString(this.fontRendererObj, I18n.format("fml.messages.countbadandgood", java8VersionException.getMods().size(), Loader.instance().getActiveModList().size()), this.width / 2, offset, 0xFFFFFF); + offset += 5; + for (ModContainer mc : java8VersionException.getMods()) + { + offset += 10; + this.drawCenteredString(this.fontRendererObj, String.format("%s (%s)", mc.getName(), mc.getModId()), this.width / 2, offset, 0xEEEEEE); + } + } + else + { + String text = I18n.format("fml.messages.upgradejava", TextFormatting.RED,TextFormatting.BOLD, TextFormatting.RESET).replaceAll("\\\\n", "\n"); + List lines = Lists.newArrayList(); + for (String line : text.split("\n")) + { + lines.addAll(this.fontRendererObj.listFormattedStringToWidth(line, this.width - this.fontRendererObj.FONT_HEIGHT * 4)); + } + + int maxWidth = 0; + for (String line : lines) + { + maxWidth = Math.max(maxWidth, this.fontRendererObj.getStringWidth(line)); + } + + for (String line : lines) + { + this.drawString(this.fontRendererObj, line, (this.width - maxWidth) / 2, offset, 0xFFFFFF); + offset += this.fontRendererObj.FONT_HEIGHT + 2; + } + + offset += 15; + } + // super.super + for (int i = 0; i < this.buttonList.size(); ++i) + { + ((GuiButton)this.buttonList.get(i)).drawButton(this.mc, mouseX, mouseY); + } + } +} diff --git a/src/main/java/net/minecraftforge/fml/client/GuiModList.java b/src/main/java/net/minecraftforge/fml/client/GuiModList.java index dadb2a257f..6ca185b66e 100644 --- a/src/main/java/net/minecraftforge/fml/client/GuiModList.java +++ b/src/main/java/net/minecraftforge/fml/client/GuiModList.java @@ -34,14 +34,14 @@ import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.gui.GuiUtilRenderComponents; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.IResourcePack; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; import net.minecraftforge.common.ForgeHooks; @@ -53,9 +53,10 @@ import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.ModContainer.Disableable; import net.minecraftforge.fml.common.versioning.ComparableVersion; -import static net.minecraft.util.EnumChatFormatting.*; +import static net.minecraft.util.text.TextFormatting.*; import org.apache.logging.log4j.Level; +import org.lwjgl.input.Mouse; import com.google.common.base.Strings; @@ -153,13 +154,14 @@ public class GuiModList extends GuiScreen @Override public void initGui() { + int slotHeight = 35; for (ModContainer mod : mods) { listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(mod.getName()) + 10); - listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(mod.getVersion()) + 10); + listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(mod.getVersion()) + 5 + slotHeight); } listWidth = Math.min(listWidth, 150); - this.modList = new GuiSlotModList(this, mods, listWidth); + this.modList = new GuiSlotModList(this, mods, listWidth, slotHeight); this.buttonList.add(new GuiButton(6, ((modList.right + this.width) / 2) - 100, this.height - 38, I18n.format("gui.done"))); configModButton = new GuiButton(20, 10, this.height - 49, this.listWidth, 20, "Config"); @@ -247,7 +249,7 @@ public class GuiModList extends GuiScreen if (type != null) { - for (GuiButton b : (List)buttonList) + for (GuiButton b : buttonList) { if (SortType.getTypeForButton(b) != null) { @@ -311,6 +313,18 @@ public class GuiModList extends GuiScreen search.drawTextBox(); } + @Override + public void handleMouseInput() throws IOException + { + int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth; + int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; + + super.handleMouseInput(); + if (this.modInfo != null) + this.modInfo.handleMouseInput(mouseX, mouseY); + this.modList.handleMouseInput(mouseX, mouseY); + } + Minecraft getMinecraftInstance() { return mc; @@ -414,7 +428,7 @@ public class GuiModList extends GuiScreen lines.add("Child mods: " + selectedMod.getMetadata().getChildModList()); if (vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED) - lines.add("Update Avalible: " + (vercheck.url == null ? "" : vercheck.url)); + lines.add("Update Available: " + (vercheck.url == null ? "" : vercheck.url)); lines.add(null); lines.add(selectedMod.getMetadata().description); @@ -451,7 +465,7 @@ public class GuiModList extends GuiScreen { private ResourceLocation logoPath; private Dimension logoDims; - private List lines = null; + private List lines = null; public Info(int width, List lines, ResourceLocation logoPath, Dimension logoDims) { @@ -475,9 +489,9 @@ public class GuiModList extends GuiScreen @Override protected void drawBackground() {} @Override protected void drawSlot(int slotIdx, int entryRight, int slotTop, int slotBuffer, Tessellator tess) { } - private List resizeContent(List lines) + private List resizeContent(List lines) { - List ret = new ArrayList(); + List ret = new ArrayList(); for (String line : lines) { if (line == null) @@ -486,8 +500,8 @@ public class GuiModList extends GuiScreen continue; } - IChatComponent chat = ForgeHooks.newChatWithLinks(line, false); - ret.addAll(GuiUtilRenderComponents.func_178908_a(chat, this.listWidth-8, GuiModList.this.fontRendererObj, false, true)); + ITextComponent chat = ForgeHooks.newChatWithLinks(line, false); + ret.addAll(GuiUtilRenderComponents.splitText(chat, this.listWidth-8, GuiModList.this.fontRendererObj, false, true)); } return ret; } @@ -524,7 +538,7 @@ public class GuiModList extends GuiScreen { GlStateManager.enableBlend(); GuiModList.this.mc.renderEngine.bindTexture(logoPath); - WorldRenderer wr = tess.getWorldRenderer(); + VertexBuffer wr = tess.getBuffer(); int offset = (this.left + this.listWidth/2) - (logoDims.width / 2); wr.begin(7, DefaultVertexFormats.POSITION_TEX); wr.pos(offset, top + logoDims.height, zLevel).tex(0, 1).endVertex(); @@ -536,7 +550,7 @@ public class GuiModList extends GuiScreen top += logoDims.height + 10; } - for (IChatComponent line : lines) + for (ITextComponent line : lines) { if (line != null) { @@ -563,14 +577,14 @@ public class GuiModList extends GuiScreen if (lineIdx >= lines.size()) return; - IChatComponent line = lines.get(lineIdx); + ITextComponent line = lines.get(lineIdx); if (line != null) { int k = -4; - for (IChatComponent part : (Iterable)line) { - if (!(part instanceof ChatComponentText)) + for (ITextComponent part : line) { + if (!(part instanceof TextComponentString)) continue; - k += GuiModList.this.fontRendererObj.getStringWidth(((ChatComponentText)part).getChatComponentText_TextValue()); + k += GuiModList.this.fontRendererObj.getStringWidth(((TextComponentString)part).getChatComponentText_TextValue()); if (k >= x) { GuiModList.this.handleComponentClick(part); diff --git a/src/main/java/net/minecraftforge/fml/client/GuiOldSaveLoadConfirm.java b/src/main/java/net/minecraftforge/fml/client/GuiOldSaveLoadConfirm.java index ccc4269dd4..0160ccfe38 100644 --- a/src/main/java/net/minecraftforge/fml/client/GuiOldSaveLoadConfirm.java +++ b/src/main/java/net/minecraftforge/fml/client/GuiOldSaveLoadConfirm.java @@ -6,12 +6,10 @@ import java.io.IOException; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiLabel; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.GuiSelectWorld; import net.minecraft.client.gui.GuiYesNo; import net.minecraft.client.gui.GuiYesNoCallback; import net.minecraft.world.WorldSettings; import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import net.minecraftforge.fml.common.StartupQuery; import net.minecraftforge.fml.common.ZipperUtil; @@ -44,12 +42,12 @@ public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback for (k = 0; k < this.buttonList.size(); ++k) { - ((GuiButton)this.buttonList.get(k)).drawButton(this.mc, mouseX, mouseY); + this.buttonList.get(k).drawButton(this.mc, mouseX, mouseY); } for (k = 0; k < this.labelList.size(); ++k) { - ((GuiLabel)this.labelList.get(k)).drawLabel(this.mc, mouseX, mouseY); + this.labelList.get(k).drawLabel(this.mc, mouseX, mouseY); } } @Override @@ -57,7 +55,6 @@ public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback { if (button.id == 1) { - ObfuscationReflectionHelper.setPrivateValue(GuiSelectWorld.class, (GuiSelectWorld)parentScreen, false, "field_"+"146634_i"); FMLClientHandler.instance().showGuiScreen(parent); } else @@ -85,7 +82,7 @@ public class GuiOldSaveLoadConfirm extends GuiYesNo implements GuiYesNoCallback try { - mc.launchIntegratedServer(dirName, saveName, (WorldSettings)null); + mc.launchIntegratedServer(dirName, saveName, null); } catch (StartupQuery.AbortedException e) { diff --git a/src/main/java/net/minecraftforge/fml/client/GuiScrollingList.java b/src/main/java/net/minecraftforge/fml/client/GuiScrollingList.java index 1e602680ff..a2d4eb67a5 100644 --- a/src/main/java/net/minecraftforge/fml/client/GuiScrollingList.java +++ b/src/main/java/net/minecraftforge/fml/client/GuiScrollingList.java @@ -12,6 +12,7 @@ package net.minecraftforge.fml.client; +import java.io.IOException; import java.util.List; import net.minecraft.client.Minecraft; @@ -20,7 +21,7 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import org.lwjgl.input.Mouse; @@ -71,6 +72,7 @@ public abstract class GuiScrollingList this.screenHeight = screenHeight; } + @Deprecated // Unused, remove in 1.9.3? public void func_27258_a(boolean p_27258_1_) { this.highlightSelected = p_27258_1_; @@ -120,6 +122,7 @@ public abstract class GuiScrollingList */ protected void drawScreen(int mouseX, int mouseY) { func_27257_b(mouseX, mouseY); } + @Deprecated // Unused, Remove in 1.9.3? public int func_27256_c(int x, int y) { int left = this.left + 1; @@ -129,7 +132,8 @@ public abstract class GuiScrollingList return x >= left && x <= right && entryIndex >= 0 && relativeY >= 0 && entryIndex < this.getSize() ? entryIndex : -1; } - public void registerScrollButtons(@SuppressWarnings("rawtypes") List buttons, int upActionID, int downActionID) + // FIXME: is this correct/still needed? + public void registerScrollButtons(List buttons, int upActionID, int downActionID) { this.scrollUpActionId = upActionID; this.scrollDownActionId = downActionID; @@ -174,6 +178,21 @@ public abstract class GuiScrollingList } } + + public void handleMouseInput(int mouseX, int mouseY) throws IOException + { + boolean isHovering = mouseX >= this.left && mouseX <= this.left + this.listWidth && + mouseY >= this.top && mouseY <= this.bottom; + if (!isHovering) + return; + + int scroll = Mouse.getEventDWheel(); + if (scroll != 0) + { + this.scrollDistance += (float)((-1 * scroll / 120.0F) * this.slotHeight / 2); + } + } + public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.mouseX = mouseX; @@ -245,25 +264,13 @@ public abstract class GuiScrollingList } else { - while (isHovering && Mouse.next()) - { - int scroll = Mouse.getEventDWheel(); - if (scroll != 0) - { - if (scroll > 0) scroll = -1; - else if (scroll < 0) scroll = 1; - - this.scrollDistance += (float)(scroll * this.slotHeight / 2); - } - } - this.initialMouseClickY = -1.0F; } this.applyScrollLimits(); Tessellator tess = Tessellator.getInstance(); - WorldRenderer worldr = tess.getWorldRenderer(); + VertexBuffer worldr = tess.getBuffer(); ScaledResolution res = new ScaledResolution(client); double scaleW = client.displayWidth / res.getScaledWidth_double(); @@ -329,10 +336,10 @@ public abstract class GuiScrollingList GlStateManager.disableDepth(); - int extraHeight = this.getContentHeight() - viewHeight - border; + int extraHeight = (this.getContentHeight() + border) - viewHeight; if (extraHeight > 0) { - int height = viewHeight * viewHeight / this.getContentHeight(); + int height = (viewHeight * viewHeight) / this.getContentHeight(); if (height < 32) height = 32; @@ -390,12 +397,12 @@ public abstract class GuiScrollingList GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - worldrenderer.pos(right, top, 0.0D).color(r1, g1, b1, a1).endVertex(); - worldrenderer.pos(left, top, 0.0D).color(r1, g1, b1, a1).endVertex(); - worldrenderer.pos(left, bottom, 0.0D).color(r2, g2, b2, a2).endVertex(); - worldrenderer.pos(right, bottom, 0.0D).color(r2, g2, b2, a2).endVertex(); + VertexBuffer VertexBuffer = tessellator.getBuffer(); + VertexBuffer.begin(7, DefaultVertexFormats.POSITION_COLOR); + VertexBuffer.pos(right, top, 0.0D).color(r1, g1, b1, a1).endVertex(); + VertexBuffer.pos(left, top, 0.0D).color(r1, g1, b1, a1).endVertex(); + VertexBuffer.pos(left, bottom, 0.0D).color(r2, g2, b2, a2).endVertex(); + VertexBuffer.pos(right, bottom, 0.0D).color(r2, g2, b2, a2).endVertex(); tessellator.draw(); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.disableBlend(); diff --git a/src/main/java/net/minecraftforge/fml/client/GuiSlotModList.java b/src/main/java/net/minecraftforge/fml/client/GuiSlotModList.java index 90198e1d21..45bbb2e4f7 100644 --- a/src/main/java/net/minecraftforge/fml/client/GuiSlotModList.java +++ b/src/main/java/net/minecraftforge/fml/client/GuiSlotModList.java @@ -14,8 +14,12 @@ package net.minecraftforge.fml.client; import java.util.ArrayList; +import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.common.ForgeVersion.CheckResult; @@ -29,12 +33,15 @@ import net.minecraftforge.fml.common.ModContainer; */ public class GuiSlotModList extends GuiScrollingList { + + private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation("forge", "textures/gui/version_check_icons.png"); + private GuiModList parent; private ArrayList mods; - public GuiSlotModList(GuiModList parent, ArrayList mods, int listWidth) + public GuiSlotModList(GuiModList parent, ArrayList mods, int listWidth, int slotHeight) { - super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 88 + 4, 10, 35, parent.width, parent.height); + super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 88 + 4, 10, slotHeight, parent.width, parent.height); this.parent = parent; this.mods = mods; } @@ -86,27 +93,23 @@ public class GuiSlotModList extends GuiScrollingList if (Loader.instance().getModState(mc) == ModState.DISABLED) { font.drawString(font.trimStringToWidth(name, listWidth - 10), this.left + 3 , top + 2, 0xFF2222); - font.drawString(font.trimStringToWidth(version, listWidth - 10), this.left + 3 , top + 12, 0xFF2222); + font.drawString(font.trimStringToWidth(version, listWidth - (5 + height)), this.left + 3 , top + 12, 0xFF2222); font.drawString(font.trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , top + 22, 0xFF2222); } else { font.drawString(font.trimStringToWidth(name, listWidth - 10), this.left + 3 , top + 2, 0xFFFFFF); - font.drawString(font.trimStringToWidth(version, listWidth - 10), this.left + 3 , top + 12, 0xCCCCCC); + font.drawString(font.trimStringToWidth(version, listWidth - (5 + height)), this.left + 3 , top + 12, 0xCCCCCC); font.drawString(font.trimStringToWidth(mc.getMetadata() != null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 10), this.left + 3 , top + 22, 0xCCCCCC); - switch(vercheck.status) //TODO: Change to icons? + if (vercheck.status.shouldDraw()) { - case BETA_OUTDATED: - case OUTDATED: - font.drawString("U", right - font.getCharWidth('U') - 1, top+height-font.FONT_HEIGHT+2, 0x22FF22); - break; - case AHEAD: - case BETA: - case FAILED: - case PENDING: - case UP_TO_DATE: - break; + //TODO: Consider adding more icons for visualization + Minecraft.getMinecraft().getTextureManager().bindTexture(VERSION_CHECK_ICONS); + GlStateManager.color(1, 1, 1, 1); + GlStateManager.pushMatrix(); + Gui.drawModalRectWithCustomSizedTexture(right - (height / 2 + 4), top + (height / 2 - 4), vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16); + GlStateManager.popMatrix(); } } } diff --git a/src/main/java/net/minecraftforge/fml/client/SplashProgress.java b/src/main/java/net/minecraftforge/fml/client/SplashProgress.java index 9ed49fefda..4882ea1103 100644 --- a/src/main/java/net/minecraftforge/fml/client/SplashProgress.java +++ b/src/main/java/net/minecraftforge/fml/client/SplashProgress.java @@ -1,55 +1,7 @@ package net.minecraftforge.fml.client; -import static org.lwjgl.opengl.GL11.GL_ALPHA_TEST; -import static org.lwjgl.opengl.GL11.GL_BLEND; -import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT; -import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST; -import static org.lwjgl.opengl.GL11.GL_GREATER; -import static org.lwjgl.opengl.GL11.GL_LEQUAL; -import static org.lwjgl.opengl.GL11.GL_LIGHTING; -import static org.lwjgl.opengl.GL11.GL_MODELVIEW; -import static org.lwjgl.opengl.GL11.GL_NEAREST; -import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; -import static org.lwjgl.opengl.GL11.GL_PROJECTION; -import static org.lwjgl.opengl.GL11.GL_QUADS; -import static org.lwjgl.opengl.GL11.GL_RENDERER; -import static org.lwjgl.opengl.GL11.GL_RGBA; -import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; -import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D; -import static org.lwjgl.opengl.GL11.GL_TEXTURE_MAG_FILTER; -import static org.lwjgl.opengl.GL11.GL_TEXTURE_MIN_FILTER; -import static org.lwjgl.opengl.GL11.GL_VENDOR; -import static org.lwjgl.opengl.GL11.GL_VERSION; -import static org.lwjgl.opengl.GL11.glAlphaFunc; -import static org.lwjgl.opengl.GL11.glBegin; -import static org.lwjgl.opengl.GL11.glBindTexture; -import static org.lwjgl.opengl.GL11.glBlendFunc; -import static org.lwjgl.opengl.GL11.glClear; -import static org.lwjgl.opengl.GL11.glClearColor; -import static org.lwjgl.opengl.GL11.glColor3ub; -import static org.lwjgl.opengl.GL11.glDeleteTextures; -import static org.lwjgl.opengl.GL11.glDepthFunc; -import static org.lwjgl.opengl.GL11.glDisable; -import static org.lwjgl.opengl.GL11.glEnable; -import static org.lwjgl.opengl.GL11.glEnd; -import static org.lwjgl.opengl.GL11.glGenTextures; -import static org.lwjgl.opengl.GL11.glGetString; -import static org.lwjgl.opengl.GL11.glLoadIdentity; -import static org.lwjgl.opengl.GL11.glMatrixMode; -import static org.lwjgl.opengl.GL11.glOrtho; -import static org.lwjgl.opengl.GL11.glPopMatrix; -import static org.lwjgl.opengl.GL11.glPushMatrix; -import static org.lwjgl.opengl.GL11.glRotatef; -import static org.lwjgl.opengl.GL11.glScalef; -import static org.lwjgl.opengl.GL11.glTexCoord2f; -import static org.lwjgl.opengl.GL11.glTexImage2D; -import static org.lwjgl.opengl.GL11.glTexParameteri; -import static org.lwjgl.opengl.GL11.glTexSubImage2D; -import static org.lwjgl.opengl.GL11.glTranslatef; -import static org.lwjgl.opengl.GL11.glVertex2f; -import static org.lwjgl.opengl.GL11.glViewport; -import static org.lwjgl.opengl.GL12.GL_BGRA; -import static org.lwjgl.opengl.GL12.GL_UNSIGNED_INT_8_8_8_8_REV; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL12.*; import java.awt.image.BufferedImage; import java.io.File; @@ -60,7 +12,6 @@ import java.io.InputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.lang.Thread.UncaughtExceptionHandler; -import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.Iterator; import java.util.Properties; @@ -74,10 +25,14 @@ import javax.imageio.stream.ImageInputStream; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.resources.DefaultResourcePack; import net.minecraft.client.resources.FileResourcePack; import net.minecraft.client.resources.FolderResourcePack; +import net.minecraft.client.resources.IResource; import net.minecraft.client.resources.IResourcePack; +import net.minecraft.client.resources.SimpleResource; import net.minecraft.crash.CrashReport; import net.minecraft.launchwrapper.Launch; import net.minecraft.util.ResourceLocation; @@ -95,7 +50,6 @@ import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.Drawable; -import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.SharedDrawable; import org.lwjgl.util.glu.GLU; @@ -499,8 +453,8 @@ public class SplashProgress if (max_texture_size != -1) return max_texture_size; for (int i = 0x4000; i > 0; i >>= 1) { - GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null); - if (GL11.glGetTexLevelParameteri(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH) != 0) + GlStateManager.glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA, i, i, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); + if (GlStateManager.glGetTexLevelParameteri(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH) != 0) { max_texture_size = i; return i; @@ -595,7 +549,7 @@ public class SplashProgress { stream.println("SplashProgress has detected a error loading Minecraft."); stream.println("This can sometimes be caused by bad video drivers."); - stream.println("We have automatically disabeled the new Splash Screen in config/splash.properties."); + stream.println("We have automatically disabled the new Splash Screen in config/splash.properties."); stream.println("Try reloading minecraft before reporting any errors."); } }; @@ -609,7 +563,7 @@ public class SplashProgress { stream.println("SplashProgress has detected a error loading Minecraft."); stream.println("This can sometimes be caused by bad video drivers."); - stream.println("Please try disabeling the new Splash Screen in config/splash.properties."); + stream.println("Please try disabling the new Splash Screen in config/splash.properties."); stream.println("After doing so, try reloading minecraft before reporting any errors."); } }; @@ -806,9 +760,10 @@ public class SplashProgress } @Override - protected InputStream getResourceInputStream(ResourceLocation location) throws IOException + protected IResource getResource(ResourceLocation location) throws IOException { - return Minecraft.getMinecraft().mcDefaultResourcePack.getInputStream(location); + DefaultResourcePack pack = Minecraft.getMinecraft().mcDefaultResourcePack; + return new SimpleResource(pack.getPackName(), location, pack.getInputStream(location), null, null); } } @@ -830,7 +785,7 @@ public class SplashProgress public static void checkGLError(String where) { - int err = GL11.glGetError(); + int err = glGetError(); if (err != 0) { throw new IllegalStateException(where + ": " + GLU.gluErrorString(err)); diff --git a/src/main/java/net/minecraftforge/fml/client/config/DummyConfigElement.java b/src/main/java/net/minecraftforge/fml/client/config/DummyConfigElement.java index 320fbf0aaa..77a5efbedc 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/DummyConfigElement.java +++ b/src/main/java/net/minecraftforge/fml/client/config/DummyConfigElement.java @@ -54,13 +54,13 @@ public class DummyConfigElement implements IConfigElement /** * This class provides a Dummy Category IConfigElement. It can be used to define a custom list of GUI entries that will - * appear on the child screen or to specify a custom IGuiConfigListEntryfor a special category. + * appear on the child screen or to specify a custom IGuiConfigListEntry for a special category. */ public static class DummyCategoryElement extends DummyConfigElement { public DummyCategoryElement(String name, String langKey, List childElements) { - this(name, langKey, childElements, (Class) null); + this(name, langKey, childElements, null); } public DummyCategoryElement(String name, String langKey, Class customListEntryClass) @@ -70,7 +70,7 @@ public class DummyConfigElement implements IConfigElement public DummyCategoryElement(String name, String langKey, List childElements, Class customListEntryClass) { - super(name, (Object) null, ConfigGuiType.CONFIG_CATEGORY, langKey); + super(name, null, ConfigGuiType.CONFIG_CATEGORY, langKey); this.childElements = childElements; this.configEntryClass = customListEntryClass; isProperty = false; @@ -84,7 +84,7 @@ public class DummyConfigElement implements IConfigElement { public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, boolean isListFixedLength, int maxListLength, Pattern validStringPattern, Object minValue, Object maxValue) { - super(name, (Object) null, type, langKey, minValue, maxValue); + super(name, null, type, langKey, minValue, maxValue); this.defaultValues = defaultValues; this.values = defaultValues; this.isListFixedLength = isListFixedLength; @@ -95,52 +95,52 @@ public class DummyConfigElement implements IConfigElement public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey) { - this(name, defaultValues, type, langKey, false, -1, (Pattern) null, (Object) null, (Object) null); + this(name, defaultValues, type, langKey, false, -1, null, null, null); } public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, boolean isListFixedLength) { - this(name, defaultValues, type, langKey, isListFixedLength, -1, (Pattern) null, (Object) null, (Object) null); + this(name, defaultValues, type, langKey, isListFixedLength, -1, null, null, null); } public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, int maxListLength) { - this(name, defaultValues, type, langKey, false, maxListLength, (Pattern) null, (Object) null, (Object) null); + this(name, defaultValues, type, langKey, false, maxListLength, null, null, null); } public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, Object minValue, Object maxValue) { - this(name, defaultValues, type, langKey, false, -1, (Pattern) null, minValue, maxValue); + this(name, defaultValues, type, langKey, false, -1, null, minValue, maxValue); } public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, boolean isListFixedLength, Object minValue, Object maxValue) { - this(name, defaultValues, type, langKey, isListFixedLength, -1, (Pattern) null, minValue, maxValue); + this(name, defaultValues, type, langKey, isListFixedLength, -1, null, minValue, maxValue); } public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, int maxListLength, Object minValue, Object maxValue) { - this(name, defaultValues, type, langKey, false, maxListLength, (Pattern) null, minValue, maxValue); + this(name, defaultValues, type, langKey, false, maxListLength, null, minValue, maxValue); } public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, boolean isListFixedLength, int maxListLength, Object minValue, Object maxValue) { - this(name, defaultValues, type, langKey, isListFixedLength, maxListLength, (Pattern) null, minValue, maxValue); + this(name, defaultValues, type, langKey, isListFixedLength, maxListLength, null, minValue, maxValue); } public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, Pattern validStringPattern) { - this(name, defaultValues, type, langKey, false, -1, validStringPattern, (Object) null, (Object) null); + this(name, defaultValues, type, langKey, false, -1, validStringPattern, null, null); } public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, boolean isListFixedLength, Pattern validStringPattern) { - this(name, defaultValues, type, langKey, isListFixedLength, -1, validStringPattern, (Object) null, (Object) null); + this(name, defaultValues, type, langKey, isListFixedLength, -1, validStringPattern, null, null); } public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, int maxListLength, Pattern validStringPattern) { - this(name, defaultValues, type, langKey, false, maxListLength, validStringPattern, (Object) null, (Object) null); + this(name, defaultValues, type, langKey, false, maxListLength, validStringPattern, null, null); } public DummyListElement setCustomEditListEntryClass(Class clazz) @@ -168,18 +168,18 @@ public class DummyConfigElement implements IConfigElement if (minValue == null) { if (type == ConfigGuiType.INTEGER) - this.minValue = (Integer) Integer.MIN_VALUE; + this.minValue = Integer.MIN_VALUE; else if (type == ConfigGuiType.DOUBLE) - this.minValue = (Double) (-Double.MAX_VALUE); + this.minValue = -Double.MAX_VALUE; } else this.minValue = minValue; if (maxValue == null) { if (type == ConfigGuiType.INTEGER) - this.maxValue = (Integer) Integer.MAX_VALUE; + this.maxValue = Integer.MAX_VALUE; else if (type == ConfigGuiType.DOUBLE) - this.maxValue = (Double) Double.MAX_VALUE; + this.maxValue = Double.MAX_VALUE; } else this.maxValue = maxValue; @@ -187,22 +187,22 @@ public class DummyConfigElement implements IConfigElement public DummyConfigElement(String name, Object defaultValue, ConfigGuiType type, String langKey, Pattern validStringPattern) { - this(name, defaultValue, type, langKey, (String[]) null, validStringPattern, (Object) null, (Object) null); + this(name, defaultValue, type, langKey, null, validStringPattern, null, null); } public DummyConfigElement(String name, Object defaultValue, ConfigGuiType type, String langKey, String[] validValues) { - this(name, defaultValue, type, langKey, validValues, (Pattern) null, (Object) null, (Object) null); + this(name, defaultValue, type, langKey, validValues, null, null, null); } public DummyConfigElement(String name, Object defaultValue, ConfigGuiType type, String langKey) { - this(name, defaultValue, type, langKey, (String[]) null, (Pattern) null, (Object) null, (Object) null); + this(name, defaultValue, type, langKey, null, null, null, null); } public DummyConfigElement(String name, Object defaultValue, ConfigGuiType type, String langKey, Object minValue, Object maxValue) { - this(name, defaultValue, type, langKey, (String[]) null, (Pattern) null, minValue, maxValue); + this(name, defaultValue, type, langKey, null, null, minValue, maxValue); } public DummyConfigElement setCustomListEntryClass(Class clazz) diff --git a/src/main/java/net/minecraftforge/fml/client/config/GuiConfig.java b/src/main/java/net/minecraftforge/fml/client/config/GuiConfig.java index 9490847d02..068a84ddf3 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/GuiConfig.java +++ b/src/main/java/net/minecraftforge/fml/client/config/GuiConfig.java @@ -24,7 +24,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; -import net.minecraft.util.ChatComponentText; +import net.minecraft.util.text.TextComponentString; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry; import net.minecraftforge.fml.client.event.ConfigChangedEvent; @@ -248,7 +248,7 @@ public class GuiConfig extends GuiScreen { flag = false; mc.displayGuiScreen(new GuiMessageDialog(parentScreen, "fml.configgui.gameRestartTitle", - new ChatComponentText(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage")); + new TextComponentString(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage")); } if (this.parentScreen instanceof GuiConfig) @@ -326,9 +326,9 @@ public class GuiConfig extends GuiScreen if (title2 != null) { int strWidth = mc.fontRendererObj.getStringWidth(title2); - int elipsisWidth = mc.fontRendererObj.getStringWidth("..."); - if (strWidth > width - 6 && strWidth > elipsisWidth) - title2 = mc.fontRendererObj.trimStringToWidth(title2, width - 6 - elipsisWidth).trim() + "..."; + int ellipsisWidth = mc.fontRendererObj.getStringWidth("..."); + if (strWidth > width - 6 && strWidth > ellipsisWidth) + title2 = mc.fontRendererObj.trimStringToWidth(title2, width - 6 - ellipsisWidth).trim() + "..."; this.drawCenteredString(this.fontRendererObj, title2, this.width / 2, 18, 16777215); } diff --git a/src/main/java/net/minecraftforge/fml/client/config/GuiConfigEntries.java b/src/main/java/net/minecraftforge/fml/client/config/GuiConfigEntries.java index a82923da54..e4780b3e60 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/GuiConfigEntries.java +++ b/src/main/java/net/minecraftforge/fml/client/config/GuiConfigEntries.java @@ -26,7 +26,7 @@ import net.minecraft.client.gui.GuiListExtended; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.resources.I18n; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; @@ -115,7 +115,7 @@ public class GuiConfigEntries extends GuiListExtended if (configElement.getConfigEntryClass() != null) try { - this.listEntries.add((IConfigEntry) configElement.getConfigEntryClass() + this.listEntries.add(configElement.getConfigEntryClass() .getConstructor(GuiConfig.class, GuiConfigEntries.class, IConfigElement.class) .newInstance(this.owningScreen, this, configElement)); } @@ -1500,22 +1500,22 @@ public class GuiConfigEntries extends GuiListExtended comment = I18n.format(configElement.getLanguageKey() + ".tooltip").replace("\\n", "\n"); if (!comment.equals(configElement.getLanguageKey() + ".tooltip")) - Collections.addAll(toolTip, (EnumChatFormatting.GREEN + name + "\n" + EnumChatFormatting.YELLOW + comment).split("\n")); + Collections.addAll(toolTip, (TextFormatting.GREEN + name + "\n" + TextFormatting.YELLOW + comment).split("\n")); else if (configElement.getComment() != null && !configElement.getComment().trim().isEmpty()) - Collections.addAll(toolTip, (EnumChatFormatting.GREEN + name + "\n" + EnumChatFormatting.YELLOW + configElement.getComment()).split("\n")); + Collections.addAll(toolTip, (TextFormatting.GREEN + name + "\n" + TextFormatting.YELLOW + configElement.getComment()).split("\n")); else - Collections.addAll(toolTip, (EnumChatFormatting.GREEN + name + "\n" + EnumChatFormatting.RED + "No tooltip defined.").split("\n")); + Collections.addAll(toolTip, (TextFormatting.GREEN + name + "\n" + TextFormatting.RED + "No tooltip defined.").split("\n")); if ((configElement.getType() == ConfigGuiType.INTEGER && (Integer.valueOf(configElement.getMinValue().toString()) != Integer.MIN_VALUE || Integer.valueOf(configElement.getMaxValue().toString()) != Integer.MAX_VALUE)) || (configElement.getType() == ConfigGuiType.DOUBLE && (Double.valueOf(configElement.getMinValue().toString()) != -Double.MAX_VALUE || Double.valueOf(configElement.getMaxValue().toString()) != Double.MAX_VALUE))) - Collections.addAll(toolTip, (EnumChatFormatting.AQUA + I18n.format("fml.configgui.tooltip.defaultNumeric", configElement.getMinValue(), configElement.getMaxValue(), configElement.getDefault())).split("\n")); + Collections.addAll(toolTip, (TextFormatting.AQUA + I18n.format("fml.configgui.tooltip.defaultNumeric", configElement.getMinValue(), configElement.getMaxValue(), configElement.getDefault())).split("\n")); else if (configElement.getType() != ConfigGuiType.CONFIG_CATEGORY) - Collections.addAll(toolTip, (EnumChatFormatting.AQUA + I18n.format("fml.configgui.tooltip.default", configElement.getDefault())).split("\n")); + Collections.addAll(toolTip, (TextFormatting.AQUA + I18n.format("fml.configgui.tooltip.default", configElement.getDefault())).split("\n")); if (configElement.requiresMcRestart() || owningScreen.allRequireMcRestart) - toolTip.add(EnumChatFormatting.RED + "[" + I18n.format("fml.configgui.gameRestartTitle") + "]"); + toolTip.add(TextFormatting.RED + "[" + I18n.format("fml.configgui.gameRestartTitle") + "]"); } @Override @@ -1525,9 +1525,9 @@ public class GuiConfigEntries extends GuiListExtended if (drawLabel) { - String label = (!isValidValue ? EnumChatFormatting.RED.toString() : - (isChanged ? EnumChatFormatting.WHITE.toString() : EnumChatFormatting.GRAY.toString())) - + (isChanged ? EnumChatFormatting.ITALIC.toString() : "") + this.name; + String label = (!isValidValue ? TextFormatting.RED.toString() : + (isChanged ? TextFormatting.WHITE.toString() : TextFormatting.GRAY.toString())) + + (isChanged ? TextFormatting.ITALIC.toString() : "") + this.name; this.mc.fontRendererObj.drawString( label, this.owningScreen.entryList.labelX, diff --git a/src/main/java/net/minecraftforge/fml/client/config/GuiEditArray.java b/src/main/java/net/minecraftforge/fml/client/config/GuiEditArray.java index faccb07616..403e07d26b 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/GuiEditArray.java +++ b/src/main/java/net/minecraftforge/fml/client/config/GuiEditArray.java @@ -22,7 +22,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.TextFormatting; import static net.minecraftforge.fml.client.config.GuiUtils.RESET_CHAR; import static net.minecraftforge.fml.client.config.GuiUtils.UNDO_CHAR; @@ -64,14 +64,14 @@ public class GuiEditArray extends GuiScreen String comment; comment = I18n.format(configElement.getLanguageKey() + ".tooltip", - "\n" + EnumChatFormatting.AQUA, configElement.getDefault(), configElement.getMinValue(), configElement.getMaxValue()); + "\n" + TextFormatting.AQUA, configElement.getDefault(), configElement.getMinValue(), configElement.getMaxValue()); if (!comment.equals(configElement.getLanguageKey() + ".tooltip")) - Collections.addAll(toolTip, (EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.YELLOW + comment).split("\n")); + Collections.addAll(toolTip, (TextFormatting.GREEN + propName + "\n" + TextFormatting.YELLOW + comment).split("\n")); else if (configElement.getComment() != null && !configElement.getComment().trim().isEmpty()) - Collections.addAll(toolTip, (EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.YELLOW + configElement.getComment()).split("\n")); + Collections.addAll(toolTip, (TextFormatting.GREEN + propName + "\n" + TextFormatting.YELLOW + configElement.getComment()).split("\n")); else - Collections.addAll(toolTip, (EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.RED + "No tooltip defined.").split("\n")); + Collections.addAll(toolTip, (TextFormatting.GREEN + propName + "\n" + TextFormatting.RED + "No tooltip defined.").split("\n")); if (parentScreen instanceof GuiConfig) { diff --git a/src/main/java/net/minecraftforge/fml/client/config/GuiEditArrayEntries.java b/src/main/java/net/minecraftforge/fml/client/config/GuiEditArrayEntries.java index 85088e8fc0..f96069c647 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/GuiEditArrayEntries.java +++ b/src/main/java/net/minecraftforge/fml/client/config/GuiEditArrayEntries.java @@ -20,7 +20,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiListExtended; import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.resources.I18n; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.client.config.GuiConfigEntries.ArrayEntry; import net.minecraftforge.fml.common.FMLLog; @@ -128,7 +128,7 @@ public class GuiEditArrayEntries extends GuiListExtended public void addNewEntry(int index) { if (configElement.isList() && configElement.getType() == ConfigGuiType.BOOLEAN) - listEntries.add(index, new BooleanEntry(this.owningGui, this, this.configElement, Boolean.valueOf(true))); + listEntries.add(index, new BooleanEntry(this.owningGui, this, this.configElement, true)); else if (configElement.isList() && configElement.getType() == ConfigGuiType.INTEGER) listEntries.add(index, new IntegerEntry(this.owningGui, this, this.configElement, 0)); else if (configElement.isList() && configElement.getType() == ConfigGuiType.DOUBLE) @@ -519,7 +519,7 @@ public class GuiEditArrayEntries extends GuiListExtended @Override public Object getValue() { - return Boolean.valueOf(value); + return value; } } @@ -560,7 +560,7 @@ public class GuiEditArrayEntries extends GuiListExtended { if (this.getValue() != null && this.isValidated) owningEntryList.mc.fontRendererObj.drawString( - isValidValue ? EnumChatFormatting.GREEN + VALID : EnumChatFormatting.RED + INVALID, + isValidValue ? TextFormatting.GREEN + VALID : TextFormatting.RED + INVALID, listWidth / 4 - owningEntryList.mc.fontRendererObj.getStringWidth(VALID) - 2, y + slotHeight / 2 - owningEntryList.mc.fontRendererObj.FONT_HEIGHT / 2, 16777215); diff --git a/src/main/java/net/minecraftforge/fml/client/config/GuiMessageDialog.java b/src/main/java/net/minecraftforge/fml/client/config/GuiMessageDialog.java index 863229afc4..041ab11c0c 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/GuiMessageDialog.java +++ b/src/main/java/net/minecraftforge/fml/client/config/GuiMessageDialog.java @@ -4,13 +4,13 @@ import net.minecraft.client.gui.GuiDisconnected; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; -import net.minecraft.util.IChatComponent; +import net.minecraft.util.text.ITextComponent; public class GuiMessageDialog extends GuiDisconnected { protected String buttonText; - public GuiMessageDialog(GuiScreen nextScreen, String title, IChatComponent message, String buttonText) + public GuiMessageDialog(GuiScreen nextScreen, String title, ITextComponent message, String buttonText) { super(nextScreen, title, message); this.buttonText = buttonText; @@ -20,6 +20,6 @@ public class GuiMessageDialog extends GuiDisconnected public void initGui() { super.initGui(); - ((GuiButton) buttonList.get(0)).displayString = I18n.format(buttonText); + buttonList.get(0).displayString = I18n.format(buttonText); } } diff --git a/src/main/java/net/minecraftforge/fml/client/config/GuiSelectString.java b/src/main/java/net/minecraftforge/fml/client/config/GuiSelectString.java index 1c6ef0a2ec..afcc062363 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/GuiSelectString.java +++ b/src/main/java/net/minecraftforge/fml/client/config/GuiSelectString.java @@ -22,7 +22,8 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.resources.I18n; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.TextFormatting; + import static net.minecraftforge.fml.client.config.GuiUtils.RESET_CHAR; import static net.minecraftforge.fml.client.config.GuiUtils.UNDO_CHAR; @@ -63,14 +64,14 @@ public class GuiSelectString extends GuiScreen String comment; comment = I18n.format(configElement.getLanguageKey() + ".tooltip", - "\n" + EnumChatFormatting.AQUA, configElement.getDefault(), configElement.getMinValue(), configElement.getMaxValue()); + "\n" + TextFormatting.AQUA, configElement.getDefault(), configElement.getMinValue(), configElement.getMaxValue()); if (!comment.equals(configElement.getLanguageKey() + ".tooltip")) - Collections.addAll(toolTip, (EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.YELLOW + comment).split("\n")); + Collections.addAll(toolTip, (TextFormatting.GREEN + propName + "\n" + TextFormatting.YELLOW + comment).split("\n")); else if (configElement.getComment() != null && !configElement.getComment().trim().isEmpty()) - Collections.addAll(toolTip, (EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.YELLOW + configElement.getComment()).split("\n")); + Collections.addAll(toolTip, (TextFormatting.GREEN + propName + "\n" + TextFormatting.YELLOW + configElement.getComment()).split("\n")); else - Collections.addAll(toolTip, (EnumChatFormatting.GREEN + propName + "\n" + EnumChatFormatting.RED + "No tooltip defined.").split("\n")); + Collections.addAll(toolTip, (TextFormatting.GREEN + propName + "\n" + TextFormatting.RED + "No tooltip defined.").split("\n")); if (parentScreen instanceof GuiConfig) { diff --git a/src/main/java/net/minecraftforge/fml/client/config/GuiUnicodeGlyphButton.java b/src/main/java/net/minecraftforge/fml/client/config/GuiUnicodeGlyphButton.java index d11289868b..c5986016be 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/GuiUnicodeGlyphButton.java +++ b/src/main/java/net/minecraftforge/fml/client/config/GuiUnicodeGlyphButton.java @@ -59,11 +59,11 @@ public class GuiUnicodeGlyphButton extends GuiButtonExt String buttonText = this.displayString; int glyphWidth = (int) (mc.fontRendererObj.getStringWidth(glyph) * glyphScale); int strWidth = mc.fontRendererObj.getStringWidth(buttonText); - int elipsisWidth = mc.fontRendererObj.getStringWidth("..."); + int ellipsisWidth = mc.fontRendererObj.getStringWidth("..."); int totalWidth = strWidth + glyphWidth; - if (totalWidth > width - 6 && totalWidth > elipsisWidth) - buttonText = mc.fontRendererObj.trimStringToWidth(buttonText, width - 6 - elipsisWidth).trim() + "..."; + if (totalWidth > width - 6 && totalWidth > ellipsisWidth) + buttonText = mc.fontRendererObj.trimStringToWidth(buttonText, width - 6 - ellipsisWidth).trim() + "..."; strWidth = mc.fontRendererObj.getStringWidth(buttonText); totalWidth = glyphWidth + strWidth; diff --git a/src/main/java/net/minecraftforge/fml/client/config/GuiUtils.java b/src/main/java/net/minecraftforge/fml/client/config/GuiUtils.java index 636e66302c..3d3ae26c99 100644 --- a/src/main/java/net/minecraftforge/fml/client/config/GuiUtils.java +++ b/src/main/java/net/minecraftforge/fml/client/config/GuiUtils.java @@ -17,7 +17,7 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; @@ -189,7 +189,7 @@ public class GuiUtils float uScale = 1f / 0x100; float vScale = 1f / 0x100; Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer wr = tessellator.getWorldRenderer(); + VertexBuffer wr = tessellator.getBuffer(); wr.begin(7, DefaultVertexFormats.POSITION_TEX); wr.pos(x , y + height, zLevel).tex( u * uScale, ((v + height) * vScale)).endVertex(); wr.pos(x + width, y + height, zLevel).tex((u + width) * uScale, ((v + height) * vScale)).endVertex(); @@ -360,16 +360,16 @@ public class GuiUtils GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.shadeModel(7425); Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); - worldrenderer.pos(right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); - worldrenderer.pos(left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); - worldrenderer.pos(left, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex(); - worldrenderer.pos(right, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex(); + VertexBuffer vertexbuffer = tessellator.getBuffer(); + vertexbuffer.begin(7, DefaultVertexFormats.POSITION_COLOR); + vertexbuffer.pos(right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); + vertexbuffer.pos(left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex(); + vertexbuffer.pos(left, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex(); + vertexbuffer.pos(right, bottom, zLevel).color(endRed, endGreen, endBlue, endAlpha).endVertex(); tessellator.draw(); GlStateManager.shadeModel(7424); diff --git a/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java b/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java index 1eaaf89106..f7c78344c2 100644 --- a/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java +++ b/src/main/java/net/minecraftforge/fml/client/event/ConfigChangedEvent.java @@ -29,23 +29,11 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult; @HasResult public class ConfigChangedEvent extends Event { - /** - * The Mod ID of the mod whose configuration just changed. - */ - public final String modID; - /** - * Whether or not a world is currently running. - */ - public final boolean isWorldRunning; - /** - * Will be set to true if any elements were changed that require a restart of Minecraft. - */ - public final boolean requiresMcRestart; - /** - * A String identifier for this ConfigChangedEvent. - */ - public final String configID; - + private final String modID; + private final boolean isWorldRunning; + private final boolean requiresMcRestart; + private final String configID; + public ConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart) { this.modID = modID; @@ -53,7 +41,39 @@ public class ConfigChangedEvent extends Event this.isWorldRunning = isWorldRunning; this.requiresMcRestart = requiresMcRestart; } - + + /** + * The Mod ID of the mod whose configuration just changed. + */ + public String getModID() + { + return modID; + } + + /** + * Whether or not a world is currently running. + */ + public boolean isWorldRunning() + { + return isWorldRunning; + } + + /** + * Will be set to true if any elements were changed that require a restart of Minecraft. + */ + public boolean isRequiresMcRestart() + { + return requiresMcRestart; + } + + /** + * A String identifier for this ConfigChangedEvent. + */ + public String getConfigID() + { + return configID; + } + /** * This event is intended to be consumed by the mod whose config has been changed. It fires when the Done button * has been clicked on a GuiConfig screen and the following conditions are met:
    diff --git a/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java b/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java index 94490d3579..fce21b3621 100644 --- a/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java +++ b/src/main/java/net/minecraftforge/fml/client/registry/ClientRegistry.java @@ -57,7 +57,7 @@ public class ClientRegistry /** * Register a shader for an entity. This shader gets activated when a spectator begins spectating an entity. - * Vanilla examples of this are the green effect for creepers and the invert effect for endermans. + * Vanilla examples of this are the green effect for creepers and the invert effect for endermen. * * @param entityClass * @param shader diff --git a/src/main/java/net/minecraftforge/fml/common/DummyModContainer.java b/src/main/java/net/minecraftforge/fml/common/DummyModContainer.java index d9e11b3af0..d73d347c0b 100644 --- a/src/main/java/net/minecraftforge/fml/common/DummyModContainer.java +++ b/src/main/java/net/minecraftforge/fml/common/DummyModContainer.java @@ -32,6 +32,7 @@ public class DummyModContainer implements ModContainer private ModMetadata md; private ArtifactVersion processedVersion; private String label; + private int classVersion; public DummyModContainer(ModMetadata md) { @@ -213,4 +214,16 @@ public class DummyModContainer implements ModContainer { return null; } + + @Override + public void setClassVersion(int classVersion) + { + this.classVersion = classVersion; + } + + @Override + public int getClassVersion() + { + return this.classVersion; + } } diff --git a/src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java b/src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java index d42da0f323..d963e0b7a3 100644 --- a/src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/FMLCommonHandler.java @@ -40,10 +40,10 @@ import net.minecraft.network.EnumConnectionState; import net.minecraft.network.INetHandler; import net.minecraft.network.NetworkManager; import net.minecraft.network.handshake.client.C00Handshake; -import net.minecraft.network.login.server.S00PacketDisconnect; +import net.minecraft.network.login.server.SPacketDisconnect; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.IThreadListener; +import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import net.minecraft.world.storage.SaveHandler; import net.minecraft.world.storage.WorldInfo; @@ -215,7 +215,7 @@ public class FMLCommonHandler { if (brandings == null) { - Builder brd = ImmutableList.builder(); + Builder brd = ImmutableList.builder(); brd.add(Loader.instance().getMCVersionString()); brd.add(Loader.instance().getMCPVersionString()); brd.add("Powered by Forge " + ForgeVersion.getVersion()); @@ -609,9 +609,9 @@ public class FMLCommonHandler { if (!shouldAllowPlayerLogins()) { - ChatComponentText text = new ChatComponentText("Server is still starting! Please wait before reconnecting."); + TextComponentString text = new TextComponentString("Server is still starting! Please wait before reconnecting."); FMLLog.info("Disconnecting Player: " + text.getUnformattedText()); - manager.sendPacket(new S00PacketDisconnect(text)); + manager.sendPacket(new SPacketDisconnect(text)); manager.closeChannel(text); return false; } @@ -619,9 +619,9 @@ public class FMLCommonHandler if (packet.getRequestedState() == EnumConnectionState.LOGIN && (!NetworkRegistry.INSTANCE.isVanillaAccepted(Side.CLIENT) && !packet.hasFMLMarker())) { manager.setConnectionState(EnumConnectionState.LOGIN); - ChatComponentText text = new ChatComponentText("This server requires FML/Forge to be installed. Contact your server admin for more details."); + TextComponentString text = new TextComponentString("This server requires FML/Forge to be installed. Contact your server admin for more details."); FMLLog.info("Disconnecting Player: " + text.getUnformattedText()); - manager.sendPacket(new S00PacketDisconnect(text)); + manager.sendPacket(new SPacketDisconnect(text)); manager.closeChannel(text); return false; } @@ -691,7 +691,7 @@ public class FMLCommonHandler } /** - * Loads a lang file, first searching for a marker to enable the 'extended' format {escape charaters} + * Loads a lang file, first searching for a marker to enable the 'extended' format {escape characters} * If the marker is not found it simply returns and let the vanilla code load things. * The Marker is 'PARSE_ESCAPES' by itself on a line starting with '#' as such: * #PARSE_ESCAPES diff --git a/src/main/java/net/minecraftforge/fml/common/FMLContainer.java b/src/main/java/net/minecraftforge/fml/common/FMLContainer.java index 6808f1c2bf..397266bff3 100644 --- a/src/main/java/net/minecraftforge/fml/common/FMLContainer.java +++ b/src/main/java/net/minecraftforge/fml/common/FMLContainer.java @@ -35,7 +35,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.NetworkCheckHandler; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.internal.FMLNetworkHandler; -import net.minecraftforge.fml.common.registry.GameData; +import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.common.registry.PersistentRegistryManager; import net.minecraftforge.fml.common.registry.VillagerRegistry; import net.minecraftforge.fml.relauncher.Side; @@ -49,7 +49,7 @@ import com.google.common.eventbus.Subscribe; * @author cpw * */ -public class FMLContainer extends DummyModContainer implements WorldAccessContainer +public final class FMLContainer extends DummyModContainer implements WorldAccessContainer { public FMLContainer() { @@ -85,8 +85,9 @@ public class FMLContainer extends DummyModContainer implements WorldAccessContai @Subscribe public void modPreinitialization(FMLPreInitializationEvent evt) { - // Initialize the villager registry - VillagerRegistry.instance(); + // Initialize all Forge/Vanilla registries {invoke the static init) + if (ForgeRegistries.ITEMS == null) + throw new RuntimeException("Something horrible went wrong in init, ForgeRegistres didn't create..."); } @NetworkCheckHandler diff --git a/src/main/java/net/minecraftforge/fml/common/FMLModContainer.java b/src/main/java/net/minecraftforge/fml/common/FMLModContainer.java index abc5753f1c..8cc40bfe9f 100644 --- a/src/main/java/net/minecraftforge/fml/common/FMLModContainer.java +++ b/src/main/java/net/minecraftforge/fml/common/FMLModContainer.java @@ -90,6 +90,7 @@ public class FMLModContainer implements ModContainer private Map customModProperties; private ModCandidate candidate; private URL updateJSONUrl; + private int classVersion; public FMLModContainer(String className, ModCandidate container, Map modDescriptor) { @@ -167,7 +168,7 @@ public class FMLModContainer implements ModContainer if (descriptor.containsKey("useMetadata")) { - overridesMetadata = !((Boolean)descriptor.get("useMetadata")).booleanValue(); + overridesMetadata = !((Boolean)descriptor.get("useMetadata")); } if (overridesMetadata || !modMetadata.useDependencyInformation) @@ -400,7 +401,7 @@ public class FMLModContainer implements ModContainer }); } - private void parseSimpleFieldAnnotation(SetMultimap annotations, String annotationClassName, Function retreiver) throws IllegalAccessException + private void parseSimpleFieldAnnotation(SetMultimap annotations, String annotationClassName, Function retriever) throws IllegalAccessException { String[] annName = annotationClassName.split("\\."); String annotationName = annName[annName.length - 1]; @@ -431,7 +432,7 @@ public class FMLModContainer implements ModContainer f = clz.getDeclaredField(targets.getObjectName()); f.setAccessible(true); isStatic = Modifier.isStatic(f.getModifiers()); - injectedMod = retreiver.apply(mc); + injectedMod = retriever.apply(mc); } catch (Exception e) { @@ -473,7 +474,7 @@ public class FMLModContainer implements ModContainer { len = certificates.length; } - Builder certBuilder = ImmutableList.builder(); + Builder certBuilder = ImmutableList.builder(); for (int i = 0; i < len; i++) { certBuilder.add(CertificateHelper.getFingerprint(certificates[i])); @@ -508,7 +509,7 @@ public class FMLModContainer implements ModContainer List> props = (List>)descriptor.get("customProperties"); if (props != null) { - com.google.common.collect.ImmutableMap.Builder builder = ImmutableMap.builder(); + com.google.common.collect.ImmutableMap.Builder builder = ImmutableMap.builder(); for (Map p : props) { builder.put((String)p.get("k"), (String)p.get("v")); @@ -663,7 +664,7 @@ public class FMLModContainer implements ModContainer { return false; } - return value.booleanValue(); + return value; } @Override @@ -699,4 +700,16 @@ public class FMLModContainer implements ModContainer { return updateJSONUrl; } + + @Override + public void setClassVersion(int classVersion) + { + this.classVersion = classVersion; + } + + @Override + public int getClassVersion() + { + return this.classVersion; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/fml/common/ILanguageAdapter.java b/src/main/java/net/minecraftforge/fml/common/ILanguageAdapter.java index 9b14eff253..50415e2bef 100644 --- a/src/main/java/net/minecraftforge/fml/common/ILanguageAdapter.java +++ b/src/main/java/net/minecraftforge/fml/common/ILanguageAdapter.java @@ -55,7 +55,7 @@ public interface ILanguageAdapter { catch (ClassNotFoundException e) { // Not a singleton, look for @Instance field as a fallback. - FMLLog.log(Level.INFO, e, "An error occured trying to load a proxy into %s.%s. Did you declare your mod as 'class' instead of 'object'?", proxyTarget.getSimpleName(), target.getName()); + FMLLog.log(Level.INFO, e, "An error occurred trying to load a proxy into %s.%s. Did you declare your mod as 'class' instead of 'object'?", proxyTarget.getSimpleName(), target.getName()); return; } @@ -91,7 +91,7 @@ public interface ILanguageAdapter { } catch (InvocationTargetException e) { - FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); + FMLLog.log(Level.ERROR, e, "An error occurred trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); throw new LoaderException(e); } @@ -148,7 +148,7 @@ public interface ILanguageAdapter { setProxy(target, proxyTarget, proxy); } catch (Exception e) { - FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); + FMLLog.log(Level.ERROR, e, "An error occurred trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); throw new LoaderException(e); } } diff --git a/src/main/java/net/minecraftforge/fml/common/IWorldGenerator.java b/src/main/java/net/minecraftforge/fml/common/IWorldGenerator.java index 20b43f83d9..6210b20a49 100644 --- a/src/main/java/net/minecraftforge/fml/common/IWorldGenerator.java +++ b/src/main/java/net/minecraftforge/fml/common/IWorldGenerator.java @@ -5,7 +5,7 @@ * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * + * * Contributors: * cpw - implementation */ @@ -15,11 +15,12 @@ package net.minecraftforge.fml.common; import java.util.Random; import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; /** - * This is called back during world generation. + * This is called back during world generation. * * @author cpw * @@ -37,5 +38,5 @@ public interface IWorldGenerator * @param chunkProvider : additionalData[2] {@link IChunkProvider} that is requesting the world generation. * */ - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider); + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider); } diff --git a/src/main/java/net/minecraftforge/fml/common/InjectedModContainer.java b/src/main/java/net/minecraftforge/fml/common/InjectedModContainer.java index 783c28b2d1..94c67cf78c 100644 --- a/src/main/java/net/minecraftforge/fml/common/InjectedModContainer.java +++ b/src/main/java/net/minecraftforge/fml/common/InjectedModContainer.java @@ -214,4 +214,16 @@ public class InjectedModContainer implements ModContainer { return wrappedContainer.getUpdateUrl(); } + + @Override + public void setClassVersion(int classVersion) + { + wrappedContainer.setClassVersion(classVersion); + } + + @Override + public int getClassVersion() + { + return wrappedContainer.getClassVersion(); + } } diff --git a/src/main/java/net/minecraftforge/fml/common/Java8VersionException.java b/src/main/java/net/minecraftforge/fml/common/Java8VersionException.java new file mode 100644 index 0000000000..c9200f6c85 --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/common/Java8VersionException.java @@ -0,0 +1,43 @@ +/* + * Forge Mod Loader + * Copyright (c) 2012-2013 cpw. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v2.1 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * + * Contributors: + * cpw - implementation + */ + +package net.minecraftforge.fml.common; + +import java.util.List; + +public class Java8VersionException extends EnhancedRuntimeException +{ + private static final long serialVersionUID = 1L; + private final List mods; + + public Java8VersionException(List mods) + { + super("Mods require Java 8"); + this.mods = mods; + } + + @Override + protected void printStackTrace(WrappedPrintStream stream) + { + stream.println("Mods requiring Java 8:"); + for (ModContainer mc : mods) + { + stream.println(String.format("\t%s : %s", mc.getName(), mc.getModId())); + } + stream.println(""); + } + + public List getMods() + { + return mods; + } +} diff --git a/src/main/java/net/minecraftforge/fml/common/LoadController.java b/src/main/java/net/minecraftforge/fml/common/LoadController.java index 3a5a60a5a0..8f2f160553 100644 --- a/src/main/java/net/minecraftforge/fml/common/LoadController.java +++ b/src/main/java/net/minecraftforge/fml/common/LoadController.java @@ -44,6 +44,8 @@ import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; +import com.google.common.eventbus.SubscriberExceptionHandler; +import com.google.common.eventbus.SubscriberExceptionContext; public class LoadController { @@ -61,7 +63,14 @@ public class LoadController public LoadController(Loader loader) { this.loader = loader; - this.masterChannel = new EventBus("FMLMainChannel"); + this.masterChannel = new EventBus(new SubscriberExceptionHandler() + { + @Override + public void handleException(Throwable exception, SubscriberExceptionContext context) + { + FMLLog.log("FMLMainChannel", Level.ERROR, exception, "Could not dispatch event: %s to %s", context.getEvent(), context.getSubscriberMethod()); + } + }); this.masterChannel.register(this); state = LoaderState.NOINIT; @@ -88,10 +97,18 @@ public class LoadController { Builder eventBus = ImmutableMap.builder(); - for (ModContainer mod : loader.getModList()) + for (final ModContainer mod : loader.getModList()) { //Create mod logger, and make the EventBus logger a child of it. - EventBus bus = new EventBus(mod.getModId()); + EventBus bus = new EventBus(new SubscriberExceptionHandler() + { + @Override + public void handleException(final Throwable exception, final SubscriberExceptionContext context) + { + LoadController.this.errorOccurred(mod, exception); + } + }); + boolean isActive = mod.registerBus(bus, this); if (isActive) { @@ -149,8 +166,8 @@ public class LoadController else { FMLLog.severe("The ForgeModLoader state engine has become corrupted. Probably, a state was missed by and invalid modification to a base class" + - "ForgeModLoader depends on. This is a critical error and not recoverable. Investigate any modifications to base classes outside of" + - "ForgeModLoader, especially Optifine, to see if there are fixes available."); + "ForgeModLoader depends on. This is a critical error and not recoverable. Investigate any modifications to base classes outside of" + + "ForgeModLoader, especially Optifine, to see if there are fixes available."); throw new RuntimeException("The ForgeModLoader state engine is invalid"); } if (toThrow != null && toThrow instanceof RuntimeException) @@ -227,7 +244,7 @@ public class LoadController public ImmutableBiMap buildModObjectList() { - ImmutableBiMap.Builder builder = ImmutableBiMap.builder(); + ImmutableBiMap.Builder builder = ImmutableBiMap.builder(); for (ModContainer mc : activeModList) { if (!mc.isImmutable() && mc.getMod()!=null) @@ -255,7 +272,7 @@ public class LoadController { if (exception instanceof InvocationTargetException) { - errors.put(modContainer.getModId(), ((InvocationTargetException)exception).getCause()); + errors.put(modContainer.getModId(), exception.getCause()); } else { @@ -317,9 +334,9 @@ public class LoadController return this.state == state; } - boolean hasReachedState(LoaderState state) { - return this.state.ordinal()>=state.ordinal() && this.state!=LoaderState.ERRORED; - } + boolean hasReachedState(LoaderState state) { + return this.state.ordinal()>=state.ordinal() && this.state!=LoaderState.ERRORED; + } void forceState(LoaderState newState) { diff --git a/src/main/java/net/minecraftforge/fml/common/Loader.java b/src/main/java/net/minecraftforge/fml/common/Loader.java index 51e3e153cb..f4b514205d 100644 --- a/src/main/java/net/minecraftforge/fml/common/Loader.java +++ b/src/main/java/net/minecraftforge/fml/common/Loader.java @@ -113,7 +113,7 @@ import com.google.gson.JsonParser; @SuppressWarnings("unused") public class Loader { - public static final String MC_VERSION = "1.8.9"; + public static final String MC_VERSION = net.minecraftforge.common.ForgeVersion.mcVersion; private static final Splitter DEPENDENCYPARTSPLITTER = Splitter.on(":").omitEmptyStrings().trimResults(); private static final Splitter DEPENDENCYSPLITTER = Splitter.on(";").omitEmptyStrings().trimResults(); /** @@ -161,6 +161,7 @@ public class Loader private File forcedModFile; private ModDiscoverer discoverer; private ProgressBar progressBar; + public final boolean java8; public static Loader instance() { @@ -187,6 +188,14 @@ public class Loader private Loader() { + String[] ver = System.getProperty("java.version").split("\\."); + int major = Integer.parseInt(ver[1]); + java8 = major > 7; + if (!java8) + { + FMLLog.severe("The game is not running with Java 8. Forge recommends Java 8 for maximum compatibility with mods"); + } + modClassLoader = new ModClassLoader(getClass().getClassLoader()); if (!mccversion.equals(MC_VERSION)) { @@ -340,7 +349,7 @@ public class Loader } catch (Exception e) { - FMLLog.log(Level.ERROR, e, "A problem occured instantiating the injected mod container %s", cont); + FMLLog.log(Level.ERROR, e, "A problem occurred instantiating the injected mod container %s", cont); throw new LoaderException(e); } mods.add(new InjectedModContainer(mc,mc.getSource())); @@ -489,6 +498,7 @@ public class Loader ModAPIManager.INSTANCE.manageAPI(modClassLoader, discoverer); disableRequestedMods(); modController.distributeStateMessage(FMLLoadEvent.class); + checkJavaCompatibility(); sortModList(); ModAPIManager.INSTANCE.cleanupAPIContainers(modController.getActiveModList()); ModAPIManager.INSTANCE.cleanupAPIContainers(mods); @@ -543,6 +553,24 @@ public class Loader modController.transition(LoaderState.PREINITIALIZATION, false); } + + private void checkJavaCompatibility() + { + if (java8) return; + List j8mods = Lists.newArrayList(); + for (ModContainer mc : getActiveModList()) + { + if (mc.getClassVersion() >= 52) + { + j8mods.add(mc); + } + } + if (!j8mods.isEmpty()) + { + throw new Java8VersionException(j8mods); + } + } + public void preinitializeMods() { if (!modController.isInState(LoaderState.PREINITIALIZATION)) @@ -705,7 +733,7 @@ public class Loader // before elements are things we are loaded before (so they are our dependants) if ("required-before".equals(instruction) || "before".equals(instruction)) { - dependants.add(VersionParser.parseVersionReference(target)); + dependants.add(VersionParser.parseVersionReference(target)); } // after elements are things that load before we do (so they are out dependencies) else if ("required-after".equals(instruction) || "after".equals(instruction)) @@ -979,12 +1007,12 @@ public class Loader } } - return PersistentRegistryManager.processIdRematches(missingMappings.values(), isLocalWorld, remapBlocks, remapItems); + return PersistentRegistryManager.processIdRematches(missingMappings.values(), isLocalWorld, missingBlocks, missingItems, remapBlocks, remapItems); } public void fireRemapEvent(Map remapBlocks, Map remapItems, boolean isFreezing) { - modController.propogateStateMessage(new FMLModIdMappingEvent(remapBlocks, remapItems, isFreezing)); + modController.propogateStateMessage(new FMLModIdMappingEvent(remapBlocks, remapItems, isFreezing)); } public void runtimeDisableMod(String modId) diff --git a/src/main/java/net/minecraftforge/fml/common/Mod.java b/src/main/java/net/minecraftforge/fml/common/Mod.java index 0460ffb43d..33ab006aaf 100644 --- a/src/main/java/net/minecraftforge/fml/common/Mod.java +++ b/src/main/java/net/minecraftforge/fml/common/Mod.java @@ -104,7 +104,7 @@ public @interface Mod /** * The acceptable range of minecraft versions that this mod will load and run in * The default ("empty string") indicates that the currently RUNNING minecraft version is acceptable. - * This means ANY version that the end user adds the mod to. Modders PLEASS set this. + * This means ANY version that the end user adds the mod to. Modders PLEASE set this. * FML will refuse to run with an error if the minecraft version is not in this range across all mods. * @return A version range as specified by the maven version range specification or the empty string */ diff --git a/src/main/java/net/minecraftforge/fml/common/ModContainer.java b/src/main/java/net/minecraftforge/fml/common/ModContainer.java index 883f8b95c0..cd82ff05c9 100644 --- a/src/main/java/net/minecraftforge/fml/common/ModContainer.java +++ b/src/main/java/net/minecraftforge/fml/common/ModContainer.java @@ -152,4 +152,8 @@ public interface ModContainer boolean shouldLoadInEnvironment(); URL getUpdateUrl(); + + void setClassVersion(int classVersion); + + int getClassVersion(); } diff --git a/src/main/java/net/minecraftforge/fml/common/ProxyInjector.java b/src/main/java/net/minecraftforge/fml/common/ProxyInjector.java index c44bca64dc..b1a22fc991 100644 --- a/src/main/java/net/minecraftforge/fml/common/ProxyInjector.java +++ b/src/main/java/net/minecraftforge/fml/common/ProxyInjector.java @@ -77,7 +77,7 @@ public class ProxyInjector } catch (Exception e) { - FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", targ.getAnnotationInfo(), targ.getClassName(), targ.getObjectName()); + FMLLog.log(Level.ERROR, e, "An error occurred trying to load a proxy into %s.%s", targ.getAnnotationInfo(), targ.getClassName(), targ.getObjectName()); throw new LoaderException(e); } } diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/AccessTransformer.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/AccessTransformer.java index 6b60ace8e7..a744891375 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/AccessTransformer.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/AccessTransformer.java @@ -219,7 +219,7 @@ public class AccessTransformer implements IClassTransformer } else { - List nowOverridable = Lists.newArrayList(); + List nowOverrideable = Lists.newArrayList(); for (MethodNode n : classNode.methods) { if ((n.name.equals(m.name) && n.desc.equals(m.desc)) || m.name.equals("*")) @@ -236,7 +236,7 @@ public class AccessTransformer implements IClassTransformer if (wasPrivate && !isNowPrivate) { - nowOverridable.add(n); + nowOverrideable.add(n); } } @@ -253,7 +253,7 @@ public class AccessTransformer implements IClassTransformer } } - replaceInvokeSpecial(classNode, nowOverridable); + replaceInvokeSpecial(classNode, nowOverrideable); } } @@ -356,7 +356,7 @@ public class AccessTransformer implements IClassTransformer if (!hasTransformer) { - System.out.println("Culd not find a valid transformer to perform"); + System.out.println("Could not find a valid transformer to perform"); System.exit(1); } diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/DeobfuscationTransformer.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/DeobfuscationTransformer.java index e88fabfa1d..236df95778 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/DeobfuscationTransformer.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/DeobfuscationTransformer.java @@ -27,7 +27,7 @@ public class DeobfuscationTransformer implements IClassTransformer, IClassNameTr private static final int WRITER_FLAGS = ClassWriter.COMPUTE_MAXS | (RECALC_FRAMES ? ClassWriter.COMPUTE_FRAMES : 0); private static final int READER_FLAGS = RECALC_FRAMES ? ClassReader.SKIP_FRAMES : ClassReader.EXPAND_FRAMES; // COMPUTE_FRAMES causes classes to be loaded, which could cause issues if the classes do not exist. - // However in testing this has not happened. {As we run post SideTransfromer} + // However in testing this has not happened. {As we run post SideTransformer} // If reported we need to add a custom implementation of ClassWriter.getCommonSuperClass // that does not cause class loading. diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriberTransformer.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriberTransformer.java index c910b2402e..a080d4237e 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriberTransformer.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriberTransformer.java @@ -35,7 +35,7 @@ public class EventSubscriberTransformer implements IClassTransformer { if (Modifier.isPrivate(methodNode.access)) { - String msg = "Cannot apply @SubsribeEvent to private method %s/%s%s"; + String msg = "Cannot apply @SubscribeEvent to private method %s/%s%s"; throw new RuntimeException(String.format(msg, classNode.name, methodNode.name, methodNode.desc)); } diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriptionTransformer.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriptionTransformer.java index 7013cb630b..5b54550045 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriptionTransformer.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/EventSubscriptionTransformer.java @@ -105,7 +105,7 @@ public class EventSubscriptionTransformer implements IClassTransformer String listDesc = tList.getDescriptor(); String listDescM = Type.getMethodDescriptor(tList); - for (MethodNode method : (List)classNode.methods) + for (MethodNode method : classNode.methods) { if (method.name.equals("setup") && method.desc.equals(voidDesc) && (method.access & ACC_PROTECTED) == ACC_PROTECTED) hasSetup = true; if ((method.access & ACC_PUBLIC) == ACC_PUBLIC) @@ -195,10 +195,10 @@ public class EventSubscriptionTransformer implements IClassTransformer method.instructions.add(new VarInsnNode(ALOAD, 0)); method.instructions.add(new MethodInsnNode(INVOKESPECIAL, tSuper.getInternalName(), "setup", voidDesc, false)); method.instructions.add(new FieldInsnNode(GETSTATIC, classNode.name, "LISTENER_LIST", listDesc)); - LabelNode initLisitener = new LabelNode(); - method.instructions.add(new JumpInsnNode(IFNULL, initLisitener)); + LabelNode initListener = new LabelNode(); + method.instructions.add(new JumpInsnNode(IFNULL, initListener)); method.instructions.add(new InsnNode(RETURN)); - method.instructions.add(initLisitener); + method.instructions.add(initListener); method.instructions.add(new FrameNode(F_SAME, 0, null, 0, null)); method.instructions.add(new TypeInsnNode(NEW, tList.getInternalName())); method.instructions.add(new InsnNode(DUP)); diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/MarkerTransformer.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/MarkerTransformer.java index 1ee32d23ce..1774ca4677 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/MarkerTransformer.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/MarkerTransformer.java @@ -143,7 +143,7 @@ public class MarkerTransformer implements IClassTransformer if (!hasTransformer) { - System.out.println("Culd not find a valid transformer to perform"); + System.out.println("Could not find a valid transformer to perform"); return; } diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/ModAPITransformer.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/ModAPITransformer.java index 849e73b4ba..e76c1b7cbc 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/ModAPITransformer.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/ModAPITransformer.java @@ -63,7 +63,7 @@ public class ModAPITransformer implements IClassTransformer { } else { - stripMethod(classNode, (String)optional.getObjectName()); + stripMethod(classNode, optional.getObjectName()); } } diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/SideTransformer.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/SideTransformer.java index db1ae089c6..17535aa7a3 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/SideTransformer.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/SideTransformer.java @@ -40,7 +40,7 @@ public class SideTransformer implements IClassTransformer ClassReader classReader = new ClassReader(bytes); classReader.accept(classNode, 0); - if (remove((List)classNode.visibleAnnotations, SIDE)) + if (remove(classNode.visibleAnnotations, SIDE)) { if (DEBUG) { @@ -53,7 +53,7 @@ public class SideTransformer implements IClassTransformer while(fields.hasNext()) { FieldNode field = fields.next(); - if (remove((List)field.visibleAnnotations, SIDE)) + if (remove(field.visibleAnnotations, SIDE)) { if (DEBUG) { @@ -66,7 +66,7 @@ public class SideTransformer implements IClassTransformer while(methods.hasNext()) { MethodNode method = methods.next(); - if (remove((List)method.visibleAnnotations, SIDE)) + if (remove(method.visibleAnnotations, SIDE)) { if (DEBUG) { diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/TerminalTransformer.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/TerminalTransformer.java index 4b468c80c0..a1d75d7ec7 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/TerminalTransformer.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/TerminalTransformer.java @@ -49,7 +49,8 @@ public class TerminalTransformer implements IClassTransformer clsName.equals("net/minecraftforge/fml/common/FMLCommonHandler") || clsName.startsWith("com/jcraft/jogg/") || clsName.startsWith("scala/sys/") || - clsName.startsWith("net/minecraft/server/gui/MinecraftServerGui") + clsName.startsWith("net/minecraft/server/gui/MinecraftServerGui") || + clsName.startsWith("com/sun/jna/") ); return new MethodVisitor(Opcodes.ASM5, super.visitMethod(mAccess, mName, mDesc, mSignature, mExceptions)) @@ -63,7 +64,7 @@ public class TerminalTransformer implements IClassTransformer { FMLRelaunchLog.warning("============================================================="); FMLRelaunchLog.warning("MOD HAS DIRECT REFERENCE System.exit() THIS IS NOT ALLOWED REROUTING TO FML!"); - FMLRelaunchLog.warning("Offendor: %s.%s%s", ExitVisitor.this.clsName, mName, mDesc); + FMLRelaunchLog.warning("Offender: %s.%s%s", ExitVisitor.this.clsName, mName, mDesc); FMLRelaunchLog.warning("Use FMLCommonHandler.exitJava instead"); FMLRelaunchLog.warning("============================================================="); } @@ -76,7 +77,7 @@ public class TerminalTransformer implements IClassTransformer { FMLRelaunchLog.warning("============================================================="); FMLRelaunchLog.warning("MOD HAS DIRECT REFERENCE Runtime.exit() THIS IS NOT ALLOWED REROUTING TO FML!"); - FMLRelaunchLog.warning("Offendor: %s.%s%s", ExitVisitor.this.clsName, mName, mDesc); + FMLRelaunchLog.warning("Offender: %s.%s%s", ExitVisitor.this.clsName, mName, mDesc); FMLRelaunchLog.warning("Use FMLCommonHandler.exitJava instead"); FMLRelaunchLog.warning("============================================================="); } diff --git a/src/main/java/net/minecraftforge/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java b/src/main/java/net/minecraftforge/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java index fcf04f4ca6..8f4f5d0a58 100644 --- a/src/main/java/net/minecraftforge/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java +++ b/src/main/java/net/minecraftforge/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java @@ -80,7 +80,7 @@ public class FMLDeobfuscatingRemapper extends Remapper { List srgList = srgSource.readLines(); rawMethodMaps = Maps.newHashMap(); rawFieldMaps = Maps.newHashMap(); - Builder builder = ImmutableBiMap.builder(); + Builder builder = ImmutableBiMap.builder(); Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults(); for (String line : srgList) { @@ -134,7 +134,7 @@ public class FMLDeobfuscatingRemapper extends Remapper { rawMethodMaps = Maps.newHashMap(); rawFieldMaps = Maps.newHashMap(); - Builder builder = ImmutableBiMap.builder(); + Builder builder = ImmutableBiMap.builder(); Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults(); for (String line : srgList) { @@ -216,7 +216,7 @@ public class FMLDeobfuscatingRemapper extends Remapper { ClassNode classNode = new ClassNode(); cr.accept(classNode, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES); Map resMap = Maps.newHashMap(); - for (FieldNode fieldNode : (List) classNode.fields) { + for (FieldNode fieldNode : classNode.fields) { resMap.put(fieldNode.name, fieldNode.desc); } fieldDescriptions.put(owner, resMap); @@ -224,7 +224,7 @@ public class FMLDeobfuscatingRemapper extends Remapper { } catch (IOException e) { - FMLRelaunchLog.log(Level.ERROR,e, "A critical exception occured reading a class file %s", owner); + FMLRelaunchLog.log(Level.ERROR,e, "A critical exception occurred reading a class file %s", owner); } return null; } @@ -403,8 +403,8 @@ public class FMLDeobfuscatingRemapper extends Remapper { findAndMergeSuperMaps(parentThing); } } - Map methodMap = Maps.newHashMap(); - Map fieldMap = Maps.newHashMap(); + Map methodMap = Maps.newHashMap(); + Map fieldMap = Maps.newHashMap(); for (String parentThing : allParents) { if (methodNameMaps.containsKey(parentThing)) diff --git a/src/main/java/net/minecraftforge/fml/common/discovery/ASMDataTable.java b/src/main/java/net/minecraftforge/fml/common/discovery/ASMDataTable.java index aa82dd0b6a..0fd5d7d253 100644 --- a/src/main/java/net/minecraftforge/fml/common/discovery/ASMDataTable.java +++ b/src/main/java/net/minecraftforge/fml/common/discovery/ASMDataTable.java @@ -35,6 +35,7 @@ public class ASMDataTable private String annotationName; private String className; private String objectName; + private int classVersion; private Map annotationInfo; public ASMData(ModCandidate candidate, String annotationName, String className, String objectName, Map info) { @@ -103,7 +104,7 @@ public class ASMDataTable { if (containerAnnotationData == null) { - ImmutableMap.Builder> mapBuilder = ImmutableMap.>builder(); + ImmutableMap.Builder> mapBuilder = ImmutableMap.builder(); for (ModContainer cont : containers) { Multimap values = Multimaps.filterValues(globalAnnotationData, new ModContainerPredicate(cont)); diff --git a/src/main/java/net/minecraftforge/fml/common/discovery/JarDiscoverer.java b/src/main/java/net/minecraftforge/fml/common/discovery/JarDiscoverer.java index 226ddd6a1d..77346da50a 100644 --- a/src/main/java/net/minecraftforge/fml/common/discovery/JarDiscoverer.java +++ b/src/main/java/net/minecraftforge/fml/common/discovery/JarDiscoverer.java @@ -83,6 +83,7 @@ public class JarDiscoverer implements ITypeDiscoverer table.addContainer(container); foundMods.add(container); container.bindMetadata(mc); + container.setClassVersion(modParser.getClassVersion()); } } } diff --git a/src/main/java/net/minecraftforge/fml/common/event/FMLFingerprintViolationEvent.java b/src/main/java/net/minecraftforge/fml/common/event/FMLFingerprintViolationEvent.java index 3f351563f2..d8ffc28916 100644 --- a/src/main/java/net/minecraftforge/fml/common/event/FMLFingerprintViolationEvent.java +++ b/src/main/java/net/minecraftforge/fml/common/event/FMLFingerprintViolationEvent.java @@ -25,10 +25,10 @@ import net.minecraftforge.fml.common.Mod; */ public class FMLFingerprintViolationEvent extends FMLEvent { - public final boolean isDirectory; - public final Set fingerprints; - public final File source; - public final String expectedFingerprint; + private final boolean isDirectory; + private final Set fingerprints; + private final File source; + private final String expectedFingerprint; public FMLFingerprintViolationEvent(boolean isDirectory, File source, ImmutableSet fingerprints, String expectedFingerprint) { @@ -38,4 +38,9 @@ public class FMLFingerprintViolationEvent extends FMLEvent { this.fingerprints = fingerprints; this.expectedFingerprint = expectedFingerprint; } + + public boolean isDirectory() { return isDirectory; } + public Set getFingerprints() { return fingerprints; } + public File getSource() { return source; } + public String getExpectedFingerprint() { return expectedFingerprint; } } diff --git a/src/main/java/net/minecraftforge/fml/common/event/FMLInterModComms.java b/src/main/java/net/minecraftforge/fml/common/event/FMLInterModComms.java index 5db8c1409a..caf03a04fe 100644 --- a/src/main/java/net/minecraftforge/fml/common/event/FMLInterModComms.java +++ b/src/main/java/net/minecraftforge/fml/common/event/FMLInterModComms.java @@ -16,6 +16,7 @@ import com.google.common.base.Function; import com.google.common.base.Optional; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Loader; @@ -35,7 +36,7 @@ import org.apache.logging.log4j.Level; * */ public class FMLInterModComms { - private static final ImmutableList emptyIMCList = ImmutableList.of(); + private static final ImmutableList emptyIMCList = ImmutableList.of(); private static ArrayListMultimap modMessages = ArrayListMultimap.create(); /** @@ -131,6 +132,15 @@ public class FMLInterModComms { { return (String) value; } + /** + * Get the ResourceLocation value from this message. + * @throws ClassCastException if this message doesn't contain a ResourceLocation value + * @return The string value + */ + public ResourceLocation getResourceLocationValue() + { + return (ResourceLocation) value; + } /** * Get the {@link NBTTagCompound} value from this message @@ -242,6 +252,18 @@ public class FMLInterModComms { return enqueueStartupMessage(modId, new IMCMessage(key, value)); } + /** + * Send a startup time message + * @param modId The modid to send it to + * @param key The mod specific key + * @param value A ResourceLocation value + * @return if the message was enqueued successfully and will be processed during startup + */ + public static boolean sendMessage(String modId, String key, ResourceLocation value) + { + return enqueueStartupMessage(modId, new IMCMessage(key, value)); + } + /** * Send a startup time message * @param modId The modid to send it to @@ -253,7 +275,6 @@ public class FMLInterModComms { { return enqueueStartupMessage(modId, new IMCMessage(key, value)); } - /** * Send a startup time function message * @param modId The modid to send it to @@ -303,6 +324,17 @@ public class FMLInterModComms { enqueueMessage(sourceMod, modId, new IMCMessage(key, value)); } + /** + * Send a post-startup message + * @param sourceMod The mod sending the message + * @param modId The modid to send it to + * @param key The mod specific key + * @param value A string value + */ + public static void sendRuntimeMessage(Object sourceMod, String modId, String key, ResourceLocation value) + { + enqueueMessage(sourceMod, modId, new IMCMessage(key, value)); + } /** * Send a post-startup function message. * diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java index 2a1b1d1009..cf32be2d0f 100644 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java +++ b/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java @@ -71,7 +71,7 @@ public class Event { if (!isCancelable()) { - throw new IllegalArgumentException("Attempted to cancel a uncancelable event"); + throw new IllegalArgumentException("Attempted to cancel a non cancellable event"); } isCanceled = cancel; } @@ -109,7 +109,7 @@ public class Event } /** * Called by the base constructor, this is used by ASM generated - * event classes to setup various functionality such as the listenerlist. + * event classes to setup various functionality such as the listener list. */ protected void setup() { diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/IEventExceptionHandler.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/IEventExceptionHandler.java index 749128b43f..b7285593de 100644 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/IEventExceptionHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/eventhandler/IEventExceptionHandler.java @@ -4,7 +4,7 @@ public interface IEventExceptionHandler { /** * Fired when a EventListener throws an exception for the specified event on the event bus. - * After this function returns, the original Throwable will be propogated upwards. + * After this function returns, the original Throwable will be propagated upwards. * * @param bus The bus the event is being fired on * @param event The event that is being fired diff --git a/src/main/java/net/minecraftforge/fml/common/functions/CollectionWrapperFactory.java b/src/main/java/net/minecraftforge/fml/common/functions/CollectionWrapperFactory.java deleted file mode 100644 index aed3a8af6f..0000000000 --- a/src/main/java/net/minecraftforge/fml/common/functions/CollectionWrapperFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.minecraftforge.fml.common.functions; - -import java.util.Collection; -import java.util.List; -import com.google.common.collect.Collections2; -import com.google.common.collect.Lists; - -public class CollectionWrapperFactory { - /** - * Return a read only cast view of the supplied ungeneric collection, based on the element type given - * @param coll The collection to cast - * @param elementType the supertype contained in the collection - * @return a collection asserting that type relationship - */ - public static Collection wrap(@SuppressWarnings("rawtypes") Collection coll, Class elementType) - { - Collection asGeneric = coll; - return Collections2.transform(asGeneric, new TypeCastFunction(elementType)); - } - - /** - * Return a read only cast view of the supplied ungeneric list, based on the element type given - * @param list The list to cast - * @param elementType the supertype contained in the list - * @return a list asserting that type relationship - */ - public static List wrap(@SuppressWarnings("rawtypes") List list, Class elementType) - { - List asGeneric = list; - return Lists.transform(asGeneric, new TypeCastFunction(elementType)); - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/launcher/FMLDeobfTweaker.java b/src/main/java/net/minecraftforge/fml/common/launcher/FMLDeobfTweaker.java index 09dc9ee523..43baa1a294 100644 --- a/src/main/java/net/minecraftforge/fml/common/launcher/FMLDeobfTweaker.java +++ b/src/main/java/net/minecraftforge/fml/common/launcher/FMLDeobfTweaker.java @@ -41,7 +41,7 @@ public class FMLDeobfTweaker implements ITweaker { catch (Exception e) { // Load in the Loader, make sure he's ready to roll - this will initialize most of the rest of minecraft here - System.out.println("A CRITICAL PROBLEM OCCURED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML"); + System.out.println("A CRITICAL PROBLEM OCCURRED INITIALIZING MINECRAFT - LIKELY YOU HAVE AN INCORRECT VERSION FOR THIS FML"); throw new RuntimeException(e); } } diff --git a/src/main/java/net/minecraftforge/fml/common/launcher/Yggdrasil.java b/src/main/java/net/minecraftforge/fml/common/launcher/Yggdrasil.java index d7cfae1917..1da0c50911 100644 --- a/src/main/java/net/minecraftforge/fml/common/launcher/Yggdrasil.java +++ b/src/main/java/net/minecraftforge/fml/common/launcher/Yggdrasil.java @@ -32,7 +32,7 @@ public class Yggdrasil { LogManager.getLogger("FMLTWEAK").error("-- Login failed! " + e.getMessage()); Throwables.propagate(e); - return; // dont set other variables + return; // don't set other variables } args.put("--username", auth.getSelectedProfile().getName()); diff --git a/src/main/java/net/minecraftforge/fml/common/network/ByteBufUtils.java b/src/main/java/net/minecraftforge/fml/common/network/ByteBufUtils.java index 266d3f17ec..c1843cc9d2 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/ByteBufUtils.java +++ b/src/main/java/net/minecraftforge/fml/common/network/ByteBufUtils.java @@ -240,7 +240,7 @@ public class ByteBufUtils { // Add the tab for alignment returnString.append('\t'); - // Add final chararacters at right, after padding + // Add final characters at right, after padding // If it was at the end of a line, print out the full line if (i > 0 && (i % 16) == 0) diff --git a/src/main/java/net/minecraftforge/fml/common/network/FMLEventChannel.java b/src/main/java/net/minecraftforge/fml/common/network/FMLEventChannel.java index 4b424dccb7..615185ccdf 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/FMLEventChannel.java +++ b/src/main/java/net/minecraftforge/fml/common/network/FMLEventChannel.java @@ -103,10 +103,10 @@ public class FMLEventChannel { if (event != null) { this.eventBus.post(event); - if (event.reply != null) + if (event.getReply() != null) { ctx.channel().attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.REPLY); - ctx.writeAndFlush(event.reply).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); + ctx.writeAndFlush(event.getReply()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } } } diff --git a/src/main/java/net/minecraftforge/fml/common/network/FMLIndexedMessageToMessageCodec.java b/src/main/java/net/minecraftforge/fml/common/network/FMLIndexedMessageToMessageCodec.java index c168081f16..dd9888ca6b 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/FMLIndexedMessageToMessageCodec.java +++ b/src/main/java/net/minecraftforge/fml/common/network/FMLIndexedMessageToMessageCodec.java @@ -44,13 +44,12 @@ public abstract class FMLIndexedMessageToMessageCodec extends MessageToMessag } public abstract void encodeInto(ChannelHandlerContext ctx, A msg, ByteBuf target) throws Exception; + @Override protected final void encode(ChannelHandlerContext ctx, A msg, List out) throws Exception { PacketBuffer buffer = new PacketBuffer(Unpooled.buffer()); - @SuppressWarnings("unchecked") // Stupid unnecessary cast I can't seem to kill - Class clazz = (Class) msg.getClass(); - byte discriminator = types.get(clazz); + byte discriminator = types.get(msg.getClass()); buffer.writeByte(discriminator); encodeInto(ctx, msg, buffer); FMLProxyPacket proxy = new FMLProxyPacket(buffer/*.copy()*/, ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get()); diff --git a/src/main/java/net/minecraftforge/fml/common/network/FMLNetworkEvent.java b/src/main/java/net/minecraftforge/fml/common/network/FMLNetworkEvent.java index a6e9129ec4..141462441d 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/FMLNetworkEvent.java +++ b/src/main/java/net/minecraftforge/fml/common/network/FMLNetworkEvent.java @@ -13,8 +13,8 @@ import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; import net.minecraftforge.fml.relauncher.Side; public class FMLNetworkEvent extends Event { - public final T handler; - public final NetworkManager manager; + private final T handler; + private final NetworkManager manager; private final Class type; FMLNetworkEvent(T thing, Class type, NetworkManager manager) @@ -25,22 +25,47 @@ public class FMLNetworkEvent extends Event { } public Class getHandlerType() + { + return getType(); + } + + public T getHandler() + { + return handler; + } + + public NetworkManager getManager() + { + return manager; + } + + public Class getType() { return type; } - + /** * Fired at the client when a client connects to a server */ public static class ClientConnectedToServerEvent extends FMLNetworkEvent { - public final boolean isLocal; - public final String connectionType; + private final boolean isLocal; + private final String connectionType; public ClientConnectedToServerEvent(NetworkManager manager, String connectionType) { super((INetHandlerPlayClient) manager.getNetHandler(), INetHandlerPlayClient.class, manager); this.isLocal = manager.isLocalChannel(); this.connectionType = connectionType; } + + public boolean isLocal() + { + return isLocal; + } + + public String getConnectionType() + { + return connectionType; + } } /** @@ -50,12 +75,17 @@ public class FMLNetworkEvent extends Event { * */ public static class ServerConnectionFromClientEvent extends FMLNetworkEvent { - public final boolean isLocal; + private final boolean isLocal; public ServerConnectionFromClientEvent(NetworkManager manager) { super((INetHandlerPlayServer) manager.getNetHandler(), INetHandlerPlayServer.class, manager); this.isLocal = manager.isLocalChannel(); } + + public boolean isLocal() + { + return isLocal; + } } /** * Fired at the server when a client disconnects. @@ -90,9 +120,9 @@ public class FMLNetworkEvent extends Event { * @param The side */ public static class CustomPacketRegistrationEvent extends FMLNetworkEvent { - public final ImmutableSet registrations; - public final String operation; - public final Side side; + private final ImmutableSet registrations; + private final String operation; + private final Side side; public CustomPacketRegistrationEvent(NetworkManager manager, Set registrations, String operation, Side side, Class type) { super(type.cast(manager.getNetHandler()), type, manager); @@ -100,18 +130,27 @@ public class FMLNetworkEvent extends Event { this.side = side; this.operation = operation; } + + public ImmutableSet getRegistrations() + { + return registrations; + } + + public String getOperation() + { + return operation; + } + + public Side getSide() + { + return side; + } } public static abstract class CustomPacketEvent extends FMLNetworkEvent { - /** - * The packet that generated the event - */ - public final FMLProxyPacket packet; + private final FMLProxyPacket packet; - /** - * Set this packet to reply to the originator - */ - public FMLProxyPacket reply; + private FMLProxyPacket reply; CustomPacketEvent(S thing, Class type, NetworkManager manager, FMLProxyPacket packet) { super(thing, type, manager); @@ -119,6 +158,27 @@ public class FMLNetworkEvent extends Event { } public abstract Side side(); + + /** + * The packet that generated the event + */ + public FMLProxyPacket getPacket() + { + return packet; + } + + /** + * Set this packet to reply to the originator + */ + public FMLProxyPacket getReply() + { + return reply; + } + + public void setReply(FMLProxyPacket reply) + { + this.reply = reply; + } } /** @@ -164,10 +224,15 @@ public class FMLNetworkEvent extends Event { * */ public static class CustomNetworkEvent extends Event { - public final Object wrappedEvent; + private final Object wrappedEvent; public CustomNetworkEvent(Object wrappedEvent) { this.wrappedEvent = wrappedEvent; } + + public Object getWrappedEvent() + { + return wrappedEvent; + } } } diff --git a/src/main/java/net/minecraftforge/fml/common/network/FMLOutboundHandler.java b/src/main/java/net/minecraftforge/fml/common/network/FMLOutboundHandler.java index 11d4715cfd..36a366f34d 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/FMLOutboundHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/network/FMLOutboundHandler.java @@ -127,8 +127,8 @@ public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter { @Override public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) { - ImmutableList.Builder builder = ImmutableList.builder(); - for (EntityPlayerMP player : (List)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) + ImmutableList.Builder builder = ImmutableList.builder(); + for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerList()) { NetworkDispatcher dispatcher = player.playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).get(); if (dispatcher != null) builder.add(dispatcher); @@ -155,8 +155,8 @@ public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter { public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) { int dimension = (Integer)args; - ImmutableList.Builder builder = ImmutableList.builder(); - for (EntityPlayerMP player : (List)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) + ImmutableList.Builder builder = ImmutableList.builder(); + for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerList()) { if (dimension == player.dimension) { @@ -189,8 +189,8 @@ public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter { public List selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet) { TargetPoint tp = (TargetPoint)args; - ImmutableList.Builder builder = ImmutableList.builder(); - for (EntityPlayerMP player : (List)FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) + ImmutableList.Builder builder = ImmutableList.builder(); + for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerList()) { if (player.dimension == tp.dimension) { diff --git a/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java b/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java index f94033add8..a098c150f2 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/network/PacketLoggingHandler.java @@ -14,27 +14,26 @@ import java.util.List; import org.apache.logging.log4j.Level; import net.minecraft.network.EnumPacketDirection; +import net.minecraft.network.NettyVarint21FrameDecoder; +import net.minecraft.network.NettyVarint21FrameEncoder; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.PacketBuffer; -import net.minecraft.util.MessageDeserializer2; -import net.minecraft.util.MessageSerializer2; import net.minecraftforge.fml.common.FMLLog; public class PacketLoggingHandler { - @SuppressWarnings("rawtypes") - public static void register(NetworkManager manager) + public static void register(NetworkManager manager) { ChannelPipeline pipeline = manager.channel().pipeline(); final EnumPacketDirection direction = manager.getDirection(); if (manager.isLocalChannel()) { - pipeline.addBefore("packet_handler", "splitter", new SimpleChannelInboundHandler() + pipeline.addBefore("packet_handler", "splitter", new SimpleChannelInboundHandler>() { String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C"); @Override - protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception + protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception { PacketBuffer buf = new PacketBuffer(Unpooled.buffer()); msg.writePacketData(buf); @@ -48,10 +47,10 @@ public class PacketLoggingHandler @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { - if (msg instanceof Packet) + if (msg instanceof Packet) { PacketBuffer buf = new PacketBuffer(Unpooled.buffer()); - ((Packet)msg).writePacketData(buf); + ((Packet)msg).writePacketData(buf); FMLLog.log(Level.DEBUG, "%s %s:\n%s", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf)); } ctx.write(msg, promise); @@ -60,7 +59,7 @@ public class PacketLoggingHandler } else { - pipeline.replace("splitter", "splitter", new MessageDeserializer2() + pipeline.replace("splitter", "splitter", new NettyVarint21FrameDecoder() { String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: C->S" : "CLIENT: S->C"); @Override @@ -77,7 +76,7 @@ public class PacketLoggingHandler } } }); - pipeline.replace("prepender", "prepender", new MessageSerializer2() + pipeline.replace("prepender", "prepender", new NettyVarint21FrameEncoder() { String prefix = (direction == EnumPacketDirection.SERVERBOUND ? "SERVER: S->C" : "CLIENT: C->S"); @Override diff --git a/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java b/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java index cf37465851..083995b63c 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java +++ b/src/main/java/net/minecraftforge/fml/common/network/handshake/NetworkDispatcher.java @@ -27,12 +27,12 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.PacketBuffer; import net.minecraft.network.play.INetHandlerPlayClient; -import net.minecraft.network.play.client.C17PacketCustomPayload; -import net.minecraft.network.play.server.S01PacketJoinGame; -import net.minecraft.network.play.server.S3FPacketCustomPayload; -import net.minecraft.network.play.server.S40PacketDisconnect; -import net.minecraft.server.management.ServerConfigurationManager; -import net.minecraft.util.ChatComponentText; +import net.minecraft.network.play.client.CPacketCustomPayload; +import net.minecraft.network.play.server.SPacketJoinGame; +import net.minecraft.network.play.server.SPacketCustomPayload; +import net.minecraft.network.play.server.SPacketDisconnect; +import net.minecraft.server.management.PlayerList; +import net.minecraft.util.text.TextComponentString; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; @@ -50,8 +50,7 @@ import net.minecraftforge.fml.relauncher.Side; import org.apache.logging.log4j.Level; -@SuppressWarnings("rawtypes") -public class NetworkDispatcher extends SimpleChannelInboundHandler implements ChannelOutboundHandler { +public class NetworkDispatcher extends SimpleChannelInboundHandler> implements ChannelOutboundHandler { private static boolean DEBUG_HANDSHAKE = Boolean.parseBoolean(System.getProperty("fml.debugNetworkHandshake", "false")); private static enum ConnectionState { OPENING, AWAITING_HANDSHAKE, HANDSHAKING, HANDSHAKECOMPLETE, FINALIZING, CONNECTED; @@ -73,7 +72,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple return net; } - public static NetworkDispatcher allocAndSet(NetworkManager manager, ServerConfigurationManager scm) + public static NetworkDispatcher allocAndSet(NetworkManager manager, PlayerList scm) { NetworkDispatcher net = new NetworkDispatcher(manager, scm); manager.channel().attr(FML_DISPATCHER).getAndSet(net); @@ -84,7 +83,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple public static final AttributeKey IS_LOCAL = AttributeKey.valueOf("fml:isLocal"); public static final AttributeKey FML_GAMEDATA_SNAPSHOT = AttributeKey.valueOf("fml:gameDataSnapshot"); public final NetworkManager manager; - private final ServerConfigurationManager scm; + private final PlayerList scm; private EntityPlayerMP player; private ConnectionState state; private ConnectionType connectionType; @@ -97,7 +96,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple public NetworkDispatcher(NetworkManager manager) { - super(Packet.class, false); + super(false); this.manager = manager; this.scm = null; this.side = Side.CLIENT; @@ -110,9 +109,9 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple PacketLoggingHandler.register(manager); } - public NetworkDispatcher(NetworkManager manager, ServerConfigurationManager scm) + public NetworkDispatcher(NetworkManager manager, PlayerList scm) { - super(Packet.class, false); + super(false); this.manager = manager; this.scm = scm; this.side = Side.SERVER; @@ -130,7 +129,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple this.player = player; insertIntoChannel(); Boolean fml = this.manager.channel().attr(NetworkRegistry.FML_MARKER).get(); - if (fml != null && fml.booleanValue()) + if (fml != null && fml) { //FML on client, send server hello //TODO: Make this cleaner as it uses netty magic 0.o @@ -189,6 +188,8 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple { completeServerSideConnection(ConnectionType.MODDED); } + // FORGE: sometimes the netqueue will tick while login is occurring, causing an NPE. We shouldn't tick until the connection is complete + if (this.playerEntity.playerNetServerHandler != this) return; super.update(); } }; @@ -206,7 +207,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple int dimension = playerNBT.getInteger("Dimension"); if (DimensionManager.isDimensionRegistered(dimension)) { - return dimension; + return dimension; } } return 0; @@ -235,21 +236,21 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple this.state = ConnectionState.CONNECTED; MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerConnectionFromClientEvent(manager)); if (DEBUG_HANDSHAKE) - manager.closeChannel(new ChatComponentText("Handshake Complete review log file for details.")); + manager.closeChannel(new TextComponentString("Handshake Complete review log file for details.")); scm.initializeConnectionToPlayer(manager, player, serverHandler); } @Override - protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception + protected void channelRead0(ChannelHandlerContext ctx, Packet msg) throws Exception { boolean handled = false; - if (msg instanceof C17PacketCustomPayload) + if (msg instanceof CPacketCustomPayload) { - handled = handleServerSideCustomPacket((C17PacketCustomPayload) msg, ctx); + handled = handleServerSideCustomPacket((CPacketCustomPayload) msg, ctx); } - else if (msg instanceof S3FPacketCustomPayload) + else if (msg instanceof SPacketCustomPayload) { - handled = handleClientSideCustomPacket((S3FPacketCustomPayload)msg, ctx); + handled = handleClientSideCustomPacket((SPacketCustomPayload)msg, ctx); } else if (state != ConnectionState.CONNECTED && state != ConnectionState.HANDSHAKECOMPLETE) { @@ -263,7 +264,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple private boolean handleVanilla(Packet msg) { - if (state == ConnectionState.AWAITING_HANDSHAKE && msg instanceof S01PacketJoinGame) + if (state == ConnectionState.AWAITING_HANDSHAKE && msg instanceof SPacketJoinGame) { handshakeChannel.pipeline().fireUserEventTriggered(msg); } @@ -303,30 +304,30 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple { kickWithMessage("This is modded. No modded response received. Bye!"); } - @SuppressWarnings("unchecked") - private void kickWithMessage(String message) + + private void kickWithMessage(String message) { - final ChatComponentText chatcomponenttext = new ChatComponentText(message); + final TextComponentString TextComponentString = new TextComponentString(message); if (side == Side.CLIENT) { - manager.closeChannel(chatcomponenttext); + manager.closeChannel(TextComponentString); } else { - manager.sendPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener>() + manager.sendPacket(new SPacketDisconnect(TextComponentString), new GenericFutureListener>() { @Override public void operationComplete(Future result) { - manager.closeChannel(chatcomponenttext); + manager.closeChannel(TextComponentString); } - }, new GenericFutureListener[0]); + }, (GenericFutureListener>[])null); } manager.channel().config().setAutoRead(false); } private MultiPartCustomPayload multipart = null; - private boolean handleClientSideCustomPacket(S3FPacketCustomPayload msg, ChannelHandlerContext context) + private boolean handleClientSideCustomPacket(SPacketCustomPayload msg, ChannelHandlerContext context) { String channelName = msg.getChannelName(); if ("FML|MP".equals(channelName)) @@ -389,7 +390,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple return false; } - private boolean handleServerSideCustomPacket(C17PacketCustomPayload msg, ChannelHandlerContext context) + private boolean handleServerSideCustomPacket(CPacketCustomPayload msg, ChannelHandlerContext context) { if (state == ConnectionState.AWAITING_HANDSHAKE) { @@ -457,11 +458,11 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple { if (side == Side.CLIENT) { - MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager)); + MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ClientDisconnectionFromServerEvent(manager)); } else { - MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager)); + MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager)); } cleanAttributes(ctx); ctx.disconnect(promise); @@ -476,7 +477,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple } else { - MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager)); + MinecraftForge.EVENT_BUS.post(new FMLNetworkEvent.ServerDisconnectionFromClientEvent(manager)); } cleanAttributes(ctx); ctx.close(promise); @@ -582,12 +583,12 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple FMLLog.fine("Received override dimension %d", overrideDim); } - public int getOverrideDimension(S01PacketJoinGame packetIn) { + public int getOverrideDimension(SPacketJoinGame packetIn) { FMLLog.fine("Overriding dimension: using %d", this.overrideLoginDim); return this.overrideLoginDim != 0 ? this.overrideLoginDim : packetIn.getDimension(); } - private class MultiPartCustomPayload extends S3FPacketCustomPayload + private class MultiPartCustomPayload extends SPacketCustomPayload { private String channel; private byte[] data; @@ -611,7 +612,7 @@ public class NetworkDispatcher extends SimpleChannelInboundHandler imple public void processPart(PacketBuffer input) throws IOException { - int part = (int)(input.readByte() & 0xFF); + int part = input.readByte() & 0xFF; if (part != part_expected) { throw new IOException("Received FML MultiPart packet out of order, Expected " + part_expected + " Got " + part); diff --git a/src/main/java/net/minecraftforge/fml/common/network/internal/EntitySpawnHandler.java b/src/main/java/net/minecraftforge/fml/common/network/internal/EntitySpawnHandler.java index 00c1f70794..b144f5161c 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/internal/EntitySpawnHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/network/internal/EntitySpawnHandler.java @@ -9,6 +9,7 @@ import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityTracker; import net.minecraft.util.IThreadListener; import net.minecraft.world.World; import net.minecraftforge.fml.client.FMLClientHandler; @@ -17,7 +18,6 @@ import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.common.network.internal.FMLMessage.EntityAdjustMessage; import net.minecraftforge.fml.common.network.internal.FMLMessage.EntityMessage; import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData; @@ -53,25 +53,6 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler cls = er.getEntityClass(); @@ -93,11 +74,12 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler 0) @@ -141,7 +121,7 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler dataWatcherList; + List> dataWatcherList; ByteBuf dataStream; public EntitySpawnMessage() {} @@ -173,10 +139,12 @@ public abstract class FMLMessage { super.toBytes(buf); ByteBufUtils.writeUTF8String(buf, modId); buf.writeInt(modEntityTypeId); + buf.writeLong(entity.getUniqueID().getMostSignificantBits()); + buf.writeLong(entity.getUniqueID().getLeastSignificantBits()); // posX, posY, posZ - buf.writeInt(MathHelper.floor_double(entity.posX * 32D)); - buf.writeInt(MathHelper.floor_double(entity.posY * 32D)); - buf.writeInt(MathHelper.floor_double(entity.posZ * 32D)); + buf.writeDouble(entity.posX); + buf.writeDouble(entity.posY); + buf.writeDouble(entity.posZ); // yaw, pitch buf.writeByte((byte)(entity.rotationYaw * 256.0F / 360.0F)); buf.writeByte((byte) (entity.rotationPitch * 256.0F / 360.0F)); @@ -193,7 +161,7 @@ public abstract class FMLMessage { PacketBuffer pb = new PacketBuffer(tmpBuf); try { - entity.getDataWatcher().writeTo(pb); + entity.getDataManager().writeEntries(pb); } catch (IOException e) { FMLLog.log(Level.FATAL,e,"Encountered fatal exception trying to send entity spawn data watchers"); @@ -236,18 +204,16 @@ public abstract class FMLMessage { super.fromBytes(dat); modId = ByteBufUtils.readUTF8String(dat); modEntityTypeId = dat.readInt(); - rawX = dat.readInt(); - rawY = dat.readInt(); - rawZ = dat.readInt(); - scaledX = rawX / 32D; - scaledY = rawY / 32D; - scaledZ = rawZ / 32D; + entityUUID = new UUID(dat.readLong(), dat.readLong()); + rawX = dat.readDouble(); + rawY = dat.readDouble(); + rawZ = dat.readDouble(); scaledYaw = dat.readByte() * 360F / 256F; scaledPitch = dat.readByte() * 360F / 256F; scaledHeadYaw = dat.readByte() * 360F / 256F; try { - dataWatcherList = DataWatcher.readWatchedListFromPacketBuffer(new PacketBuffer(dat)); + dataWatcherList = EntityDataManager.readEntries(new PacketBuffer(dat)); } catch (IOException e) { FMLLog.log(Level.FATAL, e, "There was a critical error decoding the datawatcher stream for a mod entity."); diff --git a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLNetworkHandler.java b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLNetworkHandler.java index 6afdf342b7..a04a280d33 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLNetworkHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLNetworkHandler.java @@ -27,7 +27,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; -import net.minecraft.server.management.ServerConfigurationManager; +import net.minecraft.server.management.PlayerList; import net.minecraft.world.World; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.fml.common.FMLCommonHandler; @@ -59,7 +59,7 @@ public class FMLNetworkHandler public static final int LOGIN_TIMEOUT = Integers.parseInt(System.getProperty("fml.loginTimeout","600"),600); private static EnumMap channelPair; - public static void fmlServerHandshake(ServerConfigurationManager scm, NetworkManager manager, EntityPlayerMP player) + public static void fmlServerHandshake(PlayerList scm, NetworkManager manager, EntityPlayerMP player) { NetworkDispatcher dispatcher = NetworkDispatcher.allocAndSet(manager, scm); dispatcher.serverToClientHandshake(player); @@ -104,19 +104,11 @@ public class FMLNetworkHandler } else { - FMLLog.fine("Invalid attempt to open a local GUI on a dedicated server. This is likely a bug. GUIID: %s,%d", mc.getModId(), modGuiId); + FMLLog.fine("Invalid attempt to open a local GUI on a dedicated server. This is likely a bug. GUI ID: %s,%d", mc.getModId(), modGuiId); } } - public static void makeEntitySpawnAdjustment(Entity entity, EntityPlayerMP player, int serverX, int serverY, int serverZ) - { - EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER); - embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER); - embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player); - embeddedChannel.writeOutbound(new FMLMessage.EntityAdjustMessage(entity, serverX, serverY, serverZ)); - } - public static Packet getEntitySpawningPacket(Entity entity) { EntityRegistration er = EntityRegistry.instance().lookupModSpawn(entity.getClass(), false); diff --git a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLProxyPacket.java b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLProxyPacket.java index 66a9cd302d..ba3c4b3360 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLProxyPacket.java +++ b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLProxyPacket.java @@ -13,8 +13,8 @@ import net.minecraft.network.Packet; import net.minecraft.network.PacketBuffer; import net.minecraft.network.play.INetHandlerPlayClient; import net.minecraft.network.play.INetHandlerPlayServer; -import net.minecraft.network.play.client.C17PacketCustomPayload; -import net.minecraft.network.play.server.S3FPacketCustomPayload; +import net.minecraft.network.play.client.CPacketCustomPayload; +import net.minecraft.network.play.server.SPacketCustomPayload; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.network.FMLNetworkException; import net.minecraftforge.fml.common.network.NetworkRegistry; @@ -39,13 +39,13 @@ public class FMLProxyPacket implements Packet { private static Multiset badPackets = ConcurrentHashMultiset.create(); private static int packetCountWarning = Integers.parseInt(System.getProperty("fml.badPacketCounter", "100"), 100); - public FMLProxyPacket(S3FPacketCustomPayload original) + public FMLProxyPacket(SPacketCustomPayload original) { this(original.getBufferData(), original.getChannelName()); this.target = Side.CLIENT; } - public FMLProxyPacket(C17PacketCustomPayload original) + public FMLProxyPacket(CPacketCustomPayload original) { this(original.getBufferData(), original.getChannelName()); this.target = Side.SERVER; @@ -102,7 +102,7 @@ public class FMLProxyPacket implements Packet { catch (Throwable t) { FMLLog.log(Level.ERROR, t, "There was a critical exception handling a packet on channel %s", channel); - dispatcher.rejectHandshake("A fatal error has occured, this connection is terminated"); + dispatcher.rejectHandshake("A fatal error has occurred, this connection is terminated"); } } } @@ -121,10 +121,11 @@ public class FMLProxyPacket implements Packet { } public Packet toC17Packet() { - return new C17PacketCustomPayload(channel, payload); + return new CPacketCustomPayload(channel, payload); } static final int PART_SIZE = 0x1000000 - 0x50; // Make it a constant so that it gets inlined below. + // FIXME int overflow public static final int MAX_LENGTH = PART_SIZE * 255; public List> toS3FPackets() throws IOException { @@ -133,7 +134,7 @@ public class FMLProxyPacket implements Packet { if (data.length < PART_SIZE) { - ret.add(new S3FPacketCustomPayload(channel, new PacketBuffer(payload.duplicate()))); + ret.add(new SPacketCustomPayload(channel, new PacketBuffer(payload.duplicate()))); } else { @@ -146,7 +147,7 @@ public class FMLProxyPacket implements Packet { preamble.writeString(channel); preamble.writeByte(parts); preamble.writeInt(data.length); - ret.add(new S3FPacketCustomPayload("FML|MP", preamble)); + ret.add(new SPacketCustomPayload("FML|MP", preamble)); int offset = 0; for (int x = 0; x < parts; x++) @@ -156,7 +157,7 @@ public class FMLProxyPacket implements Packet { tmp[0] = (byte)(x & 0xFF); System.arraycopy(data, offset, tmp, 1, tmp.length - 1); offset += tmp.length - 1; - ret.add(new S3FPacketCustomPayload("FML|MP", new PacketBuffer(Unpooled.wrappedBuffer(tmp)))); + ret.add(new SPacketCustomPayload("FML|MP", new PacketBuffer(Unpooled.wrappedBuffer(tmp)))); } } return ret; diff --git a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLRuntimeCodec.java b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLRuntimeCodec.java index 0212fe9f1c..8dfbe9937d 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/internal/FMLRuntimeCodec.java +++ b/src/main/java/net/minecraftforge/fml/common/network/internal/FMLRuntimeCodec.java @@ -16,7 +16,6 @@ public class FMLRuntimeCodec extends FMLIndexedMessageToMessageCodec addDiscriminator(0,FMLMessage.CompleteHandshake.class); addDiscriminator(1,FMLMessage.OpenGui.class); addDiscriminator(2,FMLMessage.EntitySpawnMessage.class); - addDiscriminator(3,FMLMessage.EntityAdjustMessage.class); } @Override public void encodeInto(ChannelHandlerContext ctx, FMLMessage msg, ByteBuf target) throws Exception diff --git a/src/main/java/net/minecraftforge/fml/common/network/simpleimpl/MessageContext.java b/src/main/java/net/minecraftforge/fml/common/network/simpleimpl/MessageContext.java index 6b4c1f436f..20b1624709 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/simpleimpl/MessageContext.java +++ b/src/main/java/net/minecraftforge/fml/common/network/simpleimpl/MessageContext.java @@ -14,7 +14,7 @@ import net.minecraftforge.fml.relauncher.Side; public class MessageContext { /** * The {@link INetHandler} for this message. It could be a client or server handler, depending - * on the {@link #side} recieved. + * on the {@link #side} received. */ public final INetHandler netHandler; diff --git a/src/main/java/net/minecraftforge/fml/common/patcher/ClassPatchManager.java b/src/main/java/net/minecraftforge/fml/common/patcher/ClassPatchManager.java index b95186f15c..299e4c6612 100644 --- a/src/main/java/net/minecraftforge/fml/common/patcher/ClassPatchManager.java +++ b/src/main/java/net/minecraftforge/fml/common/patcher/ClassPatchManager.java @@ -99,7 +99,7 @@ public class ClassPatchManager { int inputChecksum = Hashing.adler32().hashBytes(inputData).asInt(); if (patch.inputChecksum != inputChecksum) { - FMLRelaunchLog.severe("There is a binary discrepency between the expected input class %s (%s) and the actual class. Checksum on disk is %x, in patch %x. Things are probably about to go very wrong. Did you put something into the jar file?", mappedName, name, inputChecksum, patch.inputChecksum); + FMLRelaunchLog.severe("There is a binary discrepancy between the expected input class %s (%s) and the actual class. Checksum on disk is %x, in patch %x. Things are probably about to go very wrong. Did you put something into the jar file?", mappedName, name, inputChecksum, patch.inputChecksum); if (!Boolean.parseBoolean(System.getProperty("fml.ignorePatchDiscrepancies","false"))) { FMLRelaunchLog.severe("The game is going to exit, because this is a critical error, and it is very improbable that the modded game will work, please obtain clean jar files."); diff --git a/src/main/java/net/minecraftforge/fml/common/registry/EntityRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/EntityRegistry.java index 939ef706fa..36667aad06 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/EntityRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/EntityRegistry.java @@ -13,13 +13,10 @@ package net.minecraftforge.fml.common.registry; import java.util.BitSet; -import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; -import org.apache.logging.log4j.Level; - import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; @@ -33,6 +30,8 @@ import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.network.internal.FMLMessage.EntitySpawnMessage; +import org.apache.logging.log4j.Level; + import com.google.common.base.Function; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.BiMap; @@ -114,12 +113,10 @@ public class EntityRegistry private static final EntityRegistry INSTANCE = new EntityRegistry(); - private BitSet availableIndicies; + private BitSet availableIndices; private ListMultimap entityRegistrations = ArrayListMultimap.create(); private Map entityNames = Maps.newHashMap(); private BiMap, EntityRegistration> entityClassRegistrations = HashBiMap.create(); - private Map entityEggs = Maps.newHashMap(); - private Map entityEggsUn = Collections.unmodifiableMap(entityEggs); public static EntityRegistry instance() { @@ -128,11 +125,11 @@ public class EntityRegistry private EntityRegistry() { - availableIndicies = new BitSet(256); - availableIndicies.set(1,255); + availableIndices = new BitSet(256); + availableIndices.set(1,255); for (Object id : EntityList.idToClassMapping.keySet()) { - availableIndicies.clear((Integer)id); + availableIndices.clear((Integer)id); } } @@ -214,26 +211,20 @@ public class EntityRegistry * @throws IllegalArgumentException if entityClass is not registered in classToStringMapping. * */ + public static void registerEgg(Class entityClass, int primary, int secondary) { - if (!EntityList.classToStringMapping.containsKey(entityClass)) - throw new IllegalArgumentException("Entity not registered in classToString map: " + entityClass); - - String name = (String)EntityList.classToStringMapping.get(entityClass); - EntityRegistry.instance().entityEggs.put(name, new EntityList.EntityEggInfo(name, primary, secondary)); - FMLLog.fine("Registering entity egg '%s' for %s", name, entityClass); + if (EntityList.classToStringMapping.containsKey(entityClass)) + { + String name = EntityList.classToStringMapping.get(entityClass); + EntityList.entityEggs.put(name, new EntityList.EntityEggInfo(name, primary, secondary)); + FMLLog.fine("Registering entity egg '%s' for %s", name, entityClass); + } + else + { + FMLLog.fine("Failed registering entity egg %s (No entity found)", entityClass.getName()); + } } - - /** - * Returns a Unmodifiable view of the registered entity eggs list. - * - * @return An Unmodifiable view of the registered entity eggs list. - */ - public static Map getEggs() - { - return instance().entityEggsUn; - } - /** * Registers in the minecraft Entity ID list. This is generally not a good idea and shouldn't be used. * Simply use {@link #registerModEntity(Class, String, int, Object, int, int, boolean, int, int)} instead. @@ -318,11 +309,11 @@ public class EntityRegistry FMLLog.log(Level.ERROR, "The entity ID %d for mod %s is not an unsigned byte and may not work", id, Loader.instance().activeModContainer().getModId()); } - if (!availableIndicies.get(realId)) + if (!availableIndices.get(realId)) { FMLLog.severe("The mod %s has attempted to register an entity ID %d which is already reserved. This could cause severe problems", Loader.instance().activeModContainer().getModId(), id); } - availableIndicies.clear(realId); + availableIndices.clear(realId); return realId; } @@ -426,10 +417,10 @@ public class EntityRegistry @Deprecated public static int findGlobalUniqueEntityId() { - int res = instance().availableIndicies.nextSetBit(0); + int res = instance().availableIndices.nextSetBit(0); if (res < 0) { - throw new RuntimeException("No more entity indicies left"); + throw new RuntimeException("No more entity indices left"); } return res; } diff --git a/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java index d2385f314f..2f83b230fb 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/FMLControlledNamespacedRegistry.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import com.google.common.base.Joiner; @@ -15,24 +16,23 @@ import com.google.common.base.Throwables; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import org.apache.commons.lang3.Validate; import org.apache.logging.log4j.Level; -import net.minecraft.util.ObjectIntIdentityMap; -import net.minecraft.util.RegistryNamespacedDefaultedByKey; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.functions.GenericIterableFactory; import net.minecraftforge.fml.common.registry.RegistryDelegate.Delegate; -public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaultedByKey +public class FMLControlledNamespacedRegistry> extends RegistryNamespacedDefaultedByKey implements IForgeRegistry { public static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("fml.debugRegistryEntries", "false")); private final Class superType; private final boolean isDelegated; - private final Field delegateAccessor; private ResourceLocation optionalDefaultKey; private I optionalDefaultObject; private int maxId; @@ -59,43 +59,30 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul private final BitSet availabilityMap; + private final Map slaves = Maps.newHashMap(); + private final AddCallback addCallback; - public interface AddCallback - { - public void onAdd(T obj, int id); - } + private final ClearCallback clearCallback; - FMLControlledNamespacedRegistry(ResourceLocation defaultKey, int maxIdValue, int minIdValue, Class type, boolean isDelegated) - { - this(defaultKey, maxIdValue, minIdValue, type, isDelegated, null); - } + private final CreateCallback createCallback; - FMLControlledNamespacedRegistry(ResourceLocation defaultKey, int maxIdValue, int minIdValue, Class type, boolean isDelegated, AddCallback callback) + FMLControlledNamespacedRegistry(ResourceLocation defaultKey, int minIdValue, int maxIdValue, Class type, AddCallback addCallback, ClearCallback clearCallback, CreateCallback createCallback) { super(defaultKey); this.superType = type; this.optionalDefaultKey = defaultKey; - this.maxId = maxIdValue; this.minId = minIdValue; + this.maxId = maxIdValue; this.availabilityMap = new BitSet(maxIdValue + 1); - this.isDelegated = isDelegated; - if (this.isDelegated) + this.isDelegated = IForgeRegistryEntry.Impl.class.isAssignableFrom(type); + this.addCallback = addCallback; + this.clearCallback = clearCallback; + this.createCallback = createCallback; + if (createCallback != null) { - try - { - this.delegateAccessor = type.getField("delegate"); - } catch (NoSuchFieldException e) - { - FMLLog.log(Level.ERROR, e, "Delegate class identified with missing delegate field"); - throw Throwables.propagate(e); - } + createCallback.onCreate(slaves); } - else - { - this.delegateAccessor = null; - } - this.addCallback = callback; } void validateContent(ResourceLocation registryName) @@ -170,7 +157,7 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul this.dummiedLocations.clear(); this.dummiedLocations.addAll(otherRegistry.dummiedLocations); - underlyingIntegerMap = new ObjectIntIdentityMap(); + underlyingIntegerMap.func_186812_a(); registryObjects.clear(); for (I thing : otherRegistry.typeSafeIterable()) @@ -275,7 +262,7 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul */ public int getId(I thing) { - return getIDForObject(thing); + return getIDForObjectBypass(thing); } /** @@ -462,7 +449,7 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul addObjectRaw(idToUse, name, thing); if (isDelegated) { - getExistingDelegate(thing).setResourceName(name); + getExistingDelegate(thing).setName(name); } if (this.dummiedLocations.remove(name) && DEBUG) @@ -561,7 +548,7 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul availabilityMap.set(id); if (addCallback != null) { - addCallback.onAdd(thing, id); + addCallback.onAdd(thing, id, slaves); } } @@ -576,15 +563,15 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul } @SuppressWarnings("unchecked") - public Delegate getExistingDelegate(I thing) + private Delegate getExistingDelegate(I thing) { - try + if (isDelegated) { - return (Delegate)delegateAccessor.get(thing); - } catch (IllegalAccessException e) + return (Delegate)((IForgeRegistryEntry.Impl)thing).delegate; + } + else { - FMLLog.log(Level.ERROR, e, "Illegal attempt to access delegate"); - throw Throwables.propagate(e); + return null; } } @@ -655,7 +642,7 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul FMLControlledNamespacedRegistry makeShallowCopy() { - return new FMLControlledNamespacedRegistry(optionalDefaultKey, maxId, minId, superType, isDelegated); + return new FMLControlledNamespacedRegistry(optionalDefaultKey, minId, maxId, superType, addCallback, clearCallback, createCallback); } void resetSubstitutionDelegates() @@ -672,7 +659,7 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul } @SuppressWarnings("unchecked") - public FMLControlledNamespacedRegistry asType(Class type) + public > FMLControlledNamespacedRegistry asType(Class type) { return (FMLControlledNamespacedRegistry)this; } @@ -758,18 +745,118 @@ public class FMLControlledNamespacedRegistry extends RegistryNamespacedDefaul for (I i : this.underlyingIntegerMap) { - addCallback.onAdd(i, this.underlyingIntegerMap.get(i)); + addCallback.onAdd(i, this.underlyingIntegerMap.add(i), slaves); } } @Override public ResourceLocation getNameForObject(I p_177774_1_) { - ResourceLocation rl = super.getNameForObject(p_177774_1_); + ResourceLocation rl = super.getNameForObjectBypass(p_177774_1_); if (rl == null) { rl = activeSubstitutions.inverse().get(p_177774_1_); } return rl; } + + @Override + public Class getRegistrySuperType() + { + return superType; + } + + + // IForgeRegistry: Modders should only interfaces with these methods + + @Override + public void register(I value) + { + ResourceLocation key = value.getRegistryName(); + if (key == null) + { + FMLLog.severe("Attempted to register a entry with a null name: %s", value); + throw new NullPointerException(String.format("Attempted to register a entry with a null name: %s", value)); + } + add(-1, key, value); + } + + @Override + public boolean containsValue(I value) + { + return getKey(value) != null; + } + + @Override + public I getValue(ResourceLocation key) + { + return getObject(key); + } + + @Override + public ResourceLocation getKey(I value) + { + return getNameForObject(value); + } + + @Override + public List getValues() + { + return Lists.newArrayList(this.iterator()); + } + + @Override + public Set> getEntries() + { + return Sets.newHashSet(new Iterator>() + { + Iterator itr = FMLControlledNamespacedRegistry.this.iterator(); + + @Override + public boolean hasNext() + { + return itr.hasNext(); + } + + @Override + public Entry next() + { + final I value = itr.next(); + final ResourceLocation key = FMLControlledNamespacedRegistry.this.getKey(value); + return new Entry() + { + @Override + public ResourceLocation getKey() + { + return key; + } + + @Override + public I getValue() + { + return value; + } + + @Override + public I setValue(I value) + { + throw new UnsupportedOperationException("Setting the value in an iterator is not allowed"); + } + }; + } + + @Override + public void remove() + { + throw new UnsupportedOperationException("This is a READ ONLY view of this registry."); + } + }); + } + + @SuppressWarnings("unchecked") + @Override + public T getSlaveMap(ResourceLocation slaveMapName, Class type) + { + return (T)slaves.get(slaveMapName); + } } diff --git a/src/main/java/net/minecraftforge/fml/common/registry/ForgeRegistries.java b/src/main/java/net/minecraftforge/fml/common/registry/ForgeRegistries.java new file mode 100644 index 0000000000..74917b1c9a --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/common/registry/ForgeRegistries.java @@ -0,0 +1,40 @@ +package net.minecraftforge.fml.common.registry; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.item.Item; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionType; +import net.minecraft.util.SoundEvent; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; + +/** + * A class that exposes static references to all vanilla and Forge registries. + * Created to have a central place to access the registries directly if modders need. + * It is still advised that if you are registering things to go through {@link GameRegistry.register} but queries and iterations can use this. + */ +public class ForgeRegistries +{ + static { init(); } // This must be above the fields so we guarantee it's run before findRegistry is called. Yay static inializers + + public static final IForgeRegistry BLOCKS = GameRegistry.findRegistry(Block.class); + public static final IForgeRegistry ITEMS = GameRegistry.findRegistry(Item.class); + public static final IForgeRegistry POTIONS = GameRegistry.findRegistry(Potion.class); + public static final IForgeRegistry BIOMES = GameRegistry.findRegistry(BiomeGenBase.class); + public static final IForgeRegistry SOUND_EVENTS = GameRegistry.findRegistry(SoundEvent.class); + public static final IForgeRegistry POTION_TYPES = GameRegistry.findRegistry(PotionType.class); + public static final IForgeRegistry ENCHANTMENTS = GameRegistry.findRegistry(Enchantment.class); + public static final IForgeRegistry VILLAGER_PROFESSIONS = GameRegistry.findRegistry(VillagerProfession.class); + + + /** + * This function is just to make sure static inializers in other classes have run and setup their registries before we query them. + */ + private static void init() + { + GameData.getMain(); + VillagerRegistry.instance(); + } + +} diff --git a/src/main/java/net/minecraftforge/fml/common/registry/GameData.java b/src/main/java/net/minecraftforge/fml/common/registry/GameData.java index 80e94566c5..15a937f2a6 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/GameData.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/GameData.java @@ -14,112 +14,128 @@ package net.minecraftforge.fml.common.registry; import java.util.Map; +import com.google.common.collect.HashBiMap; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionType; import net.minecraft.util.ObjectIntIdentityMap; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundEvent; +import net.minecraft.util.registry.RegistryNamespaced; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModContainer; import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; +import org.apache.logging.log4j.Level; public class GameData { - static final int MIN_BLOCK_ID = 0; - static final int MAX_BLOCK_ID = 4095; - static final int MIN_ITEM_ID = 4096; - static final int MAX_ITEM_ID = 31999; - public static final int MIN_POTION_ID = 0; // 0-~31 are vanilla, forge start at 32 - public static final int MAX_POTION_ID = 255; // S1DPacketEntityEffect sends bytes, we can only use 255 + private static final int MIN_BLOCK_ID = 0; + private static final int MAX_BLOCK_ID = 4095; + private static final int MIN_ITEM_ID = 4096; + private static final int MAX_ITEM_ID = 31999; + private static final int MIN_POTION_ID = 0; // 0-~31 are vanilla, forge start at 32 + private static final int MAX_POTION_ID = 255; // SPacketEntityEffect sends bytes, we can only use 255 + private static final int MIN_BIOME_ID = 0; + private static final int MAX_BIOME_ID = 255; // Maximum number in a byte in the chunk + private static final int MIN_SOUND_ID = 0; // Varint + private static final int MAX_SOUND_ID = Integer.MAX_VALUE >> 5; // Varint (SPacketSoundEffect) + private static final int MIN_POTIONTYPE_ID = 0; // Int + private static final int MAX_POTIONTYPE_ID = Integer.MAX_VALUE >> 5; // Int (SPacketEffect) + private static final int MIN_ENCHANTMENT_ID = 0; // Int + private static final int MAX_ENCHANTMENT_ID = Integer.MAX_VALUE >> 5; // Int - not serialized as an ID? + + private static final ResourceLocation BLOCK_TO_ITEM = new ResourceLocation("minecraft:blocktoitemmap"); + private static final ResourceLocation BLOCKSTATE_TO_ID = new ResourceLocation("minecraft:blockstatetoid"); private static final GameData mainData = new GameData(); - // public api - /** - * Get the currently active block registry. - * - * @return Block Registry. - */ + public GameData() + { + iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MIN_BLOCK_ID, MAX_BLOCK_ID, true, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE); + iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MIN_ITEM_ID, MAX_ITEM_ID, true, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE); + iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MIN_POTION_ID, MAX_POTION_ID, false, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE); + iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, BiomeGenBase.class, null, MIN_BIOME_ID, MAX_BIOME_ID, false, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE); + iSoundEventRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.SOUNDEVENTS, SoundEvent.class, null, MIN_SOUND_ID, MAX_SOUND_ID, false, null, null, null); + ResourceLocation WATER = new ResourceLocation("water"); + iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null); + iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null); + } + // internal registry objects + private final FMLControlledNamespacedRegistry iBlockRegistry; + private final FMLControlledNamespacedRegistry iItemRegistry; + private final FMLControlledNamespacedRegistry iPotionRegistry; + private final FMLControlledNamespacedRegistry iBiomeRegistry; + private final FMLControlledNamespacedRegistry iSoundEventRegistry; + private final FMLControlledNamespacedRegistry iPotionTypeRegistry; + private final FMLControlledNamespacedRegistry iEnchantmentRegistry; + + /** INTERNAL ONLY */ + @Deprecated public static FMLControlledNamespacedRegistry getBlockRegistry() { return getMain().iBlockRegistry; } - /** - * Get the currently active item registry. - * - * @return Item Registry. - */ + /** INTERNAL ONLY */ + @Deprecated public static FMLControlledNamespacedRegistry getItemRegistry() { return getMain().iItemRegistry; } - /** - * Get the currently active potion registry. - * - * @return Potion Registry. - */ + /** INTERNAL ONLY */ + @Deprecated public static FMLControlledNamespacedRegistry getPotionRegistry() { return getMain().iPotionRegistry; } + /** INTERNAL ONLY */ + @Deprecated + public static FMLControlledNamespacedRegistry getBiomeRegistry() { return getMain().iBiomeRegistry; } - /*************************************************** - * INTERNAL CODE FROM HERE ON DO NOT USE! - ***************************************************/ + /** INTERNAL ONLY */ + @Deprecated + public static FMLControlledNamespacedRegistry getSoundEventRegistry() { return getMain().iSoundEventRegistry; } + /** INTERNAL ONLY */ + @Deprecated + public static FMLControlledNamespacedRegistry getPotionTypesRegistry() { return getMain().iPotionTypeRegistry; } + /** INTERNAL ONLY */ + @Deprecated + public static FMLControlledNamespacedRegistry getEnchantmentRegistry() { return getMain().iEnchantmentRegistry; } + + @Deprecated static Item findItem(String modId, String name) { return getMain().iItemRegistry.getObject(new ResourceLocation(modId, name)); } + @Deprecated static Block findBlock(String modId, String name) { return getMain().iBlockRegistry.getObject(new ResourceLocation(modId, name)); } - static GameRegistry.UniqueIdentifier getUniqueName(Block block) - { - if (block == null) - { - return null; - } - Object name = getMain().iBlockRegistry.getNameForObject(block); - return new GameRegistry.UniqueIdentifier(name); - } - - static GameRegistry.UniqueIdentifier getUniqueName(Item item) - { - if (item == null) - { - return null; - } - Object name = getMain().iItemRegistry.getNameForObject(item); - return new GameRegistry.UniqueIdentifier(name); - } - protected static GameData getMain() { return mainData; } - // internal registry objects - private final FMLControlledNamespacedRegistry iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MAX_BLOCK_ID, MIN_BLOCK_ID, true, BlockStateCapture.INSTANCE); - private final FMLControlledNamespacedRegistry iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MAX_ITEM_ID, MIN_ITEM_ID, true, ItemBlockCapture.INSTANCE); - private final FMLControlledNamespacedRegistry iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MAX_POTION_ID, MIN_POTION_ID, false, PotionArrayCapture.INSTANCE); - + @Deprecated int registerItem(Item item, String name) // from GameRegistry { return iItemRegistry.add(-1, addPrefix(name), item); } + @Deprecated int registerBlock(Block block, String name) // from GameRegistry { return iBlockRegistry.add(-1, addPrefix(name), block); @@ -166,42 +182,77 @@ public class GameData void registerSubstitutionAlias(String name, GameRegistry.Type type, Object toReplace) throws ExistingSubstitutionException { ResourceLocation nameToSubstitute = new ResourceLocation(name); + final BiMap blockItemMap = getBlockItemMap(); if (type == GameRegistry.Type.BLOCK) { iBlockRegistry.addSubstitutionAlias(Loader.instance().activeModContainer().getModId(), nameToSubstitute, (Block)toReplace); Block orig = iBlockRegistry.activateSubstitution(nameToSubstitute); - if (BLOCK_TO_ITEM.containsKey(orig)) + if (blockItemMap.containsKey(orig)) { - Item i = BLOCK_TO_ITEM.get(orig); - BLOCK_TO_ITEM.forcePut((Block)toReplace,i); + Item i = blockItemMap.get(orig); + blockItemMap.forcePut((Block)toReplace,i); } } else if (type == GameRegistry.Type.ITEM) { iItemRegistry.addSubstitutionAlias(Loader.instance().activeModContainer().getModId(), nameToSubstitute, (Item)toReplace); Item orig = iItemRegistry.activateSubstitution(nameToSubstitute); - if (BLOCK_TO_ITEM.containsValue(orig)) + if (blockItemMap.containsValue(orig)) { - Block b = BLOCK_TO_ITEM.inverse().get(orig); - BLOCK_TO_ITEM.forcePut(b, (Item)toReplace); + Block b = blockItemMap.inverse().get(orig); + blockItemMap.forcePut(b, (Item)toReplace); } } } - private static BiMap BLOCK_TO_ITEM = HashBiMap.create(); - - //Internal: DO NOT USE, will change without warning. - public static Map getBlockItemMap() + @SuppressWarnings("unchecked") + public static BiMap getBlockItemMap() { - return BLOCK_TO_ITEM; + return (BiMap)getMain().iItemRegistry.getSlaveMap(BLOCK_TO_ITEM, BiMap.class); } - private static ClearableObjectIntIdentityMap BLOCKSTATE_TO_ID = new ClearableObjectIntIdentityMap(); - - //Internal: DO NOT USE, will change without warning. - public static ClearableObjectIntIdentityMap getBlockStateIDMap() + @SuppressWarnings("unchecked") + static > K register_impl(Object object, ResourceLocation location) { - return BLOCKSTATE_TO_ID; + if (object == null) + { + FMLLog.getLogger().log(Level.ERROR, "Attempt to register a null object"); + throw new NullPointerException("Attempt to register a null object"); + } + ((K)object).setRegistryName(location); + // explicit type is needed for some reason + return GameData.register_impl(object); + } + + // argument is Object due to incorrect inferrence of the type if source level = 6, probably related to https://bugs.openjdk.java.net/browse/JDK-8026527 + @SuppressWarnings("unchecked") + static > K register_impl(Object object) + { + K castedObj = (K)object; + if (object == null) + { + FMLLog.getLogger().log(Level.ERROR, "Attempt to register a null object"); + throw new NullPointerException("Attempt to register a null object"); + } + if (castedObj.getRegistryName() == null) + { + FMLLog.getLogger().log(Level.ERROR, "Attempt to register object without having set a registry name {} (type {})", object, object.getClass().getName()); + throw new IllegalArgumentException(String.format("No registry name set for object %s (%s)", object, object.getClass().getName())); + } + final IForgeRegistry registry = PersistentRegistryManager.findRegistry(castedObj); + registry.register(castedObj); + return castedObj; + } + + @SuppressWarnings("unchecked") + public static ObjectIntIdentityMap getBlockStateIDMap() + { + return (ObjectIntIdentityMap)getMain().iBlockRegistry.getSlaveMap(BLOCKSTATE_TO_ID, ObjectIntIdentityMap.class); + } + + public static void vanillaSnapshot() + { + PersistentRegistryManager.freezeVanilla(); } //Lets us clear the map so we can rebuild it. @@ -214,49 +265,116 @@ public class GameData } } - public RegistryDelegate makeDelegate(T obj, Class rootClass) + public > RegistryDelegate makeDelegate(T obj, Class rootClass) { return PersistentRegistryManager.makeDelegate(obj, rootClass); } - private static class BlockStateCapture implements FMLControlledNamespacedRegistry.AddCallback + private static class BlockCallbacks implements IForgeRegistry.AddCallback,IForgeRegistry.ClearCallback,IForgeRegistry.CreateCallback { - static final BlockStateCapture INSTANCE = new BlockStateCapture(); + static final BlockCallbacks INSTANCE = new BlockCallbacks(); + @SuppressWarnings("unchecked") @Override - public void onAdd(Block block, int blockId) + public void onAdd(Block block, int blockId, Map slaves) { + ClearableObjectIntIdentityMap blockstateMap = (ClearableObjectIntIdentityMap)slaves.get(BLOCKSTATE_TO_ID); for (IBlockState state : block.getBlockState().getValidStates()) { - GameData.BLOCKSTATE_TO_ID.put(state, blockId << 4 | block.getMetaFromState(state)); + blockstateMap.put(state, blockId << 4 | block.getMetaFromState(state)); } } + + @SuppressWarnings("unchecked") + @Override + public void onClear(Map slaveset) + { + ClearableObjectIntIdentityMap blockstateMap = (ClearableObjectIntIdentityMap)slaveset.get(BLOCKSTATE_TO_ID); + blockstateMap.clear(); + } + + @SuppressWarnings("unchecked") + @Override + public void onCreate(Map slaveset) + { + final ClearableObjectIntIdentityMap idMap = new ClearableObjectIntIdentityMap(); + ((Map)slaveset).put(BLOCKSTATE_TO_ID, idMap); + + } } - private static class ItemBlockCapture implements FMLControlledNamespacedRegistry.AddCallback + private static class ItemCallbacks implements IForgeRegistry.AddCallback,IForgeRegistry.ClearCallback,IForgeRegistry.CreateCallback { - static final ItemBlockCapture INSTANCE = new ItemBlockCapture(); + static final ItemCallbacks INSTANCE = new ItemCallbacks(); @Override - public void onAdd(Item item, int blockId) + public void onAdd(Item item, int blockId, Map slaves) { if (item instanceof ItemBlock) { ItemBlock itemBlock = (ItemBlock)item; - BLOCK_TO_ITEM.forcePut(itemBlock.getBlock().delegate.get(), item); + @SuppressWarnings("unchecked") BiMap blockToItem = (BiMap)slaves.get(BLOCK_TO_ITEM); + blockToItem.forcePut(itemBlock.getBlock().delegate.get(), item); } } - } - - private static class PotionArrayCapture implements FMLControlledNamespacedRegistry.AddCallback - { - static final PotionArrayCapture INSTANCE = new PotionArrayCapture(); + @SuppressWarnings("unchecked") @Override - public void onAdd(Potion potion, int id) { - // fix the data in the potion and the potions-array - potion.id = id; - Potion.potionTypes[id] = potion; + public void onClear(Map slaveset) + { + Map map = (Map)slaveset.get(BLOCK_TO_ITEM); + map.clear(); + } + + @SuppressWarnings("unchecked") + @Override + public void onCreate(Map slaveset) + { + final HashBiMap map = HashBiMap.create(); + ((Map)slaveset).put(BLOCK_TO_ITEM, map); } } -} \ No newline at end of file + + private static class PotionCallbacks implements IForgeRegistry.AddCallback,IForgeRegistry.ClearCallback,IForgeRegistry.CreateCallback + { + static final PotionCallbacks INSTANCE = new PotionCallbacks(); + + @Override + public void onAdd(Potion potion, int id, Map slaves) { + // no op for the minute? + } + + @Override + public void onClear(Map slaveset) + { + // no op for the minute? + } + + @Override + public void onCreate(Map slaveset) + { + // no op for the minute? + } + } + private static class BiomeCallbacks implements IForgeRegistry.AddCallback,IForgeRegistry.ClearCallback,IForgeRegistry.CreateCallback + { + static final BiomeCallbacks INSTANCE = new BiomeCallbacks(); + + @Override + public void onAdd(BiomeGenBase potion, int id, Map slaves) { + // no op for the minute? + } + + @Override + public void onClear(Map slaveset) + { + // no op for the minute? + } + + @Override + public void onCreate(Map slaveset) + { + // no op for the minute? + } + } +} diff --git a/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java index ee5b0fcfb7..232e6053ef 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/GameRegistry.java @@ -39,6 +39,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkGenerator; import net.minecraft.world.chunk.IChunkProvider; import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.IFuelHandler; @@ -50,7 +51,6 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper; import org.apache.logging.log4j.Level; -import com.google.common.base.Objects; import com.google.common.base.Strings; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; @@ -60,6 +60,7 @@ import com.google.common.collect.ObjectArrays; import com.google.common.collect.Sets; import com.google.common.primitives.Ints; +@SuppressWarnings({"WeakerAccess", "unused"}) public class GameRegistry { private static Set worldGenerators = Sets.newHashSet(); @@ -94,7 +95,7 @@ public class GameRegistry * @param chunkGenerator The chunk generator * @param chunkProvider The chunk provider */ - public static void generateWorld(int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + public static void generateWorld(int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if (sortedGeneratorList == null) { @@ -128,42 +129,72 @@ public class GameRegistry } /** - * Register an item with the item registry with a the name specified in Item.getRegistryName() + * Register the previously named {@link IForgeRegistry} object with the registry system. + * Always ensure the object is already named using {@link IForgeRegistryEntry#setRegistryName(ResourceLocation)} + * or another mechanism. * - * @param item The item to register + * Note: That DOES NOT create the ItemBlock for you if this is a Block, you should register that item separately. + * + * @param object The object to register with a registry + * @param The registry supertype + * @throws IllegalArgumentException if the object is not yet named (use {@link #register(IForgeRegistryEntry, ResourceLocation)} instead) + * @return The object */ - public static void registerItem(Item item) + @SuppressWarnings("unchecked") + public static > K register(K object) { - registerItem(item, item.getRegistryName()); + return (K)GameData.register_impl(object); } /** - * Register an item with the item registry with a custom name : this allows for easier server->client resolution + * Register the unnamed {@link IForgeRegistry} object with the registry system. + * Always make sure you have not previously named the object. * - * @param item The item to register - * @param name The mod-unique name of the item + * It is advised that you set the object's registry name and use {@link #register(IForgeRegistryEntry)} instead. + * + * Note: That DOES NOT create the ItemBlock for you if this is a Block, you should register that item separately. + * + * @param object The object to register + * @param name The name to register it with + * @param The registry supertype + * @throws IllegalStateException if the object already has an existing name (use {@link #register(IForgeRegistryEntry)} instead) + * @return The object */ - public static void registerItem(Item item, String name) + @SuppressWarnings("unchecked") + public static > K register(K object, ResourceLocation name) { - if (Strings.isNullOrEmpty(name)) - { - throw new IllegalArgumentException("Attempted to register a block with no name: " + item); - } - GameData.getMain().registerItem(item, name); + return (K)GameData.register_impl(object, name); + } + + + /** + * Registers a named block with the Block registry. This WILL create a new ItemBlock for you with the + * same name and register it with the ItemRegistry. This method is created as a convince method for + * modder and SHOULD NOT be used. Modders should create and register their ItemBlocks like normal items. + * + * @param block The block to register with a registry + * @throws IllegalArgumentException if the object is not yet named + * @return The block + */ + @Deprecated //Modders SHOULD NOT use this, so it'll stay deprecated. Purely added to make lazy modders happy -.- + public static Block registerWithItem(Block block) + { + register(block); + register(new ItemBlock(block).setRegistryName(block.getRegistryName())); + return block; } /** - * Register the specified Item with a mod specific name : overrides the standard type based name + * Retrieves the registry associated with this super class type. + * If the return is non-null it is HIGHLY recommended that modders cache this + * value as the return will never change for a given type in a single run of Minecraft once set. * - * @param item The item to register - * @param name The mod-unique name to register it as - null will remove a custom name - * @param modId deprecated, unused + * @param registryType The base class of items in this registry. + * @return The registry, Null if none is registered. */ - @Deprecated // See version without modID remove in 1.9 - public static Item registerItem(Item item, String name, String modId) + public static > IForgeRegistry findRegistry(Class registryType) { - registerItem(item, name); - return item; + return PersistentRegistryManager.findRegistryByType(registryType); } /** @@ -182,111 +213,6 @@ public class GameRegistry GameData.getMain().registerSubstitutionAlias(nameToSubstitute, type, object); } - /** - * Register a block with the name that Block.getRegistryName returns. - * - * @param block The block to register - */ - public static Block registerBlock(Block block) - { - return registerBlock(block, block.getRegistryName()); - } - - /** - * Register a block with the specified mod specific name - * - * @param block The block to register - * @param name The mod-unique name to register it as, will get prefixed by your modid. - */ - public static Block registerBlock(Block block, String name) - { - return registerBlock(block, ItemBlock.class, name); - } - - /** - * Register a block with the world, with the specified item class using Block.getRegistryName's name - * - * @param block The block to register - * @param itemclass The item type to register with it : null registers a block without associated item. - */ - public static Block registerBlock(Block block, Class itemclass) - { - return registerBlock(block, itemclass, block.getRegistryName()); - } - - /** - * Register a block with the world, with the specified item class and block name - * - * @param block The block to register - * @param itemclass The item type to register with it : null registers a block without associated item. - * @param name The mod-unique name to register it as, will get prefixed by your modid. - */ - public static Block registerBlock(Block block, Class itemclass, String name) - { - return registerBlock(block, itemclass, name, new Object[] {}); - } - - - /** - * Register a block with the world, with the specified item class using Block.getRegistryName's name - * - * @param block The block to register - * @param itemclass The item type to register with it : null registers a block without associated item. - * @param itemCtorArgs Arguments to pass (after the required {@code Block} parameter) to the ItemBlock constructor (optional). - */ - public static Block registerBlock(Block block, Class itemclass, Object... itemCtorArgs) - { - return registerBlock(block, itemclass, block.getRegistryName(), itemCtorArgs); - } - - /** - * Register a block with the world, with the specified item class, block name and owning modId - * - * @param block The block to register - * @param itemclass The item type to register with it : null registers a block without associated item. - * @param name The mod-unique name to register it as, will get prefixed by your modid. - * @param itemCtorArgs Arguments to pass (after the required {@code Block} parameter) to the ItemBlock constructor (optional). - */ - public static Block registerBlock(Block block, Class itemclass, String name, Object... itemCtorArgs) - { - if (Strings.isNullOrEmpty(name)) - { - throw new IllegalArgumentException("Attempted to register a block with no name: " + block); - } - if (Loader.instance().isInState(LoaderState.CONSTRUCTING)) - { - FMLLog.warning("The mod %s is attempting to register a block whilst it it being constructed. This is bad modding practice - please use a proper mod lifecycle event.", Loader.instance().activeModContainer()); - } - try - { - assert block != null : "registerBlock: block cannot be null"; - ItemBlock i = null; - if (itemclass != null) - { - Class[] ctorArgClasses = new Class[itemCtorArgs.length + 1]; - ctorArgClasses[0] = Block.class; - for (int idx = 1; idx < ctorArgClasses.length; idx++) - { - ctorArgClasses[idx] = itemCtorArgs[idx - 1].getClass(); - } - Constructor itemCtor = itemclass.getConstructor(ctorArgClasses); - i = itemCtor.newInstance(ObjectArrays.concat(block, itemCtorArgs)); - } - // block registration has to happen first - GameData.getMain().registerBlock(block, name); - if (i != null) - { - GameData.getMain().registerItem(i, name); - GameData.getBlockItemMap().put(block, i); - } - return block; - } catch (Exception e) - { - FMLLog.log(Level.ERROR, e, "Caught an exception during block registration"); - throw new LoaderException(e); - } - } - public static void addRecipe(ItemStack output, Object... params) { addShapedRecipe(output, params); @@ -363,136 +289,12 @@ public class GameRegistry return fuelValue; } - /** - * Look up a mod block in the global "named item list" - * - * @param modId The modid owning the block - * @param name The name of the block itself - * @return The block or null if not found - */ - public static Block findBlock(String modId, String name) - { - return GameData.findBlock(modId, name); - } - - /** - * Look up a mod item in the global "named item list" - * - * @param modId The modid owning the item - * @param name The name of the item itself - * @return The item or null if not found - */ - public static Item findItem(String modId, String name) - { - return GameData.findItem(modId, name); - } - - /** - * Will be switching to using ResourceLocation, since it's used widely elsewhere - */ - @Deprecated - public static final class UniqueIdentifier - { - public final String modId; - public final String name; - - UniqueIdentifier(String modId, String name) - { - this.modId = modId; - this.name = name; - } - - public UniqueIdentifier(String string) - { - String[] parts = string.split(":"); - this.modId = parts[0]; - this.name = parts[1]; - } - - public UniqueIdentifier(Object obj) - { - if (obj instanceof String) - { - String[] parts = ((String)obj).split(":"); - this.modId = parts[0]; - this.name = parts[1]; - } - else if (obj instanceof ResourceLocation) - { - this.modId = ((ResourceLocation)obj).getResourceDomain(); - this.name = ((ResourceLocation)obj).getResourcePath(); - } - else - { - throw new IllegalArgumentException("UniqueIdentifier must be a String or ResourceLocation, was " + obj.getClass()); - } - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - if (obj.getClass() != this.getClass()) - { - return false; - } - final UniqueIdentifier other = (UniqueIdentifier)obj; - return Objects.equal(modId, other.modId) && Objects.equal(name, other.name); - } - - @Override - public int hashCode() - { - return Objects.hashCode(modId, name); - } - - @Override - public String toString() - { - return String.format("%s:%s", modId, name); - } - } - public enum Type { BLOCK, ITEM; } - /** - * Look up the mod identifier data for a block. - *

    - * Note: uniqueness and persistence is only guaranteed by mods using the game registry - * correctly. - * - * @param block to lookup - * @return a {@link UniqueIdentifier} for the block or null - */ - @Deprecated - public static UniqueIdentifier findUniqueIdentifierFor(Block block) - { - return GameData.getUniqueName(block); - } - - /** - * Look up the mod identifier data for an item. - *

    - * Note: uniqueness and persistence is only guaranteed by mods using the game registry - * correctly. - * - * @param item to lookup - * @return a {@link UniqueIdentifier} for the item or null - */ - @Deprecated - public static UniqueIdentifier findUniqueIdentifierFor(Item item) - { - return GameData.getUniqueName(item); - } - - /** * ObjectHolder can be used to automatically populate public static final fields with entries * from the registry. These values can then be referred within mod code directly. @@ -594,4 +396,132 @@ public class GameRegistry return is; } + + + + // ============================= DEPRECATED/INTERNAL MODDERS DO NOT USE ================================= + /** + * Use {@link #register(IForgeRegistryEntry)} instead + */ + @Deprecated public static void registerItem(Item item){ register(item); } + /** + * Use {@link #register(IForgeRegistryEntry)} instead + */ + @Deprecated + public static void registerItem(Item item, String name) + { + if (item.getRegistryName() == null && Strings.isNullOrEmpty(name)) + throw new IllegalArgumentException("Attempted to register a item with no name: " + item); + if (item.getRegistryName() != null && !item.getRegistryName().toString().equals(name)) + throw new IllegalArgumentException("Attempted to register a item with conflicting names. Old: " + item.getRegistryName() + " New: " + name); + register(item.getRegistryName() == null ? item.setRegistryName(name) : item); + } + /** + * Use {@link #register(IForgeRegistryEntry)} instead + */ + @Deprecated + public static Block registerBlock(Block block) + { + register(block); + register(new ItemBlock(block).setRegistryName(block.getRegistryName())); + return block; + } + /** + * Use {@link #register(IForgeRegistryEntry)} instead + */ + @Deprecated + public static Block registerBlock(Block block, String name) + { + if (block.getRegistryName() == null && Strings.isNullOrEmpty(name)) + throw new IllegalArgumentException("Attempted to register a Block with no name: " + block); + if (block.getRegistryName() != null && !block.getRegistryName().toString().equals(name)) + throw new IllegalArgumentException("Attempted to register a Block with conflicting names. Old: " + block.getRegistryName() + " New: " + name); + return registerBlock(block.getRegistryName() != null ? block : block.setRegistryName(name)); + } + /** + * Use {@link #register(IForgeRegistryEntry)} instead + */ + @Deprecated public static Block registerBlock(Block block, Class itemclass){ return registerBlock(block, itemclass, block.getRegistryName()); } + /** + * Use {@link #register(IForgeRegistryEntry)} instead + */ + @Deprecated public static Block registerBlock(Block block, Class itemclass, String name){ return registerBlock(block, itemclass, name, new Object[] {}); } + /** + * Use {@link #register(IForgeRegistryEntry)} instead + */ + @Deprecated public static Block registerBlock(Block block, Class itemclass, Object... itemCtorArgs){ return registerBlock(block, itemclass, block.getRegistryName().toString(), itemCtorArgs); } + /** + * Use {@link #register(IForgeRegistryEntry)} instead + */ + @Deprecated + public static Block registerBlock(Block block, Class itemclass, String name, Object... itemCtorArgs) + { + if (Strings.isNullOrEmpty(name)) + { + throw new IllegalArgumentException("Attempted to register a block with no name: " + block); + } + if (Loader.instance().isInState(LoaderState.CONSTRUCTING)) + { + FMLLog.warning("The mod %s is attempting to register a block whilst it it being constructed. This is bad modding practice - please use a proper mod lifecycle event.", Loader.instance().activeModContainer()); + } + try + { + assert block != null : "registerBlock: block cannot be null"; + if (block.getRegistryName() != null && !block.getRegistryName().toString().equals(name)) + throw new IllegalArgumentException("Attempted to register a Block with conflicting names. Old: " + block.getRegistryName() + " New: " + name); + ItemBlock i = null; + if (itemclass != null) + { + Class[] ctorArgClasses = new Class[itemCtorArgs.length + 1]; + ctorArgClasses[0] = Block.class; + for (int idx = 1; idx < ctorArgClasses.length; idx++) + { + ctorArgClasses[idx] = itemCtorArgs[idx - 1].getClass(); + } + Constructor itemCtor = itemclass.getConstructor(ctorArgClasses); + i = itemCtor.newInstance(ObjectArrays.concat(block, itemCtorArgs)); + } + // block registration has to happen first + register(block.getRegistryName() == null ? block.setRegistryName(name) : block); + if (i != null) + register(i.setRegistryName(name)); + return block; + } catch (Exception e) + { + FMLLog.log(Level.ERROR, e, "Caught an exception during block registration"); + throw new LoaderException(e); + } + } + + /** + * + * Use Block.REGISTRY.getValue(ResourceLocation) instead! + * + * + * Look up a mod block in the global "named item list" + * + * @param modId The modid owning the block + * @param name The name of the block itself + * @return The block or null if not found + */ + @Deprecated + public static Block findBlock(String modId, String name) + { + return GameData.findBlock(modId, name); + } + + /** + * Use Item.REGISTRY.getValue(ResourceLocation) instead! + * + * Look up a mod item in the global "named item list" + * + * @param modId The modid owning the item + * @param name The name of the item itself + * @return The item or null if not found + */ + @Deprecated + public static Item findItem(String modId, String name) + { + return GameData.findItem(modId, name); + } } diff --git a/src/main/java/net/minecraftforge/fml/common/registry/IForgeRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/IForgeRegistry.java new file mode 100644 index 0000000000..eb00d5b571 --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/common/registry/IForgeRegistry.java @@ -0,0 +1,67 @@ +package net.minecraftforge.fml.common.registry; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import net.minecraft.util.ResourceLocation; + +/** + * Main interface for the registry system. Use this to query the registry system. + * + * @param The top level type for the registry + */ +@SuppressWarnings({"WeakerAccess", "unused"}) +public interface IForgeRegistry> extends Iterable +{ + public Class getRegistrySuperType(); + + void register(V value); + + boolean containsKey(ResourceLocation key); + boolean containsValue(V value); + + V getValue(ResourceLocation key); + ResourceLocation getKey(V value); + + Set getKeys(); + List getValues(); + Set> getEntries(); + + /** + * Retrieve the slave map of type T from the registry. + * Slave maps are maps which are dependent on registry content in some way. + * @param slaveMapName The name of the slavemap + * @param type The type + * @param Type to return + * @return The slavemap if present + */ + T getSlaveMap(ResourceLocation slaveMapName, Class type); + + /** + * Callback fired when objects are added to the registry. This will fire when the registry is rebuilt + * on the client side from a server side synchronization, or when a world is loaded. + */ + interface AddCallback + { + void onAdd(V obj, int id, Map slaveset); + } + + /** + * Callback fired when the registry is cleared. This is done before a registry is reloaded from client + * or server. + */ + interface ClearCallback + { + void onClear(Map slaveset); + } + + /** + * Callback fired when a registry instance is created. Populate slave maps here. + */ + interface CreateCallback + { + void onCreate(Map slaveset); + } +} diff --git a/src/main/java/net/minecraftforge/fml/common/registry/IForgeRegistryEntry.java b/src/main/java/net/minecraftforge/fml/common/registry/IForgeRegistryEntry.java new file mode 100644 index 0000000000..b0f3a445ac --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/common/registry/IForgeRegistryEntry.java @@ -0,0 +1,83 @@ +package net.minecraftforge.fml.common.registry; + +import com.google.common.reflect.TypeToken; + +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.FMLContainer; +import net.minecraftforge.fml.common.FMLLog; +import net.minecraftforge.fml.common.InjectedModContainer; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; + +public interface IForgeRegistryEntry +{ + /** + * Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item. + * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does. + * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items. + * + * The supplied name will be prefixed with the currently active mod's modId. + * If the supplied name already has a prefix that is different, it will be used and a warning will be logged. + * + * If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown. + * + * Returns 'this' to allow for chaining. + * + * @param name Unique registry name + * @return This instance + */ + V setRegistryName(ResourceLocation name); + + /** + * A unique identifier for this entry, if this entry is registered already it will return it's official registry name. + * Otherwise it will return the name set in setRegistryName(). + * If neither are valid null is returned. + * + * @return Unique identifier or null. + */ + ResourceLocation getRegistryName(); + + Class getRegistryType(); + + // Default implementation, modders who make extra items SHOULD extend this instead of Object. + // We have to do this until we get default implementations in Java 8. + @SuppressWarnings({ "serial", "unchecked" }) + public static class Impl> implements IForgeRegistryEntry + { + private TypeToken token = new TypeToken(getClass()){}; + public final RegistryDelegate delegate = PersistentRegistryManager.makeDelegate((T)this, (Class)token.getRawType()); + private ResourceLocation registryName = null; + + public final T setRegistryName(String name) + { + if (getRegistryName() != null) + throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName()); + + int index = name.lastIndexOf(':'); + String oldPrefix = index == -1 ? "" : name.substring(0, index); + name = index == -1 ? name : name.substring(index + 1); + ModContainer mc = Loader.instance().activeModContainer(); + String prefix = mc == null || (mc instanceof InjectedModContainer && ((InjectedModContainer)mc).wrappedContainer instanceof FMLContainer) ? "minecraft" : mc.getModId().toLowerCase(); + if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0) + { + FMLLog.bigWarning("Dangerous alternative prefix `%s` for name `%s`, expected `%s` invalid registry invocation/invalid name?", oldPrefix, name, prefix); + prefix = oldPrefix; + } + this.registryName = new ResourceLocation(prefix, name); + return (T)this; + } + + //Helper functions + public final T setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); } + public final T setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); } + + public final ResourceLocation getRegistryName() + { + if (delegate.name() != null) return delegate.name(); + return registryName != null ? registryName : null; + } + + @Override + public final Class getRegistryType() { return token.getRawType(); }; + } +} diff --git a/src/main/java/net/minecraftforge/fml/common/registry/LanguageRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/LanguageRegistry.java deleted file mode 100644 index 217495171b..0000000000 --- a/src/main/java/net/minecraftforge/fml/common/registry/LanguageRegistry.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Forge Mod Loader - * Copyright (c) 2012-2013 cpw. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v2.1 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * - * Contributors: - * cpw - implementation - */ - -package net.minecraftforge.fml.common.registry; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.apache.logging.log4j.Level; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StringTranslate; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.relauncher.Side; - -import com.google.common.base.Charsets; -import com.google.common.base.Joiner; -import com.google.common.collect.Lists; - -public class LanguageRegistry -{ - private static final LanguageRegistry INSTANCE = new LanguageRegistry(); - - private Map modLanguageData=new HashMap(); - - private static final Pattern assetENUSLang = Pattern.compile("assets/(.*)/lang/(?:.+/|)([\\w_-]+).lang"); - - public static LanguageRegistry instance() - { - return INSTANCE; - } - - public String getStringLocalization(String key) - { - return getStringLocalization(key, FMLCommonHandler.instance().getCurrentLanguage()); - } - - public String getStringLocalization(String key, String lang) - { - String localizedString = ""; - Properties langPack = modLanguageData.get(lang); - - if (langPack != null) { - if (langPack.getProperty(key) != null) { - localizedString = langPack.getProperty(key); - } - } - - return localizedString; - } - - /** - * Deprecated for removal in 1.8. Use the assets lang system - */ - @Deprecated - public void addStringLocalization(String key, String value) - { - addStringLocalization(key, "en_US", value); - } - - /** - * Deprecated for removal in 1.8. Use the assets lang system - */ - @Deprecated - public void addStringLocalization(String key, String lang, String value) - { - Properties langPack=modLanguageData.get(lang); - if (langPack==null) { - langPack=new Properties(); - modLanguageData.put(lang, langPack); - } - langPack.put(key,value); - } - - /** - * Deprecated for removal in 1.8. Use the assets lang system - */ - @Deprecated - public void addStringLocalization(Properties langPackAdditions) { - addStringLocalization(langPackAdditions, "en_US"); - } - - /** - * Deprecated for removal in 1.8. Use the assets lang system - */ - @Deprecated - public void addStringLocalization(Properties langPackAdditions, String lang) { - Properties langPack = modLanguageData.get(lang); - if (langPack == null) { - langPack = new Properties(); - modLanguageData.put(lang, langPack); - } - if (langPackAdditions != null) { - langPack.putAll(langPackAdditions); - } - } - - /** - * Deprecated for removal in 1.8. Use the assets lang system - */ - @Deprecated - public void addNameForObject(Object objectToName, String lang, String name) - { - String objectName; - if (objectToName instanceof Item) { - objectName=((Item)objectToName).getUnlocalizedName(); - } else if (objectToName instanceof Block) { - objectName=((Block)objectToName).getUnlocalizedName(); - } else if (objectToName instanceof ItemStack) { - objectName=((ItemStack)objectToName).getItem().getUnlocalizedName((ItemStack)objectToName); - } else { - throw new IllegalArgumentException(String.format("Illegal object for naming %s",objectToName)); - } - objectName+=".name"; - addStringLocalization(objectName, lang, name); - } - - /** - * Deprecated for removal in 1.8. Use the assets lang system - */ - @Deprecated - public static void addName(Object objectToName, String name) - { - instance().addNameForObject(objectToName, "en_US", name); - } - - /** - * Deprecated for removal in 1.8. Use the assets lang system - */ - @SuppressWarnings("unchecked") - @Deprecated - public void mergeLanguageTable(@SuppressWarnings("rawtypes") Map properties, String lang) - { - Properties langPack=modLanguageData.get(lang); - if (langPack!=null) { - mergeWithoutOverwrite(langPack, properties); - } - Properties usPack=modLanguageData.get("en_US"); - if (usPack!=null) { - mergeWithoutOverwrite(usPack, properties); - } - } - - @Deprecated - private void mergeWithoutOverwrite(Map from, Map to) - { - for (Entry e : from.entrySet()) - { - if (!to.containsKey(e.getKey())) - { - to.put(e.getKey(),e.getValue()); - } - } - } - /** - * Deprecated for removal in 1.8. Use the assets lang system - */ - @Deprecated - public void loadLocalization(String localizationFile, String lang, boolean isXML) - { - URL urlResource = this.getClass().getResource(localizationFile); - if (urlResource != null) - { - loadLocalization(urlResource, lang, isXML); - } - else - { - ModContainer activeModContainer = Loader.instance().activeModContainer(); - if (activeModContainer!=null) - { - FMLLog.log(activeModContainer.getModId(), Level.ERROR, "The language resource %s cannot be located on the classpath. This is a programming error.", localizationFile); - } - else - { - FMLLog.log(Level.ERROR, "The language resource %s cannot be located on the classpath. This is a programming error.", localizationFile); - } - } - } - - /** - * Deprecated for removal in 1.8. Use the assets lang system - */ - @Deprecated - public void loadLocalization(URL localizationFile, String lang, boolean isXML) - { - InputStream langStream = null; - Properties langPack = new Properties(); - - try { - langStream = localizationFile.openStream(); - - if (isXML) { - langPack.loadFromXML(langStream); - } - else { - langPack.load(new InputStreamReader(langStream,Charsets.UTF_8)); - } - - addStringLocalization(langPack, lang); - } - catch (IOException e) { - FMLLog.log(Level.ERROR, e, "Unable to load localization from file %s", localizationFile); - } - finally { - try { - if (langStream != null) { - langStream.close(); - } - } - catch (IOException ex) { - // HUSH - } - } - } - - public void injectLanguage(String language, HashMap parsedLangFile) - { - - Properties p = modLanguageData.get(language); - if (p == null) - { - p = new Properties(); - modLanguageData.put(language, p); - } - p.putAll(parsedLangFile); - } - - public void loadLanguagesFor(ModContainer container, Side side) - { - File source = container.getSource(); - try - { - if (source.isDirectory()) - { - searchDirForLanguages(source, "", side); - } - else - { - searchZipForLanguages(source, side); - } - } - catch (IOException ioe) - { - - } - } - - private void searchZipForLanguages(File source, Side side) throws IOException - { - ZipFile zf = new ZipFile(source); - List added = Lists.newArrayList(); - for (ZipEntry ze : Collections.list(zf.entries())) - { - Matcher matcher = assetENUSLang.matcher(ze.getName()); - if (matcher.matches()) - { - String lang = matcher.group(2); - //FMLLog.fine("Injecting found translation data for lang %s in zip file %s at %s into language system", lang, source.getName(), ze.getName()); - added.add(lang); - LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(zf.getInputStream(ze))); - // Ensure en_US is available to StringTranslate on the server - if ("en_US".equals(lang) && side == Side.SERVER) - { - StringTranslate.inject(zf.getInputStream(ze)); - } - } - } - if (added.size() > 0) - FMLLog.fine("Found translations in %s [%s]", source.getName(), Joiner.on(", ").join(added)); - zf.close(); - } - - private void searchDirForLanguages(File source, String path, Side side) throws IOException - { - for (File file : source.listFiles()) - { - String currPath = path+file.getName(); - if (file.isDirectory()) - { - searchDirForLanguages(file, currPath+'/', side); - } - Matcher matcher = assetENUSLang.matcher(currPath); - if (matcher.matches()) - { - String lang = matcher.group(2); - FMLLog.fine("Injecting found translation assets for lang %s at %s into language system", lang, currPath); - LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(new FileInputStream(file))); - // Ensure en_US is available to StringTranslate on the server - if ("en_US".equals(lang) && side == Side.SERVER) - { - StringTranslate.inject(new FileInputStream(file)); - } - } - } - } -} diff --git a/src/main/java/net/minecraftforge/fml/common/registry/PersistentRegistryManager.java b/src/main/java/net/minecraftforge/fml/common/registry/PersistentRegistryManager.java index 8e8c4f7051..0001b425f1 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/PersistentRegistryManager.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/PersistentRegistryManager.java @@ -1,7 +1,6 @@ package net.minecraftforge.fml.common.registry; import java.io.IOException; -import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; @@ -9,6 +8,20 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.EnhancedRuntimeException; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.FMLLog; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.StartupQuery; +import net.minecraftforge.fml.common.ZipperUtil; +import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; + +import org.apache.logging.log4j.Level; + import com.google.common.base.Function; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; @@ -19,21 +32,6 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import com.google.common.collect.Sets.SetView; -import org.apache.logging.log4j.Level; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; -import net.minecraft.item.Item; -import net.minecraft.potion.Potion; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.EnhancedRuntimeException; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.StartupQuery; -import net.minecraftforge.fml.common.ZipperUtil; -import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; - /** * Persistent registry manager. Manages the registries loading from disk, and from network. Handles staging * registry data before loading uniformly into the active registry, and keeps a frozen registry instance @@ -41,22 +39,29 @@ import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; * * @author cpw */ +@SuppressWarnings("WeakerAccess") public class PersistentRegistryManager { private enum PersistentRegistry { - ACTIVE, FROZEN, STAGING; + ACTIVE, VANILLA, FROZEN, STAGING; private final BiMap> registries = HashBiMap.create(); - private final BiMap, ResourceLocation> registrySuperTypes = HashBiMap.create(); + private final BiMap>, ResourceLocation> registrySuperTypes = HashBiMap.create(); @SuppressWarnings("unchecked") - FMLControlledNamespacedRegistry getRegistry(ResourceLocation key, Class regType) + private > Class getRegistrySuperType(ResourceLocation key) + { + return (Class)registrySuperTypes.inverse().get(key); + } + + @SuppressWarnings("unchecked") + private > FMLControlledNamespacedRegistry getRegistry(ResourceLocation key, @SuppressWarnings("UnusedParameters") Class regType) { return (FMLControlledNamespacedRegistry)registries.get(key); } - FMLControlledNamespacedRegistry getOrShallowCopyRegistry(ResourceLocation key, Class regType, FMLControlledNamespacedRegistry other) + private > FMLControlledNamespacedRegistry getOrShallowCopyRegistry(ResourceLocation key, Class regType, FMLControlledNamespacedRegistry other) { if (!registries.containsKey(key)) { @@ -66,12 +71,7 @@ public class PersistentRegistryManager return getRegistry(key, regType); } - private FMLControlledNamespacedRegistry createRegistry(ResourceLocation registryName, Class registryType, ResourceLocation optionalDefaultKey, int minId, int maxId, boolean hasDelegates) - { - return this.createRegistry(registryName, registryType, optionalDefaultKey, minId, maxId, hasDelegates, null); - } - - private FMLControlledNamespacedRegistry createRegistry(ResourceLocation registryName, Class type, ResourceLocation defaultObjectKey, int minId, int maxId, boolean isDelegated, FMLControlledNamespacedRegistry.AddCallback addCallback) + private > FMLControlledNamespacedRegistry createRegistry(ResourceLocation registryName, Class type, ResourceLocation defaultObjectKey, int minId, int maxId, IForgeRegistry.AddCallback addCallback, IForgeRegistry.ClearCallback clearCallback, IForgeRegistry.CreateCallback createCallback) { Set> parents = Sets.newHashSet(); findSuperTypes(type, parents); @@ -82,7 +82,7 @@ public class PersistentRegistryManager FMLLog.severe("Found existing registry of type %1s named %2s, you cannot create a new registry (%3s) with type %4s, as %4s has a parent of that type", foundType, registrySuperTypes.get(foundType), registryName, type); throw new IllegalArgumentException("Duplicate registry parent type found - you can only have one registry for a particular super type"); } - FMLControlledNamespacedRegistry fmlControlledNamespacedRegistry = new FMLControlledNamespacedRegistry(defaultObjectKey, maxId, minId, type, isDelegated, addCallback); + FMLControlledNamespacedRegistry fmlControlledNamespacedRegistry = new FMLControlledNamespacedRegistry(defaultObjectKey, minId, maxId, type, addCallback, clearCallback, createCallback); registries.put(registryName, fmlControlledNamespacedRegistry); registrySuperTypes.put(type, registryName); return getRegistry(registryName, type); @@ -119,7 +119,7 @@ public class PersistentRegistryManager return registries.containsValue(registry); } - public FMLControlledNamespacedRegistry getRegistry(Class rootClass) + public > FMLControlledNamespacedRegistry getRegistry(Class rootClass) { ResourceLocation rl = registrySuperTypes.get(rootClass); return getRegistry(rl, rootClass); @@ -129,17 +129,35 @@ public class PersistentRegistryManager public static final ResourceLocation BLOCKS = new ResourceLocation("minecraft:blocks"); public static final ResourceLocation ITEMS = new ResourceLocation("minecraft:items"); public static final ResourceLocation POTIONS = new ResourceLocation("minecraft:potions"); + public static final ResourceLocation BIOMES = new ResourceLocation("minecraft:biomes"); + public static final ResourceLocation SOUNDEVENTS = new ResourceLocation("minecraft:soundevents"); + public static final ResourceLocation POTIONTYPES = new ResourceLocation("minecraft:potiontypes"); + public static final ResourceLocation ENCHANTMENTS = new ResourceLocation("minecraft:enchantments"); - public static FMLControlledNamespacedRegistry createRegistry(ResourceLocation registryName, Class registryType, ResourceLocation optionalDefaultKey, int maxId, int minId, boolean hasDelegates, FMLControlledNamespacedRegistry.AddCallback addCallback) + public static > FMLControlledNamespacedRegistry createRegistry(ResourceLocation registryName, Class registryType, ResourceLocation optionalDefaultKey, int minId, int maxId, boolean hasDelegates, IForgeRegistry.AddCallback addCallback, IForgeRegistry.ClearCallback clearCallback, IForgeRegistry.CreateCallback createCallback) { - return PersistentRegistry.ACTIVE.createRegistry(registryName, registryType, optionalDefaultKey, minId, maxId, hasDelegates, addCallback); + return PersistentRegistry.ACTIVE.createRegistry(registryName, registryType, optionalDefaultKey, minId, maxId, addCallback, clearCallback, createCallback); } - public static FMLControlledNamespacedRegistry createRegistry(ResourceLocation registryName, Class registryType, ResourceLocation optionalDefaultKey, int maxId, int minId, boolean hasDelegates) + @SuppressWarnings({ "unchecked", "rawtypes" }) + static > IForgeRegistry findRegistry(IForgeRegistryEntry entry) { - return PersistentRegistry.ACTIVE.createRegistry(registryName, registryType, optionalDefaultKey, minId, maxId, hasDelegates); + final Class registryType = (Class)(Class)entry.getRegistryType(); + final FMLControlledNamespacedRegistry registry = PersistentRegistry.ACTIVE.getRegistry(registryType); + if (registry == null) + { + FMLLog.getLogger().log(Level.ERROR, "Unable to locate registry for registered object of type {}", entry.getClass().getName()); + throw new IllegalArgumentException("Unable to locate registry for registered object"); + } + return registry; } + static > IForgeRegistry findRegistryByType(Class registryType) + { + return PersistentRegistry.ACTIVE.getRegistry(registryType); + } + + public static List injectSnapshot(GameDataSnapshot snapshot, boolean injectFrozenData, boolean isLocalWorld) { FMLLog.info("Injecting existing block and item data into this %s instance", FMLCommonHandler.instance().getEffectiveSide().isServer() ? "server" : "client"); @@ -150,15 +168,11 @@ public class PersistentRegistryManager forAllRegistries(PersistentRegistry.ACTIVE, DumpRegistryFunction.OPERATION); forAllRegistries(PersistentRegistry.ACTIVE, ResetDelegatesFunction.OPERATION); - // Empty the blockstate map before loading - GameData.getBlockStateIDMap().clear(); - // Clean up potion array before reloading it from the snapshot - Arrays.fill(Potion.potionTypes, null); - // Load the snapshot into the "STAGING" registry for (Map.Entry snapshotEntry : snapshot.entries.entrySet()) { - loadPersistentDataToStagingRegistry(injectFrozenData, remaps, missing, snapshotEntry, PersistentRegistry.ACTIVE.registrySuperTypes.inverse().get(snapshotEntry.getKey())); + final Class registrySuperType = PersistentRegistry.ACTIVE.getRegistrySuperType(snapshotEntry.getKey()); + loadPersistentDataToStagingRegistry(injectFrozenData, remaps, missing, snapshotEntry, registrySuperType); } // Handle dummied blocks @@ -216,7 +230,8 @@ public class PersistentRegistryManager // So we load it from the frozen persistent registry for (Map.Entry> r : PersistentRegistry.ACTIVE.registries.entrySet()) { - loadFrozenDataToStagingRegistry(remaps, r.getKey(), PersistentRegistry.ACTIVE.registrySuperTypes.inverse().get(r.getKey())); + final Class registrySuperType = PersistentRegistry.ACTIVE.getRegistrySuperType(r.getKey()); + loadFrozenDataToStagingRegistry(remaps, r.getKey(), registrySuperType); } } @@ -226,7 +241,8 @@ public class PersistentRegistryManager // Load the STAGING registry into the ACTIVE registry for (Map.Entry> r : PersistentRegistry.ACTIVE.registries.entrySet()) { - loadRegistry(r.getKey(), PersistentRegistry.STAGING, PersistentRegistry.ACTIVE, PersistentRegistry.ACTIVE.registrySuperTypes.inverse().get(r.getKey())); + final Class registrySuperType = PersistentRegistry.ACTIVE.getRegistrySuperType(r.getKey()); + loadRegistry(r.getKey(), PersistentRegistry.STAGING, PersistentRegistry.ACTIVE, registrySuperType); } // Dump the active registry @@ -257,7 +273,7 @@ public class PersistentRegistryManager } } - private static void loadRegistry(final ResourceLocation registryName, final PersistentRegistry from, final PersistentRegistry to, Class regType) + private static > void loadRegistry(final ResourceLocation registryName, final PersistentRegistry from, final PersistentRegistry to, final Class regType) { FMLControlledNamespacedRegistry fromRegistry = from.getRegistry(registryName, regType); if (fromRegistry == null) @@ -293,14 +309,14 @@ public class PersistentRegistryManager } } - private static void loadFrozenDataToStagingRegistry(Map> remaps, ResourceLocation registryName, Class regType) + private static > void loadFrozenDataToStagingRegistry(Map> remaps, ResourceLocation registryName, Class regType) { FMLControlledNamespacedRegistry frozenRegistry = PersistentRegistry.FROZEN.getRegistry(registryName, regType); FMLControlledNamespacedRegistry newRegistry = PersistentRegistry.STAGING.getOrShallowCopyRegistry(registryName, regType, frozenRegistry); newRegistry.loadIds(frozenRegistry.getEntriesNotIn(newRegistry), Maps.newLinkedHashMap(), remaps.get(registryName), frozenRegistry, registryName); } - private static void loadPersistentDataToStagingRegistry(boolean injectFrozenData, Map> remaps, LinkedHashMap> missing, Map.Entry snapEntry, Class regType) + private static > void loadPersistentDataToStagingRegistry(boolean injectFrozenData, Map> remaps, LinkedHashMap> missing, Map.Entry snapEntry, Class regType) { ResourceLocation registryName = snapEntry.getKey(); @@ -314,6 +330,7 @@ public class PersistentRegistryManager { FMLLog.severe("An unknown persistent registry type \"%s\" has been encountered. This Forge instance cannot understand it.", registryName); StartupQuery.abort(); + return; // fake exit to shut up null analysis } FMLControlledNamespacedRegistry newRegistry = PersistentRegistry.STAGING.getOrShallowCopyRegistry(registryName, regType, currentRegistry); // Copy the persistent substitution set from the currently active one into the new registry @@ -353,7 +370,8 @@ public class PersistentRegistryManager } for (Map.Entry> r : PersistentRegistry.ACTIVE.registries.entrySet()) { - loadRegistry(r.getKey(), PersistentRegistry.FROZEN, PersistentRegistry.ACTIVE, PersistentRegistry.ACTIVE.registrySuperTypes.inverse().get(r.getKey())); + final Class registrySuperType = PersistentRegistry.ACTIVE.getRegistrySuperType(r.getKey()); + loadRegistry(r.getKey(), PersistentRegistry.FROZEN, PersistentRegistry.ACTIVE, registrySuperType); } // the id mapping has reverted, fire remap events for those that care about id changes Loader.instance().fireRemapEvent(ImmutableMap.of(), ImmutableMap.of(), true); @@ -368,12 +386,27 @@ public class PersistentRegistryManager FMLLog.fine("Freezing block and item id maps"); for (Map.Entry> r : PersistentRegistry.ACTIVE.registries.entrySet()) { - loadRegistry(r.getKey(), PersistentRegistry.ACTIVE, PersistentRegistry.FROZEN, PersistentRegistry.ACTIVE.registrySuperTypes.inverse().get(r.getKey())); + // This has to be performed prior to invoking the method so the compiler can precompute the type bounds for the method + final Class registrySuperType = PersistentRegistry.ACTIVE.getRegistrySuperType(r.getKey()); + loadRegistry(r.getKey(), PersistentRegistry.ACTIVE, PersistentRegistry.FROZEN, registrySuperType); } forAllRegistries(PersistentRegistry.FROZEN, ValidateRegistryFunction.OPERATION); } - public static List processIdRematches(Iterable missedMappings, boolean isLocalWorld, Map remapBlocks, Map remapItems) + public static void freezeVanilla() + { + FMLLog.fine("Creating vanilla freeze snapshot"); + for (Map.Entry> r : PersistentRegistry.ACTIVE.registries.entrySet()) + { + // This has to be performed prior to invoking the method so the compiler can precompute the type bounds for the method + final Class registrySuperType = PersistentRegistry.ACTIVE.getRegistrySuperType(r.getKey()); + loadRegistry(r.getKey(), PersistentRegistry.ACTIVE, PersistentRegistry.VANILLA, registrySuperType); + } + forAllRegistries(PersistentRegistry.VANILLA, ValidateRegistryFunction.OPERATION); + FMLLog.fine("Vanilla freeze snapshot created"); + } + + public static List processIdRematches(Iterable missedMappings, boolean isLocalWorld, Map missingBlocks, Map missingItems, Map remapBlocks, Map remapItems) { List failed = Lists.newArrayList(); List ignored = Lists.newArrayList(); @@ -398,6 +431,7 @@ public class PersistentRegistryManager newName = active.getRegistry(BLOCKS, Block.class).getNameForObject((Block)remap.getTarget()); FMLLog.fine("The Block %s is being remapped to %s.", remap.name, newName); + missingBlocks.remove(new ResourceLocation(remap.name)); newId = staging.getRegistry(BLOCKS, Block.class).add(remap.id, newName, (Block)remap.getTarget()); staging.getRegistry(BLOCKS, Block.class).addAlias(remap.resourceLocation, newName); } @@ -407,6 +441,7 @@ public class PersistentRegistryManager newName = active.getRegistry(ITEMS, Item.class).getNameForObject((Item)remap.getTarget()); FMLLog.fine("The Item %s is being remapped to %s.", remap.name, newName); + missingItems.remove(new ResourceLocation(remap.name)); newId = staging.getRegistry(ITEMS, Item.class).add(remap.id, newName, (Item)remap.getTarget()); staging.getRegistry(ITEMS, Item.class).addAlias(remap.resourceLocation, newName); } @@ -577,7 +612,7 @@ public class PersistentRegistryManager public final Map entries = Maps.newHashMap(); } - public static RegistryDelegate makeDelegate(T obj, Class rootClass) + public static > RegistryDelegate makeDelegate(T obj, Class rootClass) { return PersistentRegistry.ACTIVE.getRegistry(rootClass).getDelegate(obj, rootClass); } @@ -618,4 +653,5 @@ public class PersistentRegistryManager return null; } } + } diff --git a/src/main/java/net/minecraftforge/fml/common/registry/RegistryDelegate.java b/src/main/java/net/minecraftforge/fml/common/registry/RegistryDelegate.java index 2e255f25e5..c0c5583dbb 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/RegistryDelegate.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/RegistryDelegate.java @@ -23,23 +23,12 @@ public interface RegistryDelegate { */ T get(); - /** - * Get the name of this delegate. This is completely static after registration has completed and will never change. - * - * Deprecated in favour of the resource location. - * - * @see #getResourceName() - * @return The name - */ - @Deprecated - String name(); - /** * Get the unique resource location for this delegate. Completely static after registration has completed, and * will never change. * @return The name */ - ResourceLocation getResourceName(); + ResourceLocation name(); /** * Get the delegate type. It will be dependent on the registry this delegate is sourced from. @@ -52,27 +41,22 @@ public interface RegistryDelegate { */ final class Delegate implements RegistryDelegate { - private T referant; + private T referent; private ResourceLocation name; private final Class type; - public Delegate(T referant, Class type) { - this.referant = referant; + public Delegate(T referent, Class type) { + this.referent = referent; this.type = type; } @Override public T get() { - return referant; + return referent; } @Override - public String name() { - return name.toString(); - } - - @Override - public ResourceLocation getResourceName() { return name; } + public ResourceLocation name() { return name; } @Override public Class type() @@ -82,10 +66,10 @@ public interface RegistryDelegate { void changeReference(T newTarget) { - this.referant = newTarget; + this.referent = newTarget; } - void setResourceName(ResourceLocation name) { this.name = name; } + void setName(ResourceLocation name) { this.name = name; } @Override public boolean equals(Object obj) diff --git a/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java b/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java index 7eef45e0be..0c02d63b25 100644 --- a/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java +++ b/src/main/java/net/minecraftforge/fml/common/registry/VillagerRegistry.java @@ -12,8 +12,6 @@ package net.minecraftforge.fml.common.registry; -import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Random; @@ -42,10 +40,6 @@ import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; import net.minecraft.world.gen.structure.StructureVillagePieces.PieceWeight; import net.minecraft.world.gen.structure.StructureVillagePieces.Village; -import net.minecraftforge.fml.common.FMLLog; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - /** * Registry for villager trading control * @@ -57,9 +51,6 @@ public class VillagerRegistry private static final VillagerRegistry INSTANCE = new VillagerRegistry(); private Map, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap(); - private List newVillagerIds = Lists.newArrayList(); - @SideOnly(Side.CLIENT) - private Map newVillagers; private VillagerRegistry() { @@ -110,39 +101,6 @@ public class VillagerRegistry return INSTANCE; } - /** - * Register your villager id - * - * @param id - */ - @Deprecated // Doesn't work at all. - public void registerVillagerId(int id) - { - if (newVillagerIds.contains(id)) - { - FMLLog.severe("Attempt to register duplicate villager id %d", id); - throw new RuntimeException(); - } - newVillagerIds.add(id); - } - - /** - * Register a new skin for a villager type - * - * @param villagerId - * @param villagerSkin - */ - @SideOnly(Side.CLIENT) - @Deprecated // Doesn't work at all. - public void registerVillagerSkin(int villagerId, ResourceLocation villagerSkin) - { - if (newVillagers == null) - { - newVillagers = Maps.newHashMap(); - } - newVillagers.put(villagerId, villagerSkin); - } - /** * Register a new village creation handler * @@ -153,34 +111,6 @@ public class VillagerRegistry villageCreationHandlers.put(handler.getComponentClass(), handler); } - /** - * Callback to setup new villager types - * - * @param villagerType - * @param defaultSkin - */ - @SideOnly(Side.CLIENT) - @Deprecated // Doesn't work at all. - public static ResourceLocation getVillagerSkin(int villagerType, ResourceLocation defaultSkin) - { - if (instance().newVillagers != null && instance().newVillagers.containsKey(villagerType)) - { - return instance().newVillagers.get(villagerType); - } - return defaultSkin; - } - - /** - * Returns a list of all added villager types - * - * @return newVillagerIds - */ - @Deprecated // Doesn't work at all. - public static Collection getRegisteredVillagers() - { - return Collections.unmodifiableCollection(instance().newVillagerIds); - } - public static void addExtraVillageComponents(List list, Random random, int i) { List parts = list; @@ -207,7 +137,8 @@ public class VillagerRegistry } private boolean hasInit = false; - private FMLControlledNamespacedRegistry professions = PersistentRegistryManager.createRegistry(PROFESSIONS, VillagerProfession.class, null, 1024, 0, true, null); + private FMLControlledNamespacedRegistry professions = PersistentRegistryManager.createRegistry(PROFESSIONS, VillagerProfession.class, null, 0, 1024, true, null, null, null); + public IForgeRegistry getRegistry() { return this.professions; } private void init() @@ -250,18 +181,17 @@ public class VillagerRegistry } } - public static class VillagerProfession + public static class VillagerProfession extends IForgeRegistryEntry.Impl { private ResourceLocation name; private ResourceLocation texture; private List careers = Lists.newArrayList(); - public final RegistryDelegate delegate = PersistentRegistryManager.makeDelegate(this, VillagerProfession.class); public VillagerProfession(String name, String texture) { this.name = new ResourceLocation(name); this.texture = new ResourceLocation(texture); - ((RegistryDelegate.Delegate)delegate).setResourceName(this.name); + this.setRegistryName(this.name); } private void register(VillagerCareer career) @@ -271,6 +201,22 @@ public class VillagerRegistry career.id = careers.size(); careers.add(career); } + + public ResourceLocation getSkin() { return this.texture; } + public VillagerCareer getCareer(int id) + { + for (VillagerCareer car : this.careers) + { + if (car.id == id) + return car; + } + return this.careers.get(0); + } + + public int getRandomCareer(Random rand) + { + return this.careers.get(rand.nextInt(this.careers.size())).id; + } } public static class VillagerCareer @@ -278,6 +224,7 @@ public class VillagerRegistry private VillagerProfession profession; private String name; private int id; + private ITradeList[][] trades; public VillagerCareer(VillagerProfession parent, String name) { @@ -286,8 +233,19 @@ public class VillagerRegistry parent.register(this); } - private VillagerCareer init(EntityVillager.ITradeList[][] traids) + public String getName() { + return this.name; + } + + public ITradeList[][] getTrades() + { + return this.trades; + } + + private VillagerCareer init(EntityVillager.ITradeList[][] trades) + { + this.trades = trades; return this; } @@ -316,9 +274,30 @@ public class VillagerRegistry public static void setRandomProfession(EntityVillager entity, Random rand) { Set entries = INSTANCE.professions.getKeys(); - int prof = rand.nextInt(entries.size()); - //TODO: Grab id range from internal registry - entity.setProfession(rand.nextInt(5)); + entity.setProfession(rand.nextInt(entries.size())); + } + + public static void onSetProfession(EntityVillager entity, VillagerProfession prof) + { + int network = INSTANCE.professions.getId(prof); + if (network == -1 || prof != INSTANCE.professions.getObjectById(network)) + { + throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof); + } + + if (network != entity.getProfession()) + entity.setProfession(network); + } + public static void onSetProfession(EntityVillager entity, int network) + { + VillagerProfession prof = INSTANCE.professions.getObjectById(network); + if (prof == null || INSTANCE.professions.getId(prof) != network) + { + throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof); + } + + if (prof != entity.getProfessionForge()) + entity.setProfession(prof); } //TODO: Figure out a good generic system for this. Put on hold for Patches. @@ -431,11 +410,10 @@ public class VillagerRegistry }, { new ListItemForEmeralds(Items.redstone, new PriceInfo(-4, -1)), - new ListItemForEmeralds(new ItemStack(Items.dye, 1, EnumDyeColor.BLUE.getDyeDamage()), - new PriceInfo(-2, -1)) + new ListItemForEmeralds(new ItemStack(Items.dye, 1, EnumDyeColor.BLUE.getDyeDamage()), new PriceInfo(-2, -1)) }, { - new ListItemForEmeralds(Items.ender_eye, new PriceInfo(7, 11)), + new ListItemForEmeralds(Items.ender_pearl, new PriceInfo(4, 7)), new ListItemForEmeralds(Item.getItemFromBlock(Blocks.glowstone), new PriceInfo(-3, -1)) }, { diff --git a/src/main/java/net/minecraftforge/fml/common/toposort/ModSortingException.java b/src/main/java/net/minecraftforge/fml/common/toposort/ModSortingException.java index 1ee799ef70..5fdedff13c 100644 --- a/src/main/java/net/minecraftforge/fml/common/toposort/ModSortingException.java +++ b/src/main/java/net/minecraftforge/fml/common/toposort/ModSortingException.java @@ -14,12 +14,8 @@ package net.minecraftforge.fml.common.toposort; import java.util.Set; -import org.apache.logging.log4j.Level; - import net.minecraftforge.fml.common.EnhancedRuntimeException; -import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.toposort.ModSortingException.SortingExceptionData; public class ModSortingException extends EnhancedRuntimeException { diff --git a/src/main/java/net/minecraftforge/fml/common/toposort/TopologicalSort.java b/src/main/java/net/minecraftforge/fml/common/toposort/TopologicalSort.java index bfaca5b849..6dc0e28955 100644 --- a/src/main/java/net/minecraftforge/fml/common/toposort/TopologicalSort.java +++ b/src/main/java/net/minecraftforge/fml/common/toposort/TopologicalSort.java @@ -181,7 +181,7 @@ public class TopologicalSort } FMLLog.severe("Mod Sorting failed."); - FMLLog.severe("Visting node %s", node); + FMLLog.severe("Visiting node %s", node); FMLLog.severe("Current sorted list : %s", sortedResult); FMLLog.severe("Visited set for this node : %s", visitedNodes); FMLLog.severe("Explored node set : %s", expandedNodes); diff --git a/src/main/java/net/minecraftforge/fml/relauncher/CoreModManager.java b/src/main/java/net/minecraftforge/fml/relauncher/CoreModManager.java index e54c0285b8..2af87a659d 100644 --- a/src/main/java/net/minecraftforge/fml/relauncher/CoreModManager.java +++ b/src/main/java/net/minecraftforge/fml/relauncher/CoreModManager.java @@ -227,7 +227,7 @@ public class CoreModManager { if (loadPlugins.isEmpty()) { - throw new RuntimeException("A fatal error has occured - no valid fml load plugin was found - this is a completely corrupt FML installation."); + throw new RuntimeException("A fatal error has occurred - no valid fml load plugin was found - this is a completely corrupt FML installation."); } FMLRelaunchLog.fine("All fundamental core mods are successfully located"); @@ -613,7 +613,7 @@ public class CoreModManager { Launch.blackboard.put("fml.deobfuscatedEnvironment", deobfuscatedEnvironment); tweaker.injectCascadingTweak("net.minecraftforge.fml.common.launcher.FMLDeobfTweaker"); - tweakSorting.put("net.minecraftforge.fml.common.launcher.FMLDeobfTweaker", Integer.valueOf(1000)); + tweakSorting.put("net.minecraftforge.fml.common.launcher.FMLDeobfTweaker", 1000); } public static void injectCoreModTweaks(FMLInjectionAndSortingTweaker fmlInjectionAndSortingTweaker) diff --git a/src/main/java/net/minecraftforge/fml/relauncher/FMLInjectionData.java b/src/main/java/net/minecraftforge/fml/relauncher/FMLInjectionData.java index 6a9cf9b72a..10a2116df0 100644 --- a/src/main/java/net/minecraftforge/fml/relauncher/FMLInjectionData.java +++ b/src/main/java/net/minecraftforge/fml/relauncher/FMLInjectionData.java @@ -29,7 +29,7 @@ public class FMLInjectionData static String mccversion; static String mcpversion; - public static List containers = new ArrayList(); + public static final List containers = new ArrayList(); static void build(File mcHome, LaunchClassLoader classLoader) { diff --git a/src/main/java/net/minecraftforge/fml/relauncher/FMLRelaunchLog.java b/src/main/java/net/minecraftforge/fml/relauncher/FMLRelaunchLog.java index b2d8604a57..9acd7e01d2 100644 --- a/src/main/java/net/minecraftforge/fml/relauncher/FMLRelaunchLog.java +++ b/src/main/java/net/minecraftforge/fml/relauncher/FMLRelaunchLog.java @@ -28,7 +28,7 @@ public class FMLRelaunchLog { * Our special logger for logging issues to. We copy various assets from the * Minecraft logger to achieve a similar appearance. */ - public static FMLRelaunchLog log = new FMLRelaunchLog(); + public static final FMLRelaunchLog log = new FMLRelaunchLog(); static File minecraftHome; private static boolean configured; diff --git a/src/main/java/net/minecraftforge/fml/repackage/com/nothome/delta/DebugDiffWriter.java b/src/main/java/net/minecraftforge/fml/repackage/com/nothome/delta/DebugDiffWriter.java index 0dff4d4538..26d879d040 100644 --- a/src/main/java/net/minecraftforge/fml/repackage/com/nothome/delta/DebugDiffWriter.java +++ b/src/main/java/net/minecraftforge/fml/repackage/com/nothome/delta/DebugDiffWriter.java @@ -59,7 +59,7 @@ public class DebugDiffWriter implements DiffWriter { if (ba[ix] == '\n') System.err.print("\\n"); else - System.err.print(String.valueOf((char)((char) ba[ix]))); + System.err.print(String.valueOf((char) ba[ix])); //System.err.print("0x" + Integer.toHexString(buf[ix]) + " "); // hex output } System.err.println(""); diff --git a/src/main/java/net/minecraftforge/fml/repackage/com/nothome/delta/GDiffWriter.java b/src/main/java/net/minecraftforge/fml/repackage/com/nothome/delta/GDiffWriter.java index cd47bf1b59..8f8dfa2db3 100644 --- a/src/main/java/net/minecraftforge/fml/repackage/com/nothome/delta/GDiffWriter.java +++ b/src/main/java/net/minecraftforge/fml/repackage/com/nothome/delta/GDiffWriter.java @@ -170,7 +170,7 @@ public class GDiffWriter implements DiffWriter { @Override public void close() throws IOException { this.flush(); - output.write((byte)EOF); + output.write(EOF); output.close(); } diff --git a/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java b/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java index 252e94dc30..f9e7db1d65 100644 --- a/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java +++ b/src/main/java/net/minecraftforge/fml/server/FMLServerHandler.java @@ -12,18 +12,23 @@ */ package net.minecraftforge.fml.server; -import java.io.File; +import java.io.*; +import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; import net.minecraft.command.ServerCommand; +import net.minecraft.launchwrapper.Launch; import net.minecraft.network.INetHandler; import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.network.NetworkManager; import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.util.IThreadListener; +import net.minecraft.util.text.translation.LanguageMap; import net.minecraft.world.storage.SaveFormatOld; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLLog; @@ -34,10 +39,10 @@ import net.minecraftforge.fml.common.StartupQuery; import net.minecraftforge.fml.common.eventhandler.EventBus; import net.minecraftforge.fml.common.functions.GenericIterableFactory; import net.minecraftforge.fml.common.network.FMLNetworkEvent; -import net.minecraftforge.fml.common.registry.LanguageRegistry; import net.minecraftforge.fml.relauncher.Side; import com.google.common.collect.ImmutableList; +import org.apache.commons.io.IOUtils; /** * Handles primary communication from hooked code into the system @@ -215,10 +220,50 @@ public class FMLServerHandler implements IFMLSidedHandler { return false; } + @Override public void addModAsResource(ModContainer container) { - LanguageRegistry.instance().loadLanguagesFor(container, Side.SERVER); + String langFile = "assets/" + container.getModId().toLowerCase() + "/lang/en_US.lang"; + File source = container.getSource(); + InputStream stream = null; + ZipFile zip = null; + try + { + if (source.isDirectory() && (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment")) + { + stream = new FileInputStream(new File(source.toURI().resolve(langFile).getPath())); + } + else + { + zip = new ZipFile(source); + ZipEntry entry = zip.getEntry(langFile); + if(entry == null) throw new FileNotFoundException(); + stream = zip.getInputStream(entry); + } + LanguageMap.inject(stream); + } + catch (IOException e) + { + // hush + } + catch(Exception e) + { + FMLLog.getLogger().error(e); + } + finally + { + IOUtils.closeQuietly(stream); + try + { + if (zip != null) + zip.close(); + } + catch (IOException e) + { + // shush + } + } } @Override diff --git a/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java b/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java index 433b3f48e0..9c1c320847 100644 --- a/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java +++ b/src/main/java/net/minecraftforge/items/ItemHandlerHelper.java @@ -2,8 +2,10 @@ package net.minecraftforge.items; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.SoundCategory; import net.minecraft.world.World; import net.minecraftforge.items.wrapper.PlayerMainInvWrapper; @@ -140,7 +142,7 @@ public class ItemHandlerHelper World world = player.worldObj; // try adding it into the inventory - ItemStack remainder = null; + ItemStack remainder = stack; // insert into preferred slot first if(preferredSlot >= 0) { @@ -149,14 +151,14 @@ public class ItemHandlerHelper // then into the inventory in general if(remainder != null) { - remainder = insertItemStacked(inventory, stack, false); + remainder = insertItemStacked(inventory, remainder, false); } // play sound if something got picked up if (remainder == null || remainder.stackSize != stack.stackSize) { - world.playSoundEffect(player.posX, player.posY, player.posZ, - "random.pop", 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + world.playSound(player, player.posX, player.posY, player.posZ, + SoundEvents.entity_item_pickup, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); } // drop remaining itemstack into the world diff --git a/src/main/java/net/minecraftforge/items/ItemStackHandler.java b/src/main/java/net/minecraftforge/items/ItemStackHandler.java index 5ffc6bc648..fcd05022ad 100644 --- a/src/main/java/net/minecraftforge/items/ItemStackHandler.java +++ b/src/main/java/net/minecraftforge/items/ItemStackHandler.java @@ -20,6 +20,11 @@ public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, I stacks = new ItemStack[size]; } + public ItemStackHandler(ItemStack[] stacks) + { + this.stacks = stacks; + } + public void setSize(int size) { stacks = new ItemStack[size]; diff --git a/src/main/java/net/minecraftforge/items/SlotItemHandler.java b/src/main/java/net/minecraftforge/items/SlotItemHandler.java index aa04c33be5..e5571ebed1 100644 --- a/src/main/java/net/minecraftforge/items/SlotItemHandler.java +++ b/src/main/java/net/minecraftforge/items/SlotItemHandler.java @@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack; public class SlotItemHandler extends Slot { private static IInventory emptyInventory = new InventoryBasic("[Null]", true, 0); - public final IItemHandler itemHandler; + private final IItemHandler itemHandler; private final int index; public SlotItemHandler(IItemHandler itemHandler, int index, int xPosition, int yPosition) @@ -24,21 +24,21 @@ public class SlotItemHandler extends Slot { if (stack == null) return false; - ItemStack remainder = this.itemHandler.insertItem(index, stack, true); + ItemStack remainder = this.getItemHandler().insertItem(index, stack, true); return remainder == null || remainder.stackSize < stack.stackSize; } @Override public ItemStack getStack() { - return this.itemHandler.getStackInSlot(index); + return this.getItemHandler().getStackInSlot(index); } // Override if your IItemHandler does not implement IItemHandlerModifiable @Override public void putStack(ItemStack stack) { - ((IItemHandlerModifiable) this.itemHandler).setStackInSlot(index, stack); + ((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(index, stack); this.onSlotChanged(); } @@ -53,8 +53,8 @@ public class SlotItemHandler extends Slot { ItemStack maxAdd = stack.copy(); maxAdd.stackSize = maxAdd.getMaxStackSize(); - ItemStack currentStack = this.itemHandler.getStackInSlot(index); - ItemStack remainder = this.itemHandler.insertItem(index, maxAdd, true); + ItemStack currentStack = this.getItemHandler().getStackInSlot(index); + ItemStack remainder = this.getItemHandler().insertItem(index, maxAdd, true); int current = currentStack == null ? 0 : currentStack.stackSize; int added = maxAdd.stackSize - (remainder != null ? remainder.stackSize : 0); @@ -64,12 +64,17 @@ public class SlotItemHandler extends Slot @Override public boolean canTakeStack(EntityPlayer playerIn) { - return this.itemHandler.extractItem(index, 1, true) != null; + return this.getItemHandler().extractItem(index, 1, true) != null; } @Override public ItemStack decrStackSize(int amount) { - return this.itemHandler.extractItem(index, amount, false); + return this.getItemHandler().extractItem(index, amount, false); + } + + public IItemHandler getItemHandler() + { + return itemHandler; } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/items/VanillaDoubleChestItemHandler.java b/src/main/java/net/minecraftforge/items/VanillaDoubleChestItemHandler.java index 09100c7f04..05839f6f3a 100644 --- a/src/main/java/net/minecraftforge/items/VanillaDoubleChestItemHandler.java +++ b/src/main/java/net/minecraftforge/items/VanillaDoubleChestItemHandler.java @@ -4,7 +4,7 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; @@ -12,7 +12,7 @@ import java.lang.ref.WeakReference; import com.google.common.base.Objects; -public class VanillaDoubleChestItemHandler extends WeakReference implements IItemHandler +public class VanillaDoubleChestItemHandler extends WeakReference implements IItemHandlerModifiable { // Dummy cache value to signify that we have checked and definitely found no adjacent chests public static final VanillaDoubleChestItemHandler NO_ADJACENT_CHESTS_INSTANCE = new VanillaDoubleChestItemHandler(null, null, false); @@ -91,6 +91,22 @@ public class VanillaDoubleChestItemHandler extends WeakReference getSlots()) - { - return; - } - super.setStackInSlot(slot, stack); - } - - @Override - public ItemStack getStackInSlot(int slot) - { - // prevent getting of armor inventory - if (slot > getSlots()) - { - return null; - } - return super.getStackInSlot(slot); - } - @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { - // prevent inserting into armor inventory - if (slot > getSlots()) - { - return stack; - } - ItemStack rest = super.insertItem(slot, stack, simulate); if (rest == null || rest.stackSize != stack.stackSize) { @@ -64,26 +28,20 @@ public class PlayerMainInvWrapper extends InvWrapper ItemStack inSlot = getStackInSlot(slot); if(inSlot != null) { - if (inventoryPlayer.player.worldObj.isRemote) + if (getInventoryPlayer().player.worldObj.isRemote) { inSlot.animationsToGo = 5; } - else if(inventoryPlayer.player instanceof EntityPlayerMP) { - inventoryPlayer.player.openContainer.detectAndSendChanges(); + else if(getInventoryPlayer().player instanceof EntityPlayerMP) { + getInventoryPlayer().player.openContainer.detectAndSendChanges(); } } } return rest; } - @Override - public ItemStack extractItem(int slot, int amount, boolean simulate) + public InventoryPlayer getInventoryPlayer() { - // prevent extraction from armor inventory - if (slot > getSlots()) - { - return null; - } - return super.extractItem(slot, amount, simulate); + return inventoryPlayer; } } diff --git a/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java new file mode 100644 index 0000000000..7bdbae2b65 --- /dev/null +++ b/src/main/java/net/minecraftforge/items/wrapper/PlayerOffhandInvWrapper.java @@ -0,0 +1,12 @@ +package net.minecraftforge.items.wrapper; + +import net.minecraft.entity.player.InventoryPlayer; + +public class PlayerOffhandInvWrapper extends RangedWrapper +{ + public PlayerOffhandInvWrapper(InventoryPlayer inv) + { + super(new InvWrapper(inv), inv.mainInventory.length + inv.armorInventory.length, + inv.mainInventory.length + inv.armorInventory.length + inv.offHandInventory.length); + } +} diff --git a/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java new file mode 100644 index 0000000000..00b218eb68 --- /dev/null +++ b/src/main/java/net/minecraftforge/items/wrapper/RangedWrapper.java @@ -0,0 +1,78 @@ +package net.minecraftforge.items.wrapper; + +import com.google.common.base.Preconditions; +import net.minecraft.item.ItemStack; +import net.minecraftforge.items.IItemHandlerModifiable; + +/** + * A wrapper that composes another IItemHandlerModifiable, exposing only a range of the composed slots. + * Shifting of slot indices is handled automatically for you. + */ +public class RangedWrapper implements IItemHandlerModifiable { + + private final IItemHandlerModifiable compose; + private final int minSlot; + private final int maxSlot; + + public RangedWrapper(IItemHandlerModifiable compose, int minSlot, int maxSlotExclusive) + { + Preconditions.checkArgument(maxSlotExclusive > minSlot, "Max slot must be greater than min slot"); + this.compose = compose; + this.minSlot = minSlot; + this.maxSlot = maxSlotExclusive; + } + + @Override + public int getSlots() + { + return maxSlot - minSlot; + } + + @Override + public ItemStack getStackInSlot(int slot) + { + if (checkSlot(slot)) + { + return compose.getStackInSlot(slot + minSlot); + } + + return null; + } + + @Override + public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) + { + if (checkSlot(slot)) + { + return compose.insertItem(slot + minSlot, stack, simulate); + } + + return stack; + } + + @Override + public ItemStack extractItem(int slot, int amount, boolean simulate) + { + if (checkSlot(slot)) + { + return compose.extractItem(slot + minSlot, amount, simulate); + } + + return null; + } + + @Override + public void setStackInSlot(int slot, ItemStack stack) + { + if (checkSlot(slot)) + { + compose.setStackInSlot(slot + minSlot, stack); + } + } + + private boolean checkSlot(int localSlot) + { + return localSlot + minSlot < maxSlot; + } + +} diff --git a/src/main/java/net/minecraftforge/items/wrapper/SidedInvWrapper.java b/src/main/java/net/minecraftforge/items/wrapper/SidedInvWrapper.java index 8d0d61a44c..8139a94827 100644 --- a/src/main/java/net/minecraftforge/items/wrapper/SidedInvWrapper.java +++ b/src/main/java/net/minecraftforge/items/wrapper/SidedInvWrapper.java @@ -144,7 +144,10 @@ public class SidedInvWrapper implements IItemHandlerModifiable @Override public void setStackInSlot(int slot, ItemStack stack) { - inv.setInventorySlotContents(slot, stack); + int slot1 = getSlot(inv, slot, side); + + if (slot1 != -1) + inv.setInventorySlotContents(slot1, stack); } @Override diff --git a/src/main/java/net/minecraftforge/oredict/OreDictionary.java b/src/main/java/net/minecraftforge/oredict/OreDictionary.java index d420e6237f..eabaf561ae 100644 --- a/src/main/java/net/minecraftforge/oredict/OreDictionary.java +++ b/src/main/java/net/minecraftforge/oredict/OreDictionary.java @@ -52,7 +52,7 @@ public class OreDictionary initVanillaEntries(); } - public static void initVanillaEntries() + private static void initVanillaEntries() { if (!hasInit) { @@ -351,7 +351,7 @@ public class OreDictionary continue; } - if(containsMatch(true, (ItemStack[])recipe.recipeItems.toArray(new ItemStack[recipe.recipeItems.size()]), replaceStacks)) + if(containsMatch(true, recipe.recipeItems.toArray(new ItemStack[recipe.recipeItems.size()]), replaceStacks)) { recipesToRemove.add((IRecipe)obj); IRecipe newRecipe = new ShapelessOreRecipe(recipe, replacements); @@ -364,7 +364,7 @@ public class OreDictionary recipes.addAll(recipesToAdd); if (recipesToRemove.size() > 0) { - FMLLog.info("Replaced %d ore recipies", recipesToRemove.size()); + FMLLog.info("Replaced %d ore recipes", recipesToRemove.size()); } } @@ -402,11 +402,11 @@ public class OreDictionary } /** - * Gets all the integer ID for the ores that the specified item stakc is registered to. + * Gets all the integer ID for the ores that the specified item stack is registered to. * If the item stack is not linked to any ore, this will return an empty array and no new entry will be created. * * @param stack The item stack of the ore. - * @return An array of ids that this ore is registerd as. + * @return An array of ids that this ore is registered as. */ public static int[] getOreIDs(ItemStack stack) { @@ -417,7 +417,7 @@ public class OreDictionary // HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet // IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about. // APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game. - ResourceLocation registryName = stack.getItem().delegate.getResourceName(); + ResourceLocation registryName = stack.getItem().delegate.name(); int id; if (registryName == null) { @@ -579,7 +579,7 @@ public class OreDictionary // HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet // IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about. // APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game. - ResourceLocation registryName = ore.getItem().delegate.getResourceName(); + ResourceLocation registryName = ore.getItem().delegate.name(); int hash; if (registryName == null) { @@ -615,14 +615,24 @@ public class OreDictionary public static class OreRegisterEvent extends Event { - public final String Name; - public final ItemStack Ore; + private final String Name; + private final ItemStack Ore; public OreRegisterEvent(String name, ItemStack ore) { this.Name = name; this.Ore = ore; } + + public String getName() + { + return Name; + } + + public ItemStack getOre() + { + return Ore; + } } public static void rebakeMap() @@ -636,7 +646,7 @@ public class OreDictionary for (ItemStack ore : ores) { // HACK: use the registry name's ID. It is unique and it knows about substitutions - ResourceLocation name = ore.getItem().delegate.getResourceName(); + ResourceLocation name = ore.getItem().delegate.name(); int hash; if (name == null) { diff --git a/src/main/java/net/minecraftforge/oredict/RecipeSorter.java b/src/main/java/net/minecraftforge/oredict/RecipeSorter.java index 4ef622f883..056fba7bbd 100644 --- a/src/main/java/net/minecraftforge/oredict/RecipeSorter.java +++ b/src/main/java/net/minecraftforge/oredict/RecipeSorter.java @@ -19,16 +19,17 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.RecipeBookCloning; import net.minecraft.item.crafting.RecipeFireworks; import net.minecraft.item.crafting.RecipeRepairItem; +import net.minecraft.item.crafting.RecipeTippedArrow; import net.minecraft.item.crafting.RecipesArmorDyes; import net.minecraft.item.crafting.RecipesMapCloning; import net.minecraft.item.crafting.RecipesMapExtending; import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; +import net.minecraft.item.crafting.ShieldRecipes; import net.minecraft.item.crafting.RecipesBanners.RecipeAddPattern; import net.minecraft.item.crafting.RecipesBanners.RecipeDuplicatePattern; import static net.minecraftforge.oredict.RecipeSorter.Category.*; -@SuppressWarnings("rawtypes") public class RecipeSorter implements Comparator { public enum Category @@ -69,7 +70,7 @@ public class RecipeSorter implements Comparator } else { - throw new IllegalArgumentException("Invalid dependancy: " + dep); + throw new IllegalArgumentException("Invalid dependency: " + dep); } } } @@ -102,12 +103,12 @@ public class RecipeSorter implements Comparator } }; - private static Map categories = Maps.newHashMap(); - //private static Map types = Maps.newHashMap(); + private static Map, Category> categories = Maps.newHashMap(); + //private static Map> types = Maps.newHashMap(); private static Map entries = Maps.newHashMap(); - private static Map priorities = Maps.newHashMap(); + private static Map, Integer> priorities = Maps.newHashMap(); - public static RecipeSorter INSTANCE = new RecipeSorter(); + public static final RecipeSorter INSTANCE = new RecipeSorter(); private static boolean isDirty = true; private static SortEntry before = new SortEntry("Before", null, UNKNOWN, ""); @@ -118,8 +119,10 @@ public class RecipeSorter implements Comparator register("minecraft:shaped", ShapedRecipes.class, SHAPED, "before:minecraft:shapeless"); register("minecraft:mapextending", RecipesMapExtending.class, SHAPED, "after:minecraft:shaped before:minecraft:shapeless"); register("minecraft:shapeless", ShapelessRecipes.class, SHAPELESS, "after:minecraft:shaped"); + register("minecraft:shield_deco", ShieldRecipes.Decoration.class, SHAPELESS, "after:minecraft:shapeless"); //Size 2 register("minecraft:repair", RecipeRepairItem.class, SHAPELESS, "after:minecraft:shapeless"); //Size 4 register("minecraft:bookcloning", RecipeBookCloning.class, SHAPELESS, "after:minecraft:shapeless"); //Size 9 + register("minecraft:tippedarrow", RecipeTippedArrow.class, SHAPELESS, "after:minecraft:shapeless"); //Size 9 register("minecraft:fireworks", RecipeFireworks.class, SHAPELESS, "after:minecraft:shapeless"); //Size 10 register("minecraft:armordyes", RecipesArmorDyes.class, SHAPELESS, "after:minecraft:shapeless"); //Size 10 register("minecraft:mapcloning", RecipesMapCloning.class, SHAPELESS, "after:minecraft:shapeless"); //Size 10 @@ -142,21 +145,21 @@ public class RecipeSorter implements Comparator return getPriority(r2) - getPriority(r1); // high priority value first! } - private static Set warned = Sets.newHashSet(); + private static Set> warned = Sets.newHashSet(); public static void sortCraftManager() { bake(); - FMLLog.fine("Sorting recipies"); + FMLLog.fine("Sorting recipes"); warned.clear(); Collections.sort(CraftingManager.getInstance().getRecipeList(), INSTANCE); } - public static void register(String name, Class recipe, Category category, String dependancies) + public static void register(String name, Class recipe, Category category, String dependencies) { assert(category != UNKNOWN) : "Category must not be unknown!"; isDirty = true; - SortEntry entry = new SortEntry(name, recipe, category, dependancies); + SortEntry entry = new SortEntry(name, recipe, category, dependencies); entries.put(name, entry); setCategory(recipe, category); } @@ -213,13 +216,13 @@ public class RecipeSorter implements Comparator if (ret != null) { priorities.put(recipe.getClass(), ret); - FMLLog.fine(" Parent Found: %d - %s", ret.intValue(), cls.getName()); - return ret.intValue(); + FMLLog.fine(" Parent Found: %d - %s", ret, cls.getName()); + return ret; } } } - return ret == null ? 0 : ret.intValue(); + return ret == null ? 0 : ret; } private static void bake() diff --git a/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java b/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java index 2794e8af85..d2531a38c3 100644 --- a/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java +++ b/src/main/java/net/minecraftforge/oredict/ShapedOreRecipe.java @@ -135,15 +135,15 @@ public class ShapedOreRecipe implements IRecipe for(int i = 0; i < input.length; i++) { - ItemStack ingred = recipe.recipeItems[i]; + ItemStack ingredient = recipe.recipeItems[i]; - if(ingred == null) continue; + if(ingredient == null) continue; input[i] = recipe.recipeItems[i]; for(Entry replace : replacements.entrySet()) { - if(OreDictionary.itemMatches(replace.getKey(), ingred, true)) + if(OreDictionary.itemMatches(replace.getKey(), ingredient, true)) { input[i] = OreDictionary.getOres(replace.getValue()); break; diff --git a/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java b/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java index cb235c3c26..8c4b07dc8f 100644 --- a/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java +++ b/src/main/java/net/minecraftforge/oredict/ShapelessOreRecipe.java @@ -60,12 +60,12 @@ public class ShapelessOreRecipe implements IRecipe { output = recipe.getRecipeOutput(); - for(ItemStack ingred : ((List)recipe.recipeItems)) + for(ItemStack ingredient : recipe.recipeItems) { - Object finalObj = ingred; + Object finalObj = ingredient; for(Entry replace : replacements.entrySet()) { - if(OreDictionary.itemMatches(replace.getKey(), ingred, false)) + if(OreDictionary.itemMatches(replace.getKey(), ingredient, false)) { finalObj = OreDictionary.getOres(replace.getValue()); break; diff --git a/src/main/java/net/minecraftforge/server/ForgeTimeTracker.java b/src/main/java/net/minecraftforge/server/ForgeTimeTracker.java index 7265ee268f..4912c7bdd2 100644 --- a/src/main/java/net/minecraftforge/server/ForgeTimeTracker.java +++ b/src/main/java/net/minecraftforge/server/ForgeTimeTracker.java @@ -81,7 +81,7 @@ public class ForgeTimeTracker { private ImmutableMap buildImmutableTileEntityTimingMap() { - Builder builder = ImmutableMap.builder(); + Builder builder = ImmutableMap.builder(); for (Entry entry : tileEntityTimings.entrySet()) { builder.put(entry.getKey(), Arrays.copyOfRange(entry.getValue(), 0, 100)); diff --git a/src/main/java/net/minecraftforge/server/command/ForgeCommand.java b/src/main/java/net/minecraftforge/server/command/ForgeCommand.java index 93cadbb844..a3c7148e8f 100644 --- a/src/main/java/net/minecraftforge/server/command/ForgeCommand.java +++ b/src/main/java/net/minecraftforge/server/command/ForgeCommand.java @@ -1,6 +1,5 @@ package net.minecraftforge.server.command; -import java.lang.ref.WeakReference; import java.text.DecimalFormat; import java.util.List; @@ -9,20 +8,14 @@ import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.server.ForgeTimeTracker; public class ForgeCommand extends CommandBase { private static final DecimalFormat timeFormatter = new DecimalFormat("########0.000"); - private WeakReference server; - - public ForgeCommand(MinecraftServer server) - { - this.server = new WeakReference(server); - } @Override public String getCommandName() @@ -42,7 +35,7 @@ public class ForgeCommand extends CommandBase { return 2; } @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException + public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length == 0) { @@ -54,15 +47,15 @@ public class ForgeCommand extends CommandBase { } else if ("tps".equals(args[0])) { - displayTPS(sender,args); + displayTPS(server, sender,args); } else if ("tpslog".equals(args[0])) { - doTPSLog(sender,args); + doTPSLog(server, sender,args); } else if ("track".equals(args[0])) { - handleTracking(sender, args); + handleTracking(server, sender, args); } else { @@ -71,7 +64,7 @@ public class ForgeCommand extends CommandBase { } @Override - public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) + public List getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) { if (args.length == 1) { @@ -80,7 +73,7 @@ public class ForgeCommand extends CommandBase { else if (args.length == 2) { if ("tps".equals(args[0])) { - return getListOfStringsMatchingLastWord(args, getServer().worldTickTimes.keySet()); + return getListOfStringsMatchingLastWord(args, server.worldTickTimes.keySet()); } else if ("track".equals(args[0])) { @@ -90,7 +83,7 @@ public class ForgeCommand extends CommandBase { return null; } - private void handleTracking(ICommandSender sender, String[] args) throws CommandException + private void handleTracking(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length != 3) { @@ -101,7 +94,7 @@ public class ForgeCommand extends CommandBase { if ("te".equals(type)) { - doTurnOnTileEntityTracking(sender, duration); + doTurnOnTileEntityTracking(server, sender, duration); } else { @@ -109,19 +102,19 @@ public class ForgeCommand extends CommandBase { } } - private void doTurnOnTileEntityTracking(ICommandSender sender, int duration) + private void doTurnOnTileEntityTracking(MinecraftServer server, ICommandSender sender, int duration) { ForgeTimeTracker.tileEntityTrackingDuration = duration; ForgeTimeTracker.tileEntityTracking = true; - sender.addChatMessage(new ChatComponentTranslation("commands.forge.tracking.te.enabled", duration)); + sender.addChatMessage(new TextComponentTranslation("commands.forge.tracking.te.enabled", duration)); } - private void doTPSLog(ICommandSender sender, String[] args) + private void doTPSLog(MinecraftServer server, ICommandSender sender, String[] args) { } - private void displayTPS(ICommandSender sender, String[] args) throws CommandException + private void displayTPS(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { int dim = 0; boolean summary = true; @@ -134,19 +127,19 @@ public class ForgeCommand extends CommandBase { { for (Integer dimId : DimensionManager.getIDs()) { - double worldTickTime = ForgeCommand.mean(this.getServer().worldTickTimes.get(dimId)) * 1.0E-6D; + double worldTickTime = ForgeCommand.mean(server.worldTickTimes.get(dimId)) * 1.0E-6D; double worldTPS = Math.min(1000.0/worldTickTime, 20); - sender.addChatMessage(new ChatComponentTranslation("commands.forge.tps.summary",String.format("Dim %d", dimId), timeFormatter.format(worldTickTime), timeFormatter.format(worldTPS))); + sender.addChatMessage(new TextComponentTranslation("commands.forge.tps.summary",String.format("Dim %d", dimId), timeFormatter.format(worldTickTime), timeFormatter.format(worldTPS))); } - double meanTickTime = ForgeCommand.mean(this.getServer().tickTimeArray) * 1.0E-6D; + double meanTickTime = ForgeCommand.mean(server.tickTimeArray) * 1.0E-6D; double meanTPS = Math.min(1000.0/meanTickTime, 20); - sender.addChatMessage(new ChatComponentTranslation("commands.forge.tps.summary","Overall", timeFormatter.format(meanTickTime), timeFormatter.format(meanTPS))); + sender.addChatMessage(new TextComponentTranslation("commands.forge.tps.summary","Overall", timeFormatter.format(meanTickTime), timeFormatter.format(meanTPS))); } else { - double worldTickTime = ForgeCommand.mean(this.getServer().worldTickTimes.get(dim)) * 1.0E-6D; + double worldTickTime = ForgeCommand.mean(server.worldTickTimes.get(dim)) * 1.0E-6D; double worldTPS = Math.min(1000.0/worldTickTime, 20); - sender.addChatMessage(new ChatComponentTranslation("commands.forge.tps.summary",String.format("Dim %d", dim), timeFormatter.format(worldTickTime), timeFormatter.format(worldTPS))); + sender.addChatMessage(new TextComponentTranslation("commands.forge.tps.summary",String.format("Dim %d", dim), timeFormatter.format(worldTickTime), timeFormatter.format(worldTPS))); } } @@ -160,9 +153,4 @@ public class ForgeCommand extends CommandBase { return sum / values.length; } - - private MinecraftServer getServer() - { - return this.server.get(); - } } diff --git a/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java b/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java index 89ab4ac83a..3469bbd085 100644 --- a/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java +++ b/src/main/java/net/minecraftforge/server/console/ConsoleCommandCompleter.java @@ -48,7 +48,7 @@ public final class ConsoleCommandCompleter implements Completer public List call() throws Exception { return ConsoleCommandCompleter.this.server.getTabCompletions(ConsoleCommandCompleter.this.server, input, - ConsoleCommandCompleter.this.server.getPosition()); + ConsoleCommandCompleter.this.server.getPosition(), false/* we're not a command block */); } }); try diff --git a/src/main/java/net/minecraftforge/server/console/ConsoleFormatter.java b/src/main/java/net/minecraftforge/server/console/ConsoleFormatter.java index 51719e0870..69796f734c 100644 --- a/src/main/java/net/minecraftforge/server/console/ConsoleFormatter.java +++ b/src/main/java/net/minecraftforge/server/console/ConsoleFormatter.java @@ -8,7 +8,7 @@ import org.fusesource.jansi.Ansi; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.TextFormatting; public final class ConsoleFormatter implements Function { @@ -20,31 +20,31 @@ public final class ConsoleFormatter implements Function private static final String RESET = Ansi.ansi().reset().toString(); private static final ImmutableMap REPLACEMENTS = ImmutableMap. builder() - .put(compile(EnumChatFormatting.BLACK), Ansi.ansi().reset().fg(Ansi.Color.BLACK).boldOff().toString()) - .put(compile(EnumChatFormatting.DARK_BLUE), Ansi.ansi().reset().fg(Ansi.Color.BLUE).boldOff().toString()) - .put(compile(EnumChatFormatting.DARK_GREEN), Ansi.ansi().reset().fg(Ansi.Color.GREEN).boldOff().toString()) - .put(compile(EnumChatFormatting.DARK_AQUA), Ansi.ansi().reset().fg(Ansi.Color.CYAN).boldOff().toString()) - .put(compile(EnumChatFormatting.DARK_RED), Ansi.ansi().reset().fg(Ansi.Color.RED).boldOff().toString()) - .put(compile(EnumChatFormatting.DARK_PURPLE), Ansi.ansi().reset().fg(Ansi.Color.MAGENTA).boldOff().toString()) - .put(compile(EnumChatFormatting.GOLD), Ansi.ansi().reset().fg(Ansi.Color.YELLOW).boldOff().toString()) - .put(compile(EnumChatFormatting.GRAY), Ansi.ansi().reset().fg(Ansi.Color.WHITE).boldOff().toString()) - .put(compile(EnumChatFormatting.DARK_GRAY), Ansi.ansi().reset().fg(Ansi.Color.BLACK).bold().toString()) - .put(compile(EnumChatFormatting.BLUE), Ansi.ansi().reset().fg(Ansi.Color.BLUE).bold().toString()) - .put(compile(EnumChatFormatting.GREEN), Ansi.ansi().reset().fg(Ansi.Color.GREEN).bold().toString()) - .put(compile(EnumChatFormatting.AQUA), Ansi.ansi().reset().fg(Ansi.Color.CYAN).bold().toString()) - .put(compile(EnumChatFormatting.RED), Ansi.ansi().reset().fg(Ansi.Color.RED).bold().toString()) - .put(compile(EnumChatFormatting.LIGHT_PURPLE), Ansi.ansi().reset().fg(Ansi.Color.MAGENTA).bold().toString()) - .put(compile(EnumChatFormatting.YELLOW), Ansi.ansi().reset().fg(Ansi.Color.YELLOW).bold().toString()) - .put(compile(EnumChatFormatting.WHITE), Ansi.ansi().reset().fg(Ansi.Color.WHITE).bold().toString()) - .put(compile(EnumChatFormatting.OBFUSCATED), Ansi.ansi().a(Ansi.Attribute.BLINK_SLOW).toString()) - .put(compile(EnumChatFormatting.BOLD), Ansi.ansi().a(Ansi.Attribute.UNDERLINE_DOUBLE).toString()) - .put(compile(EnumChatFormatting.STRIKETHROUGH), Ansi.ansi().a(Ansi.Attribute.STRIKETHROUGH_ON).toString()) - .put(compile(EnumChatFormatting.UNDERLINE), Ansi.ansi().a(Ansi.Attribute.UNDERLINE).toString()) - .put(compile(EnumChatFormatting.ITALIC), Ansi.ansi().a(Ansi.Attribute.ITALIC).toString()) - .put(compile(EnumChatFormatting.RESET), RESET) + .put(compile(TextFormatting.BLACK), Ansi.ansi().reset().fg(Ansi.Color.BLACK).boldOff().toString()) + .put(compile(TextFormatting.DARK_BLUE), Ansi.ansi().reset().fg(Ansi.Color.BLUE).boldOff().toString()) + .put(compile(TextFormatting.DARK_GREEN), Ansi.ansi().reset().fg(Ansi.Color.GREEN).boldOff().toString()) + .put(compile(TextFormatting.DARK_AQUA), Ansi.ansi().reset().fg(Ansi.Color.CYAN).boldOff().toString()) + .put(compile(TextFormatting.DARK_RED), Ansi.ansi().reset().fg(Ansi.Color.RED).boldOff().toString()) + .put(compile(TextFormatting.DARK_PURPLE), Ansi.ansi().reset().fg(Ansi.Color.MAGENTA).boldOff().toString()) + .put(compile(TextFormatting.GOLD), Ansi.ansi().reset().fg(Ansi.Color.YELLOW).boldOff().toString()) + .put(compile(TextFormatting.GRAY), Ansi.ansi().reset().fg(Ansi.Color.WHITE).boldOff().toString()) + .put(compile(TextFormatting.DARK_GRAY), Ansi.ansi().reset().fg(Ansi.Color.BLACK).bold().toString()) + .put(compile(TextFormatting.BLUE), Ansi.ansi().reset().fg(Ansi.Color.BLUE).bold().toString()) + .put(compile(TextFormatting.GREEN), Ansi.ansi().reset().fg(Ansi.Color.GREEN).bold().toString()) + .put(compile(TextFormatting.AQUA), Ansi.ansi().reset().fg(Ansi.Color.CYAN).bold().toString()) + .put(compile(TextFormatting.RED), Ansi.ansi().reset().fg(Ansi.Color.RED).bold().toString()) + .put(compile(TextFormatting.LIGHT_PURPLE), Ansi.ansi().reset().fg(Ansi.Color.MAGENTA).bold().toString()) + .put(compile(TextFormatting.YELLOW), Ansi.ansi().reset().fg(Ansi.Color.YELLOW).bold().toString()) + .put(compile(TextFormatting.WHITE), Ansi.ansi().reset().fg(Ansi.Color.WHITE).bold().toString()) + .put(compile(TextFormatting.OBFUSCATED), Ansi.ansi().a(Ansi.Attribute.BLINK_SLOW).toString()) + .put(compile(TextFormatting.BOLD), Ansi.ansi().a(Ansi.Attribute.UNDERLINE_DOUBLE).toString()) + .put(compile(TextFormatting.STRIKETHROUGH), Ansi.ansi().a(Ansi.Attribute.STRIKETHROUGH_ON).toString()) + .put(compile(TextFormatting.UNDERLINE), Ansi.ansi().a(Ansi.Attribute.UNDERLINE).toString()) + .put(compile(TextFormatting.ITALIC), Ansi.ansi().a(Ansi.Attribute.ITALIC).toString()) + .put(compile(TextFormatting.RESET), RESET) .build(); - private static Pattern compile(EnumChatFormatting formatting) + private static Pattern compile(TextFormatting formatting) { return Pattern.compile(formatting.toString(), Pattern.LITERAL | Pattern.CASE_INSENSITIVE); } diff --git a/src/main/java/net/minecraftforge/server/console/TerminalHandler.java b/src/main/java/net/minecraftforge/server/console/TerminalHandler.java index 142b32bc73..6bf0a2e7ca 100644 --- a/src/main/java/net/minecraftforge/server/console/TerminalHandler.java +++ b/src/main/java/net/minecraftforge/server/console/TerminalHandler.java @@ -9,7 +9,7 @@ import com.google.common.base.Function; import jline.console.ConsoleReader; import net.minecraft.server.dedicated.DedicatedServer; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.TextFormatting; public final class TerminalHandler { @@ -60,7 +60,7 @@ public final class TerminalHandler @Override public String apply(String text) { - return EnumChatFormatting.getTextWithoutFormattingCodes(text); + return TextFormatting.getTextWithoutFormattingCodes(text); } }); diff --git a/src/main/resources/assets/forge/lang/en_US.lang b/src/main/resources/assets/forge/lang/en_US.lang index 507a84a68f..cbdf6681ab 100644 --- a/src/main/resources/assets/forge/lang/en_US.lang +++ b/src/main/resources/assets/forge/lang/en_US.lang @@ -1,5 +1,5 @@ commands.forge.usage=Use /forge . Subcommands are tps, track -commands.forge.usage.tracking=Use /forge track . Valid types are te (Tile Entities). Duration is < 60. +commands.forge.usage.tracking=Use /forge track . Valid types are te (Tile Entities). Duration is < 60. commands.forge.tps.summary=%s : Mean tick time: %d ms. Mean TPS: %d commands.forge.tracking.te.enabled=Tile Entity tracking enabled for %d seconds. @@ -143,9 +143,28 @@ fml.configgui.tooltip.undoChanges=Undo Changes fml.configgui.tooltip.default=[default: %s] fml.configgui.tooltip.defaultNumeric=[range: %s ~ %s, default: %s] +forge.controlsgui.shift=SHIFT + %s +forge.controlsgui.control=CTRL + %s +forge.controlsgui.control.mac=CMD + %s +forge.controlsgui.alt=ALT + %s + fml.menu.mods=Mods fml.menu.mods.normal=Normal fml.menu.mods.search=Search: fml.menu.modoptions=Mod Options... -item.forge.bucketFilled.name=%s Bucket \ No newline at end of file +item.forge.bucketFilled.name=%s Bucket + +fml.messages.java8problem=%s%sJava Update Required%s +fml.messages.java8recommended=%s%sJava Update Recommended%s +fml.messages.modslistedbelow=The mods listed below %s +fml.messages.requirejava8=require Java 8 +fml.messages.java8warning.1=%sJAVA VERSION WARNING%s UPDATE JAVA! +fml.messages.java8warning.2=You need to update Java +fml.messages.javaversion=Your Java version is Java %s (version string %s) +fml.messages.upgradejavaorremove=%s%sUpdate Java%s or remove these mods to play +fml.messages.upgradejava=\n\nPros of updating to Java 8\n- Better Performance\n- Better Security\n- Better Compatibility with newer mods +fml.messages.countbadandgood=%s of %s mods have this problem + +fml.button.visitjavadownloads=Oracle Java SE Downloads +fml.button.continue=Continue \ No newline at end of file diff --git a/src/main/resources/assets/forge/models/item/bucket.json b/src/main/resources/assets/forge/models/item/bucket.json index 7a32f750ab..4a8c26d791 100644 --- a/src/main/resources/assets/forge/models/item/bucket.json +++ b/src/main/resources/assets/forge/models/item/bucket.json @@ -1,18 +1,6 @@ { - "parent": "builtin/generated", + "parent": "item/generated", "textures": { "layer0": "forge:items/bucket_base" - }, - "display": { - "thirdperson": { - "rotation": [ -90, 0, 0 ], - "translation": [ 0, 1, -3 ], - "scale": [ 0.55, 0.55, 0.55 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } } } diff --git a/src/main/resources/assets/forge/models/item/bucket_milk.json b/src/main/resources/assets/forge/models/item/bucket_milk.json index 2d1fe26eb9..b62a1226e4 100644 --- a/src/main/resources/assets/forge/models/item/bucket_milk.json +++ b/src/main/resources/assets/forge/models/item/bucket_milk.json @@ -1,20 +1,8 @@ { - "parent": "builtin/generated", + "parent": "item/generated", "textures": { "layer0": "forge:items/bucket_base", "layer1": "forge:items/bucket_fluid", # doubles as milk "layer2": "forge:items/bucket_cover" - }, - "display": { - "thirdperson": { - "rotation": [ -90, 0, 0 ], - "translation": [ 0, 1, -3 ], - "scale": [ 0.55, 0.55, 0.55 ] - }, - "firstperson": { - "rotation": [ 0, -135, 25 ], - "translation": [ 0, 4, 2 ], - "scale": [ 1.7, 1.7, 1.7 ] - } } } diff --git a/src/main/resources/assets/forge/textures/gui/version_check_icons.png b/src/main/resources/assets/forge/textures/gui/version_check_icons.png new file mode 100644 index 0000000000..5d5f0fa294 Binary files /dev/null and b/src/main/resources/assets/forge/textures/gui/version_check_icons.png differ diff --git a/src/main/resources/forge.exc b/src/main/resources/forge.exc index 26194f107c..6902fcec98 100644 --- a/src/main/resources/forge.exc +++ b/src/main/resources/forge.exc @@ -3,8 +3,8 @@ net/minecraft/client/renderer/ItemRenderer.renderItem(Lnet/minecraft/entity/Enti net/minecraft/client/renderer/RenderGlobal.drawBlockDamageTexture(Lnet/minecraft/client/renderer/Tessellator;Lnet/minecraft/entity/EntityLivingBase;F)V=|p_72717_1_,p_72717_2_,p_72717_3_ net/minecraft/client/renderer/entity/RenderItem.renderDroppedItem(Lnet/minecraft/entity/item/EntityItem;Lnet/minecraft/util/IIcon;IFFFFI)V=|p_77020_1_,p_77020_2_,p_77020_3_,p_77020_4_,p_77020_5_,p_77020_6_,p_77020_7_,pass net/minecraft/client/renderer/entity/RenderItem.renderItemIntoGUI(Lnet/minecraft/client/gui/FontRenderer;Lnet/minecraft/client/renderer/texture/TextureManager;Lnet/minecraft/item/ItemStack;IIZ)V=|p_77015_1_,p_77015_2_,p_77015_3_,p_77015_4_,p_77015_5_,renderEffect -net/minecraft/server/management/ServerConfigurationManager.transferPlayerToDimension(Lnet/minecraft/entity/player/EntityPlayerMP;ILnet/minecraft/world/Teleporter;)V=|p_72356_1_,p_72356_2_,teleporter -net/minecraft/server/management/ServerConfigurationManager.transferEntityToWorld(Lnet/minecraft/entity/Entity;ILnet/minecraft/world/WorldServer;Lnet/minecraft/world/WorldServer;Lnet/minecraft/world/Teleporter;)V=|p_82448_1_,p_82448_2_,p_82448_3_,p_82448_4_,teleporter +net/minecraft/server/management/PlayerList.transferPlayerToDimension(Lnet/minecraft/entity/player/EntityPlayerMP;ILnet/minecraft/world/Teleporter;)V=|p_187242_1_,p_187242_2_,teleporter +net/minecraft/server/management/PlayerList.transferEntityToWorld(Lnet/minecraft/entity/Entity;ILnet/minecraft/world/WorldServer;Lnet/minecraft/world/WorldServer;Lnet/minecraft/world/Teleporter;)V=|p_82448_1_,p_82448_2_,p_82448_3_,p_82448_4_,teleporter net/minecraft/world/World.getBiomeGenForCoordsBody(II)Lnet/minecraft/world/biome/BiomeGenBase;=|p_72807_1_,p_72807_2_ net/minecraft/world/World.getSunBrightnessFactor(F)F=|p_72967_1_ net/minecraft/world/World.getSunBrightnessBody(F)F=|p_72971_1_ @@ -19,8 +19,8 @@ net/minecraft/world/biome/BiomeGenBase.(IZ)V=|p_i1971_1_,register net/minecraft/world/chunk/storage/AnvilChunkLoader.loadChunk__Async(Lnet/minecraft/world/World;II)[Ljava/lang/Object;=|p_75815_1_,p_75815_2_,p_75815_3_ net/minecraft/world/chunk/storage/AnvilChunkLoader.checkedReadChunkFromNBT__Async(Lnet/minecraft/world/World;IILnet/minecraft/nbt/NBTTagCompound;)[Ljava/lang/Object;=|p_75822_1_,p_75822_2_,p_75822_3_,p_75822_4_ net/minecraft/world/chunk/storage/AnvilChunkLoader.loadEntities(Lnet/minecraft/world/World;Lnet/minecraft/nbt/NBTTagCompound;Lnet/minecraft/world/chunk/Chunk;)V=|p_75823_1_,p_75823_2_,chunk -net/minecraft/world/gen/ChunkProviderServer.loadChunk(II;Ljava/lang/Runnable;)Lnet/minecraft/world/chunk/Chunk;=|p_73158_1,p_73158_2,runnable -net/minecraft/world/gen/ChunkProviderServer.originalLoadChunk(II)Lnet/minecraft/world/chunk/Chunk;=|p_73158_1_,p_73158_2_ +net/minecraft/world/gen/ChunkProviderServer.loadChunk(II;Ljava/lang/Runnable;)Lnet/minecraft/world/chunk/Chunk;=|p_186025_1_,p_186025_2_,runnable +net/minecraft/world/gen/ChunkProviderServer.originalLoadChunk(II)Lnet/minecraft/world/chunk/Chunk;=|p_186025_1_,p_186025_2_ net/minecraft/block/BlockFire.tryCatchFire(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;ILjava/util/Random;ILnet/minecraft/util/EnumFacing;)V=|p_176536_1_,p_176536_2_,p_176536_3_,p_176536_4_,p_176536_5_,face net/minecraft/block/BlockSkull.getDrops(Lnet/minecraft/world/IBlockAccess;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;I)Ljava/util/List;=|p_180663_1_,p_180663_2_,p_180663_3_,fortune @@ -29,17 +29,21 @@ net/minecraft/server/management/ItemInWorldManager.removeBlock(Lnet/minecraft/ut net/minecraft/client/gui/GuiScreen.drawHoveringText(Ljava/util/List;IILnet/minecraft/client/gui/FontRenderer;)V=|p_146283_1_,p_146283_2_,p_146283_3_,font net/minecraft/block/state/BlockState.(Lnet/minecraft/block/Block;[Lnet/minecraft/block/properties/IProperty;Lcom/google/common/collect/ImmutableMap;)V=|p_i45663_1_,p_i45663_2_,unlistedProperties net/minecraft/client/renderer/entity/RenderItem.applyVanillaTransform(Lnet/minecraft/client/renderer/block/model/ItemTransformVec3f;)V=|p_175034_1_ -net/minecraft/client/resources/model/ModelBakery.bakeModel(Lnet/minecraft/client/renderer/block/model/ModelBlock;Lnet/minecraftforge/client/model/ITransformation;Z)Lnet/minecraft/client/resources/model/IBakedModel;=|p_177578_1_,p_177578_2_,p_177578_3_ -net/minecraft/client/resources/model/ModelBakery.makeBakedQuad(Lnet/minecraft/client/renderer/block/model/BlockPart;Lnet/minecraft/client/renderer/block/model/BlockPartFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/util/EnumFacing;Lnet/minecraftforge/client/model/ITransformation;Z)Lnet/minecraft/client/renderer/block/model/BakedQuad;=|p_177589_1_,p_177589_2_,p_177589_3_,p_177589_4_,p_177589_5_,p_177589_6_ -net/minecraft/client/renderer/block/model/FaceBakery.makeBakedQuad(Lorg/lwjgl/util/vector/Vector3f;Lorg/lwjgl/util/vector/Vector3f;Lnet/minecraft/client/renderer/block/model/BlockPartFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/util/EnumFacing;Lnet/minecraftforge/client/model/ITransformation;Lnet/minecraft/client/renderer/block/model/BlockPartRotation;ZZ)Lnet/minecraft/client/renderer/block/model/BakedQuad;=|p_178414_1_,p_178414_2_,p_178414_3_,p_178414_4_,p_178414_5_,p_178414_6_,p_178414_7_,p_178414_8_,p_178414_9_ -net/minecraft/client/renderer/block/model/FaceBakery.makeQuadVertexData(Lnet/minecraft/client/renderer/block/model/BlockPartFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/util/EnumFacing;[FLnet/minecraftforge/client/model/ITransformation;Lnet/minecraft/client/renderer/block/model/BlockPartRotation;ZZ)[I=|p_178405_1_,p_178405_2_,p_178405_3_,p_178405_4_,p_178405_5_,p_178405_6_,p_178405_7_,p_178405_8_ -net/minecraft/client/renderer/block/model/FaceBakery.fillVertexData([IILnet/minecraft/util/EnumFacing;Lnet/minecraft/client/renderer/block/model/BlockPartFace;[FLnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraftforge/client/model/ITransformation;Lnet/minecraft/client/renderer/block/model/BlockPartRotation;ZZ)V=|p_178402_1_,p_178402_2_,p_178402_3_,p_178402_4_,p_178402_5_,p_178402_6_,p_178402_7_,p_178402_8_,p_178402_9_,p_178402_10_ -net/minecraft/client/renderer/block/model/FaceBakery.rotateVertex(Lorg/lwjgl/util/vector/Vector3f;Lnet/minecraft/util/EnumFacing;ILnet/minecraftforge/client/model/ITransformation;Z)I=|p_178415_1_,p_178415_2_,p_178415_3_,p_178415_4_,p_178415_5_ +net/minecraft/client/renderer/block/model/ModelBakery.bakeModel(Lnet/minecraft/client/renderer/block/model/ModelBlock;Lnet/minecraftforge/common/model/ITransformation;Z)Lnet/minecraft/client/renderer/block/model/IBakedModel;=|p_177578_1_,p_177578_2_,p_177578_3_ +net/minecraft/client/renderer/block/model/ModelBakery.makeBakedQuad(Lnet/minecraft/client/renderer/block/model/BlockPart;Lnet/minecraft/client/renderer/block/model/BlockPartFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/util/EnumFacing;Lnet/minecraftforge/common/model/ITransformation;Z)Lnet/minecraft/client/renderer/block/model/BakedQuad;=|p_177589_1_,p_177589_2_,p_177589_3_,p_177589_4_,p_177589_5_,p_177589_6_ +net/minecraft/client/renderer/block/model/FaceBakery.makeBakedQuad(Lorg/lwjgl/util/vector/Vector3f;Lorg/lwjgl/util/vector/Vector3f;Lnet/minecraft/client/renderer/block/model/BlockPartFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/util/EnumFacing;Lnet/minecraftforge/common/model/ITransformation;Lnet/minecraft/client/renderer/block/model/BlockPartRotation;ZZ)Lnet/minecraft/client/renderer/block/model/BakedQuad;=|p_178414_1_,p_178414_2_,p_178414_3_,p_178414_4_,p_178414_5_,p_178414_6_,p_178414_7_,p_178414_8_,p_178414_9_ +net/minecraft/client/renderer/block/model/FaceBakery.makeQuadVertexData(Lnet/minecraft/client/renderer/block/model/BlockPartFace;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraft/util/EnumFacing;[FLnet/minecraftforge/common/model/ITransformation;Lnet/minecraft/client/renderer/block/model/BlockPartRotation;Z)[I=|p_188012_1_,p_188012_2_,p_188012_3_,p_188012_4_,p_188012_5_,p_188012_6_,p_188012_7_ +net/minecraft/client/renderer/block/model/FaceBakery.fillVertexData([IILnet/minecraft/util/EnumFacing;Lnet/minecraft/client/renderer/block/model/BlockFaceUV;[FLnet/minecraft/client/renderer/texture/TextureAtlasSprite;Lnet/minecraftforge/common/model/ITransformation;Lnet/minecraft/client/renderer/block/model/BlockPartRotation;Z)V=|p_188015_1_,p_188015_2_,p_188015_3_,p_188015_4_,p_188015_5_,p_188015_6_,p_188015_7_,p_188015_8_,p_188015_9_ +net/minecraft/client/renderer/block/model/FaceBakery.rotateVertex(Lorg/lwjgl/util/vector/Vector3f;Lnet/minecraft/util/EnumFacing;ILnet/minecraftforge/common/model/ITransformation)I=|p_188011_1_,p_188011_2_,p_188011_3_,p_188011_4_ net/minecraft/item/ItemBlock.setTileEntityNBT(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/EntityPlayer;)Z=|p_179224_0_,p_179224_1_,p_179224_2_,player -net/minecraft/server/management/ServerConfigurationManager.initializeConnectionToPlayer(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;Lnet/minecraft/network/NetHandlerPlayServer;)V=|p_72355_1_,p_72355_2_,nethandlerplayserver +net/minecraft/server/management/PlayerList.initializeConnectionToPlayer(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;Lnet/minecraft/network/NetHandlerPlayServer;)V=|p_72355_1_,p_72355_2_,nethandlerplayserver net/minecraft/item/ItemMonsterPlacer.spawnCreature(Lnet/minecraft/world/World;Ljava/lang/String;DDD)Lnet/minecraft/entity/Entity;=|p_77840_0_,name,p_77840_2_,p_77840_4_,p_77840_6_ net/minecraft/stats/StatList.mergeStatBases([Lnet/minecraft/stats/StatBase;Lnet/minecraft/block/Block;Lnet/minecraft/block/Block;Z)V=|p_151180_0_,p_151180_1_,p_151180_2_,useItemIds net/minecraft/item/ItemStack.(Lnet/minecraft/item/Item;IILnet/minecraft/nbt/NBTTagCompound;)V=|p_i1881_1_,p_i1881_2_,p_i1881_3_,capNBT + +net/minecraft/block/BlockRedstoneWire.canConnectTo(Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/util/EnumFacing;Lnet/minecraft/world/IBlockAccess;Lnet/minecraft/util/math/BlockPos;)Z=p_176343_0_,p_176343_1_,world,pos +net/minecraft/client/renderer/block/model/BakedQuad.([IILnet/minecraft/util/EnumFacing;Lnet/minecraft/client/renderer/texture/TextureAtlasSprite;ZLnet/minecraft/client/renderer/vertex/VertexFormat;)V=|p_i46574_1_,p_i46574_2_,p_i46574_3_,p_i46574_4_,applyDiffuseLighting,format +net/minecraft/client/renderer/texture/TextureMap.(Ljava/lang/String;Lnet/minecraft/client/renderer/texture/IIconCreator;Z)V=|p_i46100_1_,p_i46100_2_,skipFirst diff --git a/src/main/resources/forge_at.cfg b/src/main/resources/forge_at.cfg index f53e403c71..316062b14f 100644 --- a/src/main/resources/forge_at.cfg +++ b/src/main/resources/forge_at.cfg @@ -1,37 +1,39 @@ #Main Forge Access Transformer configuration file # EntityFishHook -public net.minecraft.entity.projectile.EntityFishHook field_146041_e -public net.minecraft.entity.projectile.EntityFishHook field_146036_f -public net.minecraft.entity.projectile.EntityFishHook field_146039_d +#public net.minecraft.entity.projectile.EntityFishHook field_146041_e +#public net.minecraft.entity.projectile.EntityFishHook field_146036_f +#public net.minecraft.entity.projectile.EntityFishHook field_146039_d # EntityEnderman #public tg.br #FD:EntityEnderman/field_70827_d #carriableBlocks # SoundManager public net.minecraft.client.audio.SoundManager field_148622_c #sndHandler # Block public net.minecraft.block.Block (Lnet/minecraft/block/material/Material;)V -public net.minecraft.block.Block func_149672_a(Lnet.minecraft.block.Block$SoundType;)Lnet.minecraft.block.Block; #setStepSound +#public net.minecraft.block.Block func_149672_a(Lnet.minecraft.block.Block$SoundType;)Lnet.minecraft.block.Block; #setStepSound public net.minecraft.block.Block func_149752_b(F)Lnet.minecraft.block.Block; #setResistance public net.minecraft.block.Block func_149711_c(F)Lnet.minecraft.block.Block; #setHardness public net.minecraft.block.Block func_149713_g(I)Lnet.minecraft.block.Block; #setLightOpacity public net.minecraft.block.Block func_149715_a(F)Lnet.minecraft.block.Block; #setLightValue public net.minecraft.block.Block func_149722_s()Lnet.minecraft.block.Block; #setBlockUnbreakable public net.minecraft.block.Block func_149675_a(Z)Lnet.minecraft.block.Block; #setTickRandomly -public net.minecraft.block.Block func_149676_a(FFFFFF)V #setBlockBounds -public net.minecraft.block.Block func_180637_b(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;I)V # dropXpOnBlockBreak +#public net.minecraft.block.Block func_149676_a(FFFFFF)V #setBlockBounds +public net.minecraft.block.Block func_180637_b(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;I)V # dropXpOnBlockBreak # BlockFire public net.minecraft.block.BlockFire func_176532_c(Lnet/minecraft/block/Block;)I # getFireSpreadSpeed public net.minecraft.block.BlockFire func_176534_d(Lnet/minecraft/block/Block;)I # getFireSpreadSpeed # Item public net.minecraft.item.Item func_77656_e(I)Lnet.minecraft.item.Item; #setMaxDamage public net.minecraft.item.Item func_77627_a(Z)Lnet.minecraft.item.Item; #setHasSubtypes -public net.minecraft.item.Item func_77631_c(Ljava.lang.String;)Lnet.minecraft.item.Item; #setPotionEffect +#public net.minecraft.item.Item func_77631_c(Ljava.lang.String;)Lnet.minecraft.item.Item; #setPotionEffect # Potion -public-f net.minecraft.potion.Potion field_76415_H #id +#public-f net.minecraft.potion.Potion field_76415_H #id # EntityPlayer -public net.minecraft.entity.player.EntityPlayer func_71012_a(Lnet/minecraft/entity/item/EntityItem;)V #joinEntityItemWithWorld -public net.minecraft.client.entity.EntityPlayerSP func_71012_a(Lnet/minecraft/entity/item/EntityItem;)V #joinEntityItemWithWorld +#public net.minecraft.entity.player.EntityPlayer func_71012_a(Lnet/minecraft/entity/item/EntityItem;)V #joinEntityItemWithWorld +#public net.minecraft.client.entity.EntityPlayerSP func_71012_a(Lnet/minecraft/entity/item/EntityItem;)V #joinEntityItemWithWorld public net.minecraft.entity.player.EntityPlayer func_71053_j()V #closeScreen #public uf.b #FD:EntityPlayer/field_71076_b #sleepTimer +# EntityTrackerEntry +public net.minecraft.entity.EntityTrackerEntry field_73134_o # trackingPlayers # World Gen Chests Related public net.minecraft.util.WeightedRandomChestContent * # Save Location @@ -49,6 +51,7 @@ public net.minecraft.world.biome.BiomeGenPlains *() public net.minecraft.world.biome.BiomeGenSavanna *() public net.minecraft.world.biome.BiomeGenSnow *() public net.minecraft.world.biome.BiomeGenTaiga *() +public net.minecraft.world.biome.BiomeGenBase$BiomeProperties *() # Map Gen Biome Lists public+f net.minecraft.world.gen.structure.MapGenStronghold field_151546_e # MapGenVillage @@ -87,12 +90,12 @@ public net.minecraft.world.gen.structure.MapGenStructureIO func_143031_a(Ljava/l # Stronghold public net.minecraft.world.gen.structure.StructureStrongholdPieces$Stronghold # Packets -public net.minecraft.network.play.server.S23PacketBlockChange field_148883_d # Block +public net.minecraft.network.play.server.SPacketBlockChange field_148883_d # blockState # WorldType public-f net.minecraft.world.WorldType field_77139_a #worldTypes # DamageSource public net.minecraft.util.DamageSource *() #All methods public, most are already -# EntityAITasks +# EntityAITasks public net.minecraft.entity.ai.EntityAITasks field_75782_a # taskEntries # EntityXPOrb public net.minecraft.entity.item.EntityXPOrb field_70530_e # xpValue @@ -100,56 +103,66 @@ public net.minecraft.entity.item.EntityXPOrb field_70530_e # xpValue public net.minecraft.world.gen.structure.StructureVillagePieces$Village # RenderPlayer public net.minecraft.client.renderer.entity.RenderBiped field_77071_a #modelBipedMain -# ChunkProviderServer -public net.minecraft.world.gen.ChunkProviderServer field_73246_d # currentChunkProvider +# ChunkProviderServer +public net.minecraft.world.gen.ChunkProviderServer field_186029_c # chunkGenerator public net.minecraft.world.gen.ChunkProviderServer field_73244_f # loadedChunkHashMap public net.minecraft.world.gen.ChunkProviderServer field_73245_g # loadedChunks public net.minecraft.world.gen.ChunkProviderServer field_73251_h # worldObj + # RenderEntityItem protected net.minecraft.client.renderer.entity.RenderEntityItem func_177078_a(Lnet/minecraft/item/ItemStack;)I # getMiniItemCount +public net.minecraft.item.crafting.RecipeTippedArrow +public net.minecraft.item.crafting.ShieldRecipes$Decoration public net.minecraft.item.crafting.RecipesBanners$RecipeAddPattern public net.minecraft.item.crafting.RecipesBanners$RecipeDuplicatePattern -public net.minecraft.block.state.BlockState$StateImplementation -protected net.minecraft.block.state.BlockState$StateImplementation (Lnet/minecraft/block/Block;Lcom/google/common/collect/ImmutableMap;)V -protected net.minecraft.block.state.BlockState$StateImplementation field_177238_c # propertyValueTable +public net.minecraft.block.state.BlockStateContainer$StateImplementation +protected net.minecraft.block.state.BlockStateContainer$StateImplementation (Lnet/minecraft/block/Block;Lcom/google/common/collect/ImmutableMap;)V +protected net.minecraft.block.state.BlockStateContainer$StateImplementation field_177238_c # propertyValueTable public net.minecraft.client.renderer.block.model.ModelBlock field_178318_c # textures public net.minecraft.client.renderer.block.model.ModelBlock field_178315_d # parent public net.minecraft.client.renderer.block.model.ModelBlock field_178322_i # ambientOcclusion -protected net.minecraft.client.resources.model.ModelBakery field_177602_b # LOCATIONS_BUILTIN_TEXTURES -protected net.minecraft.client.resources.model.ModelBakery field_177598_f # resourceManager -protected net.minecraft.client.resources.model.ModelBakery field_177599_g # sprites -protected net.minecraft.client.resources.model.ModelBakery field_177609_j # textureMap -protected net.minecraft.client.resources.model.ModelBakery field_177610_k # blockModelShapes -protected net.minecraft.client.resources.model.ModelBakery field_177605_n # bakedRegistry -protected net.minecraft.client.resources.model.ModelBakery field_177606_o # MODEL_GENERATED -protected net.minecraft.client.resources.model.ModelBakery field_177618_p # MODEL_COMPASS -protected net.minecraft.client.resources.model.ModelBakery field_177617_q # MODEL_CLOCK -protected net.minecraft.client.resources.model.ModelBakery field_177616_r # MODEL_ENTITY -protected net.minecraft.client.resources.model.ModelBakery func_177591_a(Ljava/util/Collection;)V # loadVariants -protected net.minecraft.client.resources.model.ModelBakery func_177569_a(Lnet/minecraft/client/renderer/block/model/ModelBlockDefinition;Lnet/minecraft/client/resources/model/ModelResourceLocation;)V # registerVariant -protected net.minecraft.client.resources.model.ModelBakery func_177586_a(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/block/model/ModelBlockDefinition; # getModelBlockDefinition -protected net.minecraft.client.resources.model.ModelBakery func_177594_c(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/block/model/ModelBlock; # loadModel -protected net.minecraft.client.resources.model.ModelBakery func_177592_e()V # registerVariantNames -protected net.minecraft.client.resources.model.ModelBakery func_177596_a(Lnet/minecraft/item/Item;)Ljava/util/List; # getVariantNames -protected net.minecraft.client.resources.model.ModelBakery func_177583_a(Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; # getItemLocation -protected net.minecraft.client.resources.model.ModelBakery func_177585_a(Lnet/minecraft/client/renderer/block/model/ModelBlock;)Ljava/util/Set; # getTextureLocations -protected net.minecraft.client.resources.model.ModelBakery func_177581_b(Lnet/minecraft/client/renderer/block/model/ModelBlock;)Z # hasItemModel -protected net.minecraft.client.resources.model.ModelBakery func_177587_c(Lnet/minecraft/client/renderer/block/model/ModelBlock;)Z # isCustomRenderer -protected net.minecraft.client.resources.model.ModelBakery func_177582_d(Lnet/minecraft/client/renderer/block/model/ModelBlock;)Lnet/minecraft/client/renderer/block/model/ModelBlock; # makeItemModel -protected net.minecraft.client.resources.model.ModelBakery func_177580_d(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/util/ResourceLocation; # getModelLocation -public net.minecraft.client.resources.model.WeightedBakedModel field_177565_b # models +public net.minecraft.client.renderer.block.model.ModelBlock func_187966_f()Ljava/util/List; # getOverrides +protected net.minecraft.client.renderer.block.model.ModelBakery field_177602_b # LOCATIONS_BUILTIN_TEXTURES +protected net.minecraft.client.renderer.block.model.ModelBakery field_177598_f # resourceManager +protected net.minecraft.client.renderer.block.model.ModelBakery field_177599_g # sprites +protected net.minecraft.client.renderer.block.model.ModelBakery field_177609_j # textureMap +protected net.minecraft.client.renderer.block.model.ModelBakery field_177610_k # blockModelShapes +protected net.minecraft.client.renderer.block.model.ModelBakery field_177605_n # bakedRegistry +protected net.minecraft.client.renderer.block.model.ModelBakery field_177606_o # MODEL_GENERATED +#protected net.minecraft.client.renderer.block.model.ModelBakery field_177618_p # MODEL_COMPASS +#protected net.minecraft.client.renderer.block.model.ModelBakery field_177617_q # MODEL_CLOCK +protected net.minecraft.client.renderer.block.model.ModelBakery field_177616_r # MODEL_ENTITY +#protected net.minecraft.client.renderer.block.model.ModelBakery func_177591_a(Ljava/util/Collection;)V # loadVariants +protected net.minecraft.client.renderer.block.model.ModelBakery func_177569_a(Lnet/minecraft/client/renderer/block/model/ModelBlockDefinition;Lnet/minecraft/client/renderer/block/model/ModelResourceLocation;)V # registerVariant +protected net.minecraft.client.renderer.block.model.ModelBakery func_177586_a(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/block/model/ModelBlockDefinition; # getModelBlockDefinition +protected net.minecraft.client.renderer.block.model.ModelBakery func_177594_c(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/block/model/ModelBlock; # loadModel +protected net.minecraft.client.renderer.block.model.ModelBakery func_177592_e()V # registerVariantNames +protected net.minecraft.client.renderer.block.model.ModelBakery func_177596_a(Lnet/minecraft/item/Item;)Ljava/util/List; # getVariantNames +protected net.minecraft.client.renderer.block.model.ModelBakery func_177583_a(Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; # getItemLocation +protected net.minecraft.client.renderer.block.model.ModelBakery func_177585_a(Lnet/minecraft/client/renderer/block/model/ModelBlock;)Ljava/util/Set; # getTextureLocations +protected net.minecraft.client.renderer.block.model.ModelBakery func_177581_b(Lnet/minecraft/client/renderer/block/model/ModelBlock;)Z # hasItemModel +protected net.minecraft.client.renderer.block.model.ModelBakery func_177587_c(Lnet/minecraft/client/renderer/block/model/ModelBlock;)Z # isCustomRenderer +protected net.minecraft.client.renderer.block.model.ModelBakery func_177582_d(Lnet/minecraft/client/renderer/block/model/ModelBlock;)Lnet/minecraft/client/renderer/block/model/ModelBlock; # makeItemModel +protected net.minecraft.client.renderer.block.model.ModelBakery func_177580_d(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/util/ResourceLocation; # getModelLocation +protected net.minecraft.client.renderer.block.model.ModelBakery func_188640_b()V # loadBlocks +protected net.minecraft.client.renderer.block.model.ModelBakery func_177577_b()V # loadVariantItemModels +protected net.minecraft.client.renderer.block.model.ModelBakery func_177590_d()V # loadItemModels +protected net.minecraft.client.renderer.block.model.ModelBakery func_177595_c()V # loadVariantModels +protected net.minecraft.client.renderer.block.model.ModelBakery func_188637_e()V # loadMultipartVariantModels +protected net.minecraft.client.renderer.block.model.ModelBakery func_188638_a(Lnet/minecraft/client/renderer/block/model/ModelResourceLocation;Lnet/minecraft/client/renderer/block/model/VariantList;)V # loadVariantList +#public net.minecraft.client.renderer.block.model.WeightedBakedModel field_177565_b # models # EnumFacing public net.minecraft.util.EnumFacing field_82609_l # VALUES public net.minecraft.util.EnumFacing field_176754_o # HORIZONTALS -public net.minecraft.client.renderer.WorldRenderer func_78909_a(I)I # getColorIndex -public net.minecraft.client.renderer.WorldRenderer func_178972_a(IIIII)V # putColorRGBA +public net.minecraft.client.renderer.VertexBuffer func_78909_a(I)I # getColorIndex +public net.minecraft.client.renderer.VertexBuffer func_178972_a(IIIII)V # putColorRGBA # ModelBlock Constructor -public net.minecraft.client.renderer.block.model.ModelBlock (Lnet/minecraft/util/ResourceLocation;Ljava/util/List;Ljava/util/Map;ZZLnet/minecraft/client/renderer/block/model/ItemCameraTransforms;)V +#public net.minecraft.client.renderer.block.model.ModelBlock (Lnet/minecraft/util/ResourceLocation;Ljava/util/List;Ljava/util/Map;ZZLnet/minecraft/client/renderer/block/model/ItemCameraTransforms;)V # RenderLivingEntity -public net.minecraft.client.renderer.entity.RendererLivingEntity func_177094_a(Lnet/minecraft/client/renderer/entity/layers/LayerRenderer;)Z # addLayer - +#public net.minecraft.client.renderer.entity.RenderLivingBase func_177094_a(Lnet/minecraft/client/renderer/entity/layers/LayerRenderer;)Z # addLayer + # S00PacketServerInfo -public net.minecraft.network.status.server.S00PacketServerInfo field_149297_a # GSON +public net.minecraft.network.status.server.SPacketServerInfo field_149297_a # GSON #Main FML Access Transformer configuration file # TileEntity addMapping @@ -168,6 +181,10 @@ public net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher fie public net.minecraft.client.renderer.EntityRenderer func_175069_a(Lnet/minecraft/util/ResourceLocation;)V #loadShader ## WeightedRandomItem public net.minecraft.util.WeightedRandom$Item field_76292_a #probability +# EntityPlayer +public net.minecraft.entity.player.EntityPlayer func_184816_a(Lnet/minecraft/entity/item/EntityItem;)Lnet/minecraft/item/ItemStack; # dropItemAndGetStack +# EntityPlayerSP +public net.minecraft.client.entity.EntityPlayerSP func_184816_a(Lnet/minecraft/entity/item/EntityItem;)Lnet/minecraft/item/ItemStack; # dropItemAndGetStack ## EntityPlayerMP getNextWindowId public net.minecraft.entity.player.EntityPlayerMP func_71117_bO()V public net.minecraft.entity.player.EntityPlayerMP field_71139_cq @@ -185,6 +202,7 @@ public net.minecraft.client.Minecraft field_71446_o # textureManager public net.minecraft.client.Minecraft field_110450_ap # mcDefaultResourcePack public net.minecraft.client.Minecraft func_71370_a(II)V # resize public net.minecraft.client.Minecraft func_180510_a(Lnet/minecraft/client/renderer/texture/TextureManager;)V # drawSplashScreen +public net.minecraft.client.Minecraft func_184119_a(Lnet/minecraft/item/ItemStack;Lnet/minecraft/tileentity/TileEntity;)Lnet/minecraft/item/ItemStack; # storeTEInStack ## ItemBlock public net.minecraft.item.ItemBlock field_150939_a ## DedicatedServer @@ -194,7 +212,7 @@ public net.minecraft.world.storage.SaveFormatOld field_75808_a # savesDirectory protected net.minecraft.util.ObjectIntIdentityMap field_148749_a # internal map protected net.minecraft.util.ObjectIntIdentityMap field_148748_b # internal index list -protected-f net.minecraft.util.RegistryNamespaced field_148759_a # identitymap +#protected-f net.minecraft.util.RegistryNamespaced field_148759_a # identitymap # GuiButton public net.minecraft.client.gui.GuiButton field_146120_f # width - needed for config GUI stuff @@ -231,5 +249,43 @@ protected net.minecraft.client.gui.FontRenderer func_78266_a(IZ)F # renderDefaul protected net.minecraft.client.gui.FontRenderer func_78277_a(CZ)F # renderUnicodeChar # ServerConfigurationManager -public net.minecraft.server.management.ServerConfigurationManager field_72404_b #playerEntityList - private in 1.8.8 -public net.minecraft.server.management.ServerConfigurationManager field_177454_f #uuidToPlayerMap - private in 1.8.8 +#public net.minecraft.server.management.ServerConfigurationManager field_72404_b #playerEntityList - private in 1.8.8 +#public net.minecraft.server.management.ServerConfigurationManager field_177454_f #uuidToPlayerMap - private in 1.8.8 + +# ChunkProviderServer +# ChunkProviderEnd +private-f net.minecraft.world.gen.ChunkProviderEnd field_185969_i #lperlin1 +private-f net.minecraft.world.gen.ChunkProviderEnd field_185970_j #lperlin2 +private-f net.minecraft.world.gen.ChunkProviderEnd field_185971_k #perlin +private-f net.minecraft.world.gen.ChunkProviderEnd field_185973_o #island + +# ChunkProviderOverworld +private-f net.minecraft.world.gen.ChunkProviderOverworld field_185991_j #lperlin1 +private-f net.minecraft.world.gen.ChunkProviderOverworld field_185992_k #lperlin2 +private-f net.minecraft.world.gen.ChunkProviderOverworld field_185993_l #perlin +private-f net.minecraft.world.gen.ChunkProviderOverworld field_185994_m #surface +private-f net.minecraft.world.gen.ChunkProviderOverworld field_185979_A #ravineGenerator +private-f net.minecraft.world.gen.ChunkProviderOverworld field_185980_B #oceanMonumentGenerator +private-f net.minecraft.world.gen.ChunkProviderOverworld field_186003_v #caveGenerator +private-f net.minecraft.world.gen.ChunkProviderOverworld field_186004_w #strongholdGenerator +private-f net.minecraft.world.gen.ChunkProviderOverworld field_186005_x #villageGenerator +private-f net.minecraft.world.gen.ChunkProviderOverworld field_186006_y #mineshaftGenerator +private-f net.minecraft.world.gen.ChunkProviderOverworld field_186007_z #scatteredFeatureGenerator + +# ChunkProviderHell +private-f net.minecraft.world.gen.ChunkProviderHell field_185957_u #lperlin1 +private-f net.minecraft.world.gen.ChunkProviderHell field_185958_v #lperlin2 +private-f net.minecraft.world.gen.ChunkProviderHell field_185959_w #perlin +private-f net.minecraft.world.gen.ChunkProviderHell field_73177_m #perlin2 +private-f net.minecraft.world.gen.ChunkProviderHell field_73174_n #perlin3 +public-f net.minecraft.world.gen.ChunkProviderHell field_185946_g #scale +public-f net.minecraft.world.gen.ChunkProviderHell field_185947_h #depth +private-f net.minecraft.world.gen.ChunkProviderHell field_185939_I #netherCaveGenerator +private-f net.minecraft.world.gen.ChunkProviderHell field_73172_c #netherBridgeGenerator + +# PlayerManager +private-f net.minecraft.server.management.PlayerManager$PlayerInstance field_187285_e # field_187285_e + +# RenderLivingBase +public net.minecraft.client.renderer.entity.RenderLivingBase func_177094_a(Lnet/minecraft/client/renderer/entity/layers/LayerRenderer;)Z # addLayer +public net.minecraft.client.renderer.entity.RenderLivingBase func_177089_b(Lnet/minecraft/client/renderer/entity/layers/LayerRenderer;)Z # removeLayer diff --git a/src/main/resources/lgpl-3.0.txt b/src/main/resources/lgpl-3.0.txt deleted file mode 100644 index 02bbb60bc4..0000000000 --- a/src/main/resources/lgpl-3.0.txt +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - 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 that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU 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 as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. \ No newline at end of file diff --git a/src/test/java/net/minecraftforge/debug/DynBucketTest.java b/src/test/java/net/minecraftforge/debug/DynBucketTest.java index e93adcbbc4..1846a92c2e 100644 --- a/src/test/java/net/minecraftforge/debug/DynBucketTest.java +++ b/src/test/java/net/minecraftforge/debug/DynBucketTest.java @@ -1,25 +1,30 @@ package net.minecraftforge.debug; +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelBakery; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; -import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.model.ModelLoader; @@ -40,11 +45,14 @@ import net.minecraftforge.items.wrapper.CombinedInvWrapper; import java.util.List; -@Mod(modid = "DynBucketTest", version = "0.1", dependencies = "after:" + ModelFluidDebug.MODID) +@Mod(modid = DynBucketTest.MODID, version = "0.1", dependencies = "after:" + ModelFluidDebug.MODID) public class DynBucketTest { + public static final String MODID = "DynBucketTest"; public static final Item dynBucket = new DynBucket(); public static final Item dynBottle = new DynBottle(); + private static final ResourceLocation simpleTankName = new ResourceLocation(MODID, "simpletank"); + private static final ResourceLocation testItemName = new ResourceLocation(MODID, "testitem"); static { @@ -82,21 +90,26 @@ public class DynBucketTest } }); ModelBakery.registerItemVariants(dynBottle, bottle); + ModelLoader.setCustomModelResourceLocation(Item.itemRegistry.getObject(simpleTankName), 0, new ModelResourceLocation(simpleTankName, "normal")); + ModelLoader.setCustomModelResourceLocation(Item.itemRegistry.getObject(testItemName), 0, new ModelResourceLocation(new ResourceLocation("minecraft", "stick"), "inventory")); } } + @SuppressWarnings("unused") @EventHandler public void preInit(FMLPreInitializationEvent event) { - GameRegistry.registerItem(new TestItem(), "testitem"); - GameRegistry.registerBlock(new BlockSimpleTank(), "simpletank"); + GameRegistry.register(new TestItem(), testItemName); + Block tank = new BlockSimpleTank(); + GameRegistry.register(tank, simpleTankName); + GameRegistry.register(new ItemBlock(tank), simpleTankName); GameRegistry.registerTileEntity(TileSimpleTank.class, "simpletank"); FluidRegistry.addBucketForFluid(FluidRegistry.getFluid(TestFluid.name)); FluidRegistry.addBucketForFluid(FluidRegistry.getFluid(TestGas.name)); //GameRegistry.registerItem(dynBucket, "dynbucket"); - GameRegistry.registerItem(dynBottle, "dynbottle"); + GameRegistry.register(dynBottle); // register fluid containers int i = 0; @@ -118,6 +131,7 @@ public class DynBucketTest //MinecraftForge.EVENT_BUS.register(this); } + @SuppressWarnings("unused") private void registerFluidContainer(Fluid fluid, int meta) { if (fluid == null) @@ -128,6 +142,7 @@ public class DynBucketTest FluidContainerRegistry.registerFluidContainer(fs, stack, new ItemStack(Items.bucket)); } + @SuppressWarnings("unused") private void registerFluidContainer2(Fluid fluid, int meta) { if (fluid == null) @@ -141,16 +156,16 @@ public class DynBucketTest @SubscribeEvent public void onBucketFill(FillBucketEvent event) { - IBlockState state = event.world.getBlockState(event.target.getBlockPos()); + IBlockState state = event.getWorld().getBlockState(event.getTarget().getBlockPos()); if (state.getBlock() instanceof IFluidBlock) { Fluid fluid = ((IFluidBlock) state.getBlock()).getFluid(); FluidStack fs = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME); - ItemStack filled = FluidContainerRegistry.fillFluidContainer(fs, event.current); + ItemStack filled = FluidContainerRegistry.fillFluidContainer(fs, event.getEmptyBucket()); if (filled != null) { - event.result = filled; + event.setFilledBucket(filled); event.setResult(Result.ALLOW); } } @@ -158,10 +173,10 @@ public class DynBucketTest public static class TestItem extends Item { @Override - public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) + public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { if(worldIn.isRemote) - return itemStackIn; + return new ActionResult(EnumActionResult.PASS, itemStackIn); ItemStackHandler handler = new ItemStackHandler(5); ItemStackHandler handler2 = new ItemStackHandler(5); @@ -191,7 +206,7 @@ public class DynBucketTest System.out.println("Joined: " + joined.getStackInSlot(i)); } - return itemStackIn; + return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); } } @@ -223,6 +238,7 @@ public class DynBucketTest { super(250, new ItemStack(Items.glass_bottle), true); setUnlocalizedName("dynbottle"); + setRegistryName(new ResourceLocation(MODID, "dynbottle")); setMaxStackSize(16); setHasSubtypes(true); setCreativeTab(CreativeTabs.tabMisc); @@ -246,7 +262,7 @@ public class DynBucketTest } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity te = worldIn.getTileEntity(pos); if (!(te instanceof IFluidHandler)) @@ -256,15 +272,14 @@ public class DynBucketTest IFluidHandler tank = (IFluidHandler) te; side = side.getOpposite(); - ItemStack stack = playerIn.getHeldItem(); - if (stack == null) + if (heldItem == null) { sendText(playerIn, tank, side); return false; } // do the thing with the tank and the buckets - if (FluidUtil.interactWithTank(stack, playerIn, tank, side)) + if (FluidUtil.interactWithTank(heldItem, playerIn, tank, side)) { return true; } @@ -274,7 +289,7 @@ public class DynBucketTest } // prevent interaction of the item if it's a fluidcontainer. Prevents placing liquids when interacting with the tank - return FluidContainerRegistry.isFilledContainer(stack) || stack.getItem() instanceof IFluidContainerItem; + return FluidContainerRegistry.isFilledContainer(heldItem) || heldItem.getItem() instanceof IFluidContainerItem; } private void sendText(EntityPlayer player, IFluidHandler tank, EnumFacing side) @@ -289,7 +304,7 @@ public class DynBucketTest { text = "empty"; } - player.addChatMessage(new ChatComponentText(text)); + player.addChatMessage(new TextComponentString(text)); } } } @@ -303,7 +318,8 @@ public class DynBucketTest { int filled = tank.fill(resource, doFill); if(doFill && filled > 0) { - worldObj.markBlockForUpdate(pos); + IBlockState state = worldObj.getBlockState(pos); + worldObj.notifyBlockUpdate(pos, state, state, 8); // TODO check flag } return filled; } @@ -320,7 +336,8 @@ public class DynBucketTest { FluidStack drained = tank.drain(maxDrain, doDrain); if(doDrain && drained != null) { - worldObj.markBlockForUpdate(pos); + IBlockState state = worldObj.getBlockState(pos); + worldObj.notifyBlockUpdate(pos, state, state, 8); // TODO check flag } return drained; } @@ -359,14 +376,14 @@ public class DynBucketTest } @Override - public Packet getDescriptionPacket() { + public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); writeToNBT(tag); - return new S35PacketUpdateTileEntity(this.getPos(), this.getBlockMetadata(), tag); + return new SPacketUpdateTileEntity(this.getPos(), this.getBlockMetadata(), tag); } @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { super.onDataPacket(net, pkt); readFromNBT(pkt.getNbtCompound()); } diff --git a/src/test/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java b/src/test/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java index 6fe7468fb7..fcd979faf6 100644 --- a/src/test/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java +++ b/src/test/java/net/minecraftforge/debug/ForgeBlockStatesLoaderDebug.java @@ -7,11 +7,11 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockWall; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.statemap.IStateMapper; import net.minecraft.client.renderer.block.statemap.StateMap; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; @@ -35,7 +35,7 @@ public class ForgeBlockStatesLoaderDebug { public static final String MODID = "ForgeBlockStatesLoader"; public static final String ASSETS = "forgeblockstatesloader:"; - public static final Block blockCustom = new CustomMappedBlock(); + //public static final Block blockCustom = new CustomMappedBlock(); public static final String nameCustomWall = "custom_wall"; public static final BlockWall blockCustomWall = new BlockWall(Blocks.cobblestone); public static final ItemMultiTexture itemCustomWall = (ItemMultiTexture)new ItemMultiTexture(blockCustomWall, blockCustomWall, new Function() @@ -50,12 +50,12 @@ public class ForgeBlockStatesLoaderDebug { @EventHandler public void preInit(FMLPreInitializationEvent event) { - blockCustom.setUnlocalizedName(MODID + ".customBlock").setRegistryName("customBlock"); - GameRegistry.registerBlock(blockCustom); + //blockCustom.setUnlocalizedName(MODID + ".customBlock").setRegistryName("customBlock"); + //GameRegistry.registerBlock(blockCustom); blockCustomWall.setUnlocalizedName(MODID + ".customWall").setRegistryName(nameCustomWall); - GameRegistry.registerBlock(blockCustomWall, (Class)null); - GameRegistry.registerItem(itemCustomWall); + GameRegistry.register(blockCustomWall); + GameRegistry.register(itemCustomWall); GameData.getBlockItemMap().put(blockCustomWall, itemCustomWall); if (event.getSide() == Side.CLIENT) @@ -65,7 +65,7 @@ public class ForgeBlockStatesLoaderDebug { @SideOnly(Side.CLIENT) public void preInitClient(FMLPreInitializationEvent event) { - ModelLoader.setCustomStateMapper(blockCustom, new StateMap.Builder().withName(CustomMappedBlock.VARIANT).build()); + //ModelLoader.setCustomStateMapper(blockCustom, new StateMap.Builder().withName(CustomMappedBlock.VARIANT).build()); ModelLoader.setCustomStateMapper(blockCustomWall, new IStateMapper() { @@ -91,7 +91,8 @@ public class ForgeBlockStatesLoaderDebug { } // this block is never actually used, it's only needed for the error message on load to see the variant it maps to - public static class CustomMappedBlock extends Block + // disabling until we can make it a proper test + /*public static class CustomMappedBlock extends Block { public static final PropertyEnum VARIANT = PropertyEnum.create("type", CustomVariant.class); @@ -102,8 +103,8 @@ public class ForgeBlockStatesLoaderDebug { } @Override - protected BlockState createBlockState() { - return new BlockState(this, VARIANT); + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, VARIANT); } @Override @@ -122,10 +123,10 @@ public class ForgeBlockStatesLoaderDebug { } public static enum CustomVariant implements IStringSerializable { - TypeA, - TypeB; + type_a, + type_b; public String getName() { return this.toString(); }; } - } + }*/ } diff --git a/src/test/java/net/minecraftforge/debug/ItemLayerModelDebug.java b/src/test/java/net/minecraftforge/debug/ItemLayerModelDebug.java index da52b7f666..1e827bb0c3 100644 --- a/src/test/java/net/minecraftforge/debug/ItemLayerModelDebug.java +++ b/src/test/java/net/minecraftforge/debug/ItemLayerModelDebug.java @@ -1,8 +1,9 @@ package net.minecraftforge.debug; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; @@ -26,7 +27,7 @@ public class ItemLayerModelDebug { public void preInit(FMLPreInitializationEvent event) { - GameRegistry.registerItem(TestItem.instance, TestItem.name); + GameRegistry.register(TestItem.instance); } } @@ -52,6 +53,7 @@ public class ItemLayerModelDebug { setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } } } diff --git a/src/test/java/net/minecraftforge/debug/ItemTileDebug.java b/src/test/java/net/minecraftforge/debug/ItemTileDebug.java index 6a21bba966..8cd2b7a84b 100644 --- a/src/test/java/net/minecraftforge/debug/ItemTileDebug.java +++ b/src/test/java/net/minecraftforge/debug/ItemTileDebug.java @@ -2,12 +2,15 @@ package net.minecraftforge.debug; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.event.ModelBakeEvent; @@ -43,7 +46,8 @@ public class ItemTileDebug { public void preInit(FMLPreInitializationEvent event) { - GameRegistry.registerBlock(TestBlock.instance, TestBlock.name); + GameRegistry.register(TestBlock.instance); + GameRegistry.register(new ItemBlock(TestBlock.instance).setRegistryName(TestBlock.instance.getRegistryName())); GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity"); } @@ -54,7 +58,7 @@ public class ItemTileDebug public static class ClientProxy extends CommonProxy { - private static ModelResourceLocation itemLocation = new ModelResourceLocation(blockName, "inventory"); + private static ModelResourceLocation itemLocation = new ModelResourceLocation(blockName, "normal"); @SuppressWarnings("deprecation") @Override @@ -82,7 +86,7 @@ public class ItemTileDebug @SubscribeEvent public void onModelBakeEvent(ModelBakeEvent event) { - event.modelManager.getBlockModelShapes().registerBuiltInBlocks(TestBlock.instance); + event.getModelManager().getBlockModelShapes().registerBuiltInBlocks(TestBlock.instance); } } @@ -122,13 +126,14 @@ public class ItemTileDebug super(Material.iron); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } @Override - public boolean isOpaqueCube() { return false; } + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube() { return false; } + public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isVisuallyOpaque() { return false; } diff --git a/src/test/java/net/minecraftforge/debug/LayerBreakingTest.java b/src/test/java/net/minecraftforge/debug/LayerBreakingTest.java deleted file mode 100644 index f6559bc2fa..0000000000 --- a/src/test/java/net/minecraftforge/debug/LayerBreakingTest.java +++ /dev/null @@ -1,225 +0,0 @@ - -package net.minecraftforge.debug; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockModelShapes; -import net.minecraft.client.renderer.block.model.BakedQuad; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.vertex.VertexFormat; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Blocks; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumWorldBlockLayer; -import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.model.IFlexibleBakedModel; -import net.minecraftforge.client.model.ISmartBlockModel; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; -import net.minecraftforge.fml.relauncher.Side; - -import com.google.common.primitives.Ints; - -@SuppressWarnings( "deprecation" ) -@Mod( modid = "LayerBreakingTest", name = "LayerBreakingTest", version = "0.0.0" ) -public class LayerBreakingTest -{ - public static final boolean ENABLE = true; - public static TestBlock testBlock; - - class TestBakedModel implements IFlexibleBakedModel - { - TextureAtlasSprite texture; - List list = new ArrayList(); - - private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, int u, int v) - { - return new int[] { Float.floatToRawIntBits(x), Float.floatToRawIntBits(y), Float.floatToRawIntBits(z), color, Float.floatToRawIntBits(texture.getInterpolatedU(u)), Float.floatToRawIntBits(texture.getInterpolatedV(v)), 0 }; - } - - public TestBakedModel(TextureAtlasSprite sprite, boolean top) - { - texture = sprite; - if (top) - { - list.add(new BakedQuad(Ints.concat(vertexToInts(0.5f, 1.0f, 0, -1, texture, 8, 0), vertexToInts(0.5f, 1.0f, 1, -1, texture, 8, 16), vertexToInts(1, 1.0f, 1, -1, texture, 16, 16), vertexToInts(1, 1.0f, 0, -1, texture, 16, 0)), -1, EnumFacing.UP)); - } - else - { - list.add(new BakedQuad(Ints.concat(vertexToInts(0, 1.0f, 0, -1, texture, 0, 0), vertexToInts(0, 1.0f, 1, -1, texture, 0, 16), vertexToInts(0.5f, 1.0f, 1, -1, texture, 8, 16), vertexToInts(0.5f, 1.0f, 0, -1, texture, 8, 0)), -1, EnumFacing.DOWN)); - } - } - - @Override - public boolean isAmbientOcclusion() - { - return true; - } - - @Override - public boolean isGui3d() - { - return true; - } - - @Override - public boolean isBuiltInRenderer() - { - return false; - } - - @Override - public TextureAtlasSprite getParticleTexture() - { - return texture; - } - - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return ItemCameraTransforms.DEFAULT; - } - - @Override - public List getFaceQuads(EnumFacing side) - { - return Collections.emptyList(); - } - - @Override - public List getGeneralQuads() - { - return list; - } - - @Override - public VertexFormat getFormat() - { - return null; - } - }; - - class TestBlock extends Block - { - protected TestBlock() - { - super(Material.glass); - setHardness(7); - setCreativeTab(CreativeTabs.tabBlock); - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - public boolean isFullCube() - { - return false; - } - - @Override - public boolean canRenderInLayer(EnumWorldBlockLayer layer) - { - return layer == EnumWorldBlockLayer.SOLID || layer == EnumWorldBlockLayer.TRANSLUCENT; - } - }; - - class SmartModel implements IBakedModel, ISmartBlockModel - { - IFlexibleBakedModel solid; - IFlexibleBakedModel translucent; - - @Override - public List getFaceQuads(EnumFacing p_177551_1_) - { - return Collections.emptyList(); - } - - @Override - public List getGeneralQuads() - { - return Collections.emptyList(); - } - - @Override - public boolean isAmbientOcclusion() - { - return true; - } - - @Override - public boolean isGui3d() - { - return true; - } - - @Override - public boolean isBuiltInRenderer() - { - return false; - } - - @Override - public TextureAtlasSprite getParticleTexture() - { - return null; - } - - @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return ItemCameraTransforms.DEFAULT; - } - - @Override - public IBakedModel handleBlockState(IBlockState state) - { - if (solid == null) - { - BlockModelShapes models = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes(); - translucent = new TestBakedModel(models.getModelForState(Blocks.stained_glass.getStateFromMeta(3)).getParticleTexture(), true); - solid = new TestBakedModel(models.getModelForState(Blocks.cobblestone.getDefaultState()).getParticleTexture(), false); - } - - if (net.minecraftforge.client.MinecraftForgeClient.getRenderLayer() == EnumWorldBlockLayer.SOLID) - { - return solid; - } - else - { - return translucent; - } - } - }; - - @SubscribeEvent - public void onModelBakeEvent(ModelBakeEvent event) - { - event.modelRegistry.putObject(new ModelResourceLocation("layerbreakingtest:layer_breaking_test"), new SmartModel()); - } - - @EventHandler - public void init(FMLInitializationEvent event) - { - if (ENABLE && event.getSide() == Side.CLIENT) - { - MinecraftForge.EVENT_BUS.register(this); - GameRegistry.registerBlock(testBlock = new TestBlock(), "layer_breaking_test"); - } - } -} diff --git a/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java b/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java index 81eb2cfc22..f546b01f8c 100644 --- a/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java +++ b/src/test/java/net/minecraftforge/debug/ModelAnimationDebug.java @@ -1,46 +1,45 @@ package net.minecraftforge.debug; -import java.io.IOException; - import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.client.model.IModel; -import net.minecraftforge.client.model.IModelState; -import net.minecraftforge.client.model.IRetexturableModel; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoaderRegistry; -import net.minecraftforge.client.model.MultiModel; -import net.minecraftforge.client.model.TRSRTransformation; import net.minecraftforge.client.model.animation.Animation; -import net.minecraftforge.client.model.animation.AnimationModelBase; import net.minecraftforge.client.model.animation.AnimationTESR; -import net.minecraftforge.client.model.animation.Event; -import net.minecraftforge.client.model.animation.IAnimationProvider; -import net.minecraftforge.client.model.animation.ITimeValue; -import net.minecraftforge.client.model.animation.TimeValues.VariableValue; import net.minecraftforge.client.model.b3d.B3DLoader; import net.minecraftforge.client.model.pipeline.VertexLighterSmoothAo; +import net.minecraftforge.common.animation.Event; +import net.minecraftforge.common.animation.ITimeValue; +import net.minecraftforge.common.animation.TimeValues.VariableValue; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.model.animation.CapabilityAnimation; import net.minecraftforge.common.model.animation.IAnimationStateMachine; import net.minecraftforge.common.property.ExtendedBlockState; import net.minecraftforge.common.property.IUnlistedProperty; @@ -56,8 +55,6 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; -import org.apache.commons.lang3.tuple.Pair; - import com.google.common.collect.ImmutableMap; @Mod(modid = ModelAnimationDebug.MODID, version = ModelAnimationDebug.VERSION) @@ -67,6 +64,7 @@ public class ModelAnimationDebug public static final String VERSION = "0.0"; public static String blockName = "test_animation_block"; + public static ResourceLocation blockId = new ResourceLocation(MODID, blockName); public static final PropertyDirection FACING = PropertyDirection.create("facing"); @Instance(MODID) @@ -79,11 +77,12 @@ public class ModelAnimationDebug { public void preInit(FMLPreInitializationEvent event) { - GameRegistry.registerBlock(new Block(Material.wood) + GameRegistry.register(new Block(Material.wood) { { setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + "." + blockName); + setRegistryName(blockId); } @Override @@ -93,15 +92,15 @@ public class ModelAnimationDebug } @Override - public boolean isOpaqueCube() { return false; } + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube() { return false; } + public boolean isFullCube(IBlockState state) { return false; } @Override public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { - return this.getDefaultState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(world, pos, placer)); + return this.getDefaultState().withProperty(FACING, BlockPistonBase.getFacingFromEntity(pos, placer)); } @Override @@ -140,7 +139,7 @@ public class ModelAnimationDebug }*/ @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(world.isRemote) { @@ -152,7 +151,15 @@ public class ModelAnimationDebug } return true; } - }, blockName); + }); + GameRegistry.register(new ItemBlock(Block.blockRegistry.getObject(blockId)) + { + @Override + public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) + { + return new ItemAnimationHolder(); + } + }.setRegistryName(blockId)); GameRegistry.registerTileEntity(Chest.class, MODID + ":" + "tile_" + blockName); } @@ -173,8 +180,8 @@ public class ModelAnimationDebug public void preInit(FMLPreInitializationEvent event) { super.preInit(event); - B3DLoader.instance.addDomain(MODID); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(GameRegistry.findBlock(MODID, blockName)), 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + blockName, "inventory")); + B3DLoader.INSTANCE.addDomain(MODID); + ModelLoader.setCustomModelResourceLocation(Item.itemRegistry.getObject(blockId), 0, new ModelResourceLocation(blockId, "inventory")); ClientRegistry.bindTileEntitySpecialRenderer(Chest.class, new AnimationTESR() { @Override @@ -188,77 +195,71 @@ public class ModelAnimationDebug EntityRegistry.registerModEntity(EntityChest.class, entityName, 0, ModelAnimationDebug.instance, 64, 20, true, 0xFFAAAA00, 0xFFDDDD00); RenderingRegistry.registerEntityRenderingHandler(EntityChest.class, new IRenderFactory() { + @SuppressWarnings("deprecation") public Render createRenderFor(RenderManager manager) { - try + /*model = ModelLoaderRegistry.getModel(new ResourceLocation(ModelLoaderRegistryDebug.MODID, "block/chest.b3d")); + if(model instanceof IRetexturableModel) { - /*model = ModelLoaderRegistry.getModel(new ResourceLocation(ModelLoaderRegistryDebug.MODID, "block/chest.b3d")); - if(model instanceof IRetexturableModel) + model = ((IRetexturableModel)model).retexture(ImmutableMap.of("#chest", "entity/chest/normal")); + } + if(model instanceof IModelCustomData) + { + model = ((IModelCustomData)model).process(ImmutableMap.of("mesh", "[\"Base\", \"Lid\"]")); + }*/ + ResourceLocation location = new ModelResourceLocation(new ResourceLocation(MODID, blockName), "entity"); + return new RenderLiving(manager, new net.minecraftforge.client.model.animation.AnimationModelBase(location, new VertexLighterSmoothAo(Minecraft.getMinecraft().getBlockColors())) { - model = ((IRetexturableModel)model).retexture(ImmutableMap.of("#chest", "entity/chest/normal")); - } - if(model instanceof IModelCustomData) - { - model = ((IModelCustomData)model).process(ImmutableMap.of("mesh", "[\"Base\", \"Lid\"]")); - }*/ - IModel base = ModelLoaderRegistry.getModel(new ResourceLocation(ModelAnimationDebug.MODID, "block/engine")); - IModel ring = ModelLoaderRegistry.getModel(new ResourceLocation(ModelAnimationDebug.MODID, "block/engine_ring")); - ImmutableMap textures = ImmutableMap.of( - "base", "blocks/stone", - "front", "blocks/log_oak", - "chamber", "blocks/redstone_block", - "trunk", "blocks/end_stone" - ); - if(base instanceof IRetexturableModel) - { - base = ((IRetexturableModel)base).retexture(textures); - } - if(ring instanceof IRetexturableModel) - { - ring = ((IRetexturableModel)ring).retexture(textures); - } - IModel model = new MultiModel( - new ResourceLocation(ModelAnimationDebug.MODID, "builtin/engine"), - ring, - TRSRTransformation.identity(), - ImmutableMap.of( - "base", Pair.of(base, TRSRTransformation.identity()) - ) - ); - return new RenderLiving(manager, new AnimationModelBase(model, new VertexLighterSmoothAo()) + @Override + public void handleEvents(EntityChest chest, float time, Iterable pastEvents) { - @Override - public void handleEvents(EntityChest chest, float time, Iterable pastEvents) - { - chest.handleEvents(time, pastEvents); - } - }, 0.5f) - { - protected ResourceLocation getEntityTexture(EntityChest entity) - { - return TextureMap.locationBlocksTexture; + chest.handleEvents(time, pastEvents); } - }; - } - catch(IOException e) + }, 0.5f) { - throw new RuntimeException(e); - } + protected ResourceLocation getEntityTexture(EntityChest entity) + { + return TextureMap.locationBlocksTexture; + } + }; } }); } public IAnimationStateMachine load(ResourceLocation location, ImmutableMap parameters) { - return Animation.INSTANCE.load(location, parameters); + return ModelLoaderRegistry.loadASM(location, parameters); } } + private static class ItemAnimationHolder implements ICapabilityProvider + { + private final VariableValue cycleLength = new VariableValue(4); + + private final IAnimationStateMachine asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/engine.json"), ImmutableMap.of( + "cycle_length", cycleLength + )); + + public boolean hasCapability(Capability capability, EnumFacing facing) + { + return capability == CapabilityAnimation.ANIMATION_CAPABILITY; + } + + public T getCapability(Capability capability, EnumFacing facing) + { + if(capability == CapabilityAnimation.ANIMATION_CAPABILITY) + { + return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm); + } + return null; + } + } + @EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } - public static class Chest extends TileEntity implements IAnimationProvider + public static class Chest extends TileEntity { private final IAnimationStateMachine asm; private final VariableValue cycleLength = new VariableValue(4); @@ -328,25 +329,36 @@ public class ModelAnimationDebug } } - public IAnimationStateMachine asm() + @Override + public boolean hasCapability(Capability capability, EnumFacing side) { - return asm; + if(capability == CapabilityAnimation.ANIMATION_CAPABILITY) + { + return true; + } + return super.hasCapability(capability, side); + } + + @Override + public T getCapability(Capability capability, EnumFacing side) + { + if(capability == CapabilityAnimation.ANIMATION_CAPABILITY) + { + return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm); + } + return super.getCapability(capability, side); } } - public static class EntityChest extends EntityLiving implements IAnimationProvider + public static class EntityChest extends EntityLiving { private final IAnimationStateMachine asm; - private VariableValue cycleLength; + private final VariableValue cycleLength = new VariableValue(getHealth() / 5); public EntityChest(World world) { super(world); setSize(1, 1); - if(cycleLength == null) - { - cycleLength = new VariableValue(getHealth() / 5); - } asm = proxy.load(new ResourceLocation(MODID.toLowerCase(), "asms/block/engine.json"), ImmutableMap.of( "cycle_length", cycleLength )); @@ -357,21 +369,12 @@ public class ModelAnimationDebug // TODO Auto-generated method stub } - public IAnimationStateMachine asm() - { - return asm; - } - @Override - public void onDataWatcherUpdate(int id) + public void onEntityUpdate() { - super.onDataWatcherUpdate(id); - if(id == 6) // health + super.onEntityUpdate(); + if(worldObj.isRemote && cycleLength != null) { - if(cycleLength == null) - { - cycleLength = new VariableValue(0); - } cycleLength.setValue(getHealth() / 5); } } @@ -380,7 +383,27 @@ public class ModelAnimationDebug protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(60); + this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(60); + } + + @Override + public boolean hasCapability(Capability capability, EnumFacing side) + { + if(capability == CapabilityAnimation.ANIMATION_CAPABILITY) + { + return true; + } + return super.hasCapability(capability, side); + } + + @Override + public T getCapability(Capability capability, EnumFacing side) + { + if(capability == CapabilityAnimation.ANIMATION_CAPABILITY) + { + return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm); + } + return super.getCapability(capability, side); } } } diff --git a/src/test/java/net/minecraftforge/debug/ModelBakeEventDebug.java b/src/test/java/net/minecraftforge/debug/ModelBakeEventDebug.java index fc61e2a51a..478b140a86 100644 --- a/src/test/java/net/minecraftforge/debug/ModelBakeEventDebug.java +++ b/src/test/java/net/minecraftforge/debug/ModelBakeEventDebug.java @@ -1,35 +1,38 @@ package net.minecraftforge.debug; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; -import net.minecraft.util.Vec3; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.client.event.ModelBakeEvent; -import net.minecraftforge.client.model.ISmartBlockModel; -import net.minecraftforge.client.model.ISmartItemModel; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.property.ExtendedBlockState; @@ -43,9 +46,9 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; +import com.google.common.collect.ImmutableList; import com.google.common.primitives.Ints; -@SuppressWarnings("deprecation") @Mod(modid = ModelBakeEventDebug.MODID, version = ModelBakeEventDebug.VERSION) public class ModelBakeEventDebug { @@ -53,7 +56,7 @@ public class ModelBakeEventDebug public static final String VERSION = "1.0"; public static final int cubeSize = 3; - private static String blockName = MODID.toLowerCase() + ":" + CustomModelBlock.name; + private static ResourceLocation blockName = new ResourceLocation(MODID, CustomModelBlock.name); @SuppressWarnings("unchecked") public static final IUnlistedProperty[] properties = new IUnlistedProperty[6]; @@ -76,7 +79,8 @@ public class ModelBakeEventDebug { public void preInit(FMLPreInitializationEvent event) { - GameRegistry.registerBlock(CustomModelBlock.instance, CustomModelBlock.name); + GameRegistry.register(CustomModelBlock.instance); + GameRegistry.register(new ItemBlock(CustomModelBlock.instance).setRegistryName(CustomModelBlock.instance.getRegistryName())); GameRegistry.registerTileEntity(CustomTileEntity.class, MODID.toLowerCase() + ":custom_tile_entity"); } } @@ -116,8 +120,8 @@ public class ModelBakeEventDebug TextureAtlasSprite base = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/slime"); TextureAtlasSprite overlay = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/redstone_block"); IBakedModel customModel = new CustomModel(base, overlay); - event.modelRegistry.putObject(ClientProxy.blockLocation, customModel); - event.modelRegistry.putObject(ClientProxy.itemLocation, customModel); + event.getModelRegistry().putObject(ClientProxy.blockLocation, customModel); + event.getModelRegistry().putObject(ClientProxy.itemLocation, customModel); } } @@ -131,16 +135,17 @@ public class ModelBakeEventDebug super(Material.iron); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(blockName); } @Override - public int getRenderType() { return 3; } + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } @Override - public boolean isOpaqueCube() { return false; } + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube() { return false; } + public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isVisuallyOpaque() { return false; } @@ -152,13 +157,13 @@ public class ModelBakeEventDebug } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity te = world.getTileEntity(pos); if(te instanceof CustomTileEntity) { CustomTileEntity cte = (CustomTileEntity) te; - Vec3 vec = revRotate(new Vec3(hitX - .5, hitY - .5, hitZ - .5), side).addVector(.5, .5, .5); + Vec3d vec = revRotate(new Vec3d(hitX - .5, hitY - .5, hitZ - .5), side).addVector(.5, .5, .5); IUnlistedProperty property = properties[side.ordinal()]; Integer value = cte.getState().getValue(property); if(value == null) value = 0; @@ -182,7 +187,7 @@ public class ModelBakeEventDebug } @Override - protected BlockState createBlockState() + protected BlockStateContainer createBlockState() { return new ExtendedBlockState(this, new IProperty[0], properties); } @@ -208,30 +213,18 @@ public class ModelBakeEventDebug } } - public static class CustomModel implements IBakedModel, ISmartBlockModel, ISmartItemModel + public static class CustomModel implements IBakedModel { private final TextureAtlasSprite base, overlay; //private boolean hasStateSet = false; - private final IExtendedBlockState state; public CustomModel(TextureAtlasSprite base, TextureAtlasSprite overlay) - { - this(base, overlay, null); - } - - public CustomModel(TextureAtlasSprite base, TextureAtlasSprite overlay, IExtendedBlockState state) { this.base = base; this.overlay = overlay; - this.state = state; - } - - @Override - public List getFaceQuads(EnumFacing side) - { - return Collections.emptyList(); } + // TODO update to builder private int[] vertexToInts(float x, float y, float z, int color, TextureAtlasSprite texture, float u, float v) { return new int[] { @@ -247,33 +240,35 @@ public class ModelBakeEventDebug private BakedQuad createSidedBakedQuad(float x1, float x2, float z1, float z2, float y, TextureAtlasSprite texture, EnumFacing side) { - Vec3 v1 = rotate(new Vec3(x1 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5); - Vec3 v2 = rotate(new Vec3(x1 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5); - Vec3 v3 = rotate(new Vec3(x2 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5); - Vec3 v4 = rotate(new Vec3(x2 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5); + Vec3d v1 = rotate(new Vec3d(x1 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5); + Vec3d v2 = rotate(new Vec3d(x1 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5); + Vec3d v3 = rotate(new Vec3d(x2 - .5, y - .5, z2 - .5), side).addVector(.5, .5, .5); + Vec3d v4 = rotate(new Vec3d(x2 - .5, y - .5, z1 - .5), side).addVector(.5, .5, .5); return new BakedQuad(Ints.concat( vertexToInts((float)v1.xCoord, (float)v1.yCoord, (float)v1.zCoord, -1, texture, 0, 0), vertexToInts((float)v2.xCoord, (float)v2.yCoord, (float)v2.zCoord, -1, texture, 0, 16), vertexToInts((float)v3.xCoord, (float)v3.yCoord, (float)v3.zCoord, -1, texture, 16, 16), vertexToInts((float)v4.xCoord, (float)v4.yCoord, (float)v4.zCoord, -1, texture, 16, 0) - ), -1, side); + ), -1, side, texture, true, DefaultVertexFormats.BLOCK); } @Override - public List getGeneralQuads() + public List getQuads(IBlockState state, EnumFacing side, long rand) { + if(side != null) return ImmutableList.of(); + IExtendedBlockState exState = (IExtendedBlockState)state; int len = cubeSize * 5 + 1; List ret = new ArrayList(); for(EnumFacing f : EnumFacing.values()) { ret.add(createSidedBakedQuad(0, 1, 0, 1, 1, base, f)); - for(int i = 0; i < cubeSize; i++) + if(state != null) { - for(int j = 0; j < cubeSize; j++) + for(int i = 0; i < cubeSize; i++) { - if(state != null) + for(int j = 0; j < cubeSize; j++) { - Integer value = state.getValue(properties[f.ordinal()]); + Integer value = exState.getValue(properties[f.ordinal()]); if(value != null && (value & (1 << (i * cubeSize + j))) != 0) { ret.add(createSidedBakedQuad((float)(1 + i * 5) / len, (float)(5 + i * 5) / len, (float)(1 + j * 5) / len, (float)(5 + j * 5) / len, 1.0001f, overlay, f)); @@ -298,49 +293,36 @@ public class ModelBakeEventDebug public TextureAtlasSprite getParticleTexture() { return this.base; } @Override - public ItemCameraTransforms getItemCameraTransforms() - { - return ItemCameraTransforms.DEFAULT; - } + public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; } @Override - public IBakedModel handleBlockState(IBlockState state) - { - return new CustomModel(base, overlay, (IExtendedBlockState)state); - } - - @Override - public IBakedModel handleItemState(ItemStack stack) - { - IExtendedBlockState itemState = ((IExtendedBlockState)CustomModelBlock.instance.getDefaultState()).withProperty(properties[1], (1 << (cubeSize * cubeSize)) - 1); - return new CustomModel(base, overlay, itemState); - } + public ItemOverrideList getOverrides() { return ItemOverrideList.NONE; } } - private static Vec3 rotate(Vec3 vec, EnumFacing side) + private static Vec3d rotate(Vec3d vec, EnumFacing side) { switch(side) { - case DOWN: return new Vec3( vec.xCoord, -vec.yCoord, -vec.zCoord); - case UP: return new Vec3( vec.xCoord, vec.yCoord, vec.zCoord); - case NORTH: return new Vec3( vec.xCoord, vec.zCoord, -vec.yCoord); - case SOUTH: return new Vec3( vec.xCoord, -vec.zCoord, vec.yCoord); - case WEST: return new Vec3(-vec.yCoord, vec.xCoord, vec.zCoord); - case EAST: return new Vec3( vec.yCoord, -vec.xCoord, vec.zCoord); + case DOWN: return new Vec3d( vec.xCoord, -vec.yCoord, -vec.zCoord); + case UP: return new Vec3d( vec.xCoord, vec.yCoord, vec.zCoord); + case NORTH: return new Vec3d( vec.xCoord, vec.zCoord, -vec.yCoord); + case SOUTH: return new Vec3d( vec.xCoord, -vec.zCoord, vec.yCoord); + case WEST: return new Vec3d(-vec.yCoord, vec.xCoord, vec.zCoord); + case EAST: return new Vec3d( vec.yCoord, -vec.xCoord, vec.zCoord); } return null; } - private static Vec3 revRotate(Vec3 vec, EnumFacing side) + private static Vec3d revRotate(Vec3d vec, EnumFacing side) { switch(side) { - case DOWN: return new Vec3( vec.xCoord, -vec.yCoord, -vec.zCoord); - case UP: return new Vec3( vec.xCoord, vec.yCoord, vec.zCoord); - case NORTH: return new Vec3( vec.xCoord, -vec.zCoord, vec.yCoord); - case SOUTH: return new Vec3( vec.xCoord, vec.zCoord, -vec.yCoord); - case WEST: return new Vec3( vec.yCoord, -vec.xCoord, vec.zCoord); - case EAST: return new Vec3(-vec.yCoord, vec.xCoord, vec.zCoord); + case DOWN: return new Vec3d( vec.xCoord, -vec.yCoord, -vec.zCoord); + case UP: return new Vec3d( vec.xCoord, vec.yCoord, vec.zCoord); + case NORTH: return new Vec3d( vec.xCoord, -vec.zCoord, vec.yCoord); + case SOUTH: return new Vec3d( vec.xCoord, vec.zCoord, -vec.yCoord); + case WEST: return new Vec3d( vec.yCoord, -vec.xCoord, vec.zCoord); + case EAST: return new Vec3d(-vec.yCoord, vec.xCoord, vec.zCoord); } return null; } diff --git a/src/test/java/net/minecraftforge/debug/ModelFluidDebug.java b/src/test/java/net/minecraftforge/debug/ModelFluidDebug.java index 9a48af70fc..9937c33429 100644 --- a/src/test/java/net/minecraftforge/debug/ModelFluidDebug.java +++ b/src/test/java/net/minecraftforge/debug/ModelFluidDebug.java @@ -4,10 +4,11 @@ import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.statemap.StateMapperBase; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelBakery; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; @@ -41,9 +42,12 @@ public class ModelFluidDebug FluidRegistry.registerFluid(TestFluid.instance); FluidRegistry.registerFluid(TestGas.instance); FluidRegistry.registerFluid(milkFluid); - GameRegistry.registerBlock(TestFluidBlock.instance, TestFluidBlock.name); - GameRegistry.registerBlock(TestGasBlock.instance, TestGasBlock.name); - GameRegistry.registerBlock(MilkFluidBlock.instance, MilkFluidBlock.name); + GameRegistry.register(TestFluidBlock.instance); + GameRegistry.register(new ItemBlock(TestFluidBlock.instance).setRegistryName(TestFluidBlock.instance.getRegistryName())); + GameRegistry.register(TestGasBlock.instance); + GameRegistry.register(new ItemBlock(TestGasBlock.instance).setRegistryName(TestGasBlock.instance.getRegistryName())); + GameRegistry.register(MilkFluidBlock.instance); + GameRegistry.register(new ItemBlock(MilkFluidBlock.instance).setRegistryName(MilkFluidBlock.instance.getRegistryName())); } } @@ -157,6 +161,7 @@ public class ModelFluidDebug super(TestFluid.instance, Material.water); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } } @@ -170,6 +175,7 @@ public class ModelFluidDebug super(milkFluid, Material.water); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } } @@ -183,6 +189,7 @@ public class ModelFluidDebug super(TestGas.instance, Material.lava); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } } } diff --git a/src/test/java/net/minecraftforge/debug/ModelLoaderRegistryDebug.java b/src/test/java/net/minecraftforge/debug/ModelLoaderRegistryDebug.java index 38c6124bc2..430072227a 100644 --- a/src/test/java/net/minecraftforge/debug/ModelLoaderRegistryDebug.java +++ b/src/test/java/net/minecraftforge/debug/ModelLoaderRegistryDebug.java @@ -1,6 +1,5 @@ package net.minecraftforge.debug; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -17,32 +16,33 @@ import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.ITickable; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.TextComponentString; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoaderRegistry; -import net.minecraftforge.client.model.TRSRTransformation; import net.minecraftforge.client.model.b3d.B3DLoader; import net.minecraftforge.client.model.obj.OBJLoader; import net.minecraftforge.client.model.obj.OBJModel; -import net.minecraftforge.client.model.obj.OBJModel.OBJBakedModel; +import net.minecraftforge.common.model.TRSRTransformation; import net.minecraftforge.common.property.ExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IUnlistedProperty; @@ -52,9 +52,7 @@ import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @Mod(modid = ModelLoaderRegistryDebug.MODID, version = ModelLoaderRegistryDebug.VERSION) @@ -66,48 +64,54 @@ public class ModelLoaderRegistryDebug @EventHandler public void preInit(FMLPreInitializationEvent event) { - GameRegistry.registerBlock(CustomModelBlock.instance, CustomModelBlock.name); - GameRegistry.registerBlock(OBJTesseractBlock.instance, OBJTesseractBlock.name); - GameRegistry.registerBlock(OBJVertexColoring1.instance, OBJVertexColoring1.name); - GameRegistry.registerBlock(OBJDirectionEye.instance, OBJDirectionEye.name); - GameRegistry.registerBlock(OBJVertexColoring2.instance, OBJVertexColoring2.name); - GameRegistry.registerBlock(OBJDirectionBlock.instance, OBJDirectionBlock.name); - GameRegistry.registerBlock(OBJCustomDataBlock.instance, OBJCustomDataBlock.name); - GameRegistry.registerBlock(OBJDynamicEye.instance, OBJDynamicEye.name); + List blocks = Lists.newArrayList(); + blocks.add(CustomModelBlock.instance); + blocks.add(OBJTesseractBlock.instance); + blocks.add(OBJVertexColoring1.instance); + //blocks.add(OBJDirectionEye.instance); + blocks.add(OBJVertexColoring2.instance); + blocks.add(OBJDirectionBlock.instance); + blocks.add(OBJCustomDataBlock.instance); + //blocks.add(OBJDynamicEye.instance); + for(Block block : blocks) + { + GameRegistry.register(block); + GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName())); + } GameRegistry.registerTileEntity(OBJTesseractTileEntity.class, OBJTesseractBlock.name); GameRegistry.registerTileEntity(OBJVertexColoring2TileEntity.class, OBJVertexColoring2.name); - GameRegistry.registerTileEntity(OBJDynamicEyeTileEntity.class, OBJDynamicEye.name); + //GameRegistry.registerTileEntity(OBJDynamicEyeTileEntity.class, OBJDynamicEye.name); if (event.getSide() == Side.CLIENT) clientPreInit(); } private void clientPreInit() { - B3DLoader.instance.addDomain(MODID.toLowerCase()); + B3DLoader.INSTANCE.addDomain(MODID.toLowerCase()); Item item = Item.getItemFromBlock(CustomModelBlock.instance); ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + CustomModelBlock.name, "inventory")); - - OBJLoader.instance.addDomain(MODID.toLowerCase()); + + OBJLoader.INSTANCE.addDomain(MODID.toLowerCase()); Item item2 = Item.getItemFromBlock(OBJTesseractBlock.instance); ModelLoader.setCustomModelResourceLocation(item2, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJTesseractBlock.name, "inventory")); - + Item item3 = Item.getItemFromBlock(OBJVertexColoring1.instance); ModelLoader.setCustomModelResourceLocation(item3, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJVertexColoring1.name, "inventory")); - - Item item4 = Item.getItemFromBlock(OBJDirectionEye.instance); - ModelLoader.setCustomModelResourceLocation(item4, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDirectionEye.name, "inventory")); - + + //Item item4 = Item.getItemFromBlock(OBJDirectionEye.instance); + //ModelLoader.setCustomModelResourceLocation(item4, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDirectionEye.name, "inventory")); + Item item5 = Item.getItemFromBlock(OBJVertexColoring2.instance); ModelLoader.setCustomModelResourceLocation(item5, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJVertexColoring2.name, "inventory")); - + Item item6 = Item.getItemFromBlock(OBJDirectionBlock.instance); ModelLoader.setCustomModelResourceLocation(item6, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDirectionBlock.name, "inventory")); - + Item item7 = Item.getItemFromBlock(OBJCustomDataBlock.instance); ModelLoader.setCustomModelResourceLocation(item7, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJCustomDataBlock.name, "inventory")); - - Item item8 = Item.getItemFromBlock(OBJDynamicEye.instance); - ModelLoader.setCustomModelResourceLocation(item8, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDynamicEye.name, "inventory")); + + //Item item8 = Item.getItemFromBlock(OBJDynamicEye.instance); + //ModelLoader.setCustomModelResourceLocation(item8, 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + OBJDynamicEye.name, "inventory")); } public static class CustomModelBlock extends Block @@ -116,7 +120,7 @@ public class ModelLoaderRegistryDebug public static final CustomModelBlock instance = new CustomModelBlock(); public static final String name = "CustomModelBlock"; private int counter = 1; - public ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{B3DLoader.B3DFrameProperty.instance}); + public ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{B3DLoader.B3DFrameProperty.INSTANCE}); private CustomModelBlock() { @@ -124,13 +128,14 @@ public class ModelLoaderRegistryDebug this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } @Override - public boolean isOpaqueCube() { return false; } + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube() { return false; } + public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isVisuallyOpaque() { return false; } @@ -140,29 +145,29 @@ public class ModelLoaderRegistryDebug { return this.getDefaultState().withProperty(FACING, getFacingFromEntity(world, pos, placer)); } - + @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta)); } - + @Override public int getMetaFromState(IBlockState state) { return ((EnumFacing) state.getValue(FACING)).getIndex(); } - + @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { //Only return an IExtendedBlockState from this method and createState(), otherwise block placement might break! B3DLoader.B3DState newState = new B3DLoader.B3DState(null, counter); - return ((IExtendedBlockState) state).withProperty(B3DLoader.B3DFrameProperty.instance, newState); + return ((IExtendedBlockState) state).withProperty(B3DLoader.B3DFrameProperty.INSTANCE, newState); } @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(world.isRemote) { @@ -174,13 +179,13 @@ public class ModelLoaderRegistryDebug } return false; } - + @Override - public BlockState createBlockState() + public BlockStateContainer createBlockState() { - return new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{B3DLoader.B3DFrameProperty.instance}); + return new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{B3DLoader.B3DFrameProperty.INSTANCE}); } - + public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn) { if (MathHelper.abs((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F) @@ -216,53 +221,46 @@ public class ModelLoaderRegistryDebug { public static final OBJTesseractBlock instance = new OBJTesseractBlock(); public static final String name = "OBJTesseractBlock"; - private ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); - + private ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{OBJModel.OBJProperty.INSTANCE}); + private OBJTesseractBlock() { super(Material.iron); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } - + @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new OBJTesseractTileEntity(); } - - @Override - public boolean isOpaqueCube() { return false; } @Override - public boolean isFullCube() { return false; } + public boolean isOpaqueCube(IBlockState state) { return false; } + + @Override + public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isVisuallyOpaque() { return false; } - + @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { OBJTesseractTileEntity tileEntity = (OBJTesseractTileEntity) world.getTileEntity(pos); OBJModel.OBJState retState = new OBJModel.OBJState(tileEntity == null ? Lists.newArrayList(OBJModel.Group.ALL) : tileEntity.visible, true); - return ((IExtendedBlockState) this.state.getBaseState()).withProperty(OBJModel.OBJProperty.instance, retState); + return ((IExtendedBlockState) this.state.getBaseState()).withProperty(OBJModel.OBJProperty.INSTANCE, retState); } - + @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.getTileEntity(pos) == null) world.setTileEntity(pos, new OBJTesseractTileEntity()); OBJTesseractTileEntity tileEntity = (OBJTesseractTileEntity) world.getTileEntity(pos); - IModel model = ModelLoaderRegistry.getMissingModel(); - try - { - model = ModelLoaderRegistry.getModel(new ResourceLocation(MODID.toLowerCase() + ":" + "block/tesseract.obj")); - } - catch (IOException e) - { - model = ModelLoaderRegistry.getMissingModel(); - } - + IModel model = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation(MODID.toLowerCase() + ":" + "block/tesseract.obj")); + if (player.isSneaking()) { tileEntity.decrement(); @@ -275,34 +273,35 @@ public class ModelLoaderRegistryDebug tileEntity.increment(); } } - + if (world.isRemote) { - OBJBakedModel objBaked = (OBJBakedModel) Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(state, world, pos); - objBaked.scheduleRebake(); //not necessarily needed for this specific case, but is available + // wtf + //OBJBakedModel objBaked = (OBJBakedModel) Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(state, world, pos); + //objBaked.scheduleRebake(); //not necessarily needed for this specific case, but is available } world.markBlockRangeForRenderUpdate(pos, pos); return false; } - + @Override public boolean hasTileEntity(IBlockState state) { return true; } } - + public static class OBJTesseractTileEntity extends TileEntity { private int counter = 1; private int max = 2; public List visible = new ArrayList(); - + public OBJTesseractTileEntity() { this.visible.add(OBJModel.Group.ALL); } - + public void increment() { if (this.visible.contains(OBJModel.Group.ALL)) this.visible.remove(OBJModel.Group.ALL); @@ -313,10 +312,10 @@ public class ModelLoaderRegistryDebug } this.counter++; this.visible.add(Integer.toString(this.counter)); - ChatComponentText text = new ChatComponentText("" + this.counter); + TextComponentString text = new TextComponentString("" + this.counter); if (this.worldObj.isRemote) Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(text); } - + public void decrement() { if (this.visible.contains(OBJModel.Group.ALL)) this.visible.remove(OBJModel.Group.ALL); @@ -327,10 +326,10 @@ public class ModelLoaderRegistryDebug } this.visible.remove(Integer.toString(this.counter)); this.counter--; - ChatComponentText text = new ChatComponentText("" + this.counter); + TextComponentString text = new TextComponentString("" + this.counter); if (this.worldObj.isRemote) Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(text); } - + public void reset() { this.counter = 1; @@ -338,25 +337,25 @@ public class ModelLoaderRegistryDebug this.visible.clear(); this.visible.add(Integer.toString(this.counter)); } - + public int getMax() { return this.max; } - + public void setMax(int max) { this.max = max; } - + public void setToMax() { this.counter = this.max; } } - + /** - * This block demonstrates how to utilize the vertex coloring feature + * This block demonstrates how to utilize the vertex coloring feature * of the OBJ loader. See 'vertex_coloring.obj' and 'vertex_coloring.mtl' in * 'test/resources/assets/forgedebugmodelloaderregistry/models/block/', to properly * utilize this feature an obj file must have 1 'usemtl' key before every vertex as shown, @@ -369,28 +368,29 @@ public class ModelLoaderRegistryDebug { public static final OBJVertexColoring1 instance = new OBJVertexColoring1(); public static final String name = "OBJVertexColoring1"; - + private OBJVertexColoring1() { super(Material.iron); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(name); + setRegistryName(new ResourceLocation(MODID, name)); } - - @Override - public boolean isOpaqueCube() { return false; } @Override - public boolean isFullCube() { return false; } + public boolean isOpaqueCube(IBlockState state) { return false; } + + @Override + public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isVisuallyOpaque() { return false; } } - + /** * This block demonstrates how to use IProperties and IUnlistedProperties together * in the same ExtendedBlockState. Similar to pistons, this block will face the player - * when placed. Unlike pistons, however; this block's model is an eyeball, because + * when placed. Unlike pistons, however; this block's model is an eyeball, because * the OBJ loader can load spheres. * @author shadekiller666 * @@ -400,65 +400,58 @@ public class ModelLoaderRegistryDebug public static final PropertyDirection FACING = PropertyDirection.create("facing"); public static final OBJDirectionEye instance = new OBJDirectionEye(); public static final String name = "OBJDirectionEye"; - private ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[] {FACING}, new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); - + private OBJDirectionEye() { super(Material.iron); setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(name); + setRegistryName(new ResourceLocation(MODID, name)); } - + @Override public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(FACING, getFacingFromEntity(world, pos, placer)); } - + @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta)); } - + @Override public int getMetaFromState(IBlockState state) { return ((EnumFacing) state.getValue(FACING)).getIndex(); } - - @Override - @SideOnly(Side.CLIENT) - public IBlockState getStateForEntityRender(IBlockState state) - { - return this.getDefaultState().withProperty(FACING, EnumFacing.NORTH); - } - - @Override - public BlockState createBlockState() - { - return new ExtendedBlockState(this, new IProperty[] {FACING}, new IUnlistedProperty[] {OBJModel.OBJProperty.instance}); - } - - @Override - public boolean isOpaqueCube() { return false; } @Override - public boolean isFullCube() { return false; } + public BlockStateContainer createBlockState() + { + return new ExtendedBlockState(this, new IProperty[] {FACING}, new IUnlistedProperty[] {OBJModel.OBJProperty.INSTANCE}); + } + + @Override + public boolean isOpaqueCube(IBlockState state) { return false; } + + @Override + public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isVisuallyOpaque() { return false; } - + @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { EnumFacing facing = (EnumFacing) state.getValue(FACING); TRSRTransformation transform = new TRSRTransformation(facing); OBJModel.OBJState retState = new OBJModel.OBJState(Arrays.asList(new String[]{OBJModel.Group.ALL}), true, transform); - return ((IExtendedBlockState) state).withProperty(OBJModel.OBJProperty.instance, retState); + return ((IExtendedBlockState) state).withProperty(OBJModel.OBJProperty.INSTANCE, retState); } - + public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn) { if (MathHelper.abs((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F) @@ -479,9 +472,9 @@ public class ModelLoaderRegistryDebug return entityIn.getHorizontalFacing(); } } - + /** - * This block uses the same model as CustomModelBlock3 does, but + * This block uses the same model as CustomModelBlock3 does, but * this class allows the player to cycle the colors of each vertex to black * and then back to the original color when right clicking on the block. * @author shadekiller666 @@ -489,24 +482,25 @@ public class ModelLoaderRegistryDebug */ public static class OBJVertexColoring2 extends Block implements ITileEntityProvider { - public static final OBJVertexColoring2 instance = new OBJVertexColoring2(); + public static final OBJVertexColoring2 instance = new OBJVertexColoring2(); public static final String name = "OBJVertexColoring2"; - + private OBJVertexColoring2() { super(Material.iron); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(name); + setRegistryName(new ResourceLocation(MODID, name)); } - + @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new OBJVertexColoring2TileEntity(); } - + @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof OBJVertexColoring2TileEntity) { @@ -515,7 +509,8 @@ public class ModelLoaderRegistryDebug return false; } } - + + @SuppressWarnings("unused") public static class OBJVertexColoring2TileEntity extends TileEntity { private int index = 0; @@ -523,14 +518,15 @@ public class ModelLoaderRegistryDebug private List colorList = new ArrayList(); private boolean hasFilledList = false; private boolean shouldIncrement = true; - + public OBJVertexColoring2TileEntity() {} - + public void cycleColors() { if (this.worldObj.isRemote) { FMLLog.info("%b", shouldIncrement); + /* IBakedModel bakedModel = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelFromBlockState(this.worldObj.getBlockState(this.pos), this.worldObj, this.pos); if (bakedModel != null && bakedModel instanceof OBJBakedModel) { @@ -552,6 +548,7 @@ public class ModelLoaderRegistryDebug { FMLLog.info("incrementing"); String name = materialNames.get(index); + // no objBaked.getModel().getMatLib().changeMaterialColor(name, 0xFF000000); objBaked.scheduleRebake(); index++; @@ -568,16 +565,17 @@ public class ModelLoaderRegistryDebug String name = materialNames.get(index); if (!name.equals(OBJModel.Material.WHITE_NAME)) { + // FIXME objBaked.getModel().getMatLib().changeMaterialColor(name, color); objBaked.scheduleRebake(); } } this.worldObj.markBlockRangeForRenderUpdate(this.pos, this.pos); - } + }*/ } } } - + /** * This block is a debug block that faces the player when placed, like a piston. * @author shadekiller666 @@ -588,43 +586,44 @@ public class ModelLoaderRegistryDebug public static final PropertyDirection FACING = PropertyDirection.create("facing"); public static final OBJDirectionBlock instance = new OBJDirectionBlock(); public static final String name = "OBJDirectionBlock"; - public ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); - + public ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{OBJModel.OBJProperty.INSTANCE}); + private OBJDirectionBlock() { super(Material.iron); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } - - @Override - public boolean isOpaqueCube() { return false; } @Override - public boolean isFullCube() { return false; } + public boolean isOpaqueCube(IBlockState state) { return false; } + + @Override + public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isVisuallyOpaque() { return false; } - + @Override public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(FACING, getFacingFromEntity(world, pos, placer)); } - + @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getFront(meta)); } - + @Override public int getMetaFromState(IBlockState state) { return ((EnumFacing) state.getValue(FACING)).getIndex(); } - + @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { @@ -632,15 +631,15 @@ public class ModelLoaderRegistryDebug EnumFacing facing = (EnumFacing) state.getValue(FACING); TRSRTransformation transform = new TRSRTransformation(facing); OBJModel.OBJState newState = new OBJModel.OBJState(Lists.newArrayList(OBJModel.Group.ALL), true, transform); - return ((IExtendedBlockState) state).withProperty(OBJModel.OBJProperty.instance, newState); + return ((IExtendedBlockState) state).withProperty(OBJModel.OBJProperty.INSTANCE, newState); } - + @Override - public BlockState createBlockState() + public BlockStateContainer createBlockState() { - return new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); + return new ExtendedBlockState(this, new IProperty[]{FACING}, new IUnlistedProperty[]{OBJModel.OBJProperty.INSTANCE}); } - + public static EnumFacing getFacingFromEntity(World worldIn, BlockPos clickedBlock, EntityLivingBase entityIn) { if (MathHelper.abs((float)entityIn.posX - (float)clickedBlock.getX()) < 2.0F && MathHelper.abs((float)entityIn.posZ - (float)clickedBlock.getZ()) < 2.0F) @@ -661,7 +660,7 @@ public class ModelLoaderRegistryDebug return entityIn.getHorizontalFacing().getOpposite(); } } - + /** * This block is a testing block that will be used to test the use * of "custom" data defined in a forge blockstate json. WIP, ignore for now. @@ -676,52 +675,53 @@ public class ModelLoaderRegistryDebug public static final PropertyBool EAST = PropertyBool.create("east"); public static final OBJCustomDataBlock instance = new OBJCustomDataBlock(); public static final String name = "OBJCustomDataBlock"; - + private OBJCustomDataBlock() { super(Material.iron); this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, false).withProperty(SOUTH, false).withProperty(WEST, false).withProperty(EAST, false)); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } - + @Override - public boolean isOpaqueCube() + public boolean isOpaqueCube(IBlockState state) { return false; } - + @Override - public boolean isFullCube() + public boolean isFullCube(IBlockState state) { return false; } - + @Override public int getMetaFromState(IBlockState state) { return 0; } - + public boolean canConnectTo(IBlockAccess world, BlockPos pos) { Block block = world.getBlockState(pos).getBlock(); return block instanceof OBJCustomDataBlock; } - + @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { return state.withProperty(NORTH, this.canConnectTo(world, pos.north())).withProperty(SOUTH, this.canConnectTo(world, pos.south())).withProperty(WEST, this.canConnectTo(world, pos.west())).withProperty(EAST, this.canConnectTo(world, pos.east())); } - + @Override - public BlockState createBlockState() + public BlockStateContainer createBlockState() { - return new BlockState(this, new IProperty[]{NORTH, SOUTH, WEST, EAST}); + return new BlockStateContainer(this, new IProperty[]{NORTH, SOUTH, WEST, EAST}); } } - + /** * This block uses the same model as CustomModelBlock4, but instead of facing the * player when placed, this one ALWAYS faces the player. I know, creepy right? @@ -732,38 +732,39 @@ public class ModelLoaderRegistryDebug { public static final OBJDynamicEye instance = new OBJDynamicEye(); public static final String name = "OBJDynamicEye"; - public ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {OBJModel.OBJProperty.instance}); + public ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {OBJModel.OBJProperty.INSTANCE}); private OBJDynamicEye() { super(Material.iron); setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } - + @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new OBJDynamicEyeTileEntity(); } - + @Override - public boolean isOpaqueCube() + public boolean isOpaqueCube(IBlockState state) { return false; } - + @Override - public boolean isFullCube() + public boolean isFullCube(IBlockState state) { return false; } - + @Override public boolean hasTileEntity(IBlockState state) { return true; } - + @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { @@ -772,28 +773,28 @@ public class ModelLoaderRegistryDebug OBJDynamicEyeTileEntity te = (OBJDynamicEyeTileEntity) world.getTileEntity(pos); if (te.state != null) { - return ((IExtendedBlockState) this.state.getBaseState()).withProperty(OBJModel.OBJProperty.instance, te.state); + return ((IExtendedBlockState) this.state.getBaseState()).withProperty(OBJModel.OBJProperty.INSTANCE, te.state); } } return state; } - + @Override - public BlockState createBlockState() + public BlockStateContainer createBlockState() { - return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {OBJModel.OBJProperty.instance}); + return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] {OBJModel.OBJProperty.INSTANCE}); } } - + public static class OBJDynamicEyeTileEntity extends TileEntity implements ITickable { public OBJModel.OBJState state; - + public OBJDynamicEyeTileEntity() { this.state = new OBJModel.OBJState(Lists.newArrayList(OBJModel.Group.ALL), true); } - + @Override public void update() { diff --git a/src/test/java/net/minecraftforge/debug/MultiLayerModelDebug.java b/src/test/java/net/minecraftforge/debug/MultiLayerModelDebug.java index 061f884bc7..468d37c5f8 100644 --- a/src/test/java/net/minecraftforge/debug/MultiLayerModelDebug.java +++ b/src/test/java/net/minecraftforge/debug/MultiLayerModelDebug.java @@ -2,10 +2,13 @@ package net.minecraftforge.debug; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; -import net.minecraft.util.EnumWorldBlockLayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; @@ -19,7 +22,8 @@ public class MultiLayerModelDebug public static final String MODID = "forgedebugmultilayermodel"; public static final String VERSION = "0.0"; - public static String blockName = "test_layer_block"; + private static String blockName = "test_layer_block"; + private static final ResourceLocation blockId = new ResourceLocation(MODID, blockName); @SidedProxy public static CommonProxy proxy; @@ -28,25 +32,27 @@ public class MultiLayerModelDebug { public void preInit(FMLPreInitializationEvent event) { - GameRegistry.registerBlock(new Block(Material.wood) + GameRegistry.register(new Block(Material.wood) { { setCreativeTab(CreativeTabs.tabBlock); setUnlocalizedName(MODID + "." + blockName); + setRegistryName(blockId); } @Override - public boolean isOpaqueCube() { return false; } + public boolean isOpaqueCube(IBlockState state) { return false; } @Override - public boolean isFullCube() { return false; } + public boolean isFullCube(IBlockState state) { return false; } @Override - public boolean canRenderInLayer(EnumWorldBlockLayer layer) + public boolean canRenderInLayer(BlockRenderLayer layer) { - return layer == EnumWorldBlockLayer.SOLID || layer == EnumWorldBlockLayer.TRANSLUCENT; + return layer == BlockRenderLayer.SOLID || layer == BlockRenderLayer.TRANSLUCENT; } - }, blockName); + }); + GameRegistry.register(new ItemBlock(Block.blockRegistry.getObject(blockId)).setRegistryName(blockId)); } } @@ -58,7 +64,7 @@ public class MultiLayerModelDebug public void preInit(FMLPreInitializationEvent event) { super.preInit(event); - ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(GameRegistry.findBlock(MODID, blockName)), 0, new ModelResourceLocation(MODID.toLowerCase() + ":" + blockName, "inventory")); + ModelLoader.setCustomModelResourceLocation(Item.itemRegistry.getObject(blockId), 0, new ModelResourceLocation(blockId, "inventory")); } } diff --git a/src/test/java/net/minecraftforge/debug/NoPotionEffectRenderTest.java b/src/test/java/net/minecraftforge/debug/NoPotionEffectRenderTest.java index f8d779140d..2bb868cb76 100644 --- a/src/test/java/net/minecraftforge/debug/NoPotionEffectRenderTest.java +++ b/src/test/java/net/minecraftforge/debug/NoPotionEffectRenderTest.java @@ -5,6 +5,7 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.registry.GameData; @Mod( modid = NoPotionEffectRenderTest.modID, name = "No Potion Effect Render Test", version = "0.0.0" ) public class NoPotionEffectRenderTest { @@ -12,13 +13,14 @@ public class NoPotionEffectRenderTest { @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { - TestPotion INSTANCE = new TestPotion(30, new ResourceLocation(modID, "test_potion"), false, 0xff00ff); + TestPotion INSTANCE = new TestPotion(new ResourceLocation(modID, "test_potion"), false, 0xff00ff); + GameData.getPotionRegistry().register(-1, new ResourceLocation(modID, "test_potion"), INSTANCE); } public static class TestPotion extends Potion { - public TestPotion(int potionID, ResourceLocation location, boolean badEffect, int potionColor) { - super(potionID, location, badEffect, potionColor); + public TestPotion(ResourceLocation location, boolean badEffect, int potionColor) { + super(badEffect, potionColor); } @Override diff --git a/src/test/java/net/minecraftforge/debug/PotionRegistryDebug.java b/src/test/java/net/minecraftforge/debug/PotionRegistryDebug.java index 5a60a02607..6bfb4e5930 100644 --- a/src/test/java/net/minecraftforge/debug/PotionRegistryDebug.java +++ b/src/test/java/net/minecraftforge/debug/PotionRegistryDebug.java @@ -6,13 +6,18 @@ import gnu.trove.set.hash.TIntHashSet; import java.util.Random; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.registry.GameData; @Mod(modid=PotionRegistryDebug.MODID) public class PotionRegistryDebug { @@ -20,8 +25,10 @@ public class PotionRegistryDebug { @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { - new PotionForge(new ResourceLocation("forge", "forge"), false, 0xff00ff); // test automatic id distribution - new PotionForge(200, new ResourceLocation("forge", "forgy"), true, 0x00ff00); // test that ids above 127 work + Potion forge = new PotionForge(new ResourceLocation("forge", "forge"), false, 0xff00ff); // test automatic id distribution + Potion forgy = new PotionForge(new ResourceLocation("forge", "forgy"), true, 0x00ff00); // test that ids above 127 work + GameData.getPotionRegistry().register(-1, new ResourceLocation("forge", "forge"), forge); //TODo: Generic this out in GameRegistry, 'RegistryEntry' base type? + GameData.getPotionRegistry().register(200, new ResourceLocation("forge", "forgy"), forgy); Random rand = new Random(); TIntSet taken = new TIntHashSet(100); @@ -29,7 +36,7 @@ public class PotionRegistryDebug { taken.add(ra); // a new potion with a random id so that forge has to remap it - new PotionForge(ra, new ResourceLocation("forge", "realRandomPotion"), false, 0x0000ff); + //new PotionForge(ra, new ResourceLocation("forge", "realRandomPotion"), false, 0x0000ff); for(int i = 0; i < 20; i++) { int r = rand.nextInt(200) + 35; @@ -39,25 +46,19 @@ public class PotionRegistryDebug { taken.add(r); // this potions will most likely not have the same IDs between server and client. // The forge handshake on connect should fix this. - new PotionForge(r, new ResourceLocation("forge", "randomPotion" + r), false, 0xff00ff); + //new PotionForge(new ResourceLocation("forge", "randomPotion" + r), false, 0xff00ff); } } protected class PotionForge extends Potion { - - public PotionForge(int potionID, ResourceLocation location, boolean badEffect, int potionColor) { - super(potionID, location, badEffect, potionColor); - setPotionName("potion." + location.getResourcePath()); - } - protected PotionForge(ResourceLocation location, boolean badEffect, int potionColor) { - super(location, badEffect, potionColor); + super(badEffect, potionColor); setPotionName("potion." + location.getResourcePath()); } @Override public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) { - Potion potion = Potion.potionTypes[effect.getPotionID()]; + Potion potion = effect.getPotion(); mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite("minecraft:blocks/fire_layer_0"); @@ -67,16 +68,49 @@ public class PotionRegistryDebug { int width = 18; int height = width; -/* + + float r = (float)(potion.getLiquidColor() >> 24 & 255) / 255.0F; + float g = (float)(potion.getLiquidColor() >> 16 & 255) / 255.0F; + float b = (float)(potion.getLiquidColor() >> 8 & 255) / 255.0F; + float a = (float)(potion.getLiquidColor() & 255) / 255.0F; + Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.startDrawingQuads(); - worldrenderer.setColorOpaque_I(potion.getLiquidColor()); - worldrenderer.addVertexWithUV((double) x, (double) (y + height), 0.0D, sprite.getMinU(), sprite.getMaxV()); - worldrenderer.addVertexWithUV((double)(x + width), (double)(y + height), 0.0D, sprite.getMaxU(), sprite.getMaxV()); - worldrenderer.addVertexWithUV((double)(x + width), (double)y, 0.0D, sprite.getMaxU(), sprite.getMinV()); - worldrenderer.addVertexWithUV((double)x, (double)y, 0.0D, sprite.getMinU(), sprite.getMinV()); - tessellator.draw();*/ + VertexBuffer buf = tessellator.getBuffer(); + buf.begin(7, DefaultVertexFormats.POSITION_TEX); + GlStateManager.color(r, g, b, a); + buf.pos((double) x, (double)(y + height), 0.0D).tex(sprite.getMinU(), sprite.getMaxV()).endVertex(); + buf.pos((double)(x + width), (double)(y + height), 0.0D).tex(sprite.getMaxU(), sprite.getMaxV()).endVertex(); + buf.pos((double)(x + width), (double) y, 0.0D).tex(sprite.getMaxU(), sprite.getMinV()).endVertex(); + buf.pos((double) x, (double) y, 0.0D).tex(sprite.getMinU(), sprite.getMinV()).endVertex(); + tessellator.draw(); + } + + @Override + public void renderHUDEffect(int x, int y, PotionEffect effect, Minecraft mc, float alpha) { + Potion potion = effect.getPotion(); + + mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite("minecraft:blocks/tnt_side"); + + x += 3; + y += 3; + + int width = 18; + int height = width; + + float r = (float)(potion.getLiquidColor() >> 24 & 255) / 255.0F; + float g = (float)(potion.getLiquidColor() >> 16 & 255) / 255.0F; + float b = (float)(potion.getLiquidColor() >> 8 & 255) / 255.0F; + + Tessellator tessellator = Tessellator.getInstance(); + VertexBuffer buf = tessellator.getBuffer(); + buf.begin(7, DefaultVertexFormats.POSITION_TEX); + GlStateManager.color(r, g, b, alpha); + buf.pos((double) x, (double)(y + height), 0.0D).tex(sprite.getMinU(), sprite.getMaxV()).endVertex(); + buf.pos((double)(x + width), (double)(y + height), 0.0D).tex(sprite.getMaxU(), sprite.getMaxV()).endVertex(); + buf.pos((double)(x + width), (double) y, 0.0D).tex(sprite.getMaxU(), sprite.getMinV()).endVertex(); + buf.pos((double) x, (double) y, 0.0D).tex(sprite.getMinU(), sprite.getMinV()).endVertex(); + tessellator.draw(); } } } diff --git a/src/test/java/net/minecraftforge/test/ClientCommandTest.java b/src/test/java/net/minecraftforge/test/ClientCommandTest.java index 79478f2981..86a9d8ab20 100644 --- a/src/test/java/net/minecraftforge/test/ClientCommandTest.java +++ b/src/test/java/net/minecraftforge/test/ClientCommandTest.java @@ -6,15 +6,16 @@ import java.util.List; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; -import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.registry.GameData; -@Mod(modid="clientcommandtest", name="Client Command Test", version="0.0.0") +@Mod(modid="clientcommandtest", name="Client Command Test", version="0.0.0", clientSideOnly = true) public class ClientCommandTest { @EventHandler public void init(FMLInitializationEvent event) @@ -36,13 +37,13 @@ public class ClientCommandTest { } @Override - public boolean canCommandSenderUseCommand(ICommandSender sender) + public boolean checkPermission(MinecraftServer server, ICommandSender sender) { return true; } @Override - public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) + public List getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) { if (args.length > 0) { @@ -53,15 +54,15 @@ public class ClientCommandTest { } @Override - public void processCommand(ICommandSender sender, String[] args) throws CommandException + public void execute( MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length > 0) { - sender.addChatMessage(new ChatComponentText("Input: " + Arrays.toString(args))); + sender.addChatMessage(new TextComponentString("Input: " + Arrays.toString(args))); } else { - sender.addChatMessage(new ChatComponentText("No arguments.")); + sender.addChatMessage(new TextComponentString("No arguments.")); } } } diff --git a/src/test/java/net/minecraftforge/test/EntityTravelToDimensionEventTest.java b/src/test/java/net/minecraftforge/test/EntityTravelToDimensionEventTest.java index a95b22dd1f..5b1380b42f 100644 --- a/src/test/java/net/minecraftforge/test/EntityTravelToDimensionEventTest.java +++ b/src/test/java/net/minecraftforge/test/EntityTravelToDimensionEventTest.java @@ -22,7 +22,7 @@ public class EntityTravelToDimensionEventTest public void onDimensionTravel(EntityTravelToDimensionEvent event) { if(ENABLE) { - System.out.println("Travelling to Dimension " + event.dimension); + System.out.println("Travelling to Dimension " + event.getDimension()); event.setCanceled(true); } } diff --git a/src/test/java/net/minecraftforge/test/FOVModifierTest.java b/src/test/java/net/minecraftforge/test/FOVModifierTest.java index c7ded0c58b..efcb082f0c 100644 --- a/src/test/java/net/minecraftforge/test/FOVModifierTest.java +++ b/src/test/java/net/minecraftforge/test/FOVModifierTest.java @@ -9,7 +9,7 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; /** Simple mod to test fov modifier. */ -@Mod(modid="fovmodifiertest", name="FOV Modifier Test", version="0.0.0") +@Mod(modid="fovmodifiertest", name="FOV Modifier Test", version="0.0.0", clientSideOnly = true) public class FOVModifierTest { @EventHandler @@ -20,7 +20,7 @@ public class FOVModifierTest { @SubscribeEvent public void getFOVModifier(EntityViewRenderEvent.FOVModifier event) { - if(event.block.getMaterial() == Material.water) + if(event.getState().getMaterial() == Material.water) event.setFOV(event.getFOV() / 60.0f * 50.0f); } } diff --git a/src/test/java/net/minecraftforge/test/NeighborNotifyEventTest.java b/src/test/java/net/minecraftforge/test/NeighborNotifyEventTest.java index 9be69bf6a0..af23523fbc 100644 --- a/src/test/java/net/minecraftforge/test/NeighborNotifyEventTest.java +++ b/src/test/java/net/minecraftforge/test/NeighborNotifyEventTest.java @@ -23,7 +23,7 @@ public class NeighborNotifyEventTest public void onNeighborNotify(NeighborNotifyEvent event) { if(ENABLE) { - System.out.println(event.pos.toString()); + System.out.println(event.getPos().toString()); event.setCanceled(true); } } diff --git a/src/test/java/net/minecraftforge/test/NoBedSleepingTest.java b/src/test/java/net/minecraftforge/test/NoBedSleepingTest.java index c231fcd2cf..fe1cf7f39c 100644 --- a/src/test/java/net/minecraftforge/test/NoBedSleepingTest.java +++ b/src/test/java/net/minecraftforge/test/NoBedSleepingTest.java @@ -1,19 +1,32 @@ package net.minecraftforge.test; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer.EnumStatus; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTBase.NBTPrimitive; +import net.minecraft.nbt.NBTTagByte; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import net.minecraftforge.common.IExtendedEntityProperties; +import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.EntityEvent.EntityConstructing; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; +import net.minecraftforge.common.capabilities.CapabilityManager; +import net.minecraftforge.common.capabilities.ICapabilitySerializable; +import net.minecraftforge.common.capabilities.Capability.IStorage; +import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.entity.player.PlayerWakeUpEvent; import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.Event.Result; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -24,64 +37,112 @@ public class NoBedSleepingTest { public static final String MODID = "ForgeDebugNoBedSleeping"; public static final String VERSION = "1.0"; + @CapabilityInject(IExtraSleeping.class) + private static final Capability SLEEP_CAP = null; + + @SidedProxy + public static CommonProxy proxy = null; + + public static abstract class CommonProxy + { + public void preInit(FMLPreInitializationEvent event) + { + GameRegistry.register(ItemSleepingPill.instance); + CapabilityManager.INSTANCE.register(IExtraSleeping.class, new Storage(), DefaultImpl.class); + MinecraftForge.EVENT_BUS.register(new EventHandler()); + } + } + + public static final class ServerProxy extends CommonProxy {} + + public static final class ClientProxy extends CommonProxy + { + @Override + public void preInit(FMLPreInitializationEvent event) + { + super.preInit(event); + ModelLoader.setCustomModelResourceLocation(ItemSleepingPill.instance, 0, new ModelResourceLocation(new ResourceLocation(MODID, ItemSleepingPill.name), "inventory")); + } + } @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { - GameRegistry.registerItem(ItemSleepingPill.instance, ItemSleepingPill.name); - MinecraftForge.EVENT_BUS.register(new EventHandler()); + proxy.preInit(event); } public static class EventHandler { @SubscribeEvent - public void onEntityConstruct(EntityConstructing evt) + public void onEntityConstruct(AttachCapabilitiesEvent evt) { - evt.entity.registerExtendedProperties(ExtendedPropertySleeping.name, new ExtendedPropertySleeping()); + evt.addCapability(new ResourceLocation(MODID, "IExtraSleeping"), new ICapabilitySerializable() + { + IExtraSleeping inst = SLEEP_CAP.getDefaultInstance(); + @Override + public boolean hasCapability(Capability capability, EnumFacing facing) { + return capability == SLEEP_CAP; + } + + @Override + public T getCapability(Capability capability, EnumFacing facing) { + return capability == SLEEP_CAP ? SLEEP_CAP.cast(inst) : null; + } + + @Override + public NBTPrimitive serializeNBT() { + return (NBTPrimitive)SLEEP_CAP.getStorage().writeNBT(SLEEP_CAP, inst, null); + } + + @Override + public void deserializeNBT(NBTPrimitive nbt) { + SLEEP_CAP.getStorage().readNBT(SLEEP_CAP, inst, null, nbt); + } + }); } @SubscribeEvent public void onBedCheck(SleepingLocationCheckEvent evt) { - final IExtendedEntityProperties property = evt.entityPlayer.getExtendedProperties(ExtendedPropertySleeping.name); - if (property instanceof ExtendedPropertySleeping && ((ExtendedPropertySleeping) property).isSleeping) + final IExtraSleeping sleep = evt.getEntityPlayer().getCapability(SLEEP_CAP, null); + if (sleep != null && sleep.isSleeping()) evt.setResult(Result.ALLOW); } @SubscribeEvent public void onWakeUp(PlayerWakeUpEvent evt) { - final IExtendedEntityProperties property = evt.entityPlayer.getExtendedProperties(ExtendedPropertySleeping.name); - if (property instanceof ExtendedPropertySleeping) - ((ExtendedPropertySleeping) property).isSleeping = false; + final IExtraSleeping sleep = evt.getEntityPlayer().getCapability(SLEEP_CAP, null); + if (sleep != null) + sleep.setSleeping(false); } } - public static class ExtendedPropertySleeping implements IExtendedEntityProperties + public interface IExtraSleeping { + boolean isSleeping(); + void setSleeping(boolean value); + } + + public static class Storage implements IStorage { - private static final String TAG_NAME = "IsSleepingExt"; - - public static final String name = "is_sleeping"; - - public boolean isSleeping; - @Override - public void saveNBTData(NBTTagCompound compound) + public NBTBase writeNBT(Capability capability, IExtraSleeping instance, EnumFacing side) { - compound.setBoolean(TAG_NAME, isSleeping); + return new NBTTagByte((byte)(instance.isSleeping() ? 1 : 0)); } @Override - public void loadNBTData(NBTTagCompound compound) - { - this.isSleeping = compound.getBoolean(TAG_NAME); - } - - @Override - public void init(Entity entity, World world) + public void readNBT(Capability capability, IExtraSleeping instance, EnumFacing side, NBTBase nbt) { + instance.setSleeping(((NBTPrimitive)nbt).getByte() == 1); } + } + public static class DefaultImpl implements IExtraSleeping + { + private boolean isSleeping = false; + @Override public boolean isSleeping() { return isSleeping; } + @Override public void setSleeping(boolean value) { this.isSleeping = value; } } public static class ItemSleepingPill extends Item @@ -93,21 +154,24 @@ public class NoBedSleepingTest { setCreativeTab(CreativeTabs.tabMisc); setUnlocalizedName(MODID + ":" + name); + setRegistryName(new ResourceLocation(MODID, name)); } - public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) + @Override + public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) { - if (!worldIn.isRemote) + if (!world.isRemote) { - final EnumStatus result = playerIn.trySleep(playerIn.getPosition()); + final EnumStatus result = player.trySleep(player.getPosition()); if (result == EnumStatus.OK) { - final IExtendedEntityProperties property = playerIn.getExtendedProperties(ExtendedPropertySleeping.name); - if (property instanceof ExtendedPropertySleeping) - ((ExtendedPropertySleeping) property).isSleeping = true; + final IExtraSleeping sleep = player.getCapability(SLEEP_CAP, null); + if (sleep != null) + sleep.setSleeping(true); + return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } - return itemStackIn; + return ActionResult.newResult(EnumActionResult.PASS, stack); } } } diff --git a/src/test/java/net/minecraftforge/test/PlayerInteractEventLocalTest.java b/src/test/java/net/minecraftforge/test/PlayerInteractEventLocalTest.java deleted file mode 100644 index 9e8d1031f7..0000000000 --- a/src/test/java/net/minecraftforge/test/PlayerInteractEventLocalTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.minecraftforge.test; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -@Mod(modid="PlayerInteractEventLocalTest", name="PlayerInteractEventLocalTest", version="0.0.0") -public class PlayerInteractEventLocalTest -{ - - public static final boolean ENABLE = false; - - @EventHandler - public void init(FMLInitializationEvent event) - { - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onPlayerInteract(PlayerInteractEvent event) - { - if(ENABLE && event.localPos != null) { - System.out.println(event.localPos.toString()); - } - } -} diff --git a/src/test/java/net/minecraftforge/test/PlayerInteractEventTest.java b/src/test/java/net/minecraftforge/test/PlayerInteractEventTest.java new file mode 100644 index 0000000000..97739dd877 --- /dev/null +++ b/src/test/java/net/minecraftforge/test/PlayerInteractEventTest.java @@ -0,0 +1,154 @@ +package net.minecraftforge.test; + +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.EntityCreeper; +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.entity.passive.EntityHorse; +import net.minecraft.init.Items; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.tileentity.TileEntityDropper; +import net.minecraft.util.EnumHand; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.eventhandler.Event; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.apache.logging.log4j.Logger; + +@Mod(modid="PlayerInteractEventTest", name="PlayerInteractEventTest", version="0.0.0") +public class PlayerInteractEventTest +{ + // NOTE: Test with both this ON and OFF - ensure none of the test behaviours show when this is off! + private static final boolean ENABLE = false; + private Logger logger; + + @EventHandler + public void preinit(FMLPreInitializationEvent event) + { + logger = event.getModLog(); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent(receiveCanceled = true) // this triggers after the subclasses below, and we'd like to log them all + public void global(PlayerInteractEvent evt) + { + if (!ENABLE) return; + logger.info("{} | {}", evt.getClass().getSimpleName(), evt.getSide().name()); + logger.info("{} | stack: {}", evt.getHand(), evt.getItemStack()); + logger.info("{} | face: {}", evt.getPos(), evt.getFace()); + } + + @SubscribeEvent + public void leftClickBlock(PlayerInteractEvent.LeftClickBlock evt) + { + if (!ENABLE) return; + logger.info("HIT VEC: {}", evt.getHitVec()); + + if (evt.getItemStack() != null) + { + if (evt.getItemStack().getItem() == Items.golden_pickaxe) + evt.setCanceled(true); // Redstone should not activate and pick should not be able to dig anything + if (evt.getItemStack().getItem() == Items.diamond_pickaxe) + evt.setUseBlock(Event.Result.DENY); // Redstone should not activate, pick should still dig + if (evt.getItemStack().getItem() == Items.iron_pickaxe) + evt.setUseItem(Event.Result.DENY); // Pick should not dig, Redstone should still activate + } + + // When item use denied, the event will keep firing as long as the left click button is held. + // This is due to how vanilla calls the left click handling methods to let people not lift their button when mining multiple blocks. + // Note that when item use is denied, the cool down for the item does not occur. This is good! + } + + @SubscribeEvent + public void rightClickBlock(PlayerInteractEvent.RightClickBlock evt) + { + if (!ENABLE) return; + logger.info("HIT VEC: {}", evt.getHitVec()); + + // Shift right clicking dropper with an item in hand should still open the dropper contrary to normal mechanics + // The item in hand is used as well (not specifying anything would not use the item) + TileEntity te = evt.getWorld().getTileEntity(evt.getPos()); + if (te instanceof TileEntityDropper) + { + evt.setUseBlock(Event.Result.ALLOW); + evt.setUseItem(Event.Result.ALLOW); + } + + // Same as above, except the item should no longer be used + if (te instanceof TileEntityChest) + { + evt.setUseBlock(Event.Result.ALLOW); + evt.setUseItem(Event.Result.DENY); // could be left out as well + } + + // Case: Flint and steel in main hand on top of a TE will light a fire, not open the TE. + // Note that if you do this on a chest, the f+s will fail, but then your off hand will open the chest + // If you dual wield flints and steels and right click a chest nothing should happen + if (evt.getItemStack() != null && evt.getItemStack().getItem() == Items.flint_and_steel) + evt.setUseBlock(Event.Result.DENY); + + // Case: Painting in main hand + // Opening a TE will also place a painting on the TE if possible + if (evt.getHand() == EnumHand.MAIN_HAND && evt.getItemStack() != null && evt.getItemStack().getItem() == Items.painting) { + evt.setUseItem(Event.Result.ALLOW); + } + + // Spawn egg in main hand, block in offhand -> block should be placed + // Sword in main hand, spawn egg in offhand -> nothing should happen + if (evt.getItemStack() != null && evt.getItemStack().getItem() == Items.spawn_egg) { + evt.setCanceled(true); + } + + + } + + @SubscribeEvent + public void rightClickItem(PlayerInteractEvent.RightClickItem evt) + { + if (!ENABLE) return; + + // Use survival mode + // Case: Ender pearl in main hand, bow in offhand with arrows in inv -> Bow should trigger + // Case: Sword in main hand, ender pearl in offhand -> Nothing should happen + + if (evt.getItemStack() != null && evt.getItemStack().getItem() == Items.ender_pearl) + evt.setCanceled(true); + } + + @SubscribeEvent + public void interactSpecific(PlayerInteractEvent.EntityInteractSpecific evt) + { + if (!ENABLE) return; + logger.info("LOCAL POS: {}", evt.getLocalPos()); + + if (evt.getItemStack() != null + && evt.getTarget() instanceof EntityArmorStand + && evt.getItemStack().getItem() == Items.iron_helmet) + evt.setCanceled(true); // Should not be able to place iron helmet onto armor stand (you will put it on instead) + + if (evt.getWorld().isRemote + && evt.getTarget() instanceof EntitySkeleton + && evt.getLocalPos().yCoord > evt.getTarget().height / 2.0) + { + // If we right click the upper half of a skeleton it becomes wither skeleton. Otherwise nothing happens. + ((EntitySkeleton) evt.getTarget()).setSkeletonType(1); + evt.setCanceled(true); + } + } + + @SubscribeEvent + public void interactNormal(PlayerInteractEvent.EntityInteract evt) + { + if (!ENABLE) return; + + if (evt.getItemStack() != null && (evt.getTarget() instanceof EntityHorse || evt.getTarget() instanceof EntityCreeper)) + // Should not be able to feed wild horses with golden apple (you will start eating it in survival) + // Should not be able to ignite creeper with F+S + // Applies to both hands + evt.setCanceled(true); + } +} diff --git a/src/test/java/net/minecraftforge/test/PlayerSetSpawnTest.java b/src/test/java/net/minecraftforge/test/PlayerSetSpawnTest.java index 78875dbcee..65b9b41c17 100644 --- a/src/test/java/net/minecraftforge/test/PlayerSetSpawnTest.java +++ b/src/test/java/net/minecraftforge/test/PlayerSetSpawnTest.java @@ -19,7 +19,7 @@ public class PlayerSetSpawnTest { @SubscribeEvent public void onPlayerSetSpawn(PlayerSetSpawnEvent event) { - System.out.println(event.forced + " " + event.newSpawn.toString()); + System.out.println(event.isForced() + " " + event.getNewSpawn().toString()); event.setCanceled(true); } } diff --git a/src/test/java/net/minecraftforge/test/TestCapabilityMod.java b/src/test/java/net/minecraftforge/test/TestCapabilityMod.java index 5f8285ee63..44a6d22245 100644 --- a/src/test/java/net/minecraftforge/test/TestCapabilityMod.java +++ b/src/test/java/net/minecraftforge/test/TestCapabilityMod.java @@ -4,8 +4,8 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.nbt.NBTBase; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; @@ -42,23 +42,22 @@ public class TestCapabilityMod } @SubscribeEvent - public void onInteract(PlayerInteractEvent event) + public void onInteract(PlayerInteractEvent.LeftClickBlock event) { - if (event.action != PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) return; - if (event.entityPlayer.getHeldItem() == null) return; - if (event.entityPlayer.getHeldItem().getItem() != Items.stick) return; + if (event.getItemStack() == null) return; + if (event.getItemStack().getItem() != Items.stick) return; // This is just a example of how to interact with the TE, note the strong type binding that getCapability has - TileEntity te = event.world.getTileEntity(event.pos); - if (te != null && te.hasCapability(TEST_CAP, event.face)) + TileEntity te = event.getWorld().getTileEntity(event.getPos()); + if (te != null && te.hasCapability(TEST_CAP, event.getFace())) { event.setCanceled(true); - IExampleCapability inv = te.getCapability(TEST_CAP, event.face); + IExampleCapability inv = te.getCapability(TEST_CAP, event.getFace()); System.out.println("Hi I'm a " + inv.getOwnerType()); } - if (event.world.getBlockState(event.pos).getBlock() == Blocks.dirt) + if (event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.dirt) { - event.entityPlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "" + EnumChatFormatting.ITALIC + "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST")); + event.getEntityPlayer().addChatMessage(new TextComponentString(TextFormatting.RED + "" + TextFormatting.ITALIC + "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST")); event.setCanceled(true); } } @@ -97,11 +96,10 @@ public class TestCapabilityMod { return TEST_CAP != null && capability == TEST_CAP; } - @SuppressWarnings("unchecked") //There isnt anything sane we can do about this. @Override public T getCapability(Capability capability, EnumFacing facing) { - if (TEST_CAP != null && capability == TEST_CAP) return (T)this; + if (TEST_CAP != null && capability == TEST_CAP) return TEST_CAP.cast(this); return null; } @Override diff --git a/src/test/java/net/minecraftforge/test/WRNormalMod.java b/src/test/java/net/minecraftforge/test/WRNormalMod.java index 1944461c22..bf1992f982 100644 --- a/src/test/java/net/minecraftforge/test/WRNormalMod.java +++ b/src/test/java/net/minecraftforge/test/WRNormalMod.java @@ -3,7 +3,7 @@ package net.minecraftforge.test; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.util.ResourceLocation; @@ -66,7 +66,7 @@ public class WRNormalMod } } - public static class RenderScaleTest extends RendererLivingEntity + public static class RenderScaleTest extends RenderLivingBase { private static final ResourceLocation TEXTURE = new ResourceLocation("textures/blocks/stone.png"); diff --git a/src/test/resources/assets/dynbuckettest/blockstates/simpletank.json b/src/test/resources/assets/dynbuckettest/blockstates/simpletank.json new file mode 100644 index 0000000000..a407ada13e --- /dev/null +++ b/src/test/resources/assets/dynbuckettest/blockstates/simpletank.json @@ -0,0 +1,10 @@ +{ + "forge_marker": 1, + "defaults": { + "transform": "forge:default-block", + "model": "builtin/generated" + }, + "variants": { + "normal": [{}] + } +} \ No newline at end of file diff --git a/src/test/resources/assets/forgedebugitemtile/blockstates/custom_model_block.json b/src/test/resources/assets/forgedebugitemtile/blockstates/custom_model_block.json new file mode 100644 index 0000000000..67e2f34328 --- /dev/null +++ b/src/test/resources/assets/forgedebugitemtile/blockstates/custom_model_block.json @@ -0,0 +1,10 @@ +{ + "forge_marker": 1, + "defaults": { + "transform": "forge:default-block", + "model": "builtin/generated" + }, + "variants": { + "normal": [{}] + } +} diff --git a/src/test/resources/assets/forgedebugitemtile/models/item/custom_model_block.json b/src/test/resources/assets/forgedebugitemtile/models/item/custom_model_block.json deleted file mode 100644 index 43a272a605..0000000000 --- a/src/test/resources/assets/forgedebugitemtile/models/item/custom_model_block.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "builtin/entity" -} diff --git a/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json b/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json index 6fc5602258..26dc74ed9d 100644 --- a/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json +++ b/src/test/resources/assets/forgedebugmodelanimation/blockstates/test_animation_block.json @@ -16,14 +16,7 @@ "variants": { "normal": [{}], "inventory": [{ - "transform": { - "rotation": { "y": 180 }, - "thirdperson": { - "rotation": [ { "z": 170 }, { "y": -45 }, { "z": 20 } ], - "translation": [ 0, 0.09375, -0.171875 ], - "scale": 0.375 - } - }, + "transform": "forge:default-block", "model": "forgedebugmodelanimation:engine", "submodel": { "ring": { "model": "forgedebugmodelanimation:engine_ring" } @@ -50,6 +43,12 @@ }*/ "model": "forgedebugmodelanimation:engine_ring" } - } + }, + "entity": [{ + "model": "forgedebugmodelanimation:engine", + "submodel": { + "ring": { "model": "forgedebugmodelanimation:engine_ring" } + } + }] } } diff --git a/src/test/resources/assets/forgedebugmodelanimation/models/block/engine.json b/src/test/resources/assets/forgedebugmodelanimation/models/block/engine.json index d7ef2789f3..a8d0b8ce9b 100644 --- a/src/test/resources/assets/forgedebugmodelanimation/models/block/engine.json +++ b/src/test/resources/assets/forgedebugmodelanimation/models/block/engine.json @@ -1,5 +1,3 @@ -// vanilla json model, no modifications - { "elements": [ { diff --git a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/CustomModelBlock.json b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/CustomModelBlock.json index e4e82e072e..ced7cffd1c 100644 --- a/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/CustomModelBlock.json +++ b/src/test/resources/assets/forgedebugmodelloaderregistry/blockstates/CustomModelBlock.json @@ -13,14 +13,7 @@ "variants": { "normal": [{}], "inventory": [{ - "transform": { - "rotation": { "y": 180 }, - "thirdperson": { - "rotation": [ { "z": 170 }, { "y": -45 }, { "z": 20 } ], - "translation": [ 0, 0.09375, -0.171875 ], - "scale": 0.375 - } - } + "transform": "forge:default-block" }], "facing": { "down": {"x": 90}, diff --git a/src/test/resources/assets/forgedebugmultilayermodel/blockstates/test_layer_block.json b/src/test/resources/assets/forgedebugmultilayermodel/blockstates/test_layer_block.json index 15a23f01cf..e5ff027bd1 100644 --- a/src/test/resources/assets/forgedebugmultilayermodel/blockstates/test_layer_block.json +++ b/src/test/resources/assets/forgedebugmultilayermodel/blockstates/test_layer_block.json @@ -7,13 +7,16 @@ "base": "forgedebugmultilayermodel:test_layer_block#aux", // per-layer models "Solid": "forgedebugmultilayermodel:test_layer_block#aux", - "Translucent": "minecraft:pink_stained_glass_pane#east=true,north=false,south=false,west=true" + "Translucent": "forgedebugmultilayermodel:test_layer_block#pane" }, "transform": "forge:default-block" }, "variants": { "normal": [{}], "inventory": [{}], + "pane": [{ + "model": "minecraft:pink_stained_glass_pane_noside" + }], "aux": [{ "model": "cube_all", "textures": { "all": "blocks/slime" }, diff --git a/src/test/resources/assets/forgedebugnobedsleeping/models/item/sleeping_pill.json b/src/test/resources/assets/forgedebugnobedsleeping/models/item/sleeping_pill.json new file mode 100644 index 0000000000..15928e0b20 --- /dev/null +++ b/src/test/resources/assets/forgedebugnobedsleeping/models/item/sleeping_pill.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "items/beef_cooked" + } +} \ No newline at end of file