mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 09:05:17 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa1a5d3c19 | ||
|
|
a53d8c926e | ||
|
|
714cd8d8df | ||
|
|
c9f7444d06 | ||
|
|
ea05777032 | ||
|
|
14fea4a3a3 | ||
|
|
0613858855 | ||
|
|
6687ed360b | ||
|
|
409506d2b2 | ||
|
|
b96d6e00c3 | ||
|
|
b6ae926fd3 | ||
|
|
508c986166 | ||
|
|
725201040e | ||
|
|
70d7c8fc68 | ||
|
|
05f9861da4 | ||
|
|
c588750c96 | ||
|
|
be1a80ebbd | ||
|
|
44706ae343 | ||
|
|
2af41e7c8c | ||
|
|
e5c29a75de | ||
|
|
2a36dc64bd | ||
|
|
dd128c8502 | ||
|
|
3812dc4464 | ||
|
|
851038679a | ||
|
|
146ee9b3c7 | ||
|
|
6c42a77411 | ||
|
|
7e24034fcc | ||
|
|
e6eb550bfd | ||
|
|
2dbb374869 | ||
|
|
e5efbea2ab | ||
|
|
bc74a16149 | ||
|
|
4cd6c58159 | ||
|
|
9e6fbea698 | ||
|
|
e796630120 | ||
|
|
cad5ce54dc | ||
|
|
3c3e4ca2ff | ||
|
|
b9b90c6eef | ||
|
|
747c6131bf | ||
|
|
5c65939330 | ||
|
|
cddcd9ffb3 | ||
|
|
1295c3863e | ||
|
|
99ce6e2dee | ||
|
|
a9d4a15a4f | ||
|
|
2fbf60a846 | ||
|
|
1838344b07 | ||
|
|
fd6aacd0fe | ||
|
|
4b142cbdcc | ||
|
|
802425b4d5 | ||
|
|
745d388cb0 | ||
|
|
1f52ee1dea | ||
|
|
1af7d7970a | ||
|
|
201edc0249 | ||
|
|
2f4a572a23 | ||
|
|
0cf8cca248 | ||
|
|
af4a2589a6 | ||
|
|
2d55491692 | ||
|
|
1007720589 | ||
|
|
b2f470464a | ||
|
|
683c99c8b6 | ||
|
|
428cf691f1 | ||
|
|
bfe54ef7e7 | ||
|
|
40dff18025 | ||
|
|
4d620d91e4 | ||
|
|
a502e1fc56 | ||
|
|
4f0c220d99 | ||
|
|
08a4b21460 | ||
|
|
9fd6f89fc3 | ||
|
|
11652d597f | ||
|
|
f943cd9b4b | ||
|
|
1e392e0bb3 | ||
|
|
e536c58f81 | ||
|
|
63c02cbe35 | ||
|
|
d9a8392723 | ||
|
|
ae52b91d13 | ||
|
|
370062cc55 | ||
|
|
43eae28f55 | ||
|
|
c2c27044b5 | ||
|
|
09722f3ffc | ||
|
|
2cf960b64d | ||
|
|
05b31bdd6e | ||
|
|
e115807351 | ||
|
|
f5b29d2726 | ||
|
|
dfac296402 | ||
|
|
9e2117c955 | ||
|
|
4fdf2ea290 | ||
|
|
10fb465525 | ||
|
|
d44822b7d0 | ||
|
|
18a35c1ab7 | ||
|
|
26cf077cfa | ||
|
|
c3379b44dd | ||
|
|
3ad305aa06 | ||
|
|
89d74da576 | ||
|
|
9ad4177bfa | ||
|
|
20c830c848 | ||
|
|
877bb029f9 | ||
|
|
cfb5cb1a2f | ||
|
|
245f562e1c | ||
|
|
68dc92f0e1 | ||
|
|
ee4089304a | ||
|
|
f3dfa1a955 | ||
|
|
2320e42163 | ||
|
|
bcc35775f4 | ||
|
|
3239536832 | ||
|
|
9c1c414ca7 | ||
|
|
20e5963059 | ||
|
|
70c57e2ad6 | ||
|
|
4639786521 | ||
|
|
71e873ed1f | ||
|
|
c416a82e64 | ||
|
|
539252053f | ||
|
|
da791ef721 | ||
|
|
49bca8998a | ||
|
|
6e14c67e82 | ||
|
|
7fddb9d59e | ||
|
|
006112f3d3 | ||
|
|
e075a430e2 | ||
|
|
134299b413 | ||
|
|
03059c5cd2 | ||
|
|
918d9d8687 | ||
|
|
5017f8b038 | ||
|
|
78052d2ce2 | ||
|
|
8a6b10607d | ||
|
|
034117e253 | ||
|
|
a3ddd6140b | ||
|
|
ac292296fe | ||
|
|
d50a66c8ba | ||
|
|
fb4d3b2ca9 | ||
|
|
fcdd2a9176 | ||
|
|
fa921f0aa9 | ||
|
|
ac221275d9 | ||
|
|
33f8b158a9 | ||
|
|
b9b33ebe79 | ||
|
|
a23816134b | ||
|
|
4e8e84244b | ||
|
|
a94316cc9e | ||
|
|
01a1bc9e6a | ||
|
|
d2b69b2b08 | ||
|
|
91fbba3873 | ||
|
|
a4f3bc853a | ||
|
|
b7ece58caa | ||
|
|
fe354c867d | ||
|
|
326d52f534 | ||
|
|
fbd9ac7d95 | ||
|
|
96018996fc | ||
|
|
9b205b1355 | ||
|
|
56f915eb66 | ||
|
|
46f8868961 | ||
|
|
15089f9d87 | ||
|
|
4783bfe01d | ||
|
|
7b894946bf | ||
|
|
a01e513822 | ||
|
|
3061fd3d8f | ||
|
|
9b281f0a3c | ||
|
|
e433708056 | ||
|
|
43eae51bb3 | ||
|
|
72edbe596e | ||
|
|
53b5533936 | ||
|
|
84c86fd475 | ||
|
|
a9d644e1e8 | ||
|
|
7ed6c7bd7f | ||
|
|
3fd23cee0f | ||
|
|
0665c93c2b | ||
|
|
cd741d961e | ||
|
|
ea855f82b4 | ||
|
|
d775f42703 | ||
|
|
0981d3106d | ||
|
|
a20c7f6f76 | ||
|
|
cf9b57d9fa | ||
|
|
7deedb26f5 | ||
|
|
4c2c7cb2f3 | ||
|
|
7ec180ee7c | ||
|
|
b1ee6c3c95 | ||
|
|
a36fccc9b0 | ||
|
|
36b05d9378 | ||
|
|
2b8ac71253 | ||
|
|
1ffb096508 | ||
|
|
7a66d88e9f | ||
|
|
42c5b9534a | ||
|
|
0b1f3b51e3 | ||
|
|
6646b573e8 | ||
|
|
201762ee50 | ||
|
|
99ee905038 | ||
|
|
d2afbd9216 | ||
|
|
5f49c5f646 | ||
|
|
d91c22ea24 | ||
|
|
4c9745f73c | ||
|
|
edb0ba811f | ||
|
|
a1ca27b997 | ||
|
|
285d187884 | ||
|
|
351c193b98 | ||
|
|
8586d8ae85 | ||
|
|
1a40f433a5 | ||
|
|
6c6f792c6b | ||
|
|
149fa8a577 | ||
|
|
f279476684 | ||
|
|
0ca8ace988 | ||
|
|
80f87ef569 | ||
|
|
904efdd4d8 | ||
|
|
874d3f0b17 | ||
|
|
603005ba18 | ||
|
|
6b286543d4 | ||
|
|
28992c6f13 | ||
|
|
174e208369 | ||
|
|
c632d5145e | ||
|
|
f3bee8c070 | ||
|
|
8bfeb5ac21 | ||
|
|
05dc6f8e4b | ||
|
|
2eb77acf73 | ||
|
|
f7cec9be38 | ||
|
|
8f8ee60eb1 | ||
|
|
8f14c7321b | ||
|
|
aedb80c251 | ||
|
|
e7224c7bda | ||
|
|
cceeb88c6d | ||
|
|
65f39a50c1 | ||
|
|
0a52ed381d | ||
|
|
78f2e8f38a | ||
|
|
9fdc403396 | ||
|
|
9c3a2f052d | ||
|
|
5f26a86bf7 | ||
|
|
b1d9f3d833 | ||
|
|
05ff62d85f | ||
|
|
b0774b89c7 | ||
|
|
1ec797cddb | ||
|
|
2ff2a78694 | ||
|
|
93664d10e6 | ||
|
|
10e5d42522 | ||
|
|
d531d70f1f | ||
|
|
95596bc198 | ||
|
|
b32a92df5b | ||
|
|
ac6c35d7c4 | ||
|
|
2ed8a8b807 | ||
|
|
759e92cc2a | ||
|
|
feede96d6d | ||
|
|
fc33249d32 | ||
|
|
ff48f13746 | ||
|
|
47e61610ca | ||
|
|
4f97aedbb2 | ||
|
|
51203e49f9 | ||
|
|
1906a085ad | ||
|
|
5a3ac6b96e | ||
|
|
1146660fc6 | ||
|
|
2888e1680e | ||
|
|
7bf22659e7 | ||
|
|
86f8bbd47d | ||
|
|
5bc8929795 | ||
|
|
b2853aa811 | ||
|
|
c06fc00f24 | ||
|
|
1e6eec768c | ||
|
|
33d7d77775 | ||
|
|
83b060b573 | ||
|
|
df656cb98d | ||
|
|
cb21ddc438 | ||
|
|
7b45203461 | ||
|
|
ecb07e2abb | ||
|
|
647c40ba5e | ||
|
|
9210fe1a57 | ||
|
|
9efb9741d1 | ||
|
|
87b5c870d5 | ||
|
|
bd34b97e9b | ||
|
|
c74e119993 | ||
|
|
96e23dda6b | ||
|
|
c6a0bc2487 | ||
|
|
d1efbce945 | ||
|
|
381b2b8aa1 | ||
|
|
72478fac83 | ||
|
|
c4fd53d628 | ||
|
|
ec4750f422 | ||
|
|
bc0caee371 | ||
|
|
8087bd82bf | ||
|
|
ec3fb620dc | ||
|
|
d6e5df9092 | ||
|
|
160399cee7 | ||
|
|
4b4e4b30a9 | ||
|
|
67ed21052f | ||
|
|
532f8cfce9 | ||
|
|
a45af9ac39 | ||
|
|
3b487511d7 | ||
|
|
a1cbb799be | ||
|
|
8b9545d622 | ||
|
|
cd325dc3fd | ||
|
|
9768774896 | ||
|
|
e1781bf2ae | ||
|
|
b566a7b692 | ||
|
|
e7aa295b47 | ||
|
|
2d44b44372 | ||
|
|
17e19b8cc6 | ||
|
|
e88b897635 | ||
|
|
7a0bd95113 | ||
|
|
be52c01b9f | ||
|
|
c02319cec1 | ||
|
|
f7507d3f79 | ||
|
|
31d2c84541 | ||
|
|
84d4f7765c | ||
|
|
aed6bcc737 | ||
|
|
73e2229fb4 | ||
|
|
a0633ae5e3 | ||
|
|
bdce70e891 | ||
|
|
3197817a76 | ||
|
|
0a7e8a8c3e | ||
|
|
b23bdc628b | ||
|
|
d727aed293 |
No files matched your search
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="common"/>
|
||||
<classpathentry kind="src" path="server"/>
|
||||
<classpathentry kind="src" path="minecraft_server"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -1,23 +0,0 @@
|
||||
* text eol=lf
|
||||
*.bat text eol=crlf
|
||||
*.patch text eol=lf
|
||||
*.java text eol=lf
|
||||
*.gradle text eol=crlf
|
||||
*.png binary
|
||||
*.gif binary
|
||||
*.exe binary
|
||||
*.dll binary
|
||||
*.jar binary
|
||||
*.lzma binary
|
||||
*.zip binary
|
||||
*.pyd binary
|
||||
*.cfg text eol=lf
|
||||
*.py text eol=lf
|
||||
*.jks binary
|
||||
|
||||
# Disable autocrlf on generated files, they always generate with LF
|
||||
src/generated/**/.cache/cache text eol=lf
|
||||
src/generated/**/*.json text eol=lf
|
||||
src/generated_test/**/.cache/cache text eol=lf
|
||||
src/generated_test/**/*.json text eol=lf
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Want to request a feature?
|
||||
title: ''
|
||||
labels: Feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Please note, feature requests that are submitted as GitHub issues here are rarely implemented. -->
|
||||
<!-- If you'd like to see something in Forge, you should be ready to implement it as a PR. -->
|
||||
<!-- If you're not sure, open a Draft PR or discuss it in the Discord server. -->
|
||||
<!-- Discord: https://discord.gg/UvedJ9m -->
|
||||
@@ -1,26 +0,0 @@
|
||||
---
|
||||
name: Issue report
|
||||
about: Visit the forum first for issues with crashes.
|
||||
title: ''
|
||||
labels: Triage
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!-- Thank you for reporting! -->
|
||||
|
||||
<!-- For support with crashes and issues, please create a post on the forum instead: -->
|
||||
<!-- https://www.minecraftforge.net/forum/forum/18-support-bug-reports/ -->
|
||||
|
||||
**Minecraft Version:** {Minecraft version}
|
||||
|
||||
**Forge Version:** {Forge version. *Version number, not latest/rb*}
|
||||
|
||||
**Logs:** {Link(s) to GitHub Gist with full latest.log and/or crash report}
|
||||
|
||||
**Steps to Reproduce:**
|
||||
1. Do this
|
||||
2. Then do that
|
||||
3. ...
|
||||
|
||||
**Description of issue:**
|
||||
@@ -1,43 +0,0 @@
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
|
||||
# Label to use when marking as stale
|
||||
staleLabel: Stale
|
||||
# Comment to post when removing the stale label. Set to `false` to disable
|
||||
unmarkComment: false
|
||||
# Limit the number of actions per hour, from 1-30. Default is 30
|
||||
limitPerRun: 1
|
||||
# Issues with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
- Assigned
|
||||
|
||||
pulls:
|
||||
# Number of days of inactivity before a Pull Request becomes stale
|
||||
daysUntilStale: 60
|
||||
# Number of days of inactivity before a stale Pull Request is closed
|
||||
daysUntilClose: 14
|
||||
# Comment to post when marking as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This pull request has been automatically marked as stale because it has not had recent
|
||||
activity, and will be closed if no further activity occurs. If this pull request was
|
||||
overlooked, forgotten, or should remain open for any other reason, please reply
|
||||
here to call attention to it and remove the stale status. Thank you for your contributions.
|
||||
# Comment to post when closing a stale Pull Request. Set to `false` to disable
|
||||
closeComment: >
|
||||
This pull request has been automatically closed because it has not had
|
||||
recent activity. Please feel free to update or reopen it.
|
||||
issues:
|
||||
# Number of days of inactivity before an Issue becomes stale
|
||||
daysUntilStale: 180
|
||||
# Number of days of inactivity before a stale Issue is closed
|
||||
daysUntilClose: 14
|
||||
# Comment to post when marking as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had activity
|
||||
in a long time. If this issue is still relevant and should remain open, please reply
|
||||
with a short explanation (e.g. "I have checked the code and this issue is still relevant because ___."
|
||||
or "Here's a screenshot of this issue on the latest version").
|
||||
Thank you for your contributions!
|
||||
# Comment to post when closing a stale Issue. Set to `false` to disable
|
||||
closeComment: >
|
||||
This issue has been automatically closed because it has not had
|
||||
activity in a long time. Please feel free to reopen it or create a new issue.
|
||||
@@ -1,16 +0,0 @@
|
||||
# Configuration for support-requests - https://github.com/dessant/support-requests
|
||||
|
||||
# Label used to mark issues as support requests
|
||||
supportLabel: Forum
|
||||
# Comment to post on issues marked as support requests. Add a link
|
||||
# to a support page, or set to `false` to disable
|
||||
supportComment: >
|
||||
👋 We use the issue tracker exclusively for final bug reports and feature requests.
|
||||
However, this issue appears to be better suited for the
|
||||
[Forge Support Forums](http://www.minecraftforge.net/forum/forum/18-support-bug-reports/).
|
||||
Please create a new topic on the support forum with this issue, and the conversation can
|
||||
continue there.
|
||||
# Whether to close issues marked as support requests
|
||||
close: true
|
||||
# Whether to lock issues marked as support requests
|
||||
lock: true
|
||||
+10
-48
@@ -1,48 +1,10 @@
|
||||
#eclipse
|
||||
**/bin
|
||||
**/.settings
|
||||
**/.classpath
|
||||
*.project
|
||||
|
||||
#In case people make their workspace in the repo
|
||||
/eclipse/
|
||||
|
||||
#idea
|
||||
/.idea
|
||||
/classes
|
||||
*.iml
|
||||
|
||||
#gradle
|
||||
/build
|
||||
/.gradle
|
||||
/mdk/.gradle
|
||||
/mdk/build
|
||||
|
||||
#occupational hazards
|
||||
/projects/mcp/
|
||||
/projects/clean/
|
||||
/projects/forge/
|
||||
/projects/**/build/
|
||||
/projects/**/out/
|
||||
/projects/**/run/
|
||||
/projects/**/*.launch
|
||||
/repo/
|
||||
src/generated/resources/.cache/
|
||||
|
||||
#Patch rejects
|
||||
/patches-/
|
||||
*.patch.rej
|
||||
|
||||
# FML changelog
|
||||
changelog.txt
|
||||
*.py
|
||||
*.7z
|
||||
/logs/
|
||||
|
||||
gradle.properties
|
||||
!/mdk/gradle.properties
|
||||
/projects/forge/rejects/
|
||||
|
||||
# Srg2Source causes import bugs on these patches. If you intentionnally change these, remove the ignore.
|
||||
/patches/minecraft/net/minecraft/client/renderer/ViewFrustum.java.patch
|
||||
/patches/minecraft/net/minecraft/data/BlockModelDefinition.java.patch
|
||||
/bin
|
||||
/minecraft_server
|
||||
/mods
|
||||
/fmlbuild.properties
|
||||
/fmlversion.properties
|
||||
/difflist.txt
|
||||
/.metadata/
|
||||
/eclipse/.metadata/
|
||||
/target
|
||||
fmlbranding.properties
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>fml</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>minecraft_server</name>
|
||||
<type>2</type>
|
||||
<location>/home/cpw/projects/mcworkspace/vanilla125/src-work/minecraft_server</location>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.ui.javadoc=true
|
||||
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\n * The FML Forge Mod Loader suite.\n * Copyright (C) 2012 cpw\n * \n * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free\n * Software Foundation; either version 2.1 of the License, or any later version.\n * \n * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.\n * \n * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51\n * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method sLine truncated
|
||||
+2
-6
@@ -1,6 +1,2 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "item_model_generation_test:items/pattern_test"
|
||||
}
|
||||
}
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
Minecraft Forge: Credits/Thank You
|
||||
|
||||
Forge is a set of tools and modifications to the Minecraft base game code to assist
|
||||
mod developers in creating new and exciting content. It has been in development for
|
||||
several years now, but I would like to take this time thank a few people who have
|
||||
helped it along it's way.
|
||||
|
||||
First, the people who originally created the Forge projects way back in Minecraft
|
||||
alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance
|
||||
of me taking over the project, who knows what Minecraft modding would be today.
|
||||
|
||||
Secondly, someone who has worked with me, and developed some of the core features
|
||||
that allow modding to be as functional, and as simple as it is, cpw. For developing
|
||||
FML, which stabelized the client and server modding ecosystem. As well as the base
|
||||
loading system that allows us to modify Minecraft's code as elegently as possible.
|
||||
|
||||
Mezz, who has stepped up as the issue and pull request manager. Helping to keep me
|
||||
sane as well as guiding the community into creating better additions to Forge.
|
||||
|
||||
Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which
|
||||
I am a part}. For creating some of the core tools needed to make Minecraft modding
|
||||
both possible, and as stable as can be.
|
||||
On that note, here is some specific information of the MCP data we use:
|
||||
* Minecraft Coder Pack (MCP) *
|
||||
Forge Mod Loader and Minecraft Forge have permission to distribute and automatically
|
||||
download components of MCP and distribute MCP data files. This permission is not
|
||||
transitive and others wishing to redistribute the Minecraft Forge source independently
|
||||
should seek permission of MCP or remove the MCP data files and request their users
|
||||
to download MCP separately.
|
||||
|
||||
And lastly, the countless community members who have spent time submitting bug reports,
|
||||
pull requests, and just helping out the community in general. Thank you.
|
||||
|
||||
--LexManos
|
||||
|
||||
=========================================================================
|
||||
|
||||
This is Forge Mod Loader.
|
||||
|
||||
You can find the source code at all times at https://github.com/MinecraftForge/MinecraftForge/tree/1.12.x/src/main/java/net/minecraftforge/fml
|
||||
|
||||
This minecraft mod is a clean open source implementation of a mod loader for minecraft servers
|
||||
and minecraft clients.
|
||||
|
||||
The code is authored by cpw.
|
||||
|
||||
It began by partially implementing an API defined by the client side ModLoader, authored by Risugami.
|
||||
http://www.minecraftforum.net/topic/75440-
|
||||
This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader.
|
||||
|
||||
It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge.
|
||||
http://www.minecraftforge.net/
|
||||
|
||||
Additionally, it contains an implementation of topological sort based on that
|
||||
published at http://keithschwarz.com/interesting/code/?dir=topological-sort
|
||||
|
||||
It also contains code from the Maven project for performing versioned dependency
|
||||
resolution. http://maven.apache.org/
|
||||
|
||||
It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/
|
||||
with credit to it's authors.
|
||||
|
||||
Forge Mod Loader downloads components from the Minecraft Coder Pack
|
||||
(http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team.
|
||||
|
||||
Vendored
-103
@@ -1,103 +0,0 @@
|
||||
@Library('forge-shared-library')_
|
||||
|
||||
pipeline {
|
||||
options {
|
||||
disableConcurrentBuilds()
|
||||
}
|
||||
agent {
|
||||
docker {
|
||||
image 'gradle:jdk8'
|
||||
args '-v forgegc:/home/gradle/.gradle/'
|
||||
}
|
||||
}
|
||||
environment {
|
||||
GRADLE_ARGS = '--no-daemon --console=plain' // No daemon for now as FG3 kinda derps. //'-Dorg.gradle.daemon.idletimeout=5000'
|
||||
DISCORD_WEBHOOK = credentials('forge-discord-jenkins-webhook')
|
||||
DISCORD_PREFIX = "Job: Forge Branch: ${BRANCH_NAME} Build: #${BUILD_NUMBER}"
|
||||
JENKINS_HEAD = 'https://wiki.jenkins-ci.org/download/attachments/2916393/headshot.png'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('notify_start') {
|
||||
when {
|
||||
not {
|
||||
changeRequest()
|
||||
}
|
||||
}
|
||||
steps {
|
||||
discordSend(
|
||||
title: "${DISCORD_PREFIX} Started",
|
||||
successful: true,
|
||||
result: 'ABORTED', //White border
|
||||
thumbnail: JENKINS_HEAD,
|
||||
webhookURL: DISCORD_WEBHOOK
|
||||
)
|
||||
}
|
||||
}
|
||||
stage('setup') {
|
||||
steps {
|
||||
sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue setup'
|
||||
script {
|
||||
env.MYVERSION = sh(returnStdout: true, script: './gradlew :forge:properties -q | grep "version:" | awk \'{print $2}\'').trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('changelog') {
|
||||
when {
|
||||
not {
|
||||
changeRequest()
|
||||
}
|
||||
}
|
||||
steps {
|
||||
writeChangelog(currentBuild, 'build/changelog.txt')
|
||||
}
|
||||
}
|
||||
stage('publish') {
|
||||
when {
|
||||
not {
|
||||
changeRequest()
|
||||
}
|
||||
}
|
||||
environment {
|
||||
FORGE_MAVEN = credentials('forge-maven-forge-user')
|
||||
CROWDIN = credentials('forge-crowdin')
|
||||
KEYSTORE = credentials('forge-jenkins-keystore-old')
|
||||
KEYSTORE_KEYPASS = credentials('forge-jenkins-keystore-old-keypass')
|
||||
KEYSTORE_STOREPASS = credentials('forge-jenkins-keystore-old-keypass')
|
||||
}
|
||||
steps {
|
||||
sh './gradlew ${GRADLE_ARGS} :forge:publish -PforgeMavenUser=${FORGE_MAVEN_USR} -PforgeMavenPassword=${FORGE_MAVEN_PSW} -PkeystoreKeyPass=${KEYSTORE_KEYPASS} -PkeystoreStorePass=${KEYSTORE_STOREPASS} -Pkeystore=${KEYSTORE} -PcrowdinKey=${CROWDIN}'
|
||||
sh 'curl --user ${FORGE_MAVEN} http://files.minecraftforge.net/maven/manage/promote/latest/net.minecraftforge.forge/${MYVERSION}'
|
||||
}
|
||||
}
|
||||
stage('test_publish_pr') { //Publish to local repo to test full process, but don't include credentials so it can't sign/publish to maven
|
||||
when {
|
||||
changeRequest()
|
||||
}
|
||||
environment {
|
||||
CROWDIN = credentials('forge-crowdin')
|
||||
}
|
||||
steps {
|
||||
sh './gradlew ${GRADLE_ARGS} :forge:publish -PcrowdinKey=${CROWDIN}'
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
archiveArtifacts artifacts: 'projects/forge/build/libs/**/*.*', fingerprint: true, onlyIfSuccessful: true, allowEmptyArchive: true
|
||||
|
||||
if (env.CHANGE_ID == null) { // This is unset for non-PRs
|
||||
discordSend(
|
||||
title: "${DISCORD_PREFIX} Finished ${currentBuild.currentResult}",
|
||||
description: '```\n' + getChanges(currentBuild) + '\n```',
|
||||
successful: currentBuild.resultIsBetterOrEqualTo("SUCCESS"),
|
||||
result: currentBuild.currentResult,
|
||||
thumbnail: JENKINS_HEAD,
|
||||
webhookURL: DISCORD_WEBHOOK
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +1,9 @@
|
||||
Unless noted below, Minecraft Forge, Forge Mod Loader, and all
|
||||
parts herein are licensed under the terms of the LGPL 2.1 found
|
||||
here http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt and
|
||||
copied below.
|
||||
This minecraft mod, Forge Mod Loader, including all parts herein, is licensed
|
||||
under the GNU LGPL v2.1 or later.
|
||||
|
||||
Homepage: http://minecraftforge.net/
|
||||
https://github.com/MinecraftForge/MinecraftForge
|
||||
|
||||
|
||||
A note on authorship:
|
||||
All source artifacts are property of their original author, with
|
||||
the exclusion of the contents of the patches directory and others
|
||||
copied from it from time to time. Authorship of the contents of
|
||||
the patches directory is retained by the Minecraft Forge project.
|
||||
This is because the patches are partially machine generated
|
||||
artifacts, and are changed heavily due to the way forge works.
|
||||
Individual attribution within them is impossible.
|
||||
|
||||
Consent:
|
||||
All contributions to Forge must consent to the release of any
|
||||
patch content to the Forge project.
|
||||
|
||||
A note on infectivity:
|
||||
The LGPL is chosen specifically so that projects may depend on Forge
|
||||
features without being infected with its license. That is the
|
||||
purpose of the LGPL. Mods and others using this code via ordinary
|
||||
Java mechanics for referencing libraries are specifically not bound
|
||||
by Forge's license for the Mod code.
|
||||
|
||||
|
||||
=== MCP Data ===
|
||||
This software includes data from the Minecraft Coder Pack (MCP), with kind permission
|
||||
from them. The license to MCP data is not transitive - distribution of this data by
|
||||
third parties requires independent licensing from the MCP team. This data is not
|
||||
redistributable without permission from the MCP team.
|
||||
|
||||
=== Sharing ===
|
||||
I grant permission for some parts of FML to be redistributed outside the terms of the LGPL, for the benefit of
|
||||
the minecraft modding community. All contributions to these parts should be licensed under the same additional grant.
|
||||
|
||||
-- Runtime patcher --
|
||||
License is granted to redistribute the runtime patcher code (src/main/java/net/minecraftforge/fml/common/patcher
|
||||
and subdirectories) under any alternative open source license as classified by the OSI (http://opensource.org/licenses)
|
||||
|
||||
-- ASM transformers --
|
||||
License is granted to redistribute the ASM transformer code (src/main/java/net/minecraftforge/common/asm/ and subdirectories)
|
||||
under any alternative open source license as classified by the OSI (http://opensource.org/licenses)
|
||||
|
||||
=========================================================================
|
||||
This software includes portions from the Apache Maven project at
|
||||
http://maven.apache.org/ specifically the ComparableVersion.java code. It is
|
||||
included based on guidelines at
|
||||
http://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
|
||||
with notices intact. The only change is a non-functional change of package name.
|
||||
|
||||
This software contains a partial repackaging of javaxdelta, a BSD licensed program for generating
|
||||
binary differences and applying them, sourced from the subversion at http://sourceforge.net/projects/javaxdelta/
|
||||
authored by genman, heikok, pivot.
|
||||
The only changes are to replace some Trove collection types with standard Java collections, and repackaged.
|
||||
=========================================================================
|
||||
Homepage: https://github.com/cpw/FML
|
||||
|
||||
========
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
@@ -68,10 +13,6 @@ The only changes are to replace some Trove collection types with standard Java c
|
||||
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
|
||||
@@ -117,7 +58,7 @@ 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
|
||||
@@ -173,7 +114,7 @@ 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
|
||||
|
||||
@@ -220,7 +161,7 @@ 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
|
||||
@@ -278,7 +219,7 @@ 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.
|
||||
@@ -329,7 +270,7 @@ Library will still fall under Section 6.)
|
||||
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
|
||||
@@ -391,7 +332,7 @@ 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
|
||||
@@ -432,7 +373,7 @@ 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
|
||||
@@ -484,7 +425,7 @@ 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
|
||||
@@ -1,16 +0,0 @@
|
||||
Minecraft Forge
|
||||
Copyright (c) 2016-2020.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation version 2.1
|
||||
of the License.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
@@ -0,0 +1,66 @@
|
||||
import sys
|
||||
import os, os.path, shutil
|
||||
import commands
|
||||
import fnmatch
|
||||
import re
|
||||
import subprocess, shlex
|
||||
|
||||
def cmdsplit(args):
|
||||
if os.sep == '\\':
|
||||
args = args.replace('\\', '\\\\')
|
||||
return shlex.split(args)
|
||||
|
||||
def main():
|
||||
print("Applying patches")
|
||||
sys.stdout.flush()
|
||||
patches = os.path.abspath(sys.argv[1])
|
||||
work = os.path.normpath(sys.argv[2])
|
||||
mcp = os.path.normpath(sys.argv[3])
|
||||
temp = os.path.abspath('temp.patch')
|
||||
|
||||
cmd = cmdsplit('patch -p2 -i "%s" ' % temp)
|
||||
display = True
|
||||
|
||||
if os.name == 'nt':
|
||||
mcp = os.path.abspath(os.path.join(mcp, 'runtime', 'bin', 'applydiff.exe'))
|
||||
cmd = cmdsplit('"%s" -uf -p2 -i "%s"' % (mcp, temp))
|
||||
display = False
|
||||
|
||||
for path, _, filelist in os.walk(patches, followlinks=True):
|
||||
for cur_file in fnmatch.filter(filelist, '*.patch'):
|
||||
patch_file = os.path.normpath(os.path.join(patches, path[len(patches)+1:], cur_file))
|
||||
if display:
|
||||
print 'patching file %s' % os.path.join(path[len(patches)+1:], cur_file)
|
||||
normaliselines(patch_file, temp)
|
||||
process = subprocess.Popen(cmd, cwd=work, bufsize=-1)
|
||||
process.communicate()
|
||||
|
||||
if os.path.isfile(temp):
|
||||
os.remove(temp)
|
||||
|
||||
#Taken from MCP
|
||||
def normaliselines(in_filename, out_filename=None):
|
||||
in_filename = os.path.normpath(in_filename)
|
||||
if out_filename is None:
|
||||
tmp_filename = in_filename + '.tmp'
|
||||
else:
|
||||
out_filename = os.path.normpath(out_filename)
|
||||
tmp_filename = out_filename
|
||||
dir_name = os.path.dirname(out_filename)
|
||||
if dir_name:
|
||||
if not os.path.exists(dir_name):
|
||||
os.makedirs(dir_name)
|
||||
regex_ending = re.compile(r'\r?\n')
|
||||
with open(in_filename, 'rb') as in_file:
|
||||
with open(tmp_filename, 'wb') as out_file:
|
||||
buf = in_file.read()
|
||||
if os.linesep == '\r\n':
|
||||
buf = regex_ending.sub(r'\r\n', buf)
|
||||
else:
|
||||
buf = buf.replace('\r\n', '\n')
|
||||
out_file.write(buf)
|
||||
if out_filename is None:
|
||||
shutil.move(tmp_filename, in_filename)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
-1066
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,216 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- ======================================================================
|
||||
30 Mar 2012 13:35:40
|
||||
|
||||
FML
|
||||
The Forge Mod Loader
|
||||
|
||||
cpw
|
||||
====================================================================== -->
|
||||
<project name="FML" default="build">
|
||||
<description>The Forge Mod Loader</description>
|
||||
<macrodef name="side">
|
||||
<attribute name="prop" />
|
||||
<attribute name="src" />
|
||||
<attribute name="side" />
|
||||
<sequential>
|
||||
<property name="@{prop}" value="${@{side}.@{src}}" />
|
||||
<condition property="is.client">
|
||||
<equals arg1="@{side}" arg2="client" />
|
||||
</condition>
|
||||
<condition property="is.server">
|
||||
<equals arg1="@{side}" arg2="server" />
|
||||
</condition>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<target name="writeversion" depends="buildenvsetup">
|
||||
<exec executable="${python.exe}" dir="${basedir}" failonerror="true">
|
||||
<arg value="${basedir}/getversion.py" />
|
||||
</exec>
|
||||
<propertyfile file="fmlversion.properties">
|
||||
<entry key="fmlbuild.build.number" type="int" value="${version.build}"/>
|
||||
</propertyfile>
|
||||
</target>
|
||||
|
||||
<target name="buildenvsetup">
|
||||
<tstamp>
|
||||
<format pattern="yyMMddHHmmss" property="timestamp" />
|
||||
</tstamp>
|
||||
<property environment="env" />
|
||||
<property file="fmlbuild.properties" />
|
||||
<property name="modname" value="fml" />
|
||||
<condition property="dev.home" value="${env.WORKSPACE}" else="${default.dev.home}">
|
||||
<isset property="env.WORKSPACE" />
|
||||
</condition>
|
||||
<condition property="mcp.home" value="${env.WORKSPACE}/mcpworkspace" else="${default.mcp.home}">
|
||||
<isset property="env.WORKSPACE" />
|
||||
</condition>
|
||||
<condition property="python.exe" value="${mcp.home}/runtime/bin/python/python_mcp" else="python">
|
||||
<os family="Windows" />
|
||||
</condition>
|
||||
<property name="mcp.obfoutput" location="${mcp.home}/reobf" />
|
||||
<property name="client.mcp.obfoutput" location="${mcp.obfoutput}/minecraft" />
|
||||
<property name="server.mcp.obfoutput" location="${mcp.obfoutput}/minecraft_server" />
|
||||
<property name="mcp.srcdir" location="${mcp.home}/src" />
|
||||
<property name="client.mcp.srcdir" location="${mcp.srcdir}/minecraft" />
|
||||
<property name="server.mcp.srcdir" location="${mcp.srcdir}/minecraft_server" />
|
||||
<property name="common.src.dir" location="${basedir}/common" />
|
||||
<property name="client.src.dir" location="${basedir}/client" />
|
||||
<property name="server.src.dir" location="${basedir}/server" />
|
||||
<property name="patch.src.dir" location="${basedir}/patches" />
|
||||
<condition property="version.build" value="${env.BUILD_NUMBER}" else="1">
|
||||
<isset property="env.BUILD_NUMBER" />
|
||||
</condition>
|
||||
</target>
|
||||
|
||||
<target name="init" depends="buildenvsetup">
|
||||
<antcall target="writeversion" />
|
||||
<property file="fmlversion.properties" />
|
||||
<property name="build.number" value="${fmlbuild.major.number}.${fmlbuild.minor.number}.${fmlbuild.revision.number}" />
|
||||
<property name="version.minecraft" value="${fmlbuild.mcversion}" />
|
||||
<property name="version.major" value="${fmlbuild.major.number}" />
|
||||
<property name="version.minor" value="${fmlbuild.minor.number}" />
|
||||
<property name="version.rev" value="${fmlbuild.revision.number}" />
|
||||
<property name="version" value="${version.major}.${version.minor}.${version.rev}.${version.build}" />
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<exec executable="${python.exe}" dir="${mcp.home}">
|
||||
<arg value="${mcp.home}/runtime/cleanup.py" />
|
||||
<arg value="-f" />
|
||||
</exec>
|
||||
<exec executable="${python.exe}" dir="${mcp.home}">
|
||||
<arg value="${mcp.home}/runtime/decompile.py" />
|
||||
<arg value="-d" />
|
||||
<arg value="-n" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="buildandreobfmcp" depends="init">
|
||||
<exec executable="${python.exe}" dir="${mcp.home}" failonerror="true">
|
||||
<arg value="${mcp.home}/runtime/recompile.py" />
|
||||
</exec>
|
||||
<fail message="Compilation failed">
|
||||
<condition>
|
||||
<not>
|
||||
<and>
|
||||
<available file="${mcp.home}/bin/minecraft/net/minecraft/client/Minecraft.class"/>
|
||||
<available file="${mcp.home}/bin/minecraft_server/net/minecraft/server/MinecraftServer.class"/>
|
||||
</and>
|
||||
</not>
|
||||
</condition>
|
||||
</fail>
|
||||
<exec executable="${python.exe}" dir="${mcp.home}">
|
||||
<arg value="${mcp.home}/runtime/reobfuscate.py" />
|
||||
</exec>
|
||||
<exec executable="${python.exe}" dir="${mcp.home}">
|
||||
<arg value="${basedir}/generatechangedfilelist.py"/>
|
||||
<arg value="${mcp.home}"/>
|
||||
<arg value="${basedir}/difflist.txt"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="merge-client" depends="init,clean">
|
||||
<antcall target="merge-source">
|
||||
<param name="side" value="client" />
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="merge-server" depends="init,clean">
|
||||
<antcall target="merge-source">
|
||||
<param name="side" value="server" />
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="merge-source">
|
||||
<side prop="merge-to" src="mcp.srcdir" side="${side}" />
|
||||
<side prop="side-from" src="src.dir" side="${side}" />
|
||||
|
||||
<copy todir="${merge-to}" overwrite="true" verbose="true">
|
||||
<fileset dir="${side-from}" includes="**/*.java" />
|
||||
<fileset dir="${common.src.dir}" includes="**/*.java" />
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="build-client" depends="init,merge-client,buildandreobfmcp">
|
||||
<antcall target="extract-built-jar">
|
||||
<param name="side" value="client" />
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="build-server" depends="init,clean,merge-server,buildandreobfmcp">
|
||||
<antcall target="extract-built-jar">
|
||||
<param name="side" value="server" />
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="extract-built-jar">
|
||||
<side prop="output" src="mcp.obfoutput" side="${side}" />
|
||||
<property name="jarname" value="${modname}-${side}-${version}" />
|
||||
<mkdir dir="${basedir}/target" />
|
||||
<zip destfile="${basedir}/target/${jarname}.zip">
|
||||
<fileset dir="${output}" includes="**/*.class" />
|
||||
<zipfileset dir="${basedir}" includes="fmlversion.properties"/>
|
||||
<zipfileset dir="${basedir}" includes="LICENSE-fml.txt" />
|
||||
<zipfileset dir="${basedir}" includes="install/CREDITS-fml.txt" fullpath="CREDITS-fml.txt"/>
|
||||
<mappedresources>
|
||||
<concat>
|
||||
<fileset dir="${basedir}/install" includes="README.txt" />
|
||||
<filterchain>
|
||||
<replacetokens>
|
||||
<token key="MAJOR" value="${version.major}" />
|
||||
<token key="MINOR" value="${version.minor}" />
|
||||
<token key="REV" value="${version.rev}" />
|
||||
<token key="BUILD" value="${version.build}" />
|
||||
<token key="MCVERSION" value="${version.minecraft}" />
|
||||
</replacetokens>
|
||||
</filterchain>
|
||||
</concat>
|
||||
<mergemapper to="README-fml.txt" />
|
||||
</mappedresources>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="build-source-pack">
|
||||
<property name="jarname" value="${modname}-src-${version}" />
|
||||
<zip destfile="${basedir}/target/${jarname}.zip">
|
||||
<zipfileset dir="${basedir}" includes="LICENSE-fml.txt,difflist.txt" prefix="fml" />
|
||||
<zipfileset dir="${common.src.dir}" includes="**/*.java" prefix="fml/src/minecraft_server" />
|
||||
<zipfileset dir="${common.src.dir}" includes="**/*.java" prefix="fml/src/minecraft" />
|
||||
<zipfileset dir="${client.src.dir}" includes="**/*.java" prefix="fml/src/minecraft" />
|
||||
<zipfileset dir="${server.src.dir}" includes="**/*.java" prefix="fml/src/minecraft_server" />
|
||||
<zipfileset dir="${basedir}" includes="fmlversion.properties" prefix="fml/src/minecraft" />
|
||||
<zipfileset dir="${basedir}" includes="fmlversion.properties" prefix="fml/src/minecraft_server" />
|
||||
<zipfileset dir="${patch.src.dir}" includes="**/*.patch" prefix="fml/patches" />
|
||||
<mappedresources>
|
||||
<concat>
|
||||
<fileset dir="${basedir}/install" includes="README.txt" />
|
||||
<filterchain>
|
||||
<replacetokens>
|
||||
<token key="MAJOR" value="${version.major}" />
|
||||
<token key="MINOR" value="${version.minor}" />
|
||||
<token key="REV" value="${version.rev}" />
|
||||
<token key="BUILD" value="${version.build}" />
|
||||
<token key="MCVERSION" value="${version.minecraft}" />
|
||||
</replacetokens>
|
||||
</filterchain>
|
||||
</concat>
|
||||
<mergemapper to="fml/README-fml.txt" />
|
||||
</mappedresources>
|
||||
<zipfileset dir="${basedir}/install" excludes="README.txt" prefix="fml" />
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="build" depends="init,clean,merge-server,merge-client,patch,build-server,build-client,build-source-pack" />
|
||||
|
||||
<target name="patch" depends="init">
|
||||
<exec executable="${python.exe}" dir="${basedir}">
|
||||
<arg value="${basedir}/applypatches.py" />
|
||||
<arg value="${patch.src.dir}" />
|
||||
<arg value="${mcp.srcdir}" />
|
||||
<arg value="${mcp.home}" />
|
||||
</exec>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@@ -1,2 +0,0 @@
|
||||
/.gradle/
|
||||
/build/
|
||||
@@ -1,10 +0,0 @@
|
||||
repositories {
|
||||
//mavenCentral() //TODO: Update Gradle to use HTTPS by default
|
||||
maven {
|
||||
name 'maven_central'
|
||||
url 'https://repo.maven.apache.org/maven2/'
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation 'org.ow2.asm:asm:7.2'
|
||||
}
|
||||
@@ -1,231 +0,0 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.TreeMap
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.objectweb.asm.Opcodes
|
||||
|
||||
public class CheckATs extends DefaultTask {
|
||||
@InputFile File inheritance
|
||||
@InputFiles File[] ats
|
||||
|
||||
@TaskAction
|
||||
protected void exec() {
|
||||
Util.init()
|
||||
def parse = { line ->
|
||||
def idx = line.indexOf('#')
|
||||
def comment = idx == -1 ? null : line.substring(idx)
|
||||
if (idx != -1) line = line.substring(0, idx - 1)
|
||||
def (modifier, cls, desc) = (line.trim() + ' ').split(' ', -1)
|
||||
def key = cls + (desc.isEmpty() ? '' : ' ' + desc)
|
||||
return [modifier, cls, desc, comment, key]
|
||||
}
|
||||
def accessLevel = { access ->
|
||||
if ((access & Opcodes.ACC_PUBLIC) != 0) return 3
|
||||
if ((access & Opcodes.ACC_PROTECTED) != 0) return 2
|
||||
if ((access & Opcodes.ACC_PRIVATE) != 0) return 0
|
||||
return 1
|
||||
}
|
||||
def accessStr = { access ->
|
||||
if (access.endsWith('-f') || access.endsWith('+f'))
|
||||
return 4
|
||||
switch (access.toLowerCase()) {
|
||||
case 'public': return 3
|
||||
case 'protected': return 2
|
||||
case 'default': return 1
|
||||
case 'private': return 0
|
||||
default: return -1
|
||||
}
|
||||
}
|
||||
def json = inheritance.json()
|
||||
|
||||
ats.each { f ->
|
||||
TreeMap lines = [:]
|
||||
def group = null
|
||||
for (def line : f.readLines()) {
|
||||
if (line.isEmpty()) continue
|
||||
if (line.startsWith('#group ')) {
|
||||
def (modifier, cls, desc, comment, key) = parse.call(line.substring(7))
|
||||
|
||||
if (!desc.equals('*') && !desc.equals('*()') && !desc.equals('<init>'))
|
||||
throw new IllegalStateException('Invalid group: ' + line)
|
||||
|
||||
group = [modifier: modifier, cls: cls, desc: desc, comment: comment,
|
||||
'existing': [] as Set,
|
||||
'children': [] as TreeSet,
|
||||
group: true
|
||||
]
|
||||
if (lines.containsKey(key))
|
||||
throw new IllegalStateException('Duplicate group: ' + line)
|
||||
|
||||
lines[key] = group
|
||||
} else if (group != null) {
|
||||
if (line.startsWith('#endgroup')) {
|
||||
group = null
|
||||
} else {
|
||||
def (modifier, cls, desc, comment, key) = parse.call(line)
|
||||
group['existing'].add(key)
|
||||
}
|
||||
} else if (line.startsWith('#endgroup')) {
|
||||
throw new IllegalStateException('Invalid group ending: ' + line)
|
||||
} else if (line.startsWith('#')) {
|
||||
//Nom
|
||||
} else {
|
||||
def (modifier, cls, desc, comment, key) = parse.call(line)
|
||||
if (lines.containsKey(key)) {
|
||||
println('Duplicate: ' + line)
|
||||
continue
|
||||
}
|
||||
lines[key] = [modifier: modifier, cls: cls, desc: desc, comment: comment, group: false]
|
||||
}
|
||||
}
|
||||
|
||||
// Process Groups, this will remove any entries outside the group that is covered by the group
|
||||
for (def key : new ArrayList<>(lines.keySet())) {
|
||||
def entry = lines.get(key)
|
||||
if (entry != null && entry['group']) {
|
||||
def cls = entry['cls']
|
||||
def jcls = json.get(cls.replaceAll('\\.', '/'))
|
||||
if (jcls == null) {
|
||||
lines.remove(key)
|
||||
println('Invalid Group: ' + key)
|
||||
} else if ('*'.equals(entry['desc'])) {
|
||||
if (!jcls.containsKey('fields')) {
|
||||
lines.remove(key)
|
||||
println('Invalid Group, Class has no fields: ' + key)
|
||||
} else {
|
||||
jcls['fields'].each { field, value ->
|
||||
def fkey = cls + ' ' + field
|
||||
if (accessLevel.call(value['access']) < accessStr.call(entry['modifier'])) {
|
||||
if (lines.containsKey(fkey)) {
|
||||
lines.remove(fkey)
|
||||
} else if (!entry['existing'].contains(fkey)) {
|
||||
println('Added: ' + fkey)
|
||||
}
|
||||
entry['children'].add(fkey)
|
||||
} else if (lines.containsKey(fkey)) {
|
||||
lines.remove(fkey)
|
||||
println('Removed: ' + fkey)
|
||||
}
|
||||
}
|
||||
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
||||
}
|
||||
} else if ('*()'.equals(entry['desc'])) {
|
||||
if (!jcls.containsKey('methods')) {
|
||||
lines.remove(key)
|
||||
println('Invalid Group, Class has no methods: ' + key)
|
||||
} else {
|
||||
jcls['methods'].each{ mtd, value ->
|
||||
if (mtd.startsWith('<clinit>'))
|
||||
return
|
||||
key = cls + ' ' + mtd.replace(' ', '')
|
||||
if (accessLevel.call(value['access']) < accessStr.call(entry['modifier'])) {
|
||||
if (lines.containsKey(key)) {
|
||||
lines.remove(key)
|
||||
} else if (!entry['existing'].contains(key)) {
|
||||
println('Added: ' + key)
|
||||
}
|
||||
entry['children'].add(key)
|
||||
} else if (lines.containsKey(key)) {
|
||||
lines.remove(key)
|
||||
println('Removed: ' + key)
|
||||
}
|
||||
}
|
||||
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
||||
}
|
||||
} else if ('<init>'.equals(entry['desc'])) { //Make all public non-abstract subclasses
|
||||
json.each{ tcls,value ->
|
||||
if (!value.containsKey('methods') || ((value['access'] & Opcodes.ACC_ABSTRACT) != 0))
|
||||
return
|
||||
def parents = [] as Set
|
||||
def parent = tcls
|
||||
while (parent != null && json.containsKey(parent)) {
|
||||
parents.add(parent)
|
||||
def p = json[parent]
|
||||
parent = p == null ? null : p['superName']
|
||||
}
|
||||
if (parents.contains(cls.replaceAll('\\.', '/'))) {
|
||||
value['methods'].each{ mtd, v ->
|
||||
if (mtd.startsWith('<init>')) {
|
||||
def child = tcls.replaceAll('/', '\\.') + ' ' + mtd.replace(' ', '')
|
||||
if (accessLevel.call(v['access']) < 3) {
|
||||
if (lines.containsKey(child)) {
|
||||
lines.remove(child)
|
||||
} else if (!entry['existing'].contains(child)) {
|
||||
println('Added: ' + child)
|
||||
}
|
||||
entry['children'].add(child)
|
||||
} else if (lines.containsKey(child)) {
|
||||
lines.remove(child)
|
||||
println('Removed: ' + child)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
entry['existing'].stream().findAll{ !entry['children'].contains(it) }.each{ println('Removed: ' + it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process normal lines, remove invalid and remove narrowing
|
||||
for (def key : new ArrayList<>(lines.keySet())) {
|
||||
def entry = lines.get(key)
|
||||
if (entry != null && !entry['group']) {
|
||||
def cls = entry['cls']
|
||||
def jcls = json.get(cls.replaceAll('\\.', '/'))
|
||||
if (jcls == null) {
|
||||
lines.remove(key)
|
||||
println('Invalid: ' + key)
|
||||
} else if (entry['desc'] == '') {
|
||||
if (accessLevel.call(jcls['access']) >= accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
||||
lines.remove(key)
|
||||
println('Invalid Narrowing: ' + key)
|
||||
}
|
||||
} else if (!entry['desc'].contains('(')) {
|
||||
if (!jcls.containsKey('fields') || !jcls['fields'].containsKey(entry['desc'])) {
|
||||
lines.remove(key)
|
||||
println('Invalid: ' + key)
|
||||
} else {
|
||||
def value = jcls['fields'][entry['desc']]
|
||||
if (accessLevel.call(value['access']) >= accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
||||
lines.remove(key)
|
||||
println('Invalid Narrowing: ' + key)
|
||||
println(entry.comment)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
def jdesc = entry['desc'].replace('(', ' (')
|
||||
if (!jcls.containsKey('methods') || !jcls['methods'].containsKey(jdesc)) {
|
||||
lines.remove(key)
|
||||
println('Invalid: ' + key)
|
||||
} else {
|
||||
def value = jcls['methods'][jdesc]
|
||||
if (accessLevel.call(value['access']) >= accessStr.call(entry['modifier']) && (entry.comment == null || !entry.comment.startsWith('#force '))) {
|
||||
lines.remove(key)
|
||||
println('Invalid Narrowing: ' + key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def data = []
|
||||
lines.each { key,value ->
|
||||
if (!value.group) {
|
||||
data.add(value.modifier + ' ' + key + (value.comment == null ? '' : ' ' + value.comment))
|
||||
} else {
|
||||
data.add('#group ' + value.modifier + ' ' + key + (value.comment == null ? '' : ' ' + value.comment))
|
||||
value.children.each{ data.add(value.modifier + ' ' + it) }
|
||||
data.add('#endgroup')
|
||||
}
|
||||
}
|
||||
f.text = data.join('\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.TreeMap
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
import org.objectweb.asm.ClassReader
|
||||
import org.objectweb.asm.ClassVisitor
|
||||
import org.objectweb.asm.MethodVisitor
|
||||
import org.objectweb.asm.Opcodes
|
||||
import org.objectweb.asm.Type
|
||||
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
public class CheckExcs extends DefaultTask {
|
||||
@InputFile File binary
|
||||
@InputFiles File[] excs
|
||||
|
||||
@TaskAction
|
||||
protected void exec() {
|
||||
Util.init()
|
||||
def known = []
|
||||
binary.withInputStream { i ->
|
||||
new ZipInputStream(i).withCloseable { zin ->
|
||||
def visitor = new ClassVisitor(Opcodes.ASM7) {
|
||||
private String cls
|
||||
@Override
|
||||
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||
this.cls = name
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
|
||||
known.add(this.cls + '.' + name + descriptor)
|
||||
super.visitMethod(access, name, descriptor, signature, exceptions)
|
||||
}
|
||||
}
|
||||
ZipEntry zein
|
||||
while ((zein = zin.nextEntry) != null) {
|
||||
if (zein.name.endsWith('.class')) {
|
||||
ClassReader reader = new ClassReader(zin)
|
||||
reader.accept(visitor, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
excs.each { f ->
|
||||
def lines = []
|
||||
f.eachLine { line ->
|
||||
def idx = line.indexOf('#')
|
||||
if (idx == 0 || line.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
def comment = idx == -1 ? null : line.substring(idx)
|
||||
if (idx != -1) line = line.substring(0, idx - 1)
|
||||
|
||||
if (!line.contains('=')) {
|
||||
println('Invalid: ' + line)
|
||||
return
|
||||
}
|
||||
|
||||
def (key, value) = line.split('=', 2)
|
||||
if (!known.contains(key)) {
|
||||
println(key)
|
||||
println('Invalid: ' + line)
|
||||
return
|
||||
}
|
||||
|
||||
def (cls, desc) = key.split('\\.', 2)
|
||||
if (!desc.contains('(')) {
|
||||
println('Invalid: ' + line)
|
||||
return
|
||||
}
|
||||
def name = desc.split('\\(', 2)[0]
|
||||
desc = '(' + desc.split('\\(', 2)[1]
|
||||
|
||||
def (exceptions, args) = value.contains('|') ? value.split('|', 2) : [value, '']
|
||||
|
||||
if (args.split(',').length != Type.getArgumentTypes(desc).length) {
|
||||
println('Invalid: ' + line)
|
||||
return
|
||||
}
|
||||
lines.add(line)
|
||||
}
|
||||
f.text = lines.sort().join('\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.util.regex.Pattern
|
||||
|
||||
public class CheckPatches extends DefaultTask {
|
||||
@InputDirectory File patchDir
|
||||
@Input boolean autoFix = false
|
||||
|
||||
@TaskAction
|
||||
protected void exec() {
|
||||
def hasS2SArtifact = [
|
||||
Paths.get("patches/minecraft/net/minecraft/client/renderer/ViewFrustum.java.patch"),
|
||||
Paths.get("patches/minecraft/net/minecraft/data/BlockModelDefinition.java.patch")
|
||||
]
|
||||
|
||||
def verified = true;
|
||||
project.fileTree(patchDir).each { patch ->
|
||||
def patchPath = project.rootDir.toPath().relativize(patch.toPath())
|
||||
verified &= verifyPatch(patch, autoFix, patchPath.toString(), hasS2SArtifact.contains(patchPath))
|
||||
}
|
||||
|
||||
if (!verified)
|
||||
throw new RuntimeException('One or more patches failed verification. Check the log for errors.')
|
||||
}
|
||||
|
||||
def verifyPatch(patch, fix, patchPath, hasS2SArtifact) {
|
||||
def hunk_start_pattern = Pattern.compile('^@@ -[0-9,]* \\+[0-9,]* @@$')
|
||||
def white_space_pattern = Pattern.compile('^[+\\-]\\s*$')
|
||||
def import_pattern = Pattern.compile('^[+\\-]\\s*import.*')
|
||||
def field_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^=;]*)(=.*)?;\\s*$')
|
||||
def method_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final)?([^(]*)[(]([^)]*)?[)]\\s*[{]\\s*$')
|
||||
def class_pattern = Pattern.compile('^[+\\-][\\s]*((public|protected|private)[\\s]*)?(static[\\s]*)?(final[\\s]*)?(class|interface)([^{]*)[{]\\s*$')
|
||||
|
||||
def accessMap = [("private"):0, (null):1, ("protected"):2, ("public"):3]
|
||||
|
||||
def hasProblem = false;
|
||||
def lines = patch.readLines()
|
||||
|
||||
def hunksStart = 0
|
||||
def onlyWhiteSpace = false
|
||||
|
||||
def didFix = false
|
||||
def newLines = []
|
||||
def whiteSpaceErrors = []
|
||||
|
||||
// First two lines are file name ++/-- and we do not care
|
||||
newLines.add(lines[0] + '\n')
|
||||
newLines.add(lines[1] + '\n')
|
||||
|
||||
int i = 2
|
||||
for (; i < lines.size(); ++i) {
|
||||
def line = lines[i]
|
||||
newLines.add(line + '\n')
|
||||
|
||||
if (hunk_start_pattern.matcher(line).find()) {
|
||||
if (onlyWhiteSpace) {
|
||||
if (fix || hasS2SArtifact) {
|
||||
logger.lifecycle("Removing white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
||||
def toRemove = i - hunksStart;
|
||||
while (toRemove-- > 0)
|
||||
newLines.remove(newLines.size() - 1)
|
||||
didFix = true
|
||||
}
|
||||
else {
|
||||
logger.lifecycle("Patch contains only white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
||||
hasProblem = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!whiteSpaceErrors.empty)
|
||||
hasProblem = true
|
||||
whiteSpaceErrors.each { error -> logger.lifecycle(error) }
|
||||
whiteSpaceErrors.clear()
|
||||
}
|
||||
hunksStart = i
|
||||
onlyWhiteSpace = true
|
||||
continue
|
||||
}
|
||||
|
||||
if (line.startsWithAny('+','-')) {
|
||||
def prefixChange = false
|
||||
def prevLine = lines[i - 1]
|
||||
|
||||
if (line.charAt(0) == (char)'+' && prevLine.charAt(0) == (char)'-') {
|
||||
def prevTrim = prevLine.substring(1).replaceAll("\\s", "")
|
||||
def currTrim = line.substring(1).replaceAll("\\s", "")
|
||||
|
||||
if (prevTrim.equals(currTrim)) {
|
||||
prefixChange = true
|
||||
}
|
||||
|
||||
def pMatcher = field_pattern.matcher(prevLine)
|
||||
def cMatcher = field_pattern.matcher(line)
|
||||
|
||||
if (pMatcher.find() && cMatcher.find() &&
|
||||
pMatcher.group(6) == cMatcher.group(6) && // = ...
|
||||
pMatcher.group(5) == cMatcher.group(5) && // field name
|
||||
pMatcher.group(3) == cMatcher.group(3) && // static
|
||||
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
||||
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
||||
hasProblem = true
|
||||
}
|
||||
|
||||
pMatcher = method_pattern.matcher(prevLine)
|
||||
cMatcher = method_pattern.matcher(line)
|
||||
|
||||
if (pMatcher.find() && cMatcher.find() &&
|
||||
pMatcher.group(6) == cMatcher.group(6) && // params
|
||||
pMatcher.group(5) == cMatcher.group(5) && // <T> void name
|
||||
pMatcher.group(3) == cMatcher.group(3) && // static
|
||||
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
||||
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
||||
hasProblem = true
|
||||
}
|
||||
|
||||
pMatcher = class_pattern.matcher(prevLine)
|
||||
cMatcher = class_pattern.matcher(line)
|
||||
|
||||
if (pMatcher.find() && cMatcher.find() &&
|
||||
pMatcher.group(6) == cMatcher.group(6) && // ClassName<> extends ...
|
||||
pMatcher.group(5) == cMatcher.group(5) && // class | interface
|
||||
pMatcher.group(3) == cMatcher.group(3) && // static
|
||||
(accessMap[pMatcher.group(2)] < accessMap[cMatcher.group(2)] || pMatcher.group(4) != cMatcher.group(4))) {
|
||||
logger.lifecycle("Patch contains access changes or final removal at line {}, file: {}", i + 1, patchPath)
|
||||
hasProblem = true
|
||||
}
|
||||
}
|
||||
|
||||
if (line.charAt(0) == (char)'-' && i + 1 < lines.size()) {
|
||||
def nextLine = lines[i + 1]
|
||||
if (nextLine.charAt(0) == (char)'+') {
|
||||
def nextTrim = nextLine.substring(1).replaceAll("\\s", "")
|
||||
def currTrim = line.substring(1).replaceAll("\\s", "")
|
||||
|
||||
if (nextTrim.equals(currTrim)) {
|
||||
prefixChange = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def isWhiteSpaceChange = white_space_pattern.matcher(line).find()
|
||||
|
||||
if (!prefixChange && !isWhiteSpaceChange) {
|
||||
onlyWhiteSpace = hasS2SArtifact && import_pattern.matcher(line).find()
|
||||
}
|
||||
else if (isWhiteSpaceChange) {
|
||||
def prevLineChange = prevLine.startsWithAny('+','-')
|
||||
def nextLineChange = i + 1 < lines.size() && lines[i + 1].startsWithAny('+','-')
|
||||
|
||||
if (!prevLineChange && !nextLineChange) {
|
||||
whiteSpaceErrors.add(String.format("Patch contains white space change in valid hunk at line %d (cannot auto fix), file: %s", i + 1, patchPath))
|
||||
}
|
||||
}
|
||||
|
||||
if (line.contains("\t")) {
|
||||
if (!fix) {
|
||||
logger.lifecycle("Patch contains tabs on line {}, file: {}", i + 1, patchPath)
|
||||
hasProblem = true
|
||||
}
|
||||
else {
|
||||
logger.lifecycle("Fixing tabs on line {}, file: {}", i + 1, patchPath)
|
||||
line = line.replaceAll('\t', ' ')
|
||||
newLines.remove(newLines.size() - 1)
|
||||
newLines.add(line + '\n')
|
||||
didFix = true
|
||||
}
|
||||
}
|
||||
|
||||
if (import_pattern.matcher(line).find() && !hasS2SArtifact) {
|
||||
logger.lifecycle("Patch contains import change on line {}, file: {}", i + 1, patchPath)
|
||||
hasProblem = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (onlyWhiteSpace) {
|
||||
if (fix || hasS2SArtifact) {
|
||||
logger.lifecycle("Removing white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
||||
def toRemove = i - hunksStart;
|
||||
while (toRemove-- > 0)
|
||||
newLines.remove(newLines.size() - 1)
|
||||
didFix = true
|
||||
}
|
||||
else {
|
||||
logger.lifecycle("Patch contains only white space hunk starting at line {}, file: {}", hunksStart + 1, patchPath)
|
||||
hasProblem = true
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!whiteSpaceErrors.empty)
|
||||
hasProblem = true
|
||||
whiteSpaceErrors.each { error -> logger.lifecycle(error) }
|
||||
}
|
||||
|
||||
if (didFix) {
|
||||
if (newLines.size() <= 2) {
|
||||
logger.lifecycle("Patch is now empty removing, file: {}", patchPath)
|
||||
Files.delete(patch.toPath())
|
||||
}
|
||||
else {
|
||||
if (!hasS2SArtifact)
|
||||
logger.lifecycle("*** Updating patch file. Please run setup then genPatches again. ***")
|
||||
patch.withWriter('UTF-8') { writer ->
|
||||
newLines.each { l -> writer.write(l) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !hasProblem
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.TreeMap
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.InputFiles
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.objectweb.asm.Opcodes
|
||||
|
||||
public class CheckSAS extends DefaultTask {
|
||||
@InputFile File inheritance
|
||||
@InputFiles File[] sass
|
||||
|
||||
@TaskAction
|
||||
protected void exec() {
|
||||
Util.init()
|
||||
def json = inheritance.json()
|
||||
|
||||
sass.each { f ->
|
||||
def lines = []
|
||||
f.eachLine { line ->
|
||||
if (line[0] == '\t') return //Skip any tabed lines, those are ones we add
|
||||
def idx = line.indexOf('#')
|
||||
if (idx == 0 || line.isEmpty()) {
|
||||
lines.add(line)
|
||||
return
|
||||
}
|
||||
|
||||
def comment = idx == -1 ? null : line.substring(idx)
|
||||
if (idx != -1) line = line.substring(0, idx - 1)
|
||||
|
||||
def (cls, desc) = (line.trim() + ' ').split(' ', -1)
|
||||
cls = cls.replaceAll('\\.', '/')
|
||||
desc = desc.replace('(', ' (')
|
||||
if (desc.isEmpty() || json[cls] == null || json[cls]['methods'] == null || json[cls]['methods'][desc] == null) {
|
||||
println('Invalid: ' + line)
|
||||
return
|
||||
}
|
||||
|
||||
def mtd = json[cls]['methods'][desc]
|
||||
lines.add(cls + ' ' + desc.replace(' ', '') + (comment == null ? '' : ' ' + comment))
|
||||
def children = json.values().findAll{ it.methods != null && it.methods[desc] != null && it.methods[desc].override == cls}
|
||||
.collect { it.name + ' ' + desc.replace(' ', '') } as TreeSet
|
||||
children.each { lines.add('\t' + it) }
|
||||
}
|
||||
f.text = lines.join('\n')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.Optional
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipInputStream
|
||||
import java.util.zip.ZipOutputStream
|
||||
import java.net.URL
|
||||
|
||||
public class CrowdinTask extends DefaultTask {
|
||||
@Input String id = 'minecraft-forge'
|
||||
@Input @Optional String key
|
||||
@Input boolean json = true
|
||||
@OutputFile output = project.file("build/${name}/output.zip")
|
||||
@OutputFile export = project.file("build/${name}/export.json")
|
||||
|
||||
CrowdinTask() {
|
||||
outputs.upToDateWhen{ false }
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
def run() {
|
||||
if (output.exists())
|
||||
output.delete()
|
||||
|
||||
if (key == null)
|
||||
return
|
||||
|
||||
// Force an export
|
||||
new URL("https://api.crowdin.com/api/project/${id}/export?key=${key}").withInputStream { i ->
|
||||
export.withOutputStream { it << i }
|
||||
}
|
||||
|
||||
if (!export.text.contains('success')) {
|
||||
throw new RuntimeException("Crowdin export failed, see ${export} for more info")
|
||||
}
|
||||
|
||||
new URL("https://api.crowdin.com/api/project/${id}/download/all.zip?key=${key}").withInputStream { i ->
|
||||
new ZipInputStream(i).withCloseable { zin ->
|
||||
output.withOutputStream { out ->
|
||||
new ZipOutputStream(out).withCloseable { zout ->
|
||||
ZipEntry zein
|
||||
while ((zein = zin.nextEntry) != null) {
|
||||
if (zein.isDirectory()) {
|
||||
zout.putNextEntry(new ZipEntry(zein.name))
|
||||
} else {
|
||||
// 1.13+ uses json
|
||||
if (zein.name.endsWith('.json') == json) {
|
||||
ZipEntry zeout = new ZipEntry(json ? zein.name.toLowerCase() : zein.name)
|
||||
zeout.time = 1
|
||||
zout.putNextEntry(zeout)
|
||||
zout << zin
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
|
||||
import java.io.File
|
||||
import java.util.HashSet
|
||||
import java.util.Set
|
||||
import java.net.URL
|
||||
|
||||
public class DownloadLibrariesTask extends DefaultTask {
|
||||
@InputFile File input
|
||||
@OutputDirectory File output = project.file("build/${name}/")
|
||||
Set<File> libraries = new HashSet<>()
|
||||
|
||||
@TaskAction
|
||||
def run() {
|
||||
Util.init()
|
||||
|
||||
def json = input.json().libraries.each { lib ->
|
||||
//TODO: Thread?
|
||||
def artifacts = [lib.downloads.artifact] + lib.downloads.get('classifiers', [:]).values()
|
||||
artifacts.each{ art ->
|
||||
def target = new File(output, art.path)
|
||||
libraries.add(target)
|
||||
if (!target.exists() || !art.sha1.equals(target.sha1())) {
|
||||
project.logger.lifecycle("Downloading ${art.url}")
|
||||
if (!target.parentFile.exists()) {
|
||||
target.parentFile.mkdirs()
|
||||
}
|
||||
new URL(art.url).withInputStream { i ->
|
||||
target.withOutputStream { it << i }
|
||||
}
|
||||
if (!art.sha1.equals(target.sha1())) {
|
||||
throw new IllegalStateException("Failed to download ${art.url} to ${target.canonicalPath} SHA Mismatch")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
package net.minecraftforge.forge.tasks
|
||||
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
import java.io.File
|
||||
import java.security.MessageDigest
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
public class Util {
|
||||
static void init() {
|
||||
File.metaClass.sha1 = { ->
|
||||
MessageDigest md = MessageDigest.getInstance('SHA-1')
|
||||
delegate.eachByte 4096, {bytes, size ->
|
||||
md.update(bytes, 0, size)
|
||||
}
|
||||
return md.digest().collect {String.format "%02x", it}.join()
|
||||
}
|
||||
|
||||
File.metaClass.json = { -> new JsonSlurper().parseText(delegate.text) }
|
||||
|
||||
Date.metaClass.iso8601 = { ->
|
||||
def format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
def result = format.format(delegate)
|
||||
return result[0..21] + ':' + result[22..-1]
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] getClasspath(project, libs, artifact) {
|
||||
def ret = []
|
||||
artifactTree(project, artifact).each { key, lib ->
|
||||
libs[lib.name] = lib
|
||||
if (lib.name != artifact)
|
||||
ret.add(lib.name)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
public static def getArtifacts(project, config, classifiers) {
|
||||
def ret = [:]
|
||||
config.resolvedConfiguration.resolvedArtifacts.each {
|
||||
def art = [
|
||||
group: it.moduleVersion.id.group,
|
||||
name: it.moduleVersion.id.name,
|
||||
version: it.moduleVersion.id.version,
|
||||
classifier: it.classifier,
|
||||
extension: it.extension,
|
||||
file: it.file
|
||||
]
|
||||
def key = art.group + ':' + art.name
|
||||
def folder = "${art.group.replace('.', '/')}/${art.name}/${art.version}/"
|
||||
def filename = "${art.name}-${art.version}"
|
||||
if (art.classifier != null)
|
||||
filename += "-${art.classifier}"
|
||||
filename += ".${art.extension}"
|
||||
def path = "${folder}${filename}"
|
||||
def url = "https://libraries.minecraft.net/${path}"
|
||||
if (!checkExists(url)) {
|
||||
url = "https://files.minecraftforge.net/maven/${path}"
|
||||
}
|
||||
//TODO remove when Mojang launcher is updated
|
||||
if (!classifiers && art.classifier != null) { //Mojang launcher doesn't currently support classifiers, so... move it to part of the version, and force the extension to 'jar'
|
||||
art.version = "${art.version}-${art.classifier}"
|
||||
art.classifier = null
|
||||
art.extension = 'jar'
|
||||
path = "${art.group.replace('.', '/')}/${art.name}/${art.version}/${art.name}-${art.version}.jar"
|
||||
}
|
||||
ret[key] = [
|
||||
name: "${art.group}:${art.name}:${art.version}" + (art.classifier == null ? '' : ":${art.classifier}") + (art.extension == 'jar' ? '' : "@${art.extension}"),
|
||||
downloads: [
|
||||
artifact: [
|
||||
path: path,
|
||||
url: url,
|
||||
sha1: sha1(art.file),
|
||||
size: art.file.length()
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
public static def iso8601Now() { new Date().iso8601() }
|
||||
|
||||
public static def sha1(file) {
|
||||
MessageDigest md = MessageDigest.getInstance('SHA-1')
|
||||
file.eachByte 4096, {bytes, size ->
|
||||
md.update(bytes, 0, size)
|
||||
}
|
||||
return md.digest().collect {String.format "%02x", it}.join()
|
||||
}
|
||||
|
||||
private static def artifactTree(project, artifact) {
|
||||
if (!project.ext.has('tree_resolver'))
|
||||
project.ext.tree_resolver = 1
|
||||
def cfg = project.configurations.create('tree_resolver_' + project.ext.tree_resolver++)
|
||||
def dep = project.dependencies.create(artifact)
|
||||
cfg.dependencies.add(dep)
|
||||
def files = cfg.resolve()
|
||||
return getArtifacts(project, cfg, true)
|
||||
}
|
||||
|
||||
private static boolean checkExists(url) {
|
||||
try {
|
||||
def code = new URL(url).openConnection().with {
|
||||
requestMethod = 'HEAD'
|
||||
connect()
|
||||
responseCode
|
||||
}
|
||||
return code == 200
|
||||
} catch (Exception e) {
|
||||
if (e.toString().contains('unable to find valid certification path to requested target'))
|
||||
throw new RuntimeException('Failed to connect to ' + url + ': Missing certificate root authority, try updating java')
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,637 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.server;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.LocaleLanguage;
|
||||
import net.minecraft.server.MLProp;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.BaseMod;
|
||||
import net.minecraft.server.BiomeBase;
|
||||
import net.minecraft.server.EntityItem;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.IChunkProvider;
|
||||
import net.minecraft.server.ICommandListener;
|
||||
import net.minecraft.server.IInventory;
|
||||
import net.minecraft.server.ItemStack;
|
||||
import net.minecraft.server.NetworkManager;
|
||||
import net.minecraft.server.Packet1Login;
|
||||
import net.minecraft.server.Packet250CustomPayload;
|
||||
import net.minecraft.server.Packet3Chat;
|
||||
import net.minecraft.server.BukkitRegistry;
|
||||
import net.minecraft.server.SidedProxy;
|
||||
import net.minecraft.server.World;
|
||||
import net.minecraft.server.WorldType;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.IFMLSidedHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
import cpw.mods.fml.common.ProxyInjector;
|
||||
import cpw.mods.fml.common.Side;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
import cpw.mods.fml.common.modloader.ModProperty;
|
||||
import cpw.mods.fml.common.registry.FMLRegistry;
|
||||
|
||||
/**
|
||||
* Handles primary communication from hooked code into the system
|
||||
*
|
||||
* The FML entry point is {@link #onPreLoad(MinecraftServer)} called from {@link MinecraftServer}
|
||||
*
|
||||
* Obfuscated code should focus on this class and other members of the "server" (or "client") code
|
||||
*
|
||||
* The actual mod loading is handled at arms length by {@link Loader}
|
||||
*
|
||||
* It is expected that a similar class will exist for each target environment: Bukkit and Client side.
|
||||
*
|
||||
* It should not be directly modified.
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class FMLBukkitHandler implements IFMLSidedHandler
|
||||
{
|
||||
/**
|
||||
* The singleton
|
||||
*/
|
||||
private static final FMLBukkitHandler INSTANCE = new FMLBukkitHandler();
|
||||
|
||||
/**
|
||||
* A reference to the server itself
|
||||
*/
|
||||
private MinecraftServer server;
|
||||
|
||||
/**
|
||||
* A handy list of the default overworld biomes
|
||||
*/
|
||||
private BiomeBase[] defaultOverworldBiomes;
|
||||
|
||||
FMLBukkitProfiler profiler;
|
||||
|
||||
/**
|
||||
* Called to start the whole game off from {@link MinecraftServer#startServer}
|
||||
* @param minecraftServer
|
||||
*/
|
||||
public void onPreLoad(MinecraftServer minecraftServer)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class.forName("BaseModMp", false, getClass().getClassLoader());
|
||||
MinecraftServer.log.severe(""
|
||||
+ "Forge Mod Loader has detected that this server has an ModLoaderMP installed alongside Forge Mod Loader.\n"
|
||||
+ "This will cause a serious problem with compatibility. To protect your worlds, this minecraft server will now shutdown.\n"
|
||||
+ "You should follow the installation instructions of either Minecraft Forge of Forge Mod Loader and NOT install ModLoaderMP \n"
|
||||
+ "into the minecraft_server.jar file "
|
||||
+ "before this server will be allowed to start up.\n\nFailure to do so will simply result in more startup failures.\n\n"
|
||||
+ "The authors of Minecraft Forge and Forge Mod Loader strongly suggest you talk to your mod's authors and get them to\nupdate their "
|
||||
+ "requirements. ModLoaderMP is not compatible with Minecraft Forge on the server and they will need to update their mod\n"
|
||||
+ "for Minecraft Forge and other server compatibility, unless they are Minecraft Forge mods, in which case they already\n"
|
||||
+ "don't need ModLoaderMP and the mod author simply has failed to update his requirements and should be informed appropriately.\n\n"
|
||||
+ "The authors of Forge Mod Loader would like to be compatible with ModLoaderMP but it is closed source and owned by SDK.\n"
|
||||
+ "SDK, the author of ModLoaderMP, has a standing invitation to submit compatibility patches \n"
|
||||
+ "to the open source community project that is Forge Mod Loader so that this incompatibility doesn't last. \n"
|
||||
+ "Users who wish to enjoy mods of both types are "
|
||||
+ "encouraged to request of SDK that he submit a\ncompatibility patch to the Forge Mod Loader project at \n"
|
||||
+ "http://github.com/cpw/FML.\nPosting on the minecraft forums at\nhttp://www.minecraftforum.net/topic/86765- (the MLMP thread)\n"
|
||||
+ "may encourage him in this effort. However, I ask that your requests be polite.\n"
|
||||
+ "Now, the server has to shutdown so you can reinstall your minecraft_server.jar\nproperly, until such time as we can work together.");
|
||||
throw new RuntimeException(
|
||||
"This FML based server has detected an installation of ModLoaderMP alongside. This will cause serious compatibility issues, so the server will now shut down.");
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
// We're safe. continue
|
||||
}
|
||||
server = minecraftServer;
|
||||
FMLCommonHandler.instance().beginLoading(this);
|
||||
FMLRegistry.registerRegistry(new BukkitRegistry());
|
||||
Loader.instance().loadMods();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called a bit later on during server initialization to finish loading mods
|
||||
*/
|
||||
public void onLoadComplete()
|
||||
{
|
||||
Loader.instance().initializeMods();
|
||||
for (Item i : Item.byId) {
|
||||
if (i!=null && Material.getMaterial(i.id).name().startsWith("X")) {
|
||||
Material.setMaterialName(i.id, i.l());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onWorldLoadTick()
|
||||
{
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLDLOAD));
|
||||
}
|
||||
|
||||
/**
|
||||
* Every tick just before world and other ticks occur
|
||||
*/
|
||||
public void onPreWorldTick(World world)
|
||||
{
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.WORLD),world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Every tick just after world and other ticks occur
|
||||
*/
|
||||
public void onPostWorldTick(World world)
|
||||
{
|
||||
FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.WORLD), world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server instance
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public MinecraftServer getServer()
|
||||
{
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a handle to the server's logger instance
|
||||
*/
|
||||
public Logger getMinecraftLogger()
|
||||
{
|
||||
return MinecraftServer.log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from ChunkProviderServer when a chunk needs to be populated
|
||||
*
|
||||
* To avoid polluting the worldgen seed, we generate a new random from the world seed and
|
||||
* generate a seed from that
|
||||
*
|
||||
* @param chunkProvider
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
* @param world
|
||||
* @param generator
|
||||
*/
|
||||
public void onChunkPopulate(IChunkProvider chunkProvider, int chunkX, int chunkZ, World world, IChunkProvider generator)
|
||||
{
|
||||
FMLCommonHandler.instance().handleWorldGeneration(chunkX, chunkZ, world.getSeed(), world, generator, chunkProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the furnace to lookup fuel values
|
||||
*
|
||||
* @param itemId
|
||||
* @param itemDamage
|
||||
* @return
|
||||
*/
|
||||
public int fuelLookup(int itemId, int itemDamage)
|
||||
{
|
||||
int fv = 0;
|
||||
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
fv = Math.max(fv, mod.lookupFuelValue(itemId, itemDamage));
|
||||
}
|
||||
|
||||
return fv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the offered class and instance of BaseMod and therefore a ModLoader mod?
|
||||
*/
|
||||
public boolean isModLoaderMod(Class<?> clazz)
|
||||
{
|
||||
return BaseMod.class.isAssignableFrom(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the supplied mod class into a mod container
|
||||
*/
|
||||
public ModContainer loadBaseModMod(Class<?> clazz, File canonicalFile)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Class <? extends BaseMod > bmClazz = (Class <? extends BaseMod >) clazz;
|
||||
return new ModLoaderModContainer(bmClazz, canonicalFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to notify that an item was picked up from the world
|
||||
*
|
||||
* @param entityItem
|
||||
* @param entityPlayer
|
||||
*/
|
||||
public void notifyItemPickup(EntityItem entityItem, EntityHuman entityPlayer)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsPickupNotification())
|
||||
{
|
||||
mod.getPickupNotifier().notifyPickup(entityItem, entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise an exception
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
* @param stopGame
|
||||
*/
|
||||
public void raiseException(Throwable exception, String message, boolean stopGame)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().throwing("FMLHandler", "raiseException", exception);
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to dispense the item as an entity other than just as a the item itself
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param xVelocity
|
||||
* @param zVelocity
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
public boolean tryDispensingEntity(World world, double x, double y, double z, byte xVelocity, byte zVelocity, ItemStack item)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsToDispense() && mod.getDispenseHandler().dispense(x, y, z, xVelocity, zVelocity, world, item))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
public static FMLBukkitHandler instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a list of default overworld biomes
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BiomeBase[] getDefaultOverworldBiomes()
|
||||
{
|
||||
if (defaultOverworldBiomes == null)
|
||||
{
|
||||
ArrayList<BiomeBase> biomes = new ArrayList<BiomeBase>(20);
|
||||
|
||||
for (int i = 0; i < 23; i++)
|
||||
{
|
||||
if ("Sky".equals(BiomeBase.biomes[i].y) || "Hell".equals(BiomeBase.biomes[i].y))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
biomes.add(BiomeBase.biomes[i]);
|
||||
}
|
||||
|
||||
defaultOverworldBiomes = new BiomeBase[biomes.size()];
|
||||
biomes.toArray(defaultOverworldBiomes);
|
||||
}
|
||||
|
||||
return defaultOverworldBiomes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item is crafted
|
||||
*
|
||||
* @param player
|
||||
* @param craftedItem
|
||||
* @param craftingGrid
|
||||
*/
|
||||
public void onItemCrafted(EntityHuman player, ItemStack craftedItem, IInventory craftingGrid)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsCraftingNotification())
|
||||
{
|
||||
mod.getCraftingHandler().onCrafting(player, craftedItem, craftingGrid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an item is smelted
|
||||
*
|
||||
* @param player
|
||||
* @param smeltedItem
|
||||
*/
|
||||
public void onItemSmelted(EntityHuman player, ItemStack smeltedItem)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsCraftingNotification())
|
||||
{
|
||||
mod.getCraftingHandler().onSmelting(player, smeltedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a chat packet is received
|
||||
*
|
||||
* @param chat
|
||||
* @param player
|
||||
* @return true if you want the packet to stop processing and not echo to the rest of the world
|
||||
*/
|
||||
public boolean handleChatPacket(Packet3Chat chat, EntityHuman player)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsNetworkPackets() && mod.getNetworkHandler().onChat(chat, player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a packet 250 packet is received from the player
|
||||
*
|
||||
* @param packet
|
||||
* @param player
|
||||
*/
|
||||
public void handlePacket250(Packet250CustomPayload packet, EntityHuman player)
|
||||
{
|
||||
if ("REGISTER".equals(packet.tag) || "UNREGISTER".equals(packet.tag))
|
||||
{
|
||||
handleClientRegistration(packet, player);
|
||||
return;
|
||||
}
|
||||
|
||||
ModContainer mod = FMLCommonHandler.instance().getModForChannel(packet.tag);
|
||||
|
||||
if (mod != null)
|
||||
{
|
||||
mod.getNetworkHandler().onPacket250Packet(packet, player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle register requests for packet 250 channels
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
private void handleClientRegistration(Packet250CustomPayload packet, EntityHuman player)
|
||||
{
|
||||
if (packet.data==null) {
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
for (String channel : new String(packet.data, "UTF8").split("\0"))
|
||||
{
|
||||
// Skip it if we don't know it
|
||||
if (FMLCommonHandler.instance().getModForChannel(channel) == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("REGISTER".equals(packet.tag))
|
||||
{
|
||||
FMLCommonHandler.instance().activateChannel(player, channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLCommonHandler.instance().deactivateChannel(player, channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
getMinecraftLogger().warning("Received invalid registration packet");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a login
|
||||
*
|
||||
* @param loginPacket
|
||||
* @param networkManager
|
||||
*/
|
||||
public void handleLogin(Packet1Login loginPacket, NetworkManager networkManager)
|
||||
{
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.tag = "REGISTER";
|
||||
packet.data = FMLCommonHandler.instance().getPacketRegistry();
|
||||
packet.length = packet.data.length;
|
||||
if (packet.length>0) {
|
||||
networkManager.queue(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public void announceLogin(EntityHuman player) {
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsPlayerTracking())
|
||||
{
|
||||
mod.getPlayerTracker().onPlayerLogin(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getMinecraftRootDirectory()
|
||||
{
|
||||
try {
|
||||
return server.a(".").getCanonicalFile();
|
||||
} catch (IOException ioe) {
|
||||
return new File(".");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param var2
|
||||
* @return
|
||||
*/
|
||||
public boolean handleServerCommand(String command, String player, ICommandListener listener)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList()) {
|
||||
if (mod.wantsConsoleCommands() && mod.getConsoleHandler().handleCommand(command, player, listener)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*/
|
||||
public void announceLogout(EntityHuman player)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsPlayerTracking())
|
||||
{
|
||||
mod.getPlayerTracker().onPlayerLogout(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p_28168_1_
|
||||
*/
|
||||
public void announceDimensionChange(EntityHuman player)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
if (mod.wantsPlayerTracking())
|
||||
{
|
||||
mod.getPlayerTracker().onPlayerChangedDimension(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param biome
|
||||
*/
|
||||
public void addBiomeToDefaultWorldGenerator(BiomeBase biome)
|
||||
{
|
||||
WorldType.NORMAL.addNewBiome(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param biome
|
||||
*/
|
||||
public void removeBiomeFromDefaultWorldGenerator(BiomeBase biome)
|
||||
{
|
||||
WorldType.NORMAL.removeBiome(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMinecraftInstance() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentLanguage()
|
||||
{
|
||||
return LocaleLanguage.a().getCurrentLanguage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties getCurrentLanguageTable()
|
||||
{
|
||||
return LocaleLanguage.a().getCurrentLanguageTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectName(Object instance)
|
||||
{
|
||||
String objectName;
|
||||
if (instance instanceof Item) {
|
||||
objectName=((Item)instance).getName();
|
||||
} else if (instance instanceof Block) {
|
||||
objectName=((Block)instance).getName();
|
||||
} else if (instance instanceof ItemStack) {
|
||||
objectName=Item.byId[((ItemStack)instance).id].a((ItemStack)instance);
|
||||
} else {
|
||||
throw new IllegalArgumentException(String.format("Illegal object for naming %s",instance));
|
||||
}
|
||||
objectName+=".name";
|
||||
return objectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModMetadata readMetadataFrom(InputStream input, ModContainer mod) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void profileStart(String profileLabel) {
|
||||
if (profiler!=null)
|
||||
{
|
||||
profiler.start(profileLabel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void profileEnd() {
|
||||
if (profiler!=null)
|
||||
{
|
||||
profiler.end();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModProperty getModLoaderPropertyFor(Field f) {
|
||||
if (f.isAnnotationPresent(MLProp.class)) {
|
||||
MLProp prop = f.getAnnotation(MLProp.class);
|
||||
return new ModProperty(prop.info(), prop.min(), prop.max(), prop.name());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAdditionalBrandingInformation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Side getSide() {
|
||||
return Side.BUKKIT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProxyInjector findSidedProxyOn(cpw.mods.fml.common.modloader.BaseMod mod) {
|
||||
for (Field f : mod.getClass().getDeclaredFields())
|
||||
{
|
||||
if (f.isAnnotationPresent(SidedProxy.class))
|
||||
{
|
||||
SidedProxy sp = f.getAnnotation(SidedProxy.class);
|
||||
return new ProxyInjector(sp.clientSide(), sp.serverSide(), sp.bukkitSide(), f);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onServerPostTick() {
|
||||
FMLCommonHandler.instance().tickEnd(EnumSet.of(TickType.GAME));
|
||||
}
|
||||
|
||||
public void onServerPreTick() {
|
||||
FMLCommonHandler.instance().tickStart(EnumSet.of(TickType.GAME));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package cpw.mods.fml.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableMultiset;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multiset;
|
||||
import com.google.common.collect.Multiset.Entry;
|
||||
import com.google.common.collect.Multisets;
|
||||
import com.google.common.collect.TreeMultiset;
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
public class FMLBukkitProfiler {
|
||||
private static FMLBukkitProfiler lastInstance;
|
||||
private static long endTime;
|
||||
private LinkedList<String> profiles = new LinkedList<String>();
|
||||
private TreeMultiset<String> hitCounter = TreeMultiset.create();
|
||||
private TreeMultiset<String> timings = TreeMultiset.create();
|
||||
private long timestamp;
|
||||
|
||||
public static long beginProfiling(int seconds)
|
||||
{
|
||||
long now = System.currentTimeMillis();
|
||||
if (lastInstance == null)
|
||||
{
|
||||
lastInstance = new FMLBukkitProfiler();
|
||||
FMLBukkitHandler.instance().profiler = lastInstance;
|
||||
endTime = now + seconds * 1000;
|
||||
}
|
||||
if (endTime > now)
|
||||
{
|
||||
return (endTime - now) / 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static long endProfiling()
|
||||
{
|
||||
FMLBukkitHandler.instance().profiler = null;
|
||||
return endTime - System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static void resetProfiling()
|
||||
{
|
||||
endProfiling();
|
||||
lastInstance = null;
|
||||
}
|
||||
|
||||
public void start(String profileLabel)
|
||||
{
|
||||
profiles.push(profileLabel);
|
||||
timestamp = System.nanoTime();
|
||||
}
|
||||
|
||||
public void end()
|
||||
{
|
||||
int timing = (int)((System.nanoTime() - timestamp)/1000L);
|
||||
String label = Joiner.on('.').join(profiles);
|
||||
profiles.pop();
|
||||
hitCounter.add(label);
|
||||
timings.add(label,timing);
|
||||
if (System.currentTimeMillis()>endTime)
|
||||
{
|
||||
endProfiling();
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] dumpProfileData(int count)
|
||||
{
|
||||
if (lastInstance == null)
|
||||
{
|
||||
return new String[] { "No profile data available" };
|
||||
}
|
||||
|
||||
if (endTime > System.currentTimeMillis())
|
||||
{
|
||||
return new String[] { String.format("Timing is being gathered for another %d seconds", endTime - System.currentTimeMillis()) };
|
||||
}
|
||||
return lastInstance.profileData(count);
|
||||
}
|
||||
|
||||
private String[] profileData(int count) {
|
||||
List<Entry<String>> sortedTiming = getEntriesSortedByFrequency(timings, false);
|
||||
ArrayList<String> timeLine = new ArrayList<String>();
|
||||
|
||||
double totalTime = timings.size();
|
||||
|
||||
for (Entry<String> hit : sortedTiming)
|
||||
{
|
||||
if (--count == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
timeLine.add(String.format("%s : %d microseconds, %d invocations. %.2f %% of overall time",hit.getElement(), hit.getCount(), hitCounter.count(hit.getElement()), 100.0 * hit.getCount()/totalTime));
|
||||
}
|
||||
return timeLine.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Code from http://stackoverflow.com/questions/4345633/simplest-way-to-iterate-through-a-multiset-in-the-order-of-element-frequency
|
||||
*/
|
||||
private enum EntryComp implements Comparator<Multiset.Entry<?>>{
|
||||
DESCENDING{
|
||||
@Override
|
||||
public int compare(final Entry<?> a, final Entry<?> b){
|
||||
return Ints.compare(b.getCount(), a.getCount());
|
||||
}
|
||||
},
|
||||
ASCENDING{
|
||||
@Override
|
||||
public int compare(final Entry<?> a, final Entry<?> b){
|
||||
return Ints.compare(a.getCount(), b.getCount());
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
private static <E> List<Entry<E>> getEntriesSortedByFrequency(final Multiset<E> ms, final boolean ascending) {
|
||||
final List<Entry<E>> entryList = Lists.newArrayList(ms.entrySet());
|
||||
Collections.sort(entryList, ascending ? EntryComp.ASCENDING : EntryComp.DESCENDING);
|
||||
return entryList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.craftbukkit.generator.NetherChunkGenerator;
|
||||
import org.bukkit.craftbukkit.generator.NormalChunkGenerator;
|
||||
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
|
||||
{
|
||||
// CALLBACK MECHANISMS
|
||||
|
||||
/**
|
||||
* @param minecraftInstance
|
||||
* @return
|
||||
*/
|
||||
public final boolean doTickInGame(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data)
|
||||
{
|
||||
if (tick==TickType.GAME && tickEnd) {
|
||||
return onTickInGame((MinecraftServer)minecraftInstance);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCrafting(Object... craftingParameters)
|
||||
{
|
||||
takenFromCrafting((EntityHuman)craftingParameters[0], (ItemStack)craftingParameters[1], (IInventory)craftingParameters[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onSmelting(Object... smeltingParameters)
|
||||
{
|
||||
takenFromFurnace((EntityHuman)smeltingParameters[0], (ItemStack)smeltingParameters[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean dispense(double x, double y, double z, byte xVelocity, byte zVelocity, Object... data)
|
||||
{
|
||||
return dispenseEntity((World)data[0], x, y, z, xVelocity, zVelocity, (ItemStack)data[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onChat(Object... data)
|
||||
{
|
||||
return onChatMessageReceived((EntityHuman)data[1], (Packet3Chat)data[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onServerLogin(Object handler) {
|
||||
// NOOP
|
||||
}
|
||||
|
||||
public final void onServerLogout() {
|
||||
// NOOP
|
||||
}
|
||||
@Override
|
||||
public final void onPlayerLogin(Object player)
|
||||
{
|
||||
onClientLogin((EntityHuman) player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerLogout(Object player)
|
||||
{
|
||||
onClientLogout((EntityHuman)player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerChangedDimension(Object player)
|
||||
{
|
||||
onClientDimensionChanged((EntityHuman)player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPacket250Packet(Object... data)
|
||||
{
|
||||
onPacket250Received((EntityHuman)data[1], (Packet250CustomPayload)data[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void notifyPickup(Object... pickupData)
|
||||
{
|
||||
EntityItem item = (EntityItem) pickupData[0];
|
||||
EntityHuman player = (EntityHuman) pickupData[1];
|
||||
onItemPickup(player, item.itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void generate(Random random, int chunkX, int chunkZ, Object... additionalData)
|
||||
{
|
||||
World w = (World) additionalData[0];
|
||||
IChunkProvider cp = (IChunkProvider) additionalData[1];
|
||||
|
||||
if (cp instanceof ChunkProviderHell || cp instanceof NetherChunkGenerator)
|
||||
{
|
||||
generateNether(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
else if (cp instanceof ChunkProviderGenerate || cp instanceof NormalChunkGenerator)
|
||||
{
|
||||
generateSurface(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP on client side
|
||||
*/
|
||||
@Override
|
||||
public final boolean handleCommand(String command, Object... data)
|
||||
{
|
||||
return onServerCommand(command, (String)data[0], (ICommandListener)data[1]);
|
||||
}
|
||||
@Override
|
||||
public void onRegisterAnimations() {
|
||||
// NOOP on servers
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderHarvest(@SuppressWarnings("rawtypes") Map renderers) {
|
||||
// NOOP on servers
|
||||
}
|
||||
|
||||
// BASEMOD API
|
||||
/**
|
||||
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
|
||||
*
|
||||
* @param id
|
||||
* @param metadata
|
||||
* @return
|
||||
*/
|
||||
public int addFuel(int id, int metadata)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void addRenderer(Map<Class<? extends Entity>, Object> renderers)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if you wish to perform some action other than just dispensing the item from the dispenser
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param xVel
|
||||
* @param zVel
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if you wish to generate Nether (Hell biome) blocks
|
||||
*
|
||||
* @param world
|
||||
* @param random
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
*/
|
||||
public void generateNether(World world, Random random, int chunkX, int chunkZ)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if you wish to generate Overworld (not hell or the end) blocks
|
||||
*
|
||||
* @param world
|
||||
* @param random
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
*/
|
||||
public void generateSurface(World world, Random random, int chunkX, int chunkZ)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of your mod. Defaults to the class name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get your mod priorities
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPriorities()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version of your mod
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract String getVersion();
|
||||
|
||||
public void keyboardEvent(Object event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load your mod
|
||||
*/
|
||||
public abstract void load();
|
||||
|
||||
/**
|
||||
* Finish loading your mod
|
||||
*/
|
||||
public void modsLoaded()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle item pickup
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void onItemPickup(EntityHuman player, ItemStack item)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)}
|
||||
*
|
||||
* @param minecraftServer the server
|
||||
* @return true to continue receiving ticks
|
||||
*/
|
||||
public boolean onTickInGame(MinecraftServer minecraftServer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onTickInGUI(float tick, Object game, Object gui)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only implemented on the client side
|
||||
* {@link #onChatMessageReceived(EntityPlayer, Packet3Chat)}
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
public void receiveChatPacket(String text)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Only called on the client side
|
||||
* {@link #onPacket250Received(EntityPlayer, Packet250CustomPayload)}
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
public void receiveCustomPacket(Packet250CustomPayload packet)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerAnimation(Object game)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void renderInvBlock(Object renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean renderWorldBlock(Object renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when someone crafts an item from a crafting table
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
* @param matrix
|
||||
*/
|
||||
public void takenFromCrafting(EntityHuman player, ItemStack item, IInventory matrix)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when someone takes a smelted item from a furnace
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void takenFromFurnace(EntityHuman player, ItemStack item)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The identifier string for the mod- used in client<->server negotiation
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getName() + " " + getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a 250 packet is received on a channel registered to this mod
|
||||
*
|
||||
* @param source
|
||||
* @param payload
|
||||
*/
|
||||
public void onPacket250Received(EntityHuman source, Packet250CustomPayload payload)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a chat message is received. Return true to stop further processing
|
||||
*
|
||||
* @param source
|
||||
* @param chat
|
||||
* @return true if you want to consume the message so it is not available for further processing
|
||||
*/
|
||||
public boolean onChatMessageReceived(EntityHuman source, Packet3Chat chat)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Called when a server command is received
|
||||
* @param command
|
||||
* @return true if you want to consume the message so it is not available for further processing
|
||||
*/
|
||||
public boolean onServerCommand(String command, String sender, ICommandListener listener)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a new client logs in.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientLogin(EntityHuman player)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a client logs out of the server.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientLogout(EntityHuman player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Called when a client changes dimensions on the server.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientDimensionChanged(EntityHuman player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Spare client junk
|
||||
// -------
|
||||
// void addRenderer(Map<Class<? extends Entity>, Render> renderers);
|
||||
// void registerAnimation(Minecraft game);
|
||||
// void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID);
|
||||
// boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID);
|
||||
// boolean onTickInGUI(float tick, Minecraft game, GuiScreen gui);
|
||||
// void keyboardEvent(KeyBinding event);
|
||||
|
||||
@Override
|
||||
public void keyBindingEvent(Object keybinding) {
|
||||
// NOOP on server
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.BiomeGenBase;
|
||||
|
||||
import cpw.mods.fml.common.registry.IMinecraftRegistry;
|
||||
import cpw.mods.fml.server.FMLBukkitHandler;
|
||||
|
||||
public class BukkitRegistry implements IMinecraftRegistry
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addRecipe(net.minecraft.src.ItemStack output, Object... params)
|
||||
{
|
||||
CraftingManager.getInstance().registerShapedRecipe((ItemStack) output, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addShapelessRecipe(net.minecraft.src.ItemStack output, Object... params)
|
||||
{
|
||||
CraftingManager.getInstance().registerShapelessRecipe((ItemStack) output, params);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void addRecipe(net.minecraft.src.IRecipe recipe)
|
||||
{
|
||||
CraftingManager.getInstance().getRecipies().add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSmelting(int input, net.minecraft.src.ItemStack output)
|
||||
{
|
||||
FurnaceRecipes.getInstance().registerRecipe(input, (ItemStack) output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlock(net.minecraft.src.Block block)
|
||||
{
|
||||
registerBlock(block, ItemBlock.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlock(net.minecraft.src.Block block, Class <? extends net.minecraft.src.ItemBlock > itemclass)
|
||||
{
|
||||
try
|
||||
{
|
||||
assert block != null : "registerBlock: block cannot be null";
|
||||
assert itemclass != null : "registerBlock: itemclass cannot be null";
|
||||
int blockItemId = ((Block)block).id - 256;
|
||||
itemclass.getConstructor(int.class).newInstance(blockItemId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//HMMM
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void registerEntityID(Class <? extends net.minecraft.src.Entity > entityClass, String entityName, int id)
|
||||
{
|
||||
EntityTypes.addNewEntityListMapping((Class<? extends Entity>) entityClass, entityName, id);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void registerEntityID(Class <? extends net.minecraft.src.Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
|
||||
{
|
||||
EntityTypes.addNewEntityListMapping((Class<? extends Entity>) entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void registerTileEntity(Class <? extends net.minecraft.src.TileEntity > tileEntityClass, String id)
|
||||
{
|
||||
TileEntity.addNewTileEntityMapping((Class<? extends TileEntity>) tileEntityClass, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiome(BiomeGenBase biome)
|
||||
{
|
||||
FMLBukkitHandler.instance().addBiomeToDefaultWorldGenerator((BiomeBase) biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpawn(Class <? extends net.minecraft.src.EntityLiving > entityClass, int weightedProb, int min, int max, net.minecraft.src.EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
|
||||
{
|
||||
BiomeBase[] realBiomes=(BiomeBase[]) biomes;
|
||||
for (BiomeBase biome : realBiomes)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<BiomeMeta> spawns = ((BiomeBase)biome).getMobs((EnumCreatureType)typeOfCreature);
|
||||
|
||||
for (BiomeMeta entry : spawns)
|
||||
{
|
||||
//Adjusting an existing spawn entry
|
||||
if (entry.a == entityClass)
|
||||
{
|
||||
entry.d = weightedProb;
|
||||
entry.b = min;
|
||||
entry.c = max;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spawns.add(new BiomeMeta(entityClass, weightedProb, min, max));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addSpawn(String entityName, int weightedProb, int min, int max, net.minecraft.src.EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
Class <? extends Entity > entityClazz = EntityTypes.getEntityToClassMapping().get(entityName);
|
||||
|
||||
if (EntityLiving.class.isAssignableFrom(entityClazz))
|
||||
{
|
||||
addSpawn((Class <? extends net.minecraft.src.EntityLiving >) entityClazz, weightedProb, min, max, spawnList, biomes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBiome(BiomeGenBase biome)
|
||||
{
|
||||
FMLBukkitHandler.instance().removeBiomeFromDefaultWorldGenerator((BiomeBase)biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSpawn(Class <? extends net.minecraft.src.EntityLiving > entityClass, net.minecraft.src.EnumCreatureType typeOfCreature, BiomeGenBase... biomesO)
|
||||
{
|
||||
BiomeBase[] biomes=(BiomeBase[]) biomesO;
|
||||
for (BiomeBase biome : biomes)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<BiomeMeta> spawns = ((BiomeBase)biome).getMobs((EnumCreatureType) typeOfCreature);
|
||||
|
||||
Iterator<BiomeMeta> entries = spawns.iterator();
|
||||
while (entries.hasNext())
|
||||
{
|
||||
BiomeMeta entry = entries.next();
|
||||
if (entry.a == entityClass)
|
||||
{
|
||||
entries.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void removeSpawn(String entityName, net.minecraft.src.EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
Class <? extends Entity > entityClazz = EntityTypes.getEntityToClassMapping().get(entityName);
|
||||
|
||||
if (EntityLiving.class.isAssignableFrom(entityClazz))
|
||||
{
|
||||
removeSpawn((Class <? extends net.minecraft.src.EntityLiving >) entityClazz, spawnList, biomes);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(value = RUNTIME)
|
||||
@Target(value = FIELD)
|
||||
public @interface MLProp
|
||||
{
|
||||
/**
|
||||
* Adds additional help to top of configuration file.
|
||||
*/
|
||||
String info() default "";
|
||||
|
||||
/**
|
||||
* Maximum value allowed if field is a number.
|
||||
*/
|
||||
double max() default Double.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Minimum value allowed if field is a number.
|
||||
*/
|
||||
double min() default Double.MIN_VALUE;
|
||||
|
||||
/**
|
||||
* Overrides the field name for property key.
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,780 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ReflectionHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
import cpw.mods.fml.common.registry.FMLRegistry;
|
||||
import cpw.mods.fml.server.FMLBukkitHandler;
|
||||
|
||||
public class ModLoader
|
||||
{
|
||||
/**
|
||||
* Not used on the server.
|
||||
*
|
||||
* @param achievement
|
||||
* @param name
|
||||
* @param description
|
||||
*/
|
||||
public static void addAchievementDesc(Achievement achievement, String name, String description)
|
||||
{
|
||||
String achName=achievement.getName();
|
||||
addLocalization(achName, name);
|
||||
addLocalization(achName+".desc", description);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
*
|
||||
* {@link FMLCommonHandler#fuelLookup(int, int)}
|
||||
*
|
||||
* @param id
|
||||
* @param metadata
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static int addAllFuel(int id, int metadata)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void addAllRenderers(Map<Class<? extends Entity>, Object> renderers)
|
||||
{
|
||||
}
|
||||
|
||||
public static void addAnimation(Object anim)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is unimplemented in server versions to date.
|
||||
*
|
||||
* @param armor
|
||||
* @return
|
||||
*/
|
||||
public static int addArmor(String armor)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds the supplied biome to the set of candidate biomes for the default world generator type.
|
||||
*
|
||||
* @param biome
|
||||
*/
|
||||
public static void addBiome(BiomeBase biome)
|
||||
{
|
||||
FMLRegistry.addBiome(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add localization for the specified string
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public static void addLocalization(String key, String value)
|
||||
{
|
||||
addLocalization(key, "en_US", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add localization for the specified string
|
||||
*
|
||||
* @param key
|
||||
* @param lang
|
||||
* @param value
|
||||
*/
|
||||
public static void addLocalization(String key, String lang, String value)
|
||||
{
|
||||
FMLCommonHandler.instance().addStringLocalization(key, lang, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Name the specified minecraft object with the supplied name
|
||||
*
|
||||
* @param instance
|
||||
* @param name
|
||||
*/
|
||||
public static void addName(Object instance, String name)
|
||||
{
|
||||
addName(instance,"en_US",name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unimplemented on the server as it does not generate names
|
||||
*
|
||||
* @param instance
|
||||
* @param lang
|
||||
* @param name
|
||||
*/
|
||||
public static void addName(Object instance, String lang, String name)
|
||||
{
|
||||
FMLCommonHandler.instance().addNameForObject(instance, lang, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unimplemented on the server as it does not render textures
|
||||
*
|
||||
* @param fileToOverride
|
||||
* @param fileToAdd
|
||||
* @return
|
||||
*/
|
||||
public static int addOverride(String fileToOverride, String fileToAdd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unimplemented on the server as it does not render textures
|
||||
*
|
||||
* @param path
|
||||
* @param overlayPath
|
||||
* @param index
|
||||
*/
|
||||
public static void addOverride(String path, String overlayPath, int index)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Shaped Recipe
|
||||
*
|
||||
* @param output
|
||||
* @param params
|
||||
*/
|
||||
public static void addRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
FMLRegistry.addRecipe(output, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a shapeless recipe
|
||||
*
|
||||
* @param output
|
||||
* @param params
|
||||
*/
|
||||
public static void addShapelessRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
FMLRegistry.addShapelessRecipe(output, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new product to be smelted
|
||||
*
|
||||
* @param input
|
||||
* @param output
|
||||
*/
|
||||
public static void addSmelting(int input, ItemStack output)
|
||||
{
|
||||
FMLRegistry.addSmelting(input, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
*
|
||||
* @param entityClass
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
* @param max
|
||||
* @param spawnList
|
||||
*/
|
||||
public static void addSpawn(Class <? extends EntityLiving > entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList)
|
||||
{
|
||||
FMLRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, FMLBukkitHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
* @param entityClass
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
* @param max
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
*/
|
||||
public static void addSpawn(Class <? extends EntityLiving > entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeBase... biomes)
|
||||
{
|
||||
FMLRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, biomes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
*
|
||||
* @param entityName
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
* @param max
|
||||
* @param spawnList
|
||||
*/
|
||||
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList)
|
||||
{
|
||||
FMLRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, FMLBukkitHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
* @param entityName
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
* @param max
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
*/
|
||||
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeBase... biomes)
|
||||
{
|
||||
FMLRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, biomes);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLBukkitHandler#tryDispensingEntity(World, double, double, double, byte, byte, ItemStack)}
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param xVel
|
||||
* @param zVel
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a container and drop all the items in it on the ground around
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
public static void genericContainerRemoval(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
|
||||
if (!(te instanceof IInventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IInventory inv = (IInventory)te;
|
||||
|
||||
for (int l = 0; l < inv.getSize(); l++)
|
||||
{
|
||||
ItemStack itemstack = inv.getItem(l);
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float f = world.random.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = world.random.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = world.random.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.count > 0)
|
||||
{
|
||||
int i1 = world.random.nextInt(21) + 10;
|
||||
|
||||
if (i1 > itemstack.count)
|
||||
{
|
||||
i1 = itemstack.count ;
|
||||
}
|
||||
|
||||
itemstack.count -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (float)te.x + f, (float)te.y + f1, (float)te.z + f2, new ItemStack(itemstack.id, i1, itemstack.getData()));
|
||||
float f3 = 0.05F;
|
||||
entityitem.motX = (float)world.random.nextGaussian() * f3;
|
||||
entityitem.motY = (float)world.random.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motZ = (float)world.random.nextGaussian() * f3;
|
||||
|
||||
if (itemstack.hasTag())
|
||||
{
|
||||
entityitem.itemStack.setTag((NBTTagCompound)itemstack.getTag().clone());
|
||||
}
|
||||
|
||||
world.addEntity(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all BaseMod loaded into the system
|
||||
* {@link ModLoaderModContainer#findAll}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<BaseMod> getLoadedMods()
|
||||
{
|
||||
return ModLoaderModContainer.findAll(BaseMod.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a logger instance {@link FMLCommonHandler#getFMLLogger()}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Logger getLogger()
|
||||
{
|
||||
return FMLCommonHandler.instance().getFMLLogger();
|
||||
}
|
||||
|
||||
public static Object getMinecraftInstance()
|
||||
{
|
||||
return getMinecraftServerInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minecraft server instance
|
||||
* {@link FMLServerHandler#getServer()}
|
||||
* @return
|
||||
*/
|
||||
public static MinecraftServer getMinecraftServerInstance()
|
||||
{
|
||||
return FMLBukkitHandler.instance().getServer();
|
||||
}
|
||||
/**
|
||||
* Get a value from a field using reflection
|
||||
* {@link ReflectionHelper#getPrivateValue(Class, Object, int)}
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param fieldindex
|
||||
* @return
|
||||
*/
|
||||
public static <T, E> T getPrivateValue(Class <? super E > instanceclass, E instance, int fieldindex)
|
||||
{
|
||||
return ReflectionHelper.getPrivateValue(instanceclass, instance, fieldindex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from a field using reflection
|
||||
* {@link ReflectionHelper#getPrivateValue(Class, Object, String)}
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
public static <T, E> T getPrivateValue(Class <? super E > instanceclass, E instance, String field)
|
||||
{
|
||||
return ReflectionHelper.getPrivateValue(instanceclass, instance, field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stubbed method on the server to return a unique model id
|
||||
*
|
||||
*/
|
||||
public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new unique entity id
|
||||
* {@link Entity#getNextId()}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int getUniqueEntityId()
|
||||
{
|
||||
return FMLCommonHandler.instance().nextUniqueEntityListId();
|
||||
}
|
||||
|
||||
public static int getUniqueSpriteIndex(String path)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* To properly implement packet 250 protocol you should always check your
|
||||
* channel is active prior to sending the packet
|
||||
*
|
||||
* @param player
|
||||
* @param channel
|
||||
* @return
|
||||
*/
|
||||
public static boolean isChannelActive(EntityPlayer player, String channel)
|
||||
{
|
||||
return FMLCommonHandler.instance().isChannelActive(channel, player);
|
||||
}
|
||||
|
||||
public static boolean isGUIOpen(Class<?> gui)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the named mod loaded?
|
||||
* {@link Loader#isModLoaded(String)}
|
||||
*
|
||||
* @param modname
|
||||
* @return
|
||||
*/
|
||||
public static boolean isModLoaded(String modname)
|
||||
{
|
||||
return Loader.isModLoaded(modname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented elsewhere
|
||||
*/
|
||||
@Deprecated
|
||||
public static void loadConfig()
|
||||
{
|
||||
}
|
||||
|
||||
public static Object loadImage(Object renderEngine, String path) throws Exception
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call in from elsewhere. Unimplemented here.
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
@Deprecated
|
||||
public static void onItemPickup(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Call in from elsewhere. Unimplemented here.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void onTick(float tick, Object game)
|
||||
{
|
||||
}
|
||||
|
||||
public static void openGUI(EntityPlayer player, Object gui)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void populateChunk(IChunkProvider generator, int chunkX, int chunkZ, World world)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLBukkitHandler#handlePacket250(Packet250CustomPayload, EntityHuman)}
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
@Deprecated
|
||||
public static void receivePacket(Packet250CustomPayload packet)
|
||||
{
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Object[] registerAllKeys(Object[] keys)
|
||||
{
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void registerAllTextureOverrides(Object cache)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new block
|
||||
*
|
||||
* @param block
|
||||
*/
|
||||
public static void registerBlock(Block block)
|
||||
{
|
||||
FMLRegistry.registerBlock(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new block
|
||||
*
|
||||
* @param block
|
||||
* @param itemclass
|
||||
*/
|
||||
public static void registerBlock(Block block, Class <? extends ItemBlock > itemclass)
|
||||
{
|
||||
FMLRegistry.registerBlock(block, itemclass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new entity ID
|
||||
*
|
||||
* @param entityClass
|
||||
* @param entityName
|
||||
* @param id
|
||||
*/
|
||||
public static void registerEntityID(Class <? extends Entity > entityClass, String entityName, int id)
|
||||
{
|
||||
FMLRegistry.registerEntityID(entityClass, entityName, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new entity ID
|
||||
*
|
||||
* @param entityClass
|
||||
* @param entityName
|
||||
* @param id
|
||||
* @param background
|
||||
* @param foreground
|
||||
*/
|
||||
public static void registerEntityID(Class <? extends Entity > entityClass, String entityName, int id, int background, int foreground)
|
||||
{
|
||||
FMLRegistry.registerEntityID(entityClass, entityName, id, background, foreground);
|
||||
}
|
||||
|
||||
public static void registerKey(BaseMod mod, Object keyHandler, boolean allowRepeat)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the mod for packets on this channel. This only registers the
|
||||
* channel with Forge Mod Loader, not with clients connecting- use
|
||||
* BaseMod.onClientLogin to tell them about your custom channel
|
||||
* {@link FMLCommonHandler#registerChannel(cpw.mods.fml.common.ModContainer, String)}
|
||||
*
|
||||
* @param mod
|
||||
* @param channel
|
||||
*/
|
||||
public static void registerPacketChannel(BaseMod mod, String channel)
|
||||
{
|
||||
FMLCommonHandler.instance().registerChannel(ModLoaderModContainer.findContainerFor(mod), channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new tile entity class
|
||||
*
|
||||
* @param tileEntityClass
|
||||
* @param id
|
||||
*/
|
||||
public static void registerTileEntity(Class <? extends TileEntity > tileEntityClass, String id)
|
||||
{
|
||||
FMLRegistry.registerTileEntity(tileEntityClass, id);
|
||||
}
|
||||
|
||||
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id, Object renderer)
|
||||
{
|
||||
FMLRegistry.instance().registerTileEntity(tileEntityClass, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a biome from the list of generated biomes
|
||||
*
|
||||
* @param biome
|
||||
*/
|
||||
public static void removeBiome(BiomeBase biome)
|
||||
{
|
||||
FMLRegistry.removeBiome(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
* @param entityClass
|
||||
* @param spawnList
|
||||
*/
|
||||
public static void removeSpawn(Class <? extends EntityLiving > entityClass, EnumCreatureType spawnList)
|
||||
{
|
||||
FMLRegistry.removeSpawn(entityClass, spawnList, FMLBukkitHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
* @param entityClass
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
*/
|
||||
public static void removeSpawn(Class <? extends EntityLiving > entityClass, EnumCreatureType spawnList, BiomeBase... biomes)
|
||||
{
|
||||
FMLRegistry.removeSpawn(entityClass, spawnList, biomes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
* @param entityName
|
||||
* @param spawnList
|
||||
*/
|
||||
public static void removeSpawn(String entityName, EnumCreatureType spawnList)
|
||||
{
|
||||
FMLRegistry.removeSpawn(entityName, spawnList, FMLBukkitHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
* @param entityName
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
*/
|
||||
public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeBase... biomes)
|
||||
{
|
||||
FMLRegistry.removeSpawn(entityName, spawnList, biomes);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean renderBlockIsItemFull3D(int modelID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void renderInvBlock(Object renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean renderWorldBlock(Object renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration is handled elsewhere
|
||||
* {@link ModLoaderModContainer}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void saveConfig()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a chat message to the server
|
||||
* {@link FMLServerHandler#handleChatPacket(Packet3Chat, EntityPlayer)}
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
@Deprecated
|
||||
public static void serverChat(String text)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void serverLogin(Object handler, Packet1Login loginPacket)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that you want to receive ticks
|
||||
*
|
||||
* @param mod receiving the events
|
||||
* @param enable indicates whether you want to recieve them or not
|
||||
* @param useClock Not used in server side: all ticks are sent on the server side (no render subticks)
|
||||
*/
|
||||
public static void setInGameHook(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderHelper.updateStandardTicks(mod, enable, useClock);
|
||||
}
|
||||
|
||||
|
||||
public static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderHelper.updateGUITicks(mod, enable, useClock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a private field to a value using reflection
|
||||
* {@link ReflectionHelper#setPrivateValue(Class, Object, int, Object)}
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param fieldindex
|
||||
* @param value
|
||||
*/
|
||||
public static <T, E> void setPrivateValue(Class <? super T > instanceclass, T instance, int fieldindex, E value)
|
||||
{
|
||||
ReflectionHelper.setPrivateValue(instanceclass, instance, fieldindex, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a private field to a value using reflection
|
||||
* {@link ReflectionHelper#setPrivateValue(Class, Object, String, Object)}
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param field
|
||||
* @param value
|
||||
*/
|
||||
public static <T, E> void setPrivateValue(Class <? super T > instanceclass, T instance, String field, E value)
|
||||
{
|
||||
ReflectionHelper.setPrivateValue(instanceclass, instance, field, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLBukkitHandler#onItemCrafted(EntityHuman, ItemStack, IInventory)}
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
* @param matrix
|
||||
*/
|
||||
@Deprecated
|
||||
public static void takenFromCrafting(EntityHuman player, ItemStack item, IInventory matrix)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLBukkitHandler#onItemSmelted(EntityHuman, ItemStack)}
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
@Deprecated
|
||||
public static void takenFromFurnace(EntityHuman player, ItemStack item)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw the offered exception. Likely will stop the game.
|
||||
* {@link FMLBukkitHandler#raiseException(Throwable, String, boolean)}
|
||||
* @param message
|
||||
* @param e
|
||||
*/
|
||||
public static void throwException(String message, Throwable e)
|
||||
{
|
||||
FMLBukkitHandler.instance().raiseException(e, message, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* To properly implement packet 250 protocol you should always check your channel
|
||||
* is active prior to sending the packet
|
||||
*
|
||||
* @param player
|
||||
* @param channel
|
||||
* @return
|
||||
*/
|
||||
public static boolean isChannelActive(EntityHuman player, String channel)
|
||||
{
|
||||
return FMLCommonHandler.instance().isChannelActive(channel, player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface SidedProxy
|
||||
{
|
||||
/**
|
||||
* The name of the client side class to load and populate
|
||||
* @return
|
||||
*/
|
||||
String clientSide() default "";
|
||||
|
||||
/**
|
||||
* The name of the server side class to load and populate
|
||||
* @return
|
||||
*/
|
||||
String serverSide() default "";
|
||||
|
||||
/**
|
||||
* The name of the a special bukkit plugin class to load and populate
|
||||
*/
|
||||
String bukkitSide() default "";
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface BiomeGenBase {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface Block {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface Entity {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface EntityLiving {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface EnumCreatureType {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface IRecipe {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface ItemBlock {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface ItemStack {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
public interface TileEntity {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import sys
|
||||
import os, os.path, shutil
|
||||
import fnmatch
|
||||
import re
|
||||
|
||||
def main():
|
||||
sys.stdout.flush()
|
||||
for x in range(1, len(sys.argv)):
|
||||
cleanup_source(sys.argv[x])
|
||||
|
||||
count = 0
|
||||
def cleanup_source(path):
|
||||
path = os.path.normpath(path)
|
||||
regex_cases_before = re.compile(r'((case|default).+\r?\n)\r?\n', re.MULTILINE) #Fixes newline after case before case body
|
||||
regex_cases_after = re.compile(r'\r?\n(\r?\n[ \t]+(case|default))', re.MULTILINE) #Fixes newline after case body before new case
|
||||
|
||||
def updatefile(src_file):
|
||||
global count
|
||||
tmp_file = src_file + '.tmp'
|
||||
count = 0
|
||||
with open(src_file, 'r') as fh:
|
||||
buf = fh.read()
|
||||
|
||||
def fix_cases(match):
|
||||
global count
|
||||
count += 1
|
||||
return match.group(1)
|
||||
|
||||
buf = regex_cases_before.sub(fix_cases, buf)
|
||||
buf = regex_cases_after.sub(fix_cases, buf)
|
||||
if count > 0:
|
||||
with open(tmp_file, 'w') as fh:
|
||||
fh.write(buf)
|
||||
shutil.move(tmp_file, src_file)
|
||||
|
||||
for path, _, filelist in os.walk(path, followlinks=True):
|
||||
sub_dir = os.path.relpath(path, path)
|
||||
for cur_file in fnmatch.filter(filelist, '*.java'):
|
||||
src_file = os.path.normpath(os.path.join(path, cur_file))
|
||||
updatefile(src_file)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class BlockRenderInfo
|
||||
{
|
||||
private int renderId;
|
||||
private boolean render3dInInventory;
|
||||
private ModContainer modContainer;
|
||||
|
||||
/**
|
||||
* @param modContainer
|
||||
*
|
||||
*/
|
||||
public BlockRenderInfo(int renderId, boolean render3dInInventory, ModContainer modContainer)
|
||||
{
|
||||
this.renderId=renderId;
|
||||
this.render3dInInventory=render3dInInventory;
|
||||
this.modContainer=modContainer;
|
||||
}
|
||||
|
||||
public int getRenderId()
|
||||
{
|
||||
return renderId;
|
||||
}
|
||||
|
||||
public boolean shouldRender3DInInventory()
|
||||
{
|
||||
return render3dInInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param block
|
||||
* @param modelId
|
||||
* @param renderer
|
||||
*/
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
|
||||
{
|
||||
return ((BaseMod)modContainer.getMod()).renderWorldBlock(renderer, world, x, y, z, block, modelId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param block
|
||||
* @param metadata
|
||||
* @param modelID
|
||||
* @param renderer
|
||||
*/
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
|
||||
{
|
||||
((BaseMod)modContainer.getMod()).renderInvBlock(renderer, block, metadata, modelID);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import net.minecraft.src.RenderEngine;
|
||||
import net.minecraft.src.TextureFX;
|
||||
import net.minecraft.src.TexturePackBase;
|
||||
|
||||
public class FMLTextureFX extends TextureFX implements ITextureFX
|
||||
{
|
||||
public int tileSizeBase = 16;
|
||||
public int tileSizeSquare = 256;
|
||||
public int tileSizeMask = 15;
|
||||
public int tileSizeSquareMask = 255;
|
||||
public boolean errored = false;
|
||||
protected Logger log = FMLCommonHandler.instance().getFMLLogger();
|
||||
|
||||
public FMLTextureFX(int icon)
|
||||
{
|
||||
super(icon);
|
||||
}
|
||||
|
||||
@Override public void setErrored(boolean err){ errored = err; }
|
||||
@Override public boolean getErrored(){ return errored; }
|
||||
@Override
|
||||
public void onTexturePackChanged(RenderEngine engine, TexturePackBase texturepack, Dimension dimensions)
|
||||
{
|
||||
onTextureDimensionsUpdate(dimensions.width, dimensions.height);
|
||||
}
|
||||
@Override
|
||||
public void onTextureDimensionsUpdate(int width, int height)
|
||||
{
|
||||
tileSizeBase = width >> 4;
|
||||
tileSizeSquare = tileSizeBase * tileSizeBase;
|
||||
tileSizeMask = tileSizeBase - 1;
|
||||
tileSizeSquareMask = tileSizeSquare - 1;
|
||||
setErrored(false);
|
||||
setup();
|
||||
}
|
||||
|
||||
protected void setup()
|
||||
{
|
||||
field_1127_a = new byte[tileSizeSquare << 2];
|
||||
}
|
||||
|
||||
public boolean unregister(RenderEngine engine, List<TextureFX> effects)
|
||||
{
|
||||
effects.remove(this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.common.FMLModContainer;
|
||||
import cpw.mods.fml.common.FMLModLoaderContainer;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.FontRenderer;
|
||||
import net.minecraft.src.GuiButton;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.GuiSmallButton;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
import net.minecraft.src.Tessellator;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class GuiModList extends GuiScreen
|
||||
{
|
||||
|
||||
private GuiScreen mainMenu;
|
||||
private GuiSlotModList modList;
|
||||
private int selected = -1;
|
||||
private ModContainer selectedMod;
|
||||
private int listWidth;
|
||||
private ArrayList<ModContainer> mods;
|
||||
|
||||
/**
|
||||
* @param guiMainMenu
|
||||
*/
|
||||
public GuiModList(GuiScreen mainMenu)
|
||||
{
|
||||
this.mainMenu=mainMenu;
|
||||
this.mods=new ArrayList<ModContainer>();
|
||||
FMLClientHandler.instance().addSpecialModEntries(mods);
|
||||
for (ModContainer mod : Loader.getModList()) {
|
||||
if (mod.getMetadata()!=null && mod.getMetadata().parentMod != null) {
|
||||
continue;
|
||||
}
|
||||
mods.add(mod);
|
||||
}
|
||||
}
|
||||
|
||||
public void func_6448_a()
|
||||
{
|
||||
for (ModContainer mod : mods) {
|
||||
listWidth=Math.max(listWidth,getFontRenderer().func_871_a(mod.getName()) + 10);
|
||||
listWidth=Math.max(listWidth,getFontRenderer().func_871_a(mod.getVersion()) + 10);
|
||||
}
|
||||
listWidth=Math.min(listWidth, 150);
|
||||
StringTranslate translations = StringTranslate.func_20162_a();
|
||||
this.field_949_e.add(new GuiSmallButton(6, this.field_951_c / 2 - 75, this.field_950_d - 38, translations.func_20163_a("gui.done")));
|
||||
this.modList=new GuiSlotModList(this, mods, listWidth);
|
||||
this.modList.registerScrollButtons(this.field_949_e, 7, 8);
|
||||
}
|
||||
|
||||
protected void func_572_a(GuiButton button) {
|
||||
if (button.field_937_g)
|
||||
{
|
||||
switch (button.field_938_f)
|
||||
{
|
||||
case 6:
|
||||
this.field_945_b.func_6272_a(this.mainMenu);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.func_572_a(button);
|
||||
}
|
||||
|
||||
public int drawLine(String line, int offset, int shifty)
|
||||
{
|
||||
this.field_6451_g.func_873_b(line, offset, shifty, 0xd7edea);
|
||||
return shifty + 10;
|
||||
}
|
||||
public void func_571_a(int p_571_1_, int p_571_2_, float p_571_3_)
|
||||
{
|
||||
this.modList.drawScreen(p_571_1_, p_571_2_, p_571_3_);
|
||||
this.func_548_a(this.field_6451_g, "Mod List", this.field_951_c / 2, 16, 0xFFFFFF);
|
||||
int offset = this.listWidth + 20;
|
||||
if (selectedMod != null) {
|
||||
if (selectedMod.getMetadata() != null) {
|
||||
int shifty = 35;
|
||||
if (!selectedMod.getMetadata().logoFile.isEmpty())
|
||||
{
|
||||
int texture = this.field_945_b.field_6315_n.func_1070_a(selectedMod.getMetadata().logoFile);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.field_945_b.field_6315_n.func_1076_b(texture);
|
||||
Dimension dim = FMLClientHandler.instance().getTextureDimensions(texture);
|
||||
int top = 32;
|
||||
Tessellator tess = Tessellator.field_1512_a;
|
||||
tess.func_977_b();
|
||||
tess.func_983_a(offset, top + dim.height, field_923_k, 0, 1);
|
||||
tess.func_983_a(offset + dim.width, top + dim.height, field_923_k, 1, 1);
|
||||
tess.func_983_a(offset + dim.width, top, field_923_k, 1, 0);
|
||||
tess.func_983_a(offset, top, field_923_k, 0, 0);
|
||||
tess.func_982_a();
|
||||
|
||||
shifty += 65;
|
||||
}
|
||||
this.field_6451_g.func_50103_a(selectedMod.getMetadata().name, offset, shifty, 0xFFFFFF);
|
||||
shifty += 12;
|
||||
|
||||
shifty = drawLine(String.format("Version: %s (%s)", selectedMod.getMetadata().version, selectedMod.getVersion()), offset, shifty);
|
||||
if (!selectedMod.getMetadata().credits.isEmpty()) {
|
||||
shifty = drawLine(String.format("Credits: %s", selectedMod.getMetadata().credits), offset, shifty);
|
||||
}
|
||||
shifty = drawLine(String.format("Authors: %s", selectedMod.getMetadata().getAuthorList()), offset, shifty);
|
||||
shifty = drawLine(String.format("URL: %s", selectedMod.getMetadata().url), offset, shifty);
|
||||
shifty = drawLine(selectedMod.getMetadata().childMods.isEmpty() ? "No child mods for this mod" : String.format("Child mods: %s", selectedMod.getMetadata().getChildModList()), offset, shifty);
|
||||
this.getFontRenderer().func_27278_a(selectedMod.getMetadata().description, offset, shifty + 10, this.field_951_c - offset - 20, 0xDDDDDD);
|
||||
} else {
|
||||
offset = ( this.listWidth + this.field_951_c ) / 2;
|
||||
this.func_548_a(this.field_6451_g, selectedMod.getName(), offset, 35, 0xFFFFFF);
|
||||
this.func_548_a(this.field_6451_g, String.format("Version: %s",selectedMod.getVersion()), offset, 45, 0xFFFFFF);
|
||||
this.func_548_a(this.field_6451_g, "No mod information found", offset, 55, 0xDDDDDD);
|
||||
this.func_548_a(this.field_6451_g, "Ask your mod author to provide a mod .info file", offset, 65, 0xDDDDDD);
|
||||
}
|
||||
}
|
||||
super.func_571_a(p_571_1_, p_571_2_, p_571_3_);
|
||||
}
|
||||
|
||||
Minecraft getMinecraftInstance() {
|
||||
return field_945_b;
|
||||
}
|
||||
|
||||
FontRenderer getFontRenderer() {
|
||||
return field_6451_g;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param var1
|
||||
*/
|
||||
public void selectModIndex(int var1)
|
||||
{
|
||||
this.selected=var1;
|
||||
if (var1>=0 && var1<=mods.size()) {
|
||||
this.selectedMod=mods.get(selected);
|
||||
} else {
|
||||
this.selectedMod=null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param var1
|
||||
* @return
|
||||
*/
|
||||
public boolean modIndexSelected(int var1)
|
||||
{
|
||||
return var1==selected;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.GuiButton;
|
||||
import net.minecraft.src.Tessellator;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public abstract class GuiScrollingList
|
||||
{
|
||||
private final Minecraft client;
|
||||
protected final int listWidth;
|
||||
protected final int listHeight;
|
||||
protected final int top;
|
||||
protected final int bottom;
|
||||
private final int right;
|
||||
protected final int left;
|
||||
protected final int slotHeight;
|
||||
private int scrollUpActionId;
|
||||
private int scrollDownActionId;
|
||||
protected int mouseX;
|
||||
protected int mouseY;
|
||||
private float initialMouseClickY = -2.0F;
|
||||
private float scrollFactor;
|
||||
private float scrollDistance;
|
||||
private int selectedIndex = -1;
|
||||
private long lastClickTime = 0L;
|
||||
private boolean field_25123_p = true;
|
||||
private boolean field_27262_q;
|
||||
private int field_27261_r;
|
||||
|
||||
public GuiScrollingList(Minecraft client, int width, int height, int top, int bottom, int left, int entryHeight)
|
||||
{
|
||||
this.client = client;
|
||||
this.listWidth = width;
|
||||
this.listHeight = height;
|
||||
this.top = top;
|
||||
this.bottom = bottom;
|
||||
this.slotHeight = entryHeight;
|
||||
this.left = left;
|
||||
this.right = width + this.left;
|
||||
}
|
||||
|
||||
public void func_27258_a(boolean p_27258_1_)
|
||||
{
|
||||
this.field_25123_p = p_27258_1_;
|
||||
}
|
||||
|
||||
protected void func_27259_a(boolean p_27259_1_, int p_27259_2_)
|
||||
{
|
||||
this.field_27262_q = p_27259_1_;
|
||||
this.field_27261_r = p_27259_2_;
|
||||
|
||||
if (!p_27259_1_)
|
||||
{
|
||||
this.field_27261_r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract int getSize();
|
||||
|
||||
protected abstract void elementClicked(int index, boolean doubleClick);
|
||||
|
||||
protected abstract boolean isSelected(int index);
|
||||
|
||||
protected int getContentHeight()
|
||||
{
|
||||
return this.getSize() * this.slotHeight + this.field_27261_r;
|
||||
}
|
||||
|
||||
protected abstract void drawBackground();
|
||||
|
||||
protected abstract void drawSlot(int var1, int var2, int var3, int var4, Tessellator var5);
|
||||
|
||||
protected void func_27260_a(int p_27260_1_, int p_27260_2_, Tessellator p_27260_3_) {}
|
||||
|
||||
protected void func_27255_a(int p_27255_1_, int p_27255_2_) {}
|
||||
|
||||
protected void func_27257_b(int p_27257_1_, int p_27257_2_) {}
|
||||
|
||||
public int func_27256_c(int p_27256_1_, int p_27256_2_)
|
||||
{
|
||||
int var3 = this.listWidth / 2 - 110;
|
||||
int var4 = this.listWidth / 2 + 110;
|
||||
int var5 = p_27256_2_ - this.top - this.field_27261_r + (int)this.scrollDistance - 4;
|
||||
int var6 = var5 / this.slotHeight;
|
||||
return p_27256_1_ >= var3 && p_27256_1_ <= var4 && var6 >= 0 && var5 >= 0 && var6 < this.getSize() ? var6 : -1;
|
||||
}
|
||||
|
||||
public void registerScrollButtons(List p_22240_1_, int p_22240_2_, int p_22240_3_)
|
||||
{
|
||||
this.scrollUpActionId = p_22240_2_;
|
||||
this.scrollDownActionId = p_22240_3_;
|
||||
}
|
||||
|
||||
private void applyScrollLimits()
|
||||
{
|
||||
int var1 = this.getContentHeight() - (this.bottom - this.top - 4);
|
||||
|
||||
if (var1 < 0)
|
||||
{
|
||||
var1 /= 2;
|
||||
}
|
||||
|
||||
if (this.scrollDistance < 0.0F)
|
||||
{
|
||||
this.scrollDistance = 0.0F;
|
||||
}
|
||||
|
||||
if (this.scrollDistance > (float)var1)
|
||||
{
|
||||
this.scrollDistance = (float)var1;
|
||||
}
|
||||
}
|
||||
|
||||
public void actionPerformed(GuiButton button)
|
||||
{
|
||||
if (button.field_937_g)
|
||||
{
|
||||
if (button.field_938_f == this.scrollUpActionId)
|
||||
{
|
||||
this.scrollDistance -= (float)(this.slotHeight * 2 / 3);
|
||||
this.initialMouseClickY = -2.0F;
|
||||
this.applyScrollLimits();
|
||||
}
|
||||
else if (button.field_938_f == this.scrollDownActionId)
|
||||
{
|
||||
this.scrollDistance += (float)(this.slotHeight * 2 / 3);
|
||||
this.initialMouseClickY = -2.0F;
|
||||
this.applyScrollLimits();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreen(int mouseX, int mouseY, float p_22243_3_)
|
||||
{
|
||||
this.mouseX = mouseX;
|
||||
this.mouseY = mouseY;
|
||||
this.drawBackground();
|
||||
int listLength = this.getSize();
|
||||
int scrollBarXStart = this.left + this.listWidth - 6;
|
||||
int scrollBarXEnd = scrollBarXStart + 6;
|
||||
int boxLeft = this.left;
|
||||
int boxRight = scrollBarXStart-1;
|
||||
int var10;
|
||||
int var11;
|
||||
int var13;
|
||||
int var19;
|
||||
|
||||
if (Mouse.isButtonDown(0))
|
||||
{
|
||||
if (this.initialMouseClickY == -1.0F)
|
||||
{
|
||||
boolean var7 = true;
|
||||
|
||||
if (mouseY >= this.top && mouseY <= this.bottom)
|
||||
{
|
||||
var10 = mouseY - this.top - this.field_27261_r + (int)this.scrollDistance - 4;
|
||||
var11 = var10 / this.slotHeight;
|
||||
|
||||
if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength)
|
||||
{
|
||||
boolean var12 = var11 == this.selectedIndex && System.currentTimeMillis() - this.lastClickTime < 250L;
|
||||
this.elementClicked(var11, var12);
|
||||
this.selectedIndex = var11;
|
||||
this.lastClickTime = System.currentTimeMillis();
|
||||
}
|
||||
else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0)
|
||||
{
|
||||
this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int)this.scrollDistance - 4);
|
||||
var7 = false;
|
||||
}
|
||||
|
||||
if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd)
|
||||
{
|
||||
this.scrollFactor = -1.0F;
|
||||
var19 = this.getContentHeight() - (this.bottom - this.top - 4);
|
||||
|
||||
if (var19 < 1)
|
||||
{
|
||||
var19 = 1;
|
||||
}
|
||||
|
||||
var13 = (int)((float)((this.bottom - this.top) * (this.bottom - this.top)) / (float)this.getContentHeight());
|
||||
|
||||
if (var13 < 32)
|
||||
{
|
||||
var13 = 32;
|
||||
}
|
||||
|
||||
if (var13 > this.bottom - this.top - 8)
|
||||
{
|
||||
var13 = this.bottom - this.top - 8;
|
||||
}
|
||||
|
||||
this.scrollFactor /= (float)(this.bottom - this.top - var13) / (float)var19;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.scrollFactor = 1.0F;
|
||||
}
|
||||
|
||||
if (var7)
|
||||
{
|
||||
this.initialMouseClickY = (float)mouseY;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.initialMouseClickY = -2.0F;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.initialMouseClickY = -2.0F;
|
||||
}
|
||||
}
|
||||
else if (this.initialMouseClickY >= 0.0F)
|
||||
{
|
||||
this.scrollDistance -= ((float)mouseY - this.initialMouseClickY) * this.scrollFactor;
|
||||
this.initialMouseClickY = (float)mouseY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (Mouse.next())
|
||||
{
|
||||
int var16 = Mouse.getEventDWheel();
|
||||
|
||||
if (var16 != 0)
|
||||
{
|
||||
if (var16 > 0)
|
||||
{
|
||||
var16 = -1;
|
||||
}
|
||||
else if (var16 < 0)
|
||||
{
|
||||
var16 = 1;
|
||||
}
|
||||
|
||||
this.scrollDistance += (float)(var16 * this.slotHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
this.initialMouseClickY = -1.0F;
|
||||
}
|
||||
|
||||
this.applyScrollLimits();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_FOG);
|
||||
Tessellator var18 = Tessellator.field_1512_a;
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_6315_n.func_1070_a("/gui/background.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
float var17 = 32.0F;
|
||||
var18.func_977_b();
|
||||
var18.func_990_b(2105376);
|
||||
var18.func_983_a((double)this.left, (double)this.bottom, 0.0D, (double)((float)this.left / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
|
||||
var18.func_983_a((double)this.right, (double)this.bottom, 0.0D, (double)((float)this.right / var17), (double)((float)(this.bottom + (int)this.scrollDistance) / var17));
|
||||
var18.func_983_a((double)this.right, (double)this.top, 0.0D, (double)((float)this.right / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
|
||||
var18.func_983_a((double)this.left, (double)this.top, 0.0D, (double)((float)this.left / var17), (double)((float)(this.top + (int)this.scrollDistance) / var17));
|
||||
var18.func_982_a();
|
||||
// boxRight = this.listWidth / 2 - 92 - 16;
|
||||
var10 = this.top + 4 - (int)this.scrollDistance;
|
||||
|
||||
if (this.field_27262_q)
|
||||
{
|
||||
this.func_27260_a(boxRight, var10, var18);
|
||||
}
|
||||
|
||||
int var14;
|
||||
|
||||
for (var11 = 0; var11 < listLength; ++var11)
|
||||
{
|
||||
var19 = var10 + var11 * this.slotHeight + this.field_27261_r;
|
||||
var13 = this.slotHeight - 4;
|
||||
|
||||
if (var19 <= this.bottom && var19 + var13 >= this.top)
|
||||
{
|
||||
if (this.field_25123_p && this.isSelected(var11))
|
||||
{
|
||||
var14 = boxLeft;
|
||||
int var15 = boxRight;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
var18.func_977_b();
|
||||
var18.func_990_b(8421504);
|
||||
var18.func_983_a((double)var14, (double)(var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
|
||||
var18.func_983_a((double)var15, (double)(var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
|
||||
var18.func_983_a((double)var15, (double)(var19 - 2), 0.0D, 1.0D, 0.0D);
|
||||
var18.func_983_a((double)var14, (double)(var19 - 2), 0.0D, 0.0D, 0.0D);
|
||||
var18.func_990_b(0);
|
||||
var18.func_983_a((double)(var14 + 1), (double)(var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
|
||||
var18.func_983_a((double)(var15 - 1), (double)(var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
|
||||
var18.func_983_a((double)(var15 - 1), (double)(var19 - 1), 0.0D, 1.0D, 0.0D);
|
||||
var18.func_983_a((double)(var14 + 1), (double)(var19 - 1), 0.0D, 0.0D, 0.0D);
|
||||
var18.func_982_a();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
this.drawSlot(var11, boxRight, var19, var13, var18);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
byte var20 = 4;
|
||||
this.overlayBackground(0, this.top, 255, 255);
|
||||
this.overlayBackground(this.bottom, this.listHeight, 255, 255);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
var18.func_977_b();
|
||||
var18.func_6513_a(0, 0);
|
||||
var18.func_983_a((double)this.left, (double)(this.top + var20), 0.0D, 0.0D, 1.0D);
|
||||
var18.func_983_a((double)this.right, (double)(this.top + var20), 0.0D, 1.0D, 1.0D);
|
||||
var18.func_6513_a(0, 255);
|
||||
var18.func_983_a((double)this.right, (double)this.top, 0.0D, 1.0D, 0.0D);
|
||||
var18.func_983_a((double)this.left, (double)this.top, 0.0D, 0.0D, 0.0D);
|
||||
var18.func_982_a();
|
||||
var18.func_977_b();
|
||||
var18.func_6513_a(0, 255);
|
||||
var18.func_983_a((double)this.left, (double)this.bottom, 0.0D, 0.0D, 1.0D);
|
||||
var18.func_983_a((double)this.right, (double)this.bottom, 0.0D, 1.0D, 1.0D);
|
||||
var18.func_6513_a(0, 0);
|
||||
var18.func_983_a((double)this.right, (double)(this.bottom - var20), 0.0D, 1.0D, 0.0D);
|
||||
var18.func_983_a((double)this.left, (double)(this.bottom - var20), 0.0D, 0.0D, 0.0D);
|
||||
var18.func_982_a();
|
||||
var19 = this.getContentHeight() - (this.bottom - this.top - 4);
|
||||
|
||||
if (var19 > 0)
|
||||
{
|
||||
var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();
|
||||
|
||||
if (var13 < 32)
|
||||
{
|
||||
var13 = 32;
|
||||
}
|
||||
|
||||
if (var13 > this.bottom - this.top - 8)
|
||||
{
|
||||
var13 = this.bottom - this.top - 8;
|
||||
}
|
||||
|
||||
var14 = (int)this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top;
|
||||
|
||||
if (var14 < this.top)
|
||||
{
|
||||
var14 = this.top;
|
||||
}
|
||||
|
||||
var18.func_977_b();
|
||||
var18.func_6513_a(0, 255);
|
||||
var18.func_983_a((double)scrollBarXStart, (double)this.bottom, 0.0D, 0.0D, 1.0D);
|
||||
var18.func_983_a((double)scrollBarXEnd, (double)this.bottom, 0.0D, 1.0D, 1.0D);
|
||||
var18.func_983_a((double)scrollBarXEnd, (double)this.top, 0.0D, 1.0D, 0.0D);
|
||||
var18.func_983_a((double)scrollBarXStart, (double)this.top, 0.0D, 0.0D, 0.0D);
|
||||
var18.func_982_a();
|
||||
var18.func_977_b();
|
||||
var18.func_6513_a(8421504, 255);
|
||||
var18.func_983_a((double)scrollBarXStart, (double)(var14 + var13), 0.0D, 0.0D, 1.0D);
|
||||
var18.func_983_a((double)scrollBarXEnd, (double)(var14 + var13), 0.0D, 1.0D, 1.0D);
|
||||
var18.func_983_a((double)scrollBarXEnd, (double)var14, 0.0D, 1.0D, 0.0D);
|
||||
var18.func_983_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
|
||||
var18.func_982_a();
|
||||
var18.func_977_b();
|
||||
var18.func_6513_a(12632256, 255);
|
||||
var18.func_983_a((double)scrollBarXStart, (double)(var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
|
||||
var18.func_983_a((double)(scrollBarXEnd - 1), (double)(var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
|
||||
var18.func_983_a((double)(scrollBarXEnd - 1), (double)var14, 0.0D, 1.0D, 0.0D);
|
||||
var18.func_983_a((double)scrollBarXStart, (double)var14, 0.0D, 0.0D, 0.0D);
|
||||
var18.func_982_a();
|
||||
}
|
||||
|
||||
this.func_27257_b(mouseX, mouseY);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
private void overlayBackground(int p_22239_1_, int p_22239_2_, int p_22239_3_, int p_22239_4_)
|
||||
{
|
||||
Tessellator var5 = Tessellator.field_1512_a;
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.client.field_6315_n.func_1070_a("/gui/background.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
float var6 = 32.0F;
|
||||
var5.func_977_b();
|
||||
var5.func_6513_a(4210752, p_22239_4_);
|
||||
var5.func_983_a(0.0D, (double)p_22239_2_, 0.0D, 0.0D, (double)((float)p_22239_2_ / var6));
|
||||
var5.func_983_a((double)this.listWidth + 30, (double)p_22239_2_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_2_ / var6));
|
||||
var5.func_6513_a(4210752, p_22239_3_);
|
||||
var5.func_983_a((double)this.listWidth + 30, (double)p_22239_1_, 0.0D, (double)((float)(this.listWidth + 30) / var6), (double)((float)p_22239_1_ / var6));
|
||||
var5.func_983_a(0.0D, (double)p_22239_1_, 0.0D, 0.0D, (double)((float)p_22239_1_ / var6));
|
||||
var5.func_982_a();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.GuiLanguage;
|
||||
import net.minecraft.src.GuiSlot;
|
||||
import net.minecraft.src.StringTranslate;
|
||||
import net.minecraft.src.Tessellator;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class GuiSlotModList extends GuiScrollingList
|
||||
{
|
||||
private GuiModList parent;
|
||||
private ArrayList<ModContainer> mods;
|
||||
|
||||
public GuiSlotModList(GuiModList parent, ArrayList<ModContainer> mods, int listWidth)
|
||||
{
|
||||
super(parent.getMinecraftInstance(), listWidth, parent.field_950_d, 32, parent.field_950_d - 65 + 4, 10, 35);
|
||||
this.parent=parent;
|
||||
this.mods=mods;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize()
|
||||
{
|
||||
return mods.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void elementClicked(int var1, boolean var2)
|
||||
{
|
||||
this.parent.selectModIndex(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSelected(int var1)
|
||||
{
|
||||
return this.parent.modIndexSelected(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground()
|
||||
{
|
||||
this.parent.func_578_i();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentHeight()
|
||||
{
|
||||
return (this.getSize()) * 35 + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
|
||||
{
|
||||
ModContainer mc=mods.get(listIndex);
|
||||
this.parent.getFontRenderer().func_873_b(this.parent.getFontRenderer().func_50107_a(mc.getName(), listWidth - 11), this.left + 3 , var3 + 2, 0xFFFFFF);
|
||||
this.parent.getFontRenderer().func_873_b(this.parent.getFontRenderer().func_50107_a(mc.getVersion(), listWidth - 11), this.left + 3 , var3 + 12, 0xCCCCCC);
|
||||
this.parent.getFontRenderer().func_873_b(this.parent.getFontRenderer().func_50107_a(mc.getMetadata() !=null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 9), this.left + 3 , var3 + 22, 0xCCCCCC);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.awt.Dimension;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public interface ITextureFX
|
||||
{
|
||||
public void onTexturePackChanged(RenderEngine engine, TexturePackBase texturepack, Dimension dimensions);
|
||||
|
||||
public void onTextureDimensionsUpdate(int width, int height);
|
||||
|
||||
public void setErrored(boolean errored);
|
||||
|
||||
public boolean getErrored();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import net.minecraft.src.KeyBinding;
|
||||
import cpw.mods.fml.common.IKeyHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class KeyBindingHandler implements IKeyHandler
|
||||
{
|
||||
|
||||
private boolean shouldRepeat;
|
||||
private KeyBinding keyBinding;
|
||||
private ModContainer modContainer;
|
||||
private boolean lastState = false;
|
||||
|
||||
/**
|
||||
* @param keyHandler
|
||||
* @param allowRepeat
|
||||
* @param modContainer
|
||||
*/
|
||||
public KeyBindingHandler(KeyBinding keyHandler, boolean allowRepeat, ModContainer modContainer)
|
||||
{
|
||||
this.keyBinding=keyHandler;
|
||||
this.shouldRepeat=allowRepeat;
|
||||
this.modContainer=modContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyBinding()
|
||||
{
|
||||
return this.keyBinding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modContainer
|
||||
*/
|
||||
public ModContainer getOwningContainer()
|
||||
{
|
||||
return modContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEndTick()
|
||||
{
|
||||
int keyCode = keyBinding.field_1370_b;
|
||||
boolean state = (keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode));
|
||||
if (state && (!lastState || (lastState && shouldRepeat)))
|
||||
{
|
||||
modContainer.keyBindEvent(keyBinding);
|
||||
}
|
||||
lastState = state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cpw.mods.fml.common.FMLModContainer;
|
||||
import cpw.mods.fml.common.IConsoleHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IDispenseHandler;
|
||||
import cpw.mods.fml.common.IKeyHandler;
|
||||
import cpw.mods.fml.common.INetworkHandler;
|
||||
import cpw.mods.fml.common.IPickupNotifier;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class OptifineModContainer extends FMLModContainer
|
||||
{
|
||||
private String optifineVersion;
|
||||
private ModMetadata metadata;
|
||||
/**
|
||||
* @param optifineConfig
|
||||
*/
|
||||
public OptifineModContainer(Class<?> optifineConfig)
|
||||
{
|
||||
super("Optifine");
|
||||
try
|
||||
{
|
||||
optifineVersion = (String) optifineConfig.getField("VERSION").get(null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Optifine";
|
||||
}
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
return optifineVersion;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import net.minecraft.src.TextureFX;
|
||||
|
||||
class OverrideInfo
|
||||
{
|
||||
public String texture;
|
||||
public String override;
|
||||
public int index;
|
||||
public int imageIndex;
|
||||
public TextureFX textureFX;
|
||||
public boolean added;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
try {
|
||||
OverrideInfo inf=(OverrideInfo) obj;
|
||||
return index==inf.index && imageIndex==inf.imageIndex;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return index+imageIndex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.client;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.src.ModLoader;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class SpriteHelper
|
||||
{
|
||||
private static HashMap<String, BitSet> spriteInfo = new HashMap<String, BitSet>();
|
||||
|
||||
private static void initMCSpriteMaps() {
|
||||
BitSet slots =
|
||||
SpriteHelper.toBitSet(
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000011111100" +
|
||||
"0000000011111111" +
|
||||
"0000000011111000" +
|
||||
"0000000111111100" +
|
||||
"0000000111111000" +
|
||||
"0000000000000000");
|
||||
spriteInfo.put("/terrain.png", slots);
|
||||
|
||||
slots = SpriteHelper.toBitSet(
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000000000000000" +
|
||||
"0000001000000000" +
|
||||
"0000001110000000" +
|
||||
"0000001000000000" +
|
||||
"1111111010000000" +
|
||||
"1111111010100000" +
|
||||
"1111111111111100" +
|
||||
"1111111111111111" +
|
||||
"1111111111111111" +
|
||||
"1111111111111111" +
|
||||
"0000000000000000");
|
||||
spriteInfo.put("/gui/items.png", slots);
|
||||
}
|
||||
/**
|
||||
* Register a sprite map for ModTextureStatic, to allow for other mods to override
|
||||
* your sprite page.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static void registerSpriteMapForFile(String file, String spriteMap) {
|
||||
if (spriteInfo.size() == 0) {
|
||||
initMCSpriteMaps();
|
||||
}
|
||||
if (spriteInfo.containsKey(file)) {
|
||||
FMLCommonHandler.instance().getFMLLogger().finer(String.format("Duplicate attempt to register a sprite file %s for overriding -- ignoring",file));
|
||||
return;
|
||||
}
|
||||
spriteInfo.put(file, toBitSet(spriteMap));
|
||||
}
|
||||
|
||||
public static int getUniqueSpriteIndex(String path)
|
||||
{
|
||||
if (!spriteInfo.containsKey("/terrain.png"))
|
||||
{
|
||||
initMCSpriteMaps();
|
||||
}
|
||||
|
||||
BitSet slots = spriteInfo.get(path);
|
||||
|
||||
if (slots == null)
|
||||
{
|
||||
Exception ex = new Exception(String.format("Invalid getUniqueSpriteIndex call for texture: %s", path));
|
||||
Loader.log.throwing("ModLoader", "getUniqueSpriteIndex", ex);
|
||||
FMLCommonHandler.instance().raiseException(ex,"Invalid request to getUniqueSpriteIndex",true);
|
||||
}
|
||||
|
||||
int ret = getFreeSlot(slots);
|
||||
|
||||
if (ret == -1)
|
||||
{
|
||||
Exception ex = new Exception(String.format("No more sprite indicies left for: %s", path));
|
||||
Loader.log.throwing("ModLoader", "getUniqueSpriteIndex", ex);
|
||||
FMLCommonHandler.instance().raiseException(ex,"No more sprite indicies left", true);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static BitSet toBitSet(String data)
|
||||
{
|
||||
BitSet ret = new BitSet(data.length());
|
||||
for (int x = 0; x < data.length(); x++)
|
||||
{
|
||||
ret.set(x, data.charAt(x) == '1');
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int getFreeSlot(BitSet slots)
|
||||
{
|
||||
int next=slots.nextSetBit(0);
|
||||
slots.clear(next);
|
||||
return next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param textureToOverride
|
||||
* @return
|
||||
*/
|
||||
public static int freeSlotCount(String textureToOverride)
|
||||
{
|
||||
return spriteInfo.get(textureToOverride).cardinality();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.IConsoleHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IDispenseHandler;
|
||||
import cpw.mods.fml.common.INetworkHandler;
|
||||
import cpw.mods.fml.common.IPickupNotifier;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public abstract class BaseMod implements cpw.mods.fml.common.modloader.BaseMod
|
||||
{
|
||||
// CALLBACK MECHANISMS
|
||||
|
||||
public void keyBindingEvent(Object keybinding)
|
||||
{
|
||||
this.keyboardEvent((KeyBinding)keybinding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param minecraftInstance
|
||||
* @return
|
||||
*/
|
||||
public final boolean doTickInGame(TickType tick, boolean tickEnd, Object minecraftInstance, Object... data)
|
||||
{
|
||||
Minecraft mc = (Minecraft) minecraftInstance;
|
||||
boolean hasWorld = mc.field_6324_e != null;
|
||||
// World and render ticks
|
||||
if (tickEnd && ( tick==TickType.RENDER || tick==TickType.GAME ) && hasWorld) {
|
||||
return onTickInGame((Float) data[0], mc);
|
||||
} else if (tickEnd && (tick==TickType.WORLDGUI || tick==TickType.GUI) && data[1]!=null) {
|
||||
return onTickInGUI((Float) data[0], mc, (GuiScreen)data[1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderers
|
||||
*/
|
||||
public final void onRenderHarvest(Map renderers)
|
||||
{
|
||||
addRenderer((Map<Class<? extends Entity>,Render>)renderers);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final void onRegisterAnimations()
|
||||
{
|
||||
registerAnimation(FMLClientHandler.instance().getClient());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCrafting(Object... craftingParameters)
|
||||
{
|
||||
takenFromCrafting((EntityPlayer)craftingParameters[0], (ItemStack)craftingParameters[1], (IInventory)craftingParameters[2]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onSmelting(Object... smeltingParameters)
|
||||
{
|
||||
takenFromFurnace((EntityPlayer)smeltingParameters[0], (ItemStack)smeltingParameters[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean dispense(double x, double y, double z, byte xVelocity, byte zVelocity, Object... data)
|
||||
{
|
||||
return dispenseEntity((World)data[0], x, y, z, xVelocity, zVelocity, (ItemStack)data[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onChat(Object... data)
|
||||
{
|
||||
receiveChatPacket(((Packet3Chat)data[0]).field_517_a);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void onServerLogin(Object handler) {
|
||||
serverConnect((NetClientHandler) handler);
|
||||
}
|
||||
|
||||
public final void onServerLogout() {
|
||||
serverDisconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerLogin(Object player)
|
||||
{
|
||||
onClientLogin((EntityPlayer) player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerLogout(Object player)
|
||||
{
|
||||
onClientLogout((EntityPlayer)player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPlayerChangedDimension(Object player)
|
||||
{
|
||||
onClientDimensionChanged((EntityPlayer)player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onPacket250Packet(Object... data)
|
||||
{
|
||||
receiveCustomPacket((Packet250CustomPayload)data[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void notifyPickup(Object... pickupData)
|
||||
{
|
||||
EntityItem item = (EntityItem) pickupData[0];
|
||||
EntityPlayer player = (EntityPlayer) pickupData[1];
|
||||
onItemPickup(player, item.field_801_a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void generate(Random random, int chunkX, int chunkZ, Object... additionalData)
|
||||
{
|
||||
World w = (World) additionalData[0];
|
||||
IChunkProvider cp = (IChunkProvider) additionalData[1];
|
||||
|
||||
if (cp instanceof ChunkProviderGenerate)
|
||||
{
|
||||
generateSurface(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
else if (cp instanceof ChunkProviderHell)
|
||||
{
|
||||
generateNether(w, random, chunkX << 4, chunkZ << 4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NO-OP on client side
|
||||
*/
|
||||
@Override
|
||||
public final boolean handleCommand(String command, Object... data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// BASEMOD API
|
||||
/**
|
||||
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
|
||||
*
|
||||
* @param id
|
||||
* @param metadata
|
||||
* @return
|
||||
*/
|
||||
public int addFuel(int id, int metadata)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void addRenderer(Map<Class<? extends Entity>, Render> renderers)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if you wish to perform some action other than just dispensing the item from the dispenser
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param xVel
|
||||
* @param zVel
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
public boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if you wish to generate Nether (Hell biome) blocks
|
||||
*
|
||||
* @param world
|
||||
* @param random
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
*/
|
||||
public void generateNether(World world, Random random, int chunkX, int chunkZ)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if you wish to generate Overworld (not hell or the end) blocks
|
||||
*
|
||||
* @param world
|
||||
* @param random
|
||||
* @param chunkX
|
||||
* @param chunkZ
|
||||
*/
|
||||
public void generateSurface(World world, Random random, int chunkX, int chunkZ)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of your mod. Defaults to the class name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get your mod priorities
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPriorities()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the version of your mod
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract String getVersion();
|
||||
|
||||
public void keyboardEvent(KeyBinding event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load your mod
|
||||
*/
|
||||
public abstract void load();
|
||||
|
||||
/**
|
||||
* Finish loading your mod
|
||||
*/
|
||||
public void modsLoaded()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle item pickup
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void onItemPickup(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticked every game tick if you have subscribed to tick events through {@link ModLoader#setInGameHook(BaseMod, boolean, boolean)}
|
||||
*
|
||||
* @param time the rendering subtick time (0.0-1.0)
|
||||
* @param minecraftInstance the client
|
||||
* @return true to continue receiving ticks
|
||||
*/
|
||||
public boolean onTickInGame(float time, Minecraft minecraftInstance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onTickInGUI(float tick, Minecraft game, GuiScreen gui)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only implemented on the client side
|
||||
* {@link #onChatMessageReceived(EntityPlayer, Packet3Chat)}
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
public void receiveChatPacket(String text)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Only called on the client side
|
||||
* {@link #onPacket250Received(EntityPlayer, Packet250CustomPayload)}
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
public void receiveCustomPacket(Packet250CustomPayload packet)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
public void registerAnimation(Minecraft game)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public void serverConnect(NetClientHandler handler) {
|
||||
|
||||
}
|
||||
|
||||
public void serverDisconnect() {
|
||||
|
||||
}
|
||||
/**
|
||||
* Called when someone crafts an item from a crafting table
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
* @param matrix
|
||||
*/
|
||||
public void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when someone takes a smelted item from a furnace
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void takenFromFurnace(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* The identifier string for the mod- used in client<->server negotiation
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getName() + " " + getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a 250 packet is received on a channel registered to this mod
|
||||
*
|
||||
* @param source
|
||||
* @param payload
|
||||
*/
|
||||
public void onPacket250Received(EntityPlayer source, Packet250CustomPayload payload)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a chat message is received. Return true to stop further processing
|
||||
*
|
||||
* @param source
|
||||
* @param chat
|
||||
* @return true if you want to consume the message so it is not available for further processing
|
||||
*/
|
||||
public boolean onChatMessageReceived(EntityPlayer source, Packet3Chat chat)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Called when a server command is received
|
||||
* @param command
|
||||
* @return true if you want to consume the message so it is not available for further processing
|
||||
*/
|
||||
public boolean onServerCommand(String command, String sender, Object listener)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a new client logs in.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientLogin(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a client logs out of the server.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientLogout(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Called when a client changes dimensions on the server.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void onClientDimensionChanged(EntityPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.registry.FMLRegistry;
|
||||
import cpw.mods.fml.common.registry.IMinecraftRegistry;
|
||||
|
||||
public class ClientRegistry implements IMinecraftRegistry
|
||||
{
|
||||
|
||||
public static ClientRegistry instance() {
|
||||
return (ClientRegistry) FMLRegistry.instance();
|
||||
}
|
||||
@Override
|
||||
public void addRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
CraftingManager.func_1120_a().func_1121_a(output, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addShapelessRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
CraftingManager.func_1120_a().func_21187_b(output, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRecipe(IRecipe recipe)
|
||||
{
|
||||
CraftingManager.func_1120_a().func_25193_b().add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSmelting(int input, ItemStack output)
|
||||
{
|
||||
FurnaceRecipes.func_21200_a().func_21199_a(input, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlock(Block block)
|
||||
{
|
||||
registerBlock(block, ItemBlock.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlock(Block block, Class <? extends ItemBlock > itemclass)
|
||||
{
|
||||
try
|
||||
{
|
||||
assert block != null : "registerBlock: block cannot be null";
|
||||
assert itemclass != null : "registerBlock: itemclass cannot be null";
|
||||
int blockItemId = block.field_376_bc - 256;
|
||||
itemclass.getConstructor(int.class).newInstance(blockItemId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//HMMM
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEntityID(Class <? extends Entity > entityClass, String entityName, int id)
|
||||
{
|
||||
EntityList.addNewEntityListMapping(entityClass, entityName, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEntityID(Class <? extends Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
|
||||
{
|
||||
EntityList.addNewEntityListMapping(entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTileEntity(Class <? extends TileEntity > tileEntityClass, String id)
|
||||
{
|
||||
TileEntity.addNewTileEntityMapping(tileEntityClass, id);
|
||||
}
|
||||
|
||||
public void registerTileEntity(Class <? extends TileEntity > tileEntityClass, String id, TileEntitySpecialRenderer specialRenderer)
|
||||
{
|
||||
registerTileEntity(tileEntityClass, id);
|
||||
TileEntityRenderer.setTileEntityRenderer(tileEntityClass, specialRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBiome(BiomeGenBase biome)
|
||||
{
|
||||
FMLClientHandler.instance().addBiomeToDefaultWorldGenerator(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpawn(Class <? extends EntityLiving > entityClass, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
|
||||
{
|
||||
for (BiomeGenBase biome : biomes)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<SpawnListEntry> spawns = biome.func_25063_a(typeOfCreature);
|
||||
|
||||
for (SpawnListEntry entry : spawns)
|
||||
{
|
||||
//Adjusting an existing spawn entry
|
||||
if (entry.field_25212_a == entityClass)
|
||||
{
|
||||
entry.field_35590_d = weightedProb;
|
||||
entry.field_35591_b = min;
|
||||
entry.field_35592_c = max;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spawns.add(new SpawnListEntry(entityClass, weightedProb, min, max));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
Class <? extends Entity > entityClazz = EntityList.getEntityToClassMapping().get(entityName);
|
||||
|
||||
if (EntityLiving.class.isAssignableFrom(entityClazz))
|
||||
{
|
||||
addSpawn((Class <? extends EntityLiving >) entityClazz, weightedProb, min, max, spawnList, biomes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBiome(BiomeGenBase biome)
|
||||
{
|
||||
FMLClientHandler.instance().removeBiomeFromDefaultWorldGenerator(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSpawn(Class <? extends EntityLiving > entityClass, EnumCreatureType typeOfCreature, BiomeGenBase... biomes)
|
||||
{
|
||||
for (BiomeGenBase biome : biomes)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<SpawnListEntry> spawns = biome.func_25063_a(typeOfCreature).iterator();
|
||||
|
||||
while (spawns.hasNext())
|
||||
{
|
||||
SpawnListEntry entry = spawns.next();
|
||||
if (entry.field_25212_a == entityClass)
|
||||
{
|
||||
spawns.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
Class <? extends Entity > entityClazz = EntityList.getEntityToClassMapping().get(entityName);
|
||||
|
||||
if (EntityLiving.class.isAssignableFrom(entityClazz))
|
||||
{
|
||||
removeSpawn((Class <? extends EntityLiving >) entityClazz, spawnList, biomes);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class EntityRendererProxy extends EntityRenderer
|
||||
{
|
||||
|
||||
private Minecraft game;
|
||||
|
||||
public EntityRendererProxy(Minecraft minecraft)
|
||||
{
|
||||
super(minecraft);
|
||||
game = minecraft;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_4136_b(float tick)
|
||||
{
|
||||
super.func_4136_b(tick);
|
||||
//This is where ModLoader does all of it's ticking
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
* A static hook library for optifine and other basemod editing code to access FML functions
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class FMLRenderAccessLibrary
|
||||
{
|
||||
public static Logger getLogger()
|
||||
{
|
||||
return FMLCommonHandler.instance().getFMLLogger();
|
||||
}
|
||||
|
||||
public static void log(Level level, String message)
|
||||
{
|
||||
getLogger().log(level, message);
|
||||
}
|
||||
|
||||
public static void log(Level level, String message, Throwable throwable)
|
||||
{
|
||||
getLogger().log(level, message, throwable);
|
||||
}
|
||||
|
||||
public static void setTextureDimensions(int textureId, int width, int height, List<TextureFX> textureFXList)
|
||||
{
|
||||
FMLClientHandler.instance().setTextureDimensions(textureId, width, height, textureFXList);
|
||||
}
|
||||
|
||||
public static void preRegisterEffect(TextureFX textureFX)
|
||||
{
|
||||
FMLClientHandler.instance().onPreRegisterEffect(textureFX);
|
||||
}
|
||||
|
||||
public static boolean onUpdateTextureEffect(TextureFX textureFX)
|
||||
{
|
||||
return FMLClientHandler.instance().onUpdateTextureEffect(textureFX);
|
||||
}
|
||||
|
||||
public static Dimension getTextureDimensions(TextureFX textureFX)
|
||||
{
|
||||
return FMLClientHandler.instance().getTextureDimensions(textureFX);
|
||||
}
|
||||
|
||||
public static void onTexturePackChange(RenderEngine engine, TexturePackBase texturePack, List<TextureFX> textureFXList)
|
||||
{
|
||||
FMLClientHandler.instance().onTexturePackChange(engine, texturePack, textureFXList);
|
||||
}
|
||||
|
||||
public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelId)
|
||||
{
|
||||
return FMLClientHandler.instance().renderWorldBlock(renderer, world, x, y, z, block, modelId);
|
||||
}
|
||||
|
||||
public static void renderInventoryBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
FMLClientHandler.instance().renderInventoryBlock(renderer, block, metadata, modelID);
|
||||
}
|
||||
|
||||
public static boolean renderItemAsFull3DBlock(int modelId)
|
||||
{
|
||||
return FMLClientHandler.instance().renderItemAsFull3DBlock(modelId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
import static java.lang.annotation.RetentionPolicy.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(value = RUNTIME)
|
||||
@Target(value = FIELD)
|
||||
public @interface MLProp
|
||||
{
|
||||
/**
|
||||
* Adds additional help to top of configuration file.
|
||||
*/
|
||||
String info() default "";
|
||||
|
||||
/**
|
||||
* Maximum value allowed if field is a number.
|
||||
*/
|
||||
double max() default Double.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Minimum value allowed if field is a number.
|
||||
*/
|
||||
double min() default Double.MIN_VALUE;
|
||||
|
||||
/**
|
||||
* Overrides the field name for property key.
|
||||
*/
|
||||
String name() default "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,794 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.SpriteHelper;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ReflectionHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderHelper;
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
import cpw.mods.fml.common.registry.FMLRegistry;
|
||||
|
||||
public class ModLoader
|
||||
{
|
||||
// TODO dirty workaround for millinaire
|
||||
@Deprecated
|
||||
public static final Map<String,Map<String,String>> localizedStrings=Collections.emptyMap();
|
||||
/**
|
||||
* Not used on the server.
|
||||
*
|
||||
* @param achievement
|
||||
* @param name
|
||||
* @param description
|
||||
*/
|
||||
public static void addAchievementDesc(Achievement achievement, String name, String description)
|
||||
{
|
||||
String achName=achievement.func_44020_i();
|
||||
addLocalization(achName, name);
|
||||
addLocalization(achName+".desc", description);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
*
|
||||
* {@link FMLCommonHandler#fuelLookup(int, int)}
|
||||
*
|
||||
* @param id
|
||||
* @param metadata
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static int addAllFuel(int id, int metadata)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addAllRenderers(Map<Class<? extends Entity>, Render> renderers)
|
||||
{
|
||||
}
|
||||
|
||||
public static void addAnimation(TextureFX anim)
|
||||
{
|
||||
FMLClientHandler.instance().addAnimation(anim);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is unimplemented in server versions to date.
|
||||
*
|
||||
* @param armor
|
||||
* @return
|
||||
*/
|
||||
public static int addArmor(String armor)
|
||||
{
|
||||
return FMLClientHandler.instance().addNewArmourRendererPrefix(armor);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds the supplied biome to the set of candidate biomes for the default world generator type.
|
||||
*
|
||||
* @param biome
|
||||
*/
|
||||
public static void addBiome(BiomeGenBase biome)
|
||||
{
|
||||
FMLClientHandler.instance().addBiomeToDefaultWorldGenerator(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add localization for the specified string
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public static void addLocalization(String key, String value)
|
||||
{
|
||||
addLocalization(key, "en_US", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add localization for the specified string
|
||||
*
|
||||
* @param key
|
||||
* @param lang
|
||||
* @param value
|
||||
*/
|
||||
public static void addLocalization(String key, String lang, String value)
|
||||
{
|
||||
FMLCommonHandler.instance().addStringLocalization(key, lang, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Name the specified minecraft object with the supplied name
|
||||
*
|
||||
* @param instance
|
||||
* @param name
|
||||
*/
|
||||
public static void addName(Object instance, String name)
|
||||
{
|
||||
addName(instance,"en_US",name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unimplemented on the server as it does not generate names
|
||||
*
|
||||
* @param instance
|
||||
* @param lang
|
||||
* @param name
|
||||
*/
|
||||
public static void addName(Object instance, String lang, String name)
|
||||
{
|
||||
FMLCommonHandler.instance().addNameForObject(instance, lang, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unimplemented on the server as it does not render textures
|
||||
*
|
||||
* @param fileToOverride
|
||||
* @param fileToAdd
|
||||
* @return
|
||||
*/
|
||||
public static int addOverride(String fileToOverride, String fileToAdd)
|
||||
{
|
||||
int idx = SpriteHelper.getUniqueSpriteIndex(fileToOverride);
|
||||
addOverride(fileToOverride, fileToAdd, idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unimplemented on the server as it does not render textures
|
||||
*
|
||||
* @param path
|
||||
* @param overlayPath
|
||||
* @param index
|
||||
*/
|
||||
public static void addOverride(String path, String overlayPath, int index)
|
||||
{
|
||||
FMLClientHandler.instance().addNewTextureOverride(path, overlayPath, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Shaped Recipe
|
||||
*
|
||||
* @param output
|
||||
* @param params
|
||||
*/
|
||||
public static void addRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
FMLRegistry.addRecipe(output, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a shapeless recipe
|
||||
*
|
||||
* @param output
|
||||
* @param params
|
||||
*/
|
||||
public static void addShapelessRecipe(ItemStack output, Object... params)
|
||||
{
|
||||
FMLRegistry.addShapelessRecipe(output, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new product to be smelted
|
||||
*
|
||||
* @param input
|
||||
* @param output
|
||||
*/
|
||||
public static void addSmelting(int input, ItemStack output)
|
||||
{
|
||||
FMLRegistry.addSmelting(input, output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
*
|
||||
* @param entityClass
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
* @param max
|
||||
* @param spawnList
|
||||
*/
|
||||
public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList)
|
||||
{
|
||||
FMLRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
*
|
||||
* @param entityClass
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
* @param max
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
*/
|
||||
public static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
FMLRegistry.addSpawn(entityClass, weightedProb, min, max, spawnList, biomes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
*
|
||||
* @param entityName
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
* @param max
|
||||
* @param spawnList
|
||||
*/
|
||||
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList)
|
||||
{
|
||||
FMLRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a mob to the spawn list
|
||||
*
|
||||
* @param entityName
|
||||
* @param weightedProb
|
||||
* @param min
|
||||
* @param max
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
*/
|
||||
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
FMLRegistry.addSpawn(entityName, weightedProb, min, max, spawnList, biomes);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLClientHandler#tryDispensingEntity(World, double, double, double, byte, byte, ItemStack)}
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param xVel
|
||||
* @param zVel
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a container and drop all the items in it on the ground around
|
||||
*
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
public static void genericContainerRemoval(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity te = world.func_603_b(x, y, z);
|
||||
|
||||
if (!(te instanceof IInventory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IInventory inv = (IInventory)te;
|
||||
|
||||
for (int l = 0; l < inv.func_469_c(); l++)
|
||||
{
|
||||
ItemStack itemstack = inv.func_468_c(l);
|
||||
|
||||
if (itemstack == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float f = world.field_1037_n.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = world.field_1037_n.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = world.field_1037_n.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.field_1615_a > 0)
|
||||
{
|
||||
int i1 = world.field_1037_n.nextInt(21) + 10;
|
||||
|
||||
if (i1 > itemstack.field_1615_a)
|
||||
{
|
||||
i1 = itemstack.field_1615_a;
|
||||
}
|
||||
|
||||
itemstack.field_1615_a -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (float)te.field_823_f + f, (float)te.field_822_g + f1, (float)te.field_821_h + f2, new ItemStack(itemstack.field_1617_c, i1, itemstack.func_21181_i()));
|
||||
float f3 = 0.05F;
|
||||
entityitem.field_608_an = (float) world.field_1037_n.nextGaussian() * f3;
|
||||
entityitem.field_607_ao = (float) world.field_1037_n.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.field_606_ap = (float) world.field_1037_n.nextGaussian() * f3;
|
||||
|
||||
if (itemstack.func_40710_n())
|
||||
{
|
||||
entityitem.field_801_a.func_40706_d((NBTTagCompound) itemstack.func_40709_o().func_40195_b());
|
||||
}
|
||||
|
||||
world.func_674_a(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all BaseMod loaded into the system
|
||||
* {@link ModLoaderModContainer#findAll}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<BaseMod> getLoadedMods()
|
||||
{
|
||||
return ModLoaderModContainer.findAll(BaseMod.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a logger instance {@link FMLCommonHandler#getFMLLogger()}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Logger getLogger()
|
||||
{
|
||||
return FMLCommonHandler.instance().getFMLLogger();
|
||||
}
|
||||
|
||||
public static Minecraft getMinecraftInstance()
|
||||
{
|
||||
return FMLClientHandler.instance().getClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not the server
|
||||
* {@link FMLClientHandler#getServer()}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Object getMinecraftServerInstance()
|
||||
{
|
||||
return getMinecraftInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from a field using reflection
|
||||
* {@link ReflectionHelper#getPrivateValue(Class, Object, int)}
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param fieldindex
|
||||
* @return
|
||||
*/
|
||||
public static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, int fieldindex)
|
||||
{
|
||||
return ReflectionHelper.getPrivateValue(instanceclass, instance, fieldindex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from a field using reflection
|
||||
* {@link ReflectionHelper#getPrivateValue(Class, Object, String)}
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
public static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, String field)
|
||||
{
|
||||
return ReflectionHelper.getPrivateValue(instanceclass, instance, field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stubbed method on the server to return a unique model id
|
||||
*
|
||||
*/
|
||||
public static int getUniqueBlockModelID(BaseMod mod, boolean inventoryRenderer)
|
||||
{
|
||||
return FMLClientHandler.instance().obtainBlockModelIdFor(mod, inventoryRenderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new unique entity id
|
||||
* {@link Entity#getNextId()}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int getUniqueEntityId()
|
||||
{
|
||||
return FMLCommonHandler.instance().nextUniqueEntityListId();
|
||||
}
|
||||
|
||||
public static int getUniqueSpriteIndex(String path)
|
||||
{
|
||||
return SpriteHelper.getUniqueSpriteIndex(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* To properly implement packet 250 protocol you should always check your
|
||||
* channel is active prior to sending the packet
|
||||
*
|
||||
* @param player
|
||||
* @param channel
|
||||
* @return
|
||||
*/
|
||||
public static boolean isChannelActive(EntityPlayer player, String channel)
|
||||
{
|
||||
return FMLCommonHandler.instance().isChannelActive(channel, player);
|
||||
}
|
||||
|
||||
public static boolean isGUIOpen(Class<? extends GuiScreen> gui)
|
||||
{
|
||||
return FMLClientHandler.instance().getClient().field_6313_p!=null && FMLClientHandler.instance().getClient().field_6313_p.equals(gui);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the named mod loaded?
|
||||
* {@link Loader#isModLoaded(String)}
|
||||
*
|
||||
* @param modname
|
||||
* @return
|
||||
*/
|
||||
public static boolean isModLoaded(String modname)
|
||||
{
|
||||
return Loader.isModLoaded(modname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented elsewhere
|
||||
*/
|
||||
@Deprecated
|
||||
public static void loadConfig()
|
||||
{
|
||||
}
|
||||
|
||||
public static BufferedImage loadImage(RenderEngine renderEngine, String path) throws Exception
|
||||
{
|
||||
return FMLClientHandler.instance().loadImageFromTexturePack(renderEngine, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call in from elsewhere. Unimplemented here.
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
@Deprecated
|
||||
public static void onItemPickup(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Call in from elsewhere. Unimplemented here.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void onTick(float tick, Minecraft game)
|
||||
{
|
||||
}
|
||||
|
||||
public static void openGUI(EntityPlayer player, GuiScreen gui)
|
||||
{
|
||||
FMLClientHandler.instance().displayGuiScreen(player, gui);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void populateChunk(IChunkProvider generator, int chunkX, int chunkZ, World world)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLServerHandler#handlePacket250(Packet250CustomPayload, EntityPlayer)}
|
||||
*
|
||||
* @param packet
|
||||
*/
|
||||
@Deprecated
|
||||
public static void receivePacket(Packet250CustomPayload packet)
|
||||
{
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static KeyBinding[] registerAllKeys(KeyBinding[] keys)
|
||||
{
|
||||
return keys;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void registerAllTextureOverrides(RenderEngine cache)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new block
|
||||
*
|
||||
* @param block
|
||||
*/
|
||||
public static void registerBlock(Block block)
|
||||
{
|
||||
FMLRegistry.registerBlock(block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new block
|
||||
*
|
||||
* @param block
|
||||
* @param itemclass
|
||||
*/
|
||||
public static void registerBlock(Block block, Class<? extends ItemBlock> itemclass)
|
||||
{
|
||||
FMLRegistry.registerBlock(block, itemclass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new entity ID
|
||||
*
|
||||
* @param entityClass
|
||||
* @param entityName
|
||||
* @param id
|
||||
*/
|
||||
public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id)
|
||||
{
|
||||
FMLRegistry.registerEntityID(entityClass, entityName, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new entity ID
|
||||
*
|
||||
* @param entityClass
|
||||
* @param entityName
|
||||
* @param id
|
||||
* @param background
|
||||
* @param foreground
|
||||
*/
|
||||
public static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id, int background, int foreground)
|
||||
{
|
||||
FMLRegistry.registerEntityID(entityClass, entityName, id, background, foreground);
|
||||
}
|
||||
|
||||
public static void registerKey(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat)
|
||||
{
|
||||
FMLClientHandler.instance().registerKeyHandler(mod, keyHandler, allowRepeat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the mod for packets on this channel. This only registers the
|
||||
* channel with Forge Mod Loader, not with clients connecting- use
|
||||
* BaseMod.onClientLogin to tell them about your custom channel
|
||||
* {@link FMLCommonHandler#registerChannel(cpw.mods.fml.common.ModContainer, String)}
|
||||
*
|
||||
* @param mod
|
||||
* @param channel
|
||||
*/
|
||||
public static void registerPacketChannel(BaseMod mod, String channel)
|
||||
{
|
||||
FMLCommonHandler.instance().registerChannel(FMLCommonHandler.instance().findContainerFor(mod), channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new tile entity class
|
||||
*
|
||||
* @param tileEntityClass
|
||||
* @param id
|
||||
*/
|
||||
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id)
|
||||
{
|
||||
FMLRegistry.registerTileEntity(tileEntityClass, id);
|
||||
}
|
||||
|
||||
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id, TileEntitySpecialRenderer renderer)
|
||||
{
|
||||
ClientRegistry.instance().registerTileEntity(tileEntityClass, id, renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a biome from the list of generated biomes
|
||||
*
|
||||
* @param biome
|
||||
*/
|
||||
public static void removeBiome(BiomeGenBase biome)
|
||||
{
|
||||
FMLRegistry.removeBiome(biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
* @param entityClass
|
||||
* @param spawnList
|
||||
*/
|
||||
public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList)
|
||||
{
|
||||
FMLRegistry.removeSpawn(entityClass, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
* @param entityClass
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
*/
|
||||
public static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
FMLRegistry.removeSpawn(entityClass, spawnList, biomes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
* @param entityName
|
||||
* @param spawnList
|
||||
*/
|
||||
public static void removeSpawn(String entityName, EnumCreatureType spawnList)
|
||||
{
|
||||
FMLRegistry.removeSpawn(entityName, spawnList, FMLClientHandler.instance().getDefaultOverworldBiomes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a spawn
|
||||
*
|
||||
* @param entityName
|
||||
* @param spawnList
|
||||
* @param biomes
|
||||
*/
|
||||
public static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes)
|
||||
{
|
||||
FMLRegistry.removeSpawn(entityName, spawnList, biomes);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean renderBlockIsItemFull3D(int modelID)
|
||||
{
|
||||
return FMLClientHandler.instance().renderItemAsFull3DBlock(modelID);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID)
|
||||
{
|
||||
FMLClientHandler.instance().renderInventoryBlock(renderer, block, metadata, modelID);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID)
|
||||
{
|
||||
return FMLClientHandler.instance().renderWorldBlock(renderer, world, x, y, z, block, modelID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration is handled elsewhere
|
||||
* {@link ModLoaderModContainer}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void saveConfig()
|
||||
{
|
||||
}
|
||||
|
||||
public static void sendPacket(Packet packet) {
|
||||
FMLClientHandler.instance().sendPacket(packet);
|
||||
}
|
||||
/**
|
||||
* Send a chat message to the server
|
||||
* {@link FMLClientHandler#handleChatPacket(Packet3Chat, EntityPlayer)}
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
@Deprecated
|
||||
public static void serverChat(String text)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void serverLogin(NetClientHandler handler, Packet1Login loginPacket)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that you want to receive ticks
|
||||
*
|
||||
* @param mod receiving the events
|
||||
* @param enable indicates whether you want to recieve them or not
|
||||
* @param useClock don't receive render subticks, just world ticks
|
||||
*/
|
||||
public static void setInGameHook(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderHelper.updateStandardTicks(mod, enable, useClock);
|
||||
}
|
||||
|
||||
|
||||
public static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderHelper.updateGUITicks(mod, enable, useClock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a private field to a value using reflection
|
||||
* {@link ReflectionHelper#setPrivateValue(Class, Object, int, Object)}
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param fieldindex
|
||||
* @param value
|
||||
*/
|
||||
public static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, int fieldindex, E value)
|
||||
{
|
||||
ReflectionHelper.setPrivateValue(instanceclass, instance, fieldindex, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a private field to a value using reflection
|
||||
* {@link ReflectionHelper#setPrivateValue(Class, Object, String, Object)}
|
||||
*
|
||||
* @param instanceclass
|
||||
* @param instance
|
||||
* @param field
|
||||
* @param value
|
||||
*/
|
||||
public static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, String field, E value)
|
||||
{
|
||||
ReflectionHelper.setPrivateValue(instanceclass, instance, field, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLClientHandler#onItemCrafted(EntityPlayer, ItemStack, IInventory)}
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
* @param matrix
|
||||
*/
|
||||
@Deprecated
|
||||
public static void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is a call in hook from modified external code. Implemented elsewhere.
|
||||
* {@link FMLClientHandler#onItemSmelted(EntityPlayer, ItemStack)}
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
@Deprecated
|
||||
public static void takenFromFurnace(EntityPlayer player, ItemStack item)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw the offered exception. Likely will stop the game.
|
||||
* {@link FMLClientHandler#raiseException(Throwable, String, boolean)}
|
||||
*
|
||||
* @param message
|
||||
* @param e
|
||||
*/
|
||||
public static void throwException(String message, Throwable e)
|
||||
{
|
||||
FMLCommonHandler.instance().raiseException(e, message, true);
|
||||
}
|
||||
|
||||
public static void throwException(Throwable e)
|
||||
{
|
||||
throwException("Exception in ModLoader", e);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.FMLTextureFX;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
/**
|
||||
* A texture override for animations, it takes a vertical image of
|
||||
* texture frames and constantly rotates them in the texture.
|
||||
*/
|
||||
public class ModTextureAnimation extends FMLTextureFX
|
||||
{
|
||||
private final int tickRate;
|
||||
private byte[][] images;
|
||||
private int index = 0;
|
||||
private int ticks = 0;
|
||||
|
||||
private String targetTex = null;
|
||||
private BufferedImage imgData = null;
|
||||
|
||||
public ModTextureAnimation(int icon, int target, BufferedImage image, int tickCount)
|
||||
{
|
||||
this(icon, 1, target, image, tickCount);
|
||||
}
|
||||
|
||||
public ModTextureAnimation(int icon, int size, int target, BufferedImage image, int tickCount)
|
||||
{
|
||||
this(icon, size, (target == 0 ? "/terrain.png" : "/gui/items.png"), image, tickCount);
|
||||
}
|
||||
|
||||
public ModTextureAnimation(int icon, int size, String target, BufferedImage image, int tickCount)
|
||||
{
|
||||
super(icon);
|
||||
RenderEngine re = FMLClientHandler.instance().getClient().field_6315_n;
|
||||
|
||||
targetTex = target;
|
||||
field_1129_e = size;
|
||||
field_1128_f = re.func_1070_a(target);
|
||||
|
||||
tickRate = tickCount;
|
||||
ticks = tickCount;
|
||||
imgData = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
super.setup();
|
||||
|
||||
int sWidth = imgData.getWidth();
|
||||
int sHeight = imgData.getHeight();
|
||||
int tWidth = tileSizeBase;
|
||||
int tHeight = tileSizeBase;
|
||||
|
||||
|
||||
int frames = (int)Math.floor((double)(sHeight / sWidth));
|
||||
|
||||
if (frames < 1)
|
||||
{
|
||||
throw new IllegalArgumentException(String.format("Attempted to create a TextureAnimation with no complete frames: %dx%d", sWidth, sHeight));
|
||||
}
|
||||
else
|
||||
{
|
||||
images = new byte[frames][];
|
||||
BufferedImage image = imgData;
|
||||
|
||||
if (sWidth != tWidth)
|
||||
{
|
||||
BufferedImage b = new BufferedImage(tWidth, tHeight * frames, 6);
|
||||
Graphics2D g = b.createGraphics();
|
||||
g.drawImage(imgData, 0, 0, tWidth, tHeight * frames, 0, 0, sWidth, sHeight, (ImageObserver)null);
|
||||
g.dispose();
|
||||
image = b;
|
||||
}
|
||||
|
||||
for (int frame = 0; frame < frames; frame++)
|
||||
{
|
||||
int[] pixels = new int[tileSizeSquare];
|
||||
image.getRGB(0, tHeight * frame, tWidth, tHeight, pixels, 0, tWidth);
|
||||
images[frame] = new byte[tileSizeSquare << 2];
|
||||
|
||||
for (int i = 0; i < pixels.length; i++)
|
||||
{
|
||||
int i4 = i * 4;
|
||||
images[frame][i4 + 0] = (byte)(pixels[i] >> 16 & 255);
|
||||
images[frame][i4 + 1] = (byte)(pixels[i] >> 8 & 255);
|
||||
images[frame][i4 + 2] = (byte)(pixels[i] >> 0 & 255);
|
||||
images[frame][i4 + 3] = (byte)(pixels[i] >> 24 & 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void func_783_a()
|
||||
{
|
||||
if (++ticks >= tickRate)
|
||||
{
|
||||
if (++index >= images.length)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
field_1127_a = images[index];
|
||||
ticks = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.client.FMLTextureFX;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class ModTextureStatic extends FMLTextureFX
|
||||
{
|
||||
private boolean oldanaglyph = false;
|
||||
private int[] pixels = null;
|
||||
private String targetTex = null;
|
||||
private int storedSize;
|
||||
private BufferedImage overrideData = null;
|
||||
private int needApply = 2;
|
||||
|
||||
|
||||
public ModTextureStatic(int icon, int target, BufferedImage image)
|
||||
{
|
||||
this(icon, 1, target, image);
|
||||
}
|
||||
|
||||
public ModTextureStatic(int icon, int size, int target, BufferedImage image)
|
||||
{
|
||||
this(icon, size, (target == 0 ? "/terrain.png" : "/gui/items.png"), image);
|
||||
}
|
||||
|
||||
public ModTextureStatic(int icon, int size, String target, BufferedImage image)
|
||||
{
|
||||
super(icon);
|
||||
RenderEngine re = FMLClientHandler.instance().getClient().field_6315_n;
|
||||
|
||||
targetTex = target;
|
||||
storedSize = size;
|
||||
field_1129_e = size;
|
||||
field_1128_f = re.func_1070_a(target);
|
||||
overrideData = image;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup()
|
||||
{
|
||||
super.setup();
|
||||
int sWidth = overrideData.getWidth();
|
||||
int sHeight = overrideData.getHeight();
|
||||
|
||||
pixels = new int[tileSizeSquare];
|
||||
if (tileSizeBase == sWidth && tileSizeBase == sHeight)
|
||||
{
|
||||
overrideData.getRGB(0, 0, sWidth, sHeight, pixels, 0, sWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferedImage tmp = new BufferedImage(tileSizeBase, tileSizeBase, 6);
|
||||
Graphics2D gfx = tmp.createGraphics();
|
||||
gfx.drawImage(overrideData, 0, 0, tileSizeBase, tileSizeBase, 0, 0, sWidth, sHeight, (ImageObserver)null);
|
||||
tmp.getRGB(0, 0, tileSizeBase, tileSizeBase, pixels, 0, tileSizeBase);
|
||||
gfx.dispose();
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
public void func_783_a()
|
||||
{
|
||||
if (oldanaglyph != field_1131_c)
|
||||
{
|
||||
update();
|
||||
}
|
||||
// This makes it so we only apply the texture to the target texture when we need to,
|
||||
//due to the fact that update is called when the Effect is first registered, we actually
|
||||
//need to wait for the next one.
|
||||
field_1129_e = (needApply == 0 ? 0 : storedSize);
|
||||
if (needApply > 0)
|
||||
{
|
||||
needApply--;
|
||||
}
|
||||
}
|
||||
|
||||
public void func_782_a(RenderEngine p_782_1_)
|
||||
{
|
||||
GL11.glBindTexture(GL_TEXTURE_2D, p_782_1_.func_1070_a(targetTex));
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
needApply = 2;
|
||||
for (int idx = 0; idx < pixels.length; idx++)
|
||||
{
|
||||
int i = idx * 4;
|
||||
int a = pixels[idx] >> 24 & 255;
|
||||
int r = pixels[idx] >> 16 & 255;
|
||||
int g = pixels[idx] >> 8 & 255;
|
||||
int b = pixels[idx] >> 0 & 255;
|
||||
|
||||
if (field_1131_c)
|
||||
{
|
||||
r = g = b = (r + g + b) / 3;
|
||||
}
|
||||
|
||||
field_1127_a[i + 0] = (byte)r;
|
||||
field_1127_a[i + 1] = (byte)g;
|
||||
field_1127_a[i + 2] = (byte)b;
|
||||
field_1127_a[i + 3] = (byte)a;
|
||||
}
|
||||
|
||||
oldanaglyph = field_1131_c;
|
||||
}
|
||||
|
||||
//Implementation of http://scale2x.sourceforge.net/algorithm.html
|
||||
public static BufferedImage scale2x(BufferedImage image)
|
||||
{
|
||||
int w = image.getWidth();
|
||||
int h = image.getHeight();
|
||||
BufferedImage tmp = new BufferedImage(w * 2, h * 2, 2);
|
||||
|
||||
for (int x = 0; x < h; ++x)
|
||||
{
|
||||
int x2 = x * 2;
|
||||
for (int y = 0; y < w; ++y)
|
||||
{
|
||||
int y2 = y * 2;
|
||||
int E = image.getRGB(y, x);
|
||||
int D = (x == 0 ? E : image.getRGB(y, x - 1));
|
||||
int B = (y == 0 ? E : image.getRGB(y - 1, x ));
|
||||
int H = (y >= w - 1 ? E : image.getRGB(y + 1, x ));
|
||||
int F = (x >= h - 1 ? E : image.getRGB(y, x + 1));
|
||||
|
||||
int e0, e1, e2, e3;
|
||||
|
||||
if (B != H && D != F)
|
||||
{
|
||||
e0 = D == B ? D : E;
|
||||
e1 = B == F ? F : E;
|
||||
e2 = D == H ? D : E;
|
||||
e3 = H == F ? F : E;
|
||||
}
|
||||
else
|
||||
{
|
||||
e0 = e1 = e2 = e3 = E;
|
||||
}
|
||||
|
||||
tmp.setRGB(y2, x2, e0);
|
||||
tmp.setRGB(y2 + 1, x2, e1);
|
||||
tmp.setRGB(y2, x2 + 1, e2);
|
||||
tmp.setRGB(y2 + 1, x2 + 1, e3);
|
||||
}
|
||||
}
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.format("ModTextureStatic %s @ %d", targetTex, field_1126_b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface SidedProxy
|
||||
{
|
||||
/**
|
||||
* The name of the client side class to load and populate
|
||||
* @return
|
||||
*/
|
||||
String clientSide() default "";
|
||||
|
||||
/**
|
||||
* The name of the server side class to load and populate
|
||||
* @return
|
||||
*/
|
||||
String serverSide() default "";
|
||||
|
||||
/**
|
||||
* The name of the a special bukkit plugin class to load and populate
|
||||
*/
|
||||
String bukkitSide() default "";
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package fml.stubs.mcp;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.KeyBinding;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.Render;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public interface BaseMod {
|
||||
int addFuel(int id, int metadata);
|
||||
|
||||
void addRenderer(Map<Class<? extends Entity>, Render> renderers);
|
||||
|
||||
boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item);
|
||||
|
||||
void generateNether(World world, Random random, int chunkX, int chunkZ);
|
||||
|
||||
void generateSurface(World world, Random random, int chunkX, int chunkZ);
|
||||
|
||||
String getName();
|
||||
|
||||
String getPriorities();
|
||||
|
||||
abstract String getVersion();
|
||||
|
||||
void keyboardEvent(KeyBinding event);
|
||||
|
||||
abstract void load();
|
||||
|
||||
void modsLoaded();
|
||||
|
||||
void onItemPickup(EntityPlayer player, ItemStack item);
|
||||
|
||||
boolean onTickInGame(float tick, Minecraft game);
|
||||
|
||||
boolean onTickInGUI(float tick, Minecraft game, GuiScreen gui);
|
||||
|
||||
void receiveChatPacket(String text);
|
||||
|
||||
void receiveCustomPacket(Packet250CustomPayload packet);
|
||||
|
||||
void registerAnimation(Minecraft game);
|
||||
|
||||
void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID);
|
||||
|
||||
boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID);
|
||||
|
||||
void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix);
|
||||
|
||||
void takenFromFurnace(EntityPlayer player, ItemStack item);
|
||||
|
||||
String toString();
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package fml.stubs.mcp;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.Achievement;
|
||||
import net.minecraft.src.BiomeGenBase;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.EntityLiving;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.EnumCreatureType;
|
||||
import net.minecraft.src.GuiScreen;
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
import net.minecraft.src.IChunkProvider;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.ItemBlock;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.KeyBinding;
|
||||
import net.minecraft.src.NetClientHandler;
|
||||
import net.minecraft.src.Packet1Login;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.Render;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import net.minecraft.src.RenderEngine;
|
||||
import net.minecraft.src.TextureFX;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||
import net.minecraft.src.World;
|
||||
|
||||
public class ModLoader {
|
||||
static void addAchievementDesc(Achievement achievement, String name, String description) {
|
||||
}
|
||||
|
||||
static int addAllFuel(int id, int metadata) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void addAllRenderers(Map<Class<? extends Entity>, Render> renderers) {
|
||||
}
|
||||
|
||||
static void addAnimation(TextureFX anim) {
|
||||
}
|
||||
|
||||
static int addArmor(String armor) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void addBiome(BiomeGenBase biome) {
|
||||
}
|
||||
|
||||
static void addLocalization(String key, String value) {
|
||||
}
|
||||
|
||||
static void addLocalization(String key, String lang, String value) {
|
||||
}
|
||||
|
||||
static void addName(Object instance, String name) {
|
||||
}
|
||||
|
||||
static void addName(Object instance, String lang, String name) {
|
||||
}
|
||||
|
||||
static int addOverride(String fileToOverride, String fileToAdd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void addOverride(String path, String overlayPath, int index) {
|
||||
}
|
||||
|
||||
static void addRecipe(ItemStack output, Object... params) {
|
||||
}
|
||||
|
||||
static void addShapelessRecipe(ItemStack output, Object... params) {
|
||||
}
|
||||
|
||||
static void addSmelting(int input, ItemStack output) {
|
||||
}
|
||||
|
||||
static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
static void addSpawn(Class<? extends EntityLiving> entityClass, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
static boolean dispenseEntity(World world, double x, double y, double z, int xVel, int zVel, ItemStack item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void genericContainerRemoval(World world, int x, int y, int z) {
|
||||
}
|
||||
|
||||
static List<BaseMod> getLoadedMods() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Logger getLogger() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Minecraft getMinecraftInstance() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, int fieldindex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static <T, E> T getPrivateValue(Class<? super E> instanceclass, E instance, String field) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static int getUniqueBlockModelID(BaseMod mod, boolean full3DItem) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int getUniqueEntityId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int getUniqueSpriteIndex(String path) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static boolean isGUIOpen(Class<? extends GuiScreen> gui) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean isModLoaded(String modname) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void loadConfig() {
|
||||
}
|
||||
|
||||
static BufferedImage loadImage(RenderEngine texCache, String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static void onItemPickup(EntityPlayer player, ItemStack item) {
|
||||
}
|
||||
|
||||
static void onTick(float tick, net.minecraft.client.Minecraft game) {
|
||||
}
|
||||
|
||||
static void openGUI(EntityPlayer player, GuiScreen gui) {
|
||||
}
|
||||
|
||||
static void populateChunk(IChunkProvider generator, int chunkX, int chunkZ, World world) {
|
||||
}
|
||||
|
||||
static void receivePacket(Packet250CustomPayload packet) {
|
||||
}
|
||||
|
||||
static KeyBinding[] registerAllKeys(KeyBinding[] keys) {
|
||||
return keys;
|
||||
}
|
||||
|
||||
static void registerAllTextureOverrides(RenderEngine cache) {
|
||||
}
|
||||
|
||||
static void registerBlock(Block block) {
|
||||
}
|
||||
|
||||
static void registerBlock(Block block, Class<? extends ItemBlock> itemclass) {
|
||||
}
|
||||
|
||||
static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id) {
|
||||
}
|
||||
|
||||
static void registerEntityID(Class<? extends Entity> entityClass, String entityName, int id, int background, int foreground) {
|
||||
}
|
||||
|
||||
static void registerKey(BaseMod mod, KeyBinding keyHandler, boolean allowRepeat) {
|
||||
}
|
||||
|
||||
static void registerPacketChannel(BaseMod mod, String channel) {
|
||||
}
|
||||
|
||||
static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id) {
|
||||
}
|
||||
|
||||
static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id, TileEntitySpecialRenderer renderer) {
|
||||
}
|
||||
|
||||
static void removeBiome(BiomeGenBase biome) {
|
||||
}
|
||||
|
||||
static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
static void removeSpawn(Class<? extends EntityLiving> entityClass, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
static void removeSpawn(String entityName, EnumCreatureType spawnList) {
|
||||
}
|
||||
|
||||
static void removeSpawn(String entityName, EnumCreatureType spawnList, BiomeGenBase... biomes) {
|
||||
}
|
||||
|
||||
static boolean renderBlockIsItemFull3D(int modelID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void renderInvBlock(RenderBlocks renderer, Block block, int metadata, int modelID) {
|
||||
}
|
||||
|
||||
static boolean renderWorldBlock(RenderBlocks renderer, IBlockAccess world, int x, int y, int z, Block block, int modelID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void saveConfig() {
|
||||
}
|
||||
|
||||
static void serverChat(String text) {
|
||||
}
|
||||
|
||||
static void serverLogin(NetClientHandler handler, Packet1Login loginPacket) {
|
||||
}
|
||||
|
||||
static void setInGameHook(BaseMod mod, boolean enable, boolean useClock) {
|
||||
}
|
||||
|
||||
static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock) {
|
||||
}
|
||||
|
||||
static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, int fieldindex, E value) {
|
||||
}
|
||||
|
||||
static <T, E> void setPrivateValue(Class<? super T> instanceclass, T instance, String field, E value) {
|
||||
}
|
||||
|
||||
static void takenFromCrafting(EntityPlayer player, ItemStack item, IInventory matrix) {
|
||||
}
|
||||
|
||||
static void takenFromFurnace(EntityPlayer player, ItemStack item) {
|
||||
}
|
||||
|
||||
static void throwException(String message, Throwable e) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package fml.stubs.obf;
|
||||
|
||||
public interface BaseMod {
|
||||
int addFuel(int id, int metadata);
|
||||
|
||||
void addRenderer(java.util.Map<java.lang.Class<? extends nn>, um> renderers);
|
||||
|
||||
boolean dispenseEntity(xd world, double x, double y, double z, int xVel, int zVel, aan item);
|
||||
|
||||
void generateNether(xd world, java.util.Random random, int chunkX, int chunkZ);
|
||||
|
||||
void generateSurface(xd world, java.util.Random random, int chunkX, int chunkZ);
|
||||
|
||||
java.lang.String getName();
|
||||
|
||||
java.lang.String getPriorities();
|
||||
|
||||
abstract java.lang.String getVersion();
|
||||
|
||||
void keyboardEvent(afu event);
|
||||
|
||||
abstract void load();
|
||||
|
||||
void modsLoaded();
|
||||
|
||||
void onItemPickup(yw player, aan item);
|
||||
|
||||
boolean onTickInGame(float tick, net.minecraft.client.Minecraft game);
|
||||
|
||||
boolean onTickInGUI(float tick, net.minecraft.client.Minecraft game, vp gui);
|
||||
|
||||
void receiveChatPacket(java.lang.String text);
|
||||
|
||||
void receiveCustomPacket(ee packet);
|
||||
|
||||
void registerAnimation(net.minecraft.client.Minecraft game);
|
||||
|
||||
void renderInvBlock(vl renderer, pb block, int metadata, int modelID);
|
||||
|
||||
boolean renderWorldBlock(vl renderer, ali world, int x, int y, int z, pb block, int modelID);
|
||||
|
||||
void takenFromCrafting(yw player, aan item, io matrix);
|
||||
|
||||
void takenFromFurnace(yw player, aan item);
|
||||
|
||||
java.lang.String toString();
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package fml.stubs.obf;
|
||||
|
||||
public interface ModLoader {
|
||||
static void addAchievementDesc(aeb achievement, java.lang.String name, java.lang.String description);
|
||||
|
||||
static int addAllFuel(int id, int metadata);
|
||||
|
||||
static void addAllRenderers(java.util.Map<java.lang.Class<? extends nn>, um> renderers);
|
||||
|
||||
static void addAnimation(tt anim);
|
||||
|
||||
static int addArmor(java.lang.String armor);
|
||||
|
||||
static void addBiome(abn biome);
|
||||
|
||||
static void addLocalization(java.lang.String key, java.lang.String value);
|
||||
|
||||
static void addLocalization(java.lang.String key, java.lang.String lang, java.lang.String value);
|
||||
|
||||
static void addName(java.lang.Object instance, java.lang.String name);
|
||||
|
||||
static void addName(java.lang.Object instance, java.lang.String lang, java.lang.String name);
|
||||
|
||||
static int addOverride(java.lang.String fileToOverride, java.lang.String fileToAdd);
|
||||
|
||||
static void addOverride(java.lang.String path, java.lang.String overlayPath, int index);
|
||||
|
||||
static void addRecipe(aan output, java.lang.Object... params);
|
||||
|
||||
static void addShapelessRecipe(aan output, java.lang.Object... params);
|
||||
|
||||
static void addSmelting(int input, aan output);
|
||||
|
||||
static void addSpawn(java.lang.Class<? extends acq> entityClass, int weightedProb, int min, int max, acf spawnList);
|
||||
|
||||
static void addSpawn(java.lang.Class<? extends acq> entityClass, int weightedProb, int min, int max, acf spawnList, abn... biomes);
|
||||
|
||||
static void addSpawn(java.lang.String entityName, int weightedProb, int min, int max, acf spawnList);
|
||||
|
||||
static void addSpawn(java.lang.String entityName, int weightedProb, int min, int max, acf spawnList, abn... biomes);
|
||||
|
||||
static boolean dispenseEntity(xd world, double x, double y, double z, int xVel, int zVel, aan item);
|
||||
|
||||
static void genericContainerRemoval(xd world, int x, int y, int z);
|
||||
|
||||
static java.util.List<BaseMod> getLoadedMods();
|
||||
|
||||
static java.util.logging.Logger getLogger();
|
||||
|
||||
static net.minecraft.client.Minecraft getMinecraftInstance();
|
||||
|
||||
static <T, E> T getPrivateValue(java.lang.Class<? super E> instanceclass, E instance, int fieldindex);
|
||||
|
||||
static <T, E> T getPrivateValue(java.lang.Class<? super E> instanceclass, E instance, java.lang.String field);
|
||||
|
||||
static int getUniqueBlockModelID(BaseMod mod, boolean full3DItem);
|
||||
|
||||
static int getUniqueEntityId();
|
||||
|
||||
static int getUniqueSpriteIndex(java.lang.String path);
|
||||
|
||||
static boolean isGUIOpen(java.lang.Class<? extends vp> gui);
|
||||
|
||||
static boolean isModLoaded(java.lang.String modname);
|
||||
|
||||
static void loadConfig();
|
||||
|
||||
static java.awt.image.BufferedImage loadImage(aaw texCache, java.lang.String path);
|
||||
|
||||
static void onItemPickup(yw player, aan item);
|
||||
|
||||
static void onTick(float tick, net.minecraft.client.Minecraft game);
|
||||
|
||||
static void openGUI(yw player, vp gui);
|
||||
|
||||
static void populateChunk(ca generator, int chunkX, int chunkZ, xd world);
|
||||
|
||||
static void receivePacket(ee packet);
|
||||
|
||||
static afu[] registerAllKeys(afu[] keys);
|
||||
|
||||
static void registerAllTextureOverrides(aaw cache);
|
||||
|
||||
static void registerBlock(pb block);
|
||||
|
||||
static void registerBlock(pb block, java.lang.Class<? extends vd> itemclass);
|
||||
|
||||
static void registerEntityID(java.lang.Class<? extends nn> entityClass, java.lang.String entityName, int id);
|
||||
|
||||
static void registerEntityID(java.lang.Class<? extends nn> entityClass, java.lang.String entityName, int id, int background, int foreground);
|
||||
|
||||
static void registerKey(BaseMod mod, afu keyHandler, boolean allowRepeat);
|
||||
|
||||
static void registerPacketChannel(BaseMod mod, java.lang.String channel);
|
||||
|
||||
static void registerTileEntity(java.lang.Class<? extends kw> tileEntityClass, java.lang.String id);
|
||||
|
||||
static void registerTileEntity(java.lang.Class<? extends kw> tileEntityClass, java.lang.String id, aar renderer);
|
||||
|
||||
static void removeBiome(abn biome);
|
||||
|
||||
static void removeSpawn(java.lang.Class<? extends acq> entityClass, acf spawnList);
|
||||
|
||||
static void removeSpawn(java.lang.Class<? extends acq> entityClass, acf spawnList, abn... biomes);
|
||||
|
||||
static void removeSpawn(java.lang.String entityName, acf spawnList);
|
||||
|
||||
static void removeSpawn(java.lang.String entityName, acf spawnList, abn... biomes);
|
||||
|
||||
static boolean renderBlockIsItemFull3D(int modelID);
|
||||
|
||||
static void renderInvBlock(vl renderer, pb block, int metadata, int modelID);
|
||||
|
||||
static boolean renderWorldBlock(vl renderer, ali world, int x, int y, int z, pb block, int modelID);
|
||||
|
||||
static void saveConfig();
|
||||
|
||||
static void serverChat(java.lang.String text);
|
||||
|
||||
static void serverLogin(adl handler, aec loginPacket);
|
||||
|
||||
static void setInGameHook(BaseMod mod, boolean enable, boolean useClock);
|
||||
|
||||
static void setInGUIHook(BaseMod mod, boolean enable, boolean useClock);
|
||||
|
||||
static <T, E> void setPrivateValue(java.lang.Class<? super T> instanceclass, T instance, int fieldindex, E value);
|
||||
|
||||
static <T, E> void setPrivateValue(java.lang.Class<? super T> instanceclass, T instance, java.lang.String field, E value);
|
||||
|
||||
static void takenFromCrafting(yw player, aan item, io matrix);
|
||||
|
||||
static void takenFromFurnace(yw player, aan item);
|
||||
|
||||
static void throwException(java.lang.String message, java.lang.Throwable e);
|
||||
}
|
||||
@@ -0,0 +1,657 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.PriorityQueue;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import cpw.mods.fml.common.ModContainer.SourceType;
|
||||
|
||||
/**
|
||||
* The main class for non-obfuscated hook handling code
|
||||
*
|
||||
* Anything that doesn't require obfuscated or client/server specific code should
|
||||
* go in this handler
|
||||
*
|
||||
* It also contains a reference to the sided handler instance that is valid
|
||||
* allowing for common code to access specific properties from the obfuscated world
|
||||
* without a direct dependency
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class FMLCommonHandler
|
||||
{
|
||||
/**
|
||||
* The singleton
|
||||
*/
|
||||
private static final FMLCommonHandler INSTANCE = new FMLCommonHandler();
|
||||
private static final Pattern metadataFile = Pattern.compile("$/modinfo.json$");;
|
||||
/**
|
||||
* A map of mods to their network channels
|
||||
*/
|
||||
private Map<ModContainer, Set<String>> channelList = new HashMap<ModContainer, Set<String>>();
|
||||
/**
|
||||
* A map of channels to mods
|
||||
*/
|
||||
private Map<String, ModContainer> modChannels = new HashMap<String, ModContainer>();
|
||||
/**
|
||||
* A map of active channels per player
|
||||
*/
|
||||
private Map<Object, Set<String>> activeChannels = new HashMap<Object, Set<String>>();
|
||||
/**
|
||||
* The delegate for side specific data and functions
|
||||
*/
|
||||
private IFMLSidedHandler sidedDelegate;
|
||||
|
||||
private int uniqueEntityListId = 220;
|
||||
|
||||
private List<ModContainer> auxilliaryContainers = new ArrayList<ModContainer>();
|
||||
|
||||
private Map<String,Properties> modLanguageData=new HashMap<String,Properties>();
|
||||
|
||||
private PriorityQueue<TickQueueElement> tickHandlers = new PriorityQueue<TickQueueElement>();
|
||||
|
||||
private List<IScheduledTickHandler> scheduledTicks = new ArrayList<IScheduledTickHandler>();
|
||||
|
||||
private Set<IWorldGenerator> worldGenerators = new HashSet<IWorldGenerator>();
|
||||
/**
|
||||
* We register our delegate here
|
||||
* @param handler
|
||||
*/
|
||||
|
||||
private static class TickQueueElement implements Comparable<TickQueueElement>
|
||||
{
|
||||
static long tickCounter = 0;
|
||||
public TickQueueElement(IScheduledTickHandler ticker)
|
||||
{
|
||||
this.ticker = ticker;
|
||||
update();
|
||||
}
|
||||
@Override
|
||||
public int compareTo(TickQueueElement o)
|
||||
{
|
||||
return (int)(next - o.next);
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
next = tickCounter + Math.max(ticker.nextTickSpacing(),1);
|
||||
}
|
||||
|
||||
private long next;
|
||||
private IScheduledTickHandler ticker;
|
||||
|
||||
public boolean scheduledNow()
|
||||
{
|
||||
return tickCounter >= next;
|
||||
}
|
||||
}
|
||||
|
||||
public void beginLoading(IFMLSidedHandler handler)
|
||||
{
|
||||
sidedDelegate = handler;
|
||||
getFMLLogger().info("Attempting early MinecraftForge initialization");
|
||||
callForgeMethod("initialize");
|
||||
getFMLLogger().info("Completed early MinecraftForge initialization");
|
||||
}
|
||||
|
||||
public void rescheduleTicks()
|
||||
{
|
||||
sidedDelegate.profileStart("modTickScheduling");
|
||||
TickQueueElement.tickCounter++;
|
||||
scheduledTicks.clear();
|
||||
while (true)
|
||||
{
|
||||
if (tickHandlers.size()==0 || !tickHandlers.peek().scheduledNow())
|
||||
{
|
||||
break;
|
||||
}
|
||||
TickQueueElement tickQueueElement = tickHandlers.poll();
|
||||
tickQueueElement.update();
|
||||
tickHandlers.offer(tickQueueElement);
|
||||
scheduledTicks.add(tickQueueElement.ticker);
|
||||
}
|
||||
sidedDelegate.profileEnd();
|
||||
}
|
||||
public void tickStart(EnumSet<TickType> ticks, Object ... data)
|
||||
{
|
||||
if (scheduledTicks.size()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sidedDelegate.profileStart("modTickStart$"+ticks);
|
||||
for (IScheduledTickHandler ticker : scheduledTicks)
|
||||
{
|
||||
EnumSet<TickType> ticksToRun = EnumSet.copyOf(ticker.ticks());
|
||||
ticksToRun.removeAll(EnumSet.complementOf(ticks));
|
||||
if (!ticksToRun.isEmpty())
|
||||
{
|
||||
sidedDelegate.profileStart(ticker.getLabel());
|
||||
ticker.tickStart(ticksToRun, data);
|
||||
sidedDelegate.profileEnd();
|
||||
}
|
||||
}
|
||||
sidedDelegate.profileEnd();
|
||||
}
|
||||
|
||||
public void tickEnd(EnumSet<TickType> ticks, Object ... data)
|
||||
{
|
||||
if (scheduledTicks.size()==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sidedDelegate.profileStart("modTickEnd$"+ticks);
|
||||
for (IScheduledTickHandler ticker : scheduledTicks)
|
||||
{
|
||||
EnumSet<TickType> ticksToRun = EnumSet.copyOf(ticker.ticks());
|
||||
ticksToRun.removeAll(EnumSet.complementOf(ticks));
|
||||
if (!ticksToRun.isEmpty())
|
||||
{
|
||||
sidedDelegate.profileStart(ticker.getLabel());
|
||||
ticker.tickEnd(ticksToRun, data);
|
||||
sidedDelegate.profileEnd();
|
||||
}
|
||||
}
|
||||
sidedDelegate.profileEnd();
|
||||
}
|
||||
|
||||
public List<IKeyHandler> gatherKeyBindings() {
|
||||
List<IKeyHandler> allKeys=new ArrayList<IKeyHandler>();
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
allKeys.addAll(mod.getKeys());
|
||||
}
|
||||
for (ModContainer mod : auxilliaryContainers)
|
||||
{
|
||||
allKeys.addAll(mod.getKeys());
|
||||
}
|
||||
return allKeys;
|
||||
}
|
||||
/**
|
||||
* @return the instance
|
||||
*/
|
||||
public static FMLCommonHandler instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
/**
|
||||
* Find the container that associates with the supplied mod object
|
||||
* @param mod
|
||||
* @return
|
||||
*/
|
||||
public ModContainer findContainerFor(Object mod)
|
||||
{
|
||||
for (ModContainer mc : Loader.getModList())
|
||||
{
|
||||
if (mc.matches(mod))
|
||||
{
|
||||
return mc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Lookup the mod for a channel
|
||||
* @param channel
|
||||
* @return
|
||||
*/
|
||||
public ModContainer getModForChannel(String channel)
|
||||
{
|
||||
return modChannels.get(channel);
|
||||
}
|
||||
/**
|
||||
* Get the channel list for a mod
|
||||
* @param modLoaderModContainer
|
||||
* @return
|
||||
*/
|
||||
public Set<String> getChannelListFor(ModContainer container)
|
||||
{
|
||||
return channelList.get(container);
|
||||
}
|
||||
|
||||
/**
|
||||
* register a channel to a mod
|
||||
* @param container
|
||||
* @param channelName
|
||||
*/
|
||||
public void registerChannel(ModContainer container, String channelName)
|
||||
{
|
||||
if (modChannels.containsKey(channelName))
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
|
||||
Set<String> list = channelList.get(container);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
list = new HashSet<String>();
|
||||
channelList.put(container, list);
|
||||
}
|
||||
|
||||
list.add(channelName);
|
||||
modChannels.put(channelName, container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the channel for the player
|
||||
* @param player
|
||||
*/
|
||||
public void activateChannel(Object player, String channel)
|
||||
{
|
||||
Set<String> active = activeChannels.get(player);
|
||||
|
||||
if (active == null)
|
||||
{
|
||||
active = new HashSet<String>();
|
||||
activeChannels.put(player, active);
|
||||
}
|
||||
|
||||
active.add(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate the channel for the player
|
||||
* @param player
|
||||
* @param channel
|
||||
*/
|
||||
public void deactivateChannel(Object player, String channel)
|
||||
{
|
||||
Set<String> active = activeChannels.get(player);
|
||||
|
||||
if (active == null)
|
||||
{
|
||||
active = new HashSet<String>();
|
||||
activeChannels.put(player, active);
|
||||
}
|
||||
|
||||
active.remove(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the packet 250 channel registration string
|
||||
* @return
|
||||
*/
|
||||
public byte[] getPacketRegistry()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
for (String chan : modChannels.keySet())
|
||||
{
|
||||
sb.append(chan).append("\0");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return sb.toString().getBytes("UTF8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
Loader.log.warning("Error building registration list");
|
||||
Loader.log.throwing("FMLHooks", "getPacketRegistry", e);
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the specified channel active for the player?
|
||||
* @param channel
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean isChannelActive(String channel, Object player)
|
||||
{
|
||||
return activeChannels.get(player).contains(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the forge mod loader logging instance (goes to the forgemodloader log file)
|
||||
* @return
|
||||
*/
|
||||
public Logger getFMLLogger()
|
||||
{
|
||||
return Loader.log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minecraft logger (goes to the server log file)
|
||||
* @return
|
||||
*/
|
||||
public Logger getMinecraftLogger()
|
||||
{
|
||||
if (sidedDelegate == null)
|
||||
{
|
||||
throw new RuntimeException("sidedDelegate null when attempting to getMinecraftLogger, this is generally caused by you not installing FML properly, " +
|
||||
"or installing some other mod that edits Minecraft.class on top of FML such as ModLoader, do not do this. Reinstall FML properly and try again.");
|
||||
}
|
||||
return sidedDelegate.getMinecraftLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a modloader mod?
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public boolean isModLoaderMod(Class<?> clazz)
|
||||
{
|
||||
return sidedDelegate.isModLoaderMod(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the modloader mod
|
||||
* @param clazz
|
||||
* @param canonicalPath
|
||||
* @return
|
||||
*/
|
||||
public ModContainer loadBaseModMod(Class<?> clazz, File canonicalFile)
|
||||
{
|
||||
return sidedDelegate.loadBaseModMod(clazz, canonicalFile);
|
||||
}
|
||||
|
||||
public File getMinecraftRootDirectory() {
|
||||
return sidedDelegate.getMinecraftRootDirectory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Object getMinecraftInstance()
|
||||
{
|
||||
return sidedDelegate.getMinecraftInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int nextUniqueEntityListId()
|
||||
{
|
||||
return uniqueEntityListId++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @param lang
|
||||
* @param value
|
||||
*/
|
||||
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);
|
||||
|
||||
handleLanguageLoad(sidedDelegate.getCurrentLanguageTable(), lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param languagePack
|
||||
* @param lang
|
||||
*/
|
||||
public void handleLanguageLoad(Properties languagePack, String lang)
|
||||
{
|
||||
Properties usPack=modLanguageData.get("en_US");
|
||||
if (usPack!=null) {
|
||||
languagePack.putAll(usPack);
|
||||
}
|
||||
Properties langPack=modLanguageData.get(lang);
|
||||
if (langPack==null) {
|
||||
return;
|
||||
}
|
||||
languagePack.putAll(langPack);
|
||||
}
|
||||
|
||||
public Side getSide()
|
||||
{
|
||||
return sidedDelegate.getSide();
|
||||
}
|
||||
|
||||
public void addAuxilliaryModContainer(ModContainer ticker)
|
||||
{
|
||||
auxilliaryContainers.add(ticker);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the furnace to lookup fuel values
|
||||
*
|
||||
* @param itemId
|
||||
* @param itemDamage
|
||||
* @return
|
||||
*/
|
||||
public int fuelLookup(int itemId, int itemDamage)
|
||||
{
|
||||
int fv = 0;
|
||||
|
||||
for (ModContainer mod : Loader.getModList())
|
||||
{
|
||||
fv = Math.max(fv, mod.lookupFuelValue(itemId, itemDamage));
|
||||
}
|
||||
|
||||
return fv;
|
||||
}
|
||||
|
||||
public void addNameForObject(Object minecraftObject, String lang, String name) {
|
||||
String label=sidedDelegate.getObjectName(minecraftObject);
|
||||
addStringLocalization(label, lang, name);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Raise an exception
|
||||
*
|
||||
* @param exception
|
||||
* @param message
|
||||
* @param stopGame
|
||||
*/
|
||||
public void raiseException(Throwable exception, String message, boolean stopGame)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().throwing("FMLHandler", "raiseException", exception);
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
|
||||
private Class<?> forge;
|
||||
private boolean noForge;
|
||||
|
||||
private Class<?> findMinecraftForge()
|
||||
{
|
||||
if (forge==null && !noForge)
|
||||
{
|
||||
try {
|
||||
forge = Class.forName("forge.MinecraftForge");
|
||||
} catch (Exception ex) {
|
||||
try {
|
||||
forge = Class.forName("net.minecraft.src.forge.MinecraftForge");
|
||||
} catch (Exception ex2) {
|
||||
// Ignore- forge isn't loaded
|
||||
noForge = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return forge;
|
||||
}
|
||||
|
||||
private Object callForgeMethod(String method)
|
||||
{
|
||||
if (noForge)
|
||||
return null;
|
||||
try
|
||||
{
|
||||
return findMinecraftForge().getMethod(method).invoke(null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// No Forge installation
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param string
|
||||
* @return
|
||||
*/
|
||||
public String[] getBrandingStrings(String mcVersion)
|
||||
{
|
||||
ArrayList<String> brandings=new ArrayList<String>();
|
||||
brandings.add(mcVersion);
|
||||
brandings.add(Loader.instance().getFMLVersionString());
|
||||
String forgeVersion = (String)callForgeMethod("getVersionString");
|
||||
if (forgeVersion != null)
|
||||
{
|
||||
brandings.add(forgeVersion);
|
||||
}
|
||||
brandings.addAll(sidedDelegate.getAdditionalBrandingInformation());
|
||||
try {
|
||||
Properties props=new Properties();
|
||||
props.load(FMLCommonHandler.class.getClassLoader().getResourceAsStream("fmlbranding.properties"));
|
||||
brandings.add(props.getProperty("fmlbranding"));
|
||||
} catch (Exception ex) {
|
||||
// Ignore - no branding file found
|
||||
}
|
||||
brandings.add(String.format("%d mod%s loaded",Loader.getModList().size(), Loader.getModList().size()!=1?"s":""));
|
||||
Collections.reverse(brandings);
|
||||
return brandings.toArray(new String[brandings.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
*/
|
||||
public void loadMetadataFor(ModContainer mod)
|
||||
{
|
||||
if (mod.getSourceType()==SourceType.JAR) {
|
||||
ZipFile jar = null;
|
||||
try
|
||||
{
|
||||
jar = new ZipFile(mod.getSource());
|
||||
ZipEntry infoFile=jar.getEntry("mcmod.info");
|
||||
if (infoFile!=null) {
|
||||
InputStream input=jar.getInputStream(infoFile);
|
||||
ModMetadata data=sidedDelegate.readMetadataFrom(input, mod);
|
||||
mod.setMetadata(data);
|
||||
} else {
|
||||
getFMLLogger().fine(String.format("Failed to find mcmod.info file in %s for %s", mod.getSource().getName(), mod.getName()));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Something wrong but we don't care
|
||||
getFMLLogger().fine(String.format("Failed to find mcmod.info file in %s for %s", mod.getSource().getName(), mod.getName()));
|
||||
getFMLLogger().throwing("FMLCommonHandler", "loadMetadataFor", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (jar!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
jar.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// GO AWAY
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try
|
||||
{
|
||||
InputStream input=Loader.instance().getModClassLoader().getResourceAsStream(mod.getName()+".info");
|
||||
if (input==null) {
|
||||
input=Loader.instance().getModClassLoader().getResourceAsStream("net/minecraft/src/"+mod.getName()+".info");
|
||||
}
|
||||
if (input!=null) {
|
||||
ModMetadata data=sidedDelegate.readMetadataFrom(input, mod);
|
||||
mod.setMetadata(data);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Something wrong but we don't care
|
||||
getFMLLogger().fine(String.format("Failed to find %s.info file in %s for %s", mod.getName(), mod.getSource().getName(), mod.getName()));
|
||||
getFMLLogger().throwing("FMLCommonHandler", "loadMetadataFor", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public IFMLSidedHandler getSidedDelegate()
|
||||
{
|
||||
return sidedDelegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
*/
|
||||
public void injectSidedProxyDelegate(ModContainer mod)
|
||||
{
|
||||
ProxyInjector injector = mod.findSidedProxy();
|
||||
if (injector != null)
|
||||
{
|
||||
injector.inject(mod, sidedDelegate.getSide());
|
||||
}
|
||||
}
|
||||
|
||||
public void handleWorldGeneration(int chunkX, int chunkZ, long worldSeed, Object... data)
|
||||
{
|
||||
Random fmlRandom = new Random(worldSeed);
|
||||
long xSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
long zSeed = fmlRandom.nextLong() >> 2 + 1L;
|
||||
fmlRandom.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ worldSeed);
|
||||
|
||||
for (IWorldGenerator generator : worldGenerators)
|
||||
{
|
||||
generator.generate(fmlRandom, chunkX, chunkZ, data);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerTickHandler(ITickHandler handler)
|
||||
{
|
||||
registerScheduledTickHandler(new SingleIntervalHandler(handler));
|
||||
}
|
||||
|
||||
public void registerScheduledTickHandler(IScheduledTickHandler handler)
|
||||
{
|
||||
tickHandlers.add(new TickQueueElement(handler));
|
||||
}
|
||||
|
||||
public void registerWorldGenerator(IWorldGenerator generator)
|
||||
{
|
||||
worldGenerators.add(generator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
/**
|
||||
* Copied from ConsoleLogFormatter for shared use on the client
|
||||
*
|
||||
*/
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
final class FMLLogFormatter extends Formatter
|
||||
{
|
||||
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public String format(LogRecord record)
|
||||
{
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append(this.dateFormat.format(Long.valueOf(record.getMillis())));
|
||||
Level lvl = record.getLevel();
|
||||
|
||||
if (lvl == Level.FINEST)
|
||||
{
|
||||
msg.append(" [FINEST] ");
|
||||
}
|
||||
else if (lvl == Level.FINER)
|
||||
{
|
||||
msg.append(" [FINER] ");
|
||||
}
|
||||
else if (lvl == Level.FINE)
|
||||
{
|
||||
msg.append(" [FINE] ");
|
||||
}
|
||||
else if (lvl == Level.INFO)
|
||||
{
|
||||
msg.append(" [INFO] ");
|
||||
}
|
||||
else if (lvl == Level.WARNING)
|
||||
{
|
||||
msg.append(" [WARNING] ");
|
||||
}
|
||||
else if (lvl == Level.SEVERE)
|
||||
{
|
||||
msg.append(" [SEVERE] ");
|
||||
}
|
||||
else if (lvl == Level.SEVERE)
|
||||
{
|
||||
msg.append(" [" + lvl.getLocalizedName() + "] ");
|
||||
}
|
||||
|
||||
msg.append(record.getMessage());
|
||||
msg.append(System.getProperty("line.separator"));
|
||||
Throwable thr = record.getThrown();
|
||||
|
||||
if (thr != null)
|
||||
{
|
||||
StringWriter thrDump = new StringWriter();
|
||||
thr.printStackTrace(new PrintWriter(thrDump));
|
||||
msg.append(thrDump.toString());
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FMLModContainer implements ModContainer
|
||||
{
|
||||
private Mod modDescriptor;
|
||||
private Object modInstance;
|
||||
private File source;
|
||||
private ModMetadata modMetadata;
|
||||
|
||||
public FMLModContainer(String dummy)
|
||||
{
|
||||
this(new File(dummy));
|
||||
}
|
||||
public FMLModContainer(File source)
|
||||
{
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public FMLModContainer(Class<?> clazz)
|
||||
{
|
||||
if (clazz == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
modDescriptor = clazz.getAnnotation(Mod.class);
|
||||
|
||||
try
|
||||
{
|
||||
modInstance = clazz.newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsPreInit()
|
||||
{
|
||||
return modDescriptor.wantsPreInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsPostInit()
|
||||
{
|
||||
return modDescriptor.wantsPostInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public static ModContainer buildFor(Class<?> clazz)
|
||||
{
|
||||
return new FMLModContainer(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModState getModState()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nextState()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public String getSortingRules()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Object mod)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getSource()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMod()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lookupFuelValue(int itemId, int itemDamage)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsPickupNotification()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPickupNotifier getPickupNotifier()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#wantsToDispense()
|
||||
*/
|
||||
@Override
|
||||
public boolean wantsToDispense()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getDispenseHandler()
|
||||
*/
|
||||
@Override
|
||||
public IDispenseHandler getDispenseHandler()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#wantsCraftingNotification()
|
||||
*/
|
||||
@Override
|
||||
public boolean wantsCraftingNotification()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getCraftingHandler()
|
||||
*/
|
||||
@Override
|
||||
public ICraftingHandler getCraftingHandler()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getDependencies()
|
||||
*/
|
||||
@Override
|
||||
public List<String> getDependencies()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return new ArrayList<String>(0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getPreDepends()
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPreDepends()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return new ArrayList<String>(0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getPostDepends()
|
||||
*/
|
||||
@Override
|
||||
public List<String> getPostDepends()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return new ArrayList<String>(0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getSource().getName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#wantsNetworkPackets()
|
||||
*/
|
||||
@Override
|
||||
public boolean wantsNetworkPackets()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getNetworkHandler()
|
||||
*/
|
||||
@Override
|
||||
public INetworkHandler getNetworkHandler()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#ownsNetworkChannel(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public boolean ownsNetworkChannel(String channel)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#wantsConsoleCommands()
|
||||
*/
|
||||
@Override
|
||||
public boolean wantsConsoleCommands()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getConsoleHandler()
|
||||
*/
|
||||
@Override
|
||||
public IConsoleHandler getConsoleHandler()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#wantsPlayerTracking()
|
||||
*/
|
||||
@Override
|
||||
public boolean wantsPlayerTracking()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getPlayerTracker()
|
||||
*/
|
||||
@Override
|
||||
public IPlayerTracker getPlayerTracker()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getKeys()
|
||||
*/
|
||||
@Override
|
||||
public List<IKeyHandler> getKeys()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getSourceType()
|
||||
*/
|
||||
@Override
|
||||
public SourceType getSourceType()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#setSourceType(cpw.mods.fml.common.ModContainer.SourceType)
|
||||
*/
|
||||
@Override
|
||||
public void setSourceType(SourceType type)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getMetadata()
|
||||
*/
|
||||
@Override
|
||||
public ModMetadata getMetadata()
|
||||
{
|
||||
return modMetadata;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#setMetadata(cpw.mods.fml.common.ModMetadata)
|
||||
*/
|
||||
@Override
|
||||
public void setMetadata(ModMetadata meta)
|
||||
{
|
||||
this.modMetadata=meta;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#gatherRenderers(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void gatherRenderers(Map renderers)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#requestAnimations()
|
||||
*/
|
||||
@Override
|
||||
public void requestAnimations()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getVersion()
|
||||
*/
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#findSidedProxy()
|
||||
*/
|
||||
@Override
|
||||
public ProxyInjector findSidedProxy()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#keyBindEvernt(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void keyBindEvent(Object keyBinding)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class FMLModLoaderContainer extends FMLModContainer
|
||||
{
|
||||
|
||||
/**
|
||||
* @param dummy
|
||||
*/
|
||||
public FMLModLoaderContainer()
|
||||
{
|
||||
super("Forge Mod Loader");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.FMLModContainer#getMetadata()
|
||||
*/
|
||||
@Override
|
||||
public ModMetadata getMetadata()
|
||||
{
|
||||
if (super.getMetadata()==null) {
|
||||
ModMetadata md=new ModMetadata(this);
|
||||
setMetadata(md);
|
||||
md.name="Forge Mod Loader";
|
||||
md.version=Loader.instance().getFMLVersionString();
|
||||
md.credits="Made possible with help from many people";
|
||||
md.authorList=Arrays.asList("cpw, LexManos");
|
||||
md.description="The Forge Mod Loader provides the ability for systems to load mods " +
|
||||
"from the file system. It also provides key capabilities for mods to be able " +
|
||||
"to cooperate and provide a good modding environment. " +
|
||||
"The mod loading system is compatible with ModLoader, all your ModLoader " +
|
||||
"mods should work.";
|
||||
md.url="https://github.com/cpw/FML/wiki";
|
||||
md.updateUrl="https://github.com/cpw/FML/wiki";
|
||||
md.screenshots=new String[0];
|
||||
md.logoFile="";
|
||||
}
|
||||
return super.getMetadata();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.FMLModContainer#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Forge Mod Loader";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.FMLModContainer#getVersion()
|
||||
*/
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
return Loader.instance().getFMLVersionString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface IConsoleHandler
|
||||
{
|
||||
public boolean handleCommand(String command, Object... data);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
/**
|
||||
* Return a crafting handler for the mod container to call
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface ICraftingHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* The object array contains these three arguments
|
||||
*
|
||||
* @param player
|
||||
* @param craftedItem
|
||||
* @param craftingGrid
|
||||
*/
|
||||
void onCrafting(Object... craftingParameters);
|
||||
|
||||
/**
|
||||
* The object array contains these two arguments
|
||||
* @param player
|
||||
* @param smeltedItem
|
||||
*/
|
||||
void onSmelting(Object... smeltingParameters);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
|
||||
public interface IDispenseHandler
|
||||
{
|
||||
boolean dispense(double x, double y, double z, byte xVelocity, byte zVelocity, Object... data);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import cpw.mods.fml.common.modloader.BaseMod;
|
||||
import cpw.mods.fml.common.modloader.ModProperty;
|
||||
|
||||
public interface IFMLSidedHandler
|
||||
{
|
||||
Logger getMinecraftLogger();
|
||||
File getMinecraftRootDirectory();
|
||||
boolean isModLoaderMod(Class<?> clazz);
|
||||
ModContainer loadBaseModMod(Class<?> clazz, File canonicalFile);
|
||||
Object getMinecraftInstance();
|
||||
String getCurrentLanguage();
|
||||
Properties getCurrentLanguageTable();
|
||||
String getObjectName(Object minecraftObject);
|
||||
ModMetadata readMetadataFrom(InputStream input, ModContainer mod) throws Exception;
|
||||
void profileStart(String profileLabel);
|
||||
void profileEnd();
|
||||
ModProperty getModLoaderPropertyFor(Field f);
|
||||
List<String> getAdditionalBrandingInformation();
|
||||
Side getSide();
|
||||
ProxyInjector findSidedProxyOn(BaseMod mod);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface IKeyHandler
|
||||
{
|
||||
|
||||
Object getKeyBinding();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
ModContainer getOwningContainer();
|
||||
|
||||
void onEndTick();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface INetworkHandler
|
||||
{
|
||||
boolean onChat(Object... data);
|
||||
void onPacket250Packet(Object... data);
|
||||
void onServerLogin(Object handler);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
public interface IPickupNotifier
|
||||
{
|
||||
void notifyPickup(Object... pickupData);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface IPlayerTracker
|
||||
{
|
||||
void onPlayerLogin(Object player);
|
||||
void onPlayerLogout(Object player);
|
||||
void onPlayerChangedDimension(Object player);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
public interface IScheduledTickHandler extends ITickHandler
|
||||
{
|
||||
/**
|
||||
* Return the number of actual ticks that will pass
|
||||
* before your next tick will fire. This will be called
|
||||
* just after your last tick fired to compute the next delay.
|
||||
* @param tick
|
||||
* @return
|
||||
*/
|
||||
public int nextTickSpacing();
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Tick handler for mods to implement and register through the TickRegistry
|
||||
*
|
||||
* The data available to each tick is documented in the TickType
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface ITickHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Called at the "start" phase of a tick
|
||||
*
|
||||
* Multiple ticks may fire simultaneously- you will only be called once with all the firing ticks
|
||||
*
|
||||
* @param type
|
||||
* @param tickData
|
||||
*/
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData);
|
||||
|
||||
/**
|
||||
* Called at the "end" phase of a tick
|
||||
*
|
||||
* Multiple ticks may fire simultaneously- you will only be called once with all the firing ticks
|
||||
*
|
||||
* @param type
|
||||
* @param tickData
|
||||
*/
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData);
|
||||
|
||||
/**
|
||||
* Returns the list of ticks this tick handler is interested in receiving at the minute
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public EnumSet<TickType> ticks();
|
||||
|
||||
/**
|
||||
* A profiling label for this tick handler
|
||||
* @return
|
||||
*/
|
||||
public String getLabel();
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* This is called back during world generation. The {@link #generate(Random, int, int, Object...)} method passes in some additional data that
|
||||
* can be cast into minecraft objects.
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface IWorldGenerator
|
||||
{
|
||||
/**
|
||||
* Generate some world
|
||||
*
|
||||
* @param random the chunk specific {@link Random}.
|
||||
* @param chunkX the block X coordinate of this chunk.
|
||||
* @param chunkZ the block Z coordinate of this chunk.
|
||||
* @param world : additionalData[0] The minecraft {@link World} we're generating for.
|
||||
* @param generator : additionalData[1] The {@link IChunkProvider} that is generating.
|
||||
* @param chunkProvider : additionalData[2] {@link IChunkProvider} that is requesting the world generation.
|
||||
*
|
||||
*/
|
||||
public void generate(Random random, int chunkX, int chunkZ, Object...additionalData);
|
||||
}
|
||||
@@ -0,0 +1,674 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import cpw.mods.fml.common.ModContainer.SourceType;
|
||||
import cpw.mods.fml.common.toposort.ModSorter;
|
||||
import cpw.mods.fml.common.toposort.TopologicalSort;
|
||||
|
||||
/**
|
||||
* The loader class performs the actual loading of the mod code from disk.
|
||||
*
|
||||
* <p>There are several {@link State}s to mod loading, triggered in two different stages from the FML handler code's hooks into the
|
||||
* minecraft code.</p>
|
||||
*
|
||||
* <ol>
|
||||
* <li>LOADING. Scanning the filesystem for mod containers to load (zips, jars, directories), adding them to the {@link #modClassLoader}
|
||||
* Scanning, the loaded containers for mod classes to load and registering them appropriately.</li>
|
||||
* <li>PREINIT. The mod classes are configured, they are sorted into a load order, and instances of the mods are constructed.</li>
|
||||
* <li>INIT. The mod instances are initialized. For BaseMod mods, this involves calling the load method.</li>
|
||||
* <li>POSTINIT. The mod instances are post initialized. For BaseMod mods this involves calling the modsLoaded method.</li>
|
||||
* <li>UP. The Loader is complete</li>
|
||||
* <li>ERRORED. The loader encountered an error during the LOADING phase and dropped to this state instead. It will not complete
|
||||
* loading from this state, but it attempts to continue loading before abandoning and giving a fatal error.</li>
|
||||
* </ol>
|
||||
*
|
||||
* Phase 1 code triggers the LOADING and PREINIT states. Phase 2 code triggers the INIT and POSTINIT states.
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class Loader
|
||||
{
|
||||
private static Pattern zipJar = Pattern.compile("(.+).(zip|jar)$");
|
||||
private static Pattern modClass = Pattern.compile("(.+/|)(mod\\_[^\\s$]+).class$");
|
||||
|
||||
/**
|
||||
* The state enum used to help track state progression for the loader
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
private enum State
|
||||
{
|
||||
NOINIT, LOADING, PREINIT, INIT, POSTINIT, UP, ERRORED
|
||||
};
|
||||
|
||||
/**
|
||||
* The singleton instance
|
||||
*/
|
||||
private static Loader instance;
|
||||
/**
|
||||
* Our special logger for logging issues to. We copy various assets from the Minecraft logger to acheive a similar appearance.
|
||||
*/
|
||||
public static Logger log = Logger.getLogger("ForgeModLoader");
|
||||
|
||||
|
||||
/**
|
||||
* Build information for tracking purposes.
|
||||
*/
|
||||
private static String major;
|
||||
private static String minor;
|
||||
private static String rev;
|
||||
private static String build;
|
||||
private static String mcversion;
|
||||
|
||||
/**
|
||||
* The {@link State} of the loader
|
||||
*/
|
||||
private State state;
|
||||
/**
|
||||
* The class loader we load the mods into.
|
||||
*/
|
||||
private ModClassLoader modClassLoader;
|
||||
/**
|
||||
* The sorted list of mods.
|
||||
*/
|
||||
private List<ModContainer> mods;
|
||||
/**
|
||||
* A named list of mods
|
||||
*/
|
||||
private Map<String, ModContainer> namedMods;
|
||||
/**
|
||||
* The canonical configuration directory
|
||||
*/
|
||||
private File canonicalConfigDir;
|
||||
/**
|
||||
* The canonical minecraft directory
|
||||
*/
|
||||
private File canonicalMinecraftDir;
|
||||
private Exception capturedError;
|
||||
|
||||
|
||||
public static Loader instance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new Loader();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Loader()
|
||||
{
|
||||
FMLLogFormatter formatter=new FMLLogFormatter();
|
||||
if (FMLCommonHandler.instance().getMinecraftLogger()!=null) {
|
||||
Loader.log.setParent(FMLCommonHandler.instance().getMinecraftLogger());
|
||||
} else {
|
||||
ConsoleHandler ch=new ConsoleHandler();
|
||||
Loader.log.setUseParentHandlers(false);
|
||||
Loader.log.addHandler(ch);
|
||||
ch.setFormatter(formatter);
|
||||
|
||||
}
|
||||
Loader.log.setLevel(Level.ALL);
|
||||
try
|
||||
{
|
||||
File logPath=new File(FMLCommonHandler.instance().getMinecraftRootDirectory().getCanonicalPath(),"ForgeModLoader-%g.log");
|
||||
FileHandler fileHandler = new FileHandler(logPath.getPath(), 0, 3);
|
||||
// We're stealing minecraft's log formatter
|
||||
fileHandler.setFormatter(new FMLLogFormatter());
|
||||
fileHandler.setLevel(Level.ALL);
|
||||
Loader.log.addHandler(fileHandler);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Whatever - give up
|
||||
}
|
||||
InputStream stream = Loader.class.getClassLoader().getResourceAsStream("fmlversion.properties");
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (stream != null) {
|
||||
try {
|
||||
properties.load(stream);
|
||||
major = properties.getProperty("fmlbuild.major.number","none");
|
||||
minor = properties.getProperty("fmlbuild.minor.number","none");
|
||||
rev = properties.getProperty("fmlbuild.revision.number","none");
|
||||
build = properties.getProperty("fmlbuild.build.number","none");
|
||||
mcversion = properties.getProperty("fmlbuild.mcversion","none");
|
||||
} catch (IOException ex) {
|
||||
Loader.log.log(Level.SEVERE,"Could not get FML version information - corrupted installation detected!", ex);
|
||||
throw new LoaderException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
log.info(String.format("Forge Mod Loader version %s.%s.%s.%s for Minecraft %s loading", major, minor, rev, build, mcversion));
|
||||
modClassLoader = new ModClassLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the mods into a sorted list, using dependency information from the containers. The sorting is performed
|
||||
* using a {@link TopologicalSort} based on the pre- and post- dependency information provided by the mods.
|
||||
*/
|
||||
private void sortModList()
|
||||
{
|
||||
log.fine("Verifying mod dependencies are satisfied");
|
||||
|
||||
for (ModContainer mod : mods)
|
||||
{
|
||||
if (!namedMods.keySet().containsAll(mod.getDependencies()))
|
||||
{
|
||||
log.severe(String.format("The mod %s requires mods %s to be available, one or more are not", mod.getName(), mod.getDependencies()));
|
||||
LoaderException le = new LoaderException();
|
||||
log.throwing("Loader", "sortModList", le);
|
||||
throw new LoaderException();
|
||||
}
|
||||
}
|
||||
|
||||
log.fine("All dependencies are satisfied");
|
||||
ModSorter sorter = new ModSorter(mods, namedMods);
|
||||
|
||||
try
|
||||
{
|
||||
log.fine("Sorting mods into an ordered list");
|
||||
mods = sorter.sort();
|
||||
log.fine("Sorted mod list:");
|
||||
for (ModContainer mod : mods)
|
||||
{
|
||||
log.fine(String.format("\t%s: %s (%s)", mod.getName(), mod.getSource().getName(), mod.getSortingRules()));
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException iae)
|
||||
{
|
||||
log.severe("A dependency cycle was detected in the input mod set so they cannot be loaded in order");
|
||||
log.throwing("Loader", "sortModList", iae);
|
||||
throw new LoaderException(iae);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The first mod initialization stage, performed immediately after the jar files and mod classes are loaded,
|
||||
* {@link State#PREINIT}. The mods are configured from their configuration data and instantiated (for BaseMod mods).
|
||||
*/
|
||||
private void preModInit()
|
||||
{
|
||||
state = State.PREINIT;
|
||||
log.fine("Beginning mod pre-initialization");
|
||||
|
||||
for (ModContainer mod : mods)
|
||||
{
|
||||
if (mod.wantsPreInit())
|
||||
{
|
||||
log.finer(String.format("Pre-initializing %s", mod.getSource()));
|
||||
mod.preInit();
|
||||
namedMods.put(mod.getName(), mod);
|
||||
}
|
||||
mod.nextState();
|
||||
}
|
||||
// Link up mod metadatas
|
||||
|
||||
for (ModContainer mod : mods) {
|
||||
if (mod.getMetadata()!=null) {
|
||||
mod.getMetadata().associate(namedMods);
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().injectSidedProxyDelegate(mod);
|
||||
}
|
||||
log.fine("Mod pre-initialization complete");
|
||||
}
|
||||
|
||||
/**
|
||||
* The main mod initialization stage, performed on the sorted mod list.
|
||||
*/
|
||||
private void modInit()
|
||||
{
|
||||
state = State.INIT;
|
||||
log.fine("Beginning mod initialization");
|
||||
|
||||
for (ModContainer mod : mods)
|
||||
{
|
||||
log.finer(String.format("Initializing %s", mod.getName()));
|
||||
mod.init();
|
||||
mod.nextState();
|
||||
}
|
||||
|
||||
log.fine("Mod initialization complete");
|
||||
}
|
||||
|
||||
private void postModInit()
|
||||
{
|
||||
state = State.POSTINIT;
|
||||
log.fine("Beginning mod post-initialization");
|
||||
|
||||
for (ModContainer mod : mods)
|
||||
{
|
||||
if (mod.wantsPostInit())
|
||||
{
|
||||
log.finer(String.format("Post-initializing %s", mod.getName()));
|
||||
mod.postInit();
|
||||
mod.nextState();
|
||||
}
|
||||
}
|
||||
|
||||
log.fine("Mod post-initialization complete");
|
||||
}
|
||||
|
||||
/**
|
||||
* The primary loading code
|
||||
*
|
||||
* This is visited during first initialization by Minecraft to scan and load the mods
|
||||
* from all sources
|
||||
* 1. The minecraft jar itself (for loading of in jar mods- I would like to remove this if possible but forge depends on it at present)
|
||||
* 2. The mods directory with expanded subdirs, searching for mods named mod_*.class
|
||||
* 3. The mods directory for zip and jar files, searching for mod classes named mod_*.class again
|
||||
*
|
||||
* The found resources are first loaded into the {@link #modClassLoader} (always) then scanned for class resources matching the specification above.
|
||||
*
|
||||
* If they provide the {@link Mod} annotation, they will be loaded as "FML mods", which currently is effectively a NO-OP.
|
||||
* If they are determined to be {@link BaseMod} subclasses they are loaded as such.
|
||||
*
|
||||
* Finally, if they are successfully loaded as classes, they are then added to the available mod list.
|
||||
*/
|
||||
private void load()
|
||||
{
|
||||
File minecraftDir = FMLCommonHandler.instance().getMinecraftRootDirectory();
|
||||
File modsDir = new File(minecraftDir, "mods");
|
||||
File configDir = new File(minecraftDir, "config");
|
||||
String canonicalModsPath;
|
||||
String canonicalConfigPath;
|
||||
|
||||
try
|
||||
{
|
||||
canonicalMinecraftDir = minecraftDir.getCanonicalFile();
|
||||
canonicalModsPath = modsDir.getCanonicalPath();
|
||||
canonicalConfigPath = configDir.getCanonicalPath();
|
||||
canonicalConfigDir = configDir.getCanonicalFile();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
log.severe(String.format("Failed to resolve mods directory mods %s", modsDir.getAbsolutePath()));
|
||||
log.throwing("fml.server.Loader", "initialize", ioe);
|
||||
throw new LoaderException(ioe);
|
||||
}
|
||||
|
||||
if (!modsDir.exists())
|
||||
{
|
||||
log.fine(String.format("No mod directory found, creating one: %s", canonicalModsPath));
|
||||
|
||||
try
|
||||
{
|
||||
modsDir.mkdir();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.throwing("fml.server.Loader", "initialize", e);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!configDir.exists())
|
||||
{
|
||||
log.fine(String.format("No config directory found, creating one: %s", canonicalConfigPath));
|
||||
|
||||
try
|
||||
{
|
||||
configDir.mkdir();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.throwing("fml.server.Loader", "initialize", e);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!modsDir.isDirectory())
|
||||
{
|
||||
log.severe(String.format("Attempting to load mods from %s, which is not a directory", canonicalModsPath));
|
||||
LoaderException loaderException = new LoaderException();
|
||||
log.throwing("fml.server.Loader", "initialize", loaderException);
|
||||
throw loaderException;
|
||||
}
|
||||
|
||||
if (!configDir.isDirectory())
|
||||
{
|
||||
log.severe(String.format("Attempting to load configuration from %s, which is not a directory", canonicalConfigPath));
|
||||
LoaderException loaderException = new LoaderException();
|
||||
log.throwing("fml.server.Loader", "initialize", loaderException);
|
||||
throw loaderException;
|
||||
}
|
||||
|
||||
state = State.LOADING;
|
||||
log.fine("Attempting to load mods contained in the minecraft jar file and associated classes");
|
||||
File[] minecraftSources=modClassLoader.getParentSources();
|
||||
if (minecraftSources.length==1 && minecraftSources[0].isFile()) {
|
||||
log.fine(String.format("Minecraft is a file at %s, loading",minecraftSources[0].getAbsolutePath()));
|
||||
attemptFileLoad(minecraftSources[0], SourceType.CLASSPATH);
|
||||
} else {
|
||||
for (int i=0; i<minecraftSources.length; i++) {
|
||||
if (minecraftSources[i].isFile()) {
|
||||
log.fine(String.format("Found a minecraft related file at %s, loading",minecraftSources[i].getAbsolutePath()));
|
||||
attemptFileLoad(minecraftSources[i], SourceType.CLASSPATH);
|
||||
} else if (minecraftSources[i].isDirectory()) {
|
||||
log.fine(String.format("Found a minecraft related directory at %s, loading",minecraftSources[i].getAbsolutePath()));
|
||||
attemptDirLoad(minecraftSources[i],"",SourceType.CLASSPATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.fine("Minecraft jar mods loaded successfully");
|
||||
|
||||
log.info(String.format("Loading mods from %s", canonicalModsPath));
|
||||
File[] modList = modsDir.listFiles();
|
||||
// Sort the files into alphabetical order first
|
||||
Arrays.sort(modList);
|
||||
|
||||
for (File modFile : modList)
|
||||
{
|
||||
if (modFile.isDirectory())
|
||||
{
|
||||
log.fine(String.format("Found a directory %s, attempting to load it", modFile.getName()));
|
||||
boolean modFound = attemptDirLoad(modFile,"", SourceType.DIR);
|
||||
|
||||
if (modFound)
|
||||
{
|
||||
log.fine(String.format("Directory %s loaded successfully", modFile.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info(String.format("Directory %s contained no mods", modFile.getName()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Matcher matcher = zipJar.matcher(modFile.getName());
|
||||
|
||||
if (matcher.matches())
|
||||
{
|
||||
log.fine(String.format("Found a zip or jar file %s, attempting to load it", matcher.group(0)));
|
||||
boolean modFound = attemptFileLoad(modFile, SourceType.JAR);
|
||||
|
||||
if (modFound)
|
||||
{
|
||||
log.fine(String.format("File %s loaded successfully", matcher.group(0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info(String.format("File %s contained no mods", matcher.group(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state == State.ERRORED)
|
||||
{
|
||||
log.severe("A problem has occured during mod loading. Likely a corrupt jar is located in your mods directory");
|
||||
throw new LoaderException(capturedError);
|
||||
}
|
||||
|
||||
log.info(String.format("Forge Mod Loader has loaded %d mods", mods.size()));
|
||||
}
|
||||
|
||||
private boolean attemptDirLoad(File modDir, String path, SourceType sourceType)
|
||||
{
|
||||
if (path.length()==0) {
|
||||
extendClassLoader(modDir);
|
||||
}
|
||||
boolean foundAModClass = false;
|
||||
File[] content = modDir.listFiles(new FileFilter()
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File file)
|
||||
{
|
||||
return (file.isFile() && modClass.matcher(file.getName()).find()) || file.isDirectory();
|
||||
}
|
||||
});
|
||||
|
||||
// Always sort our content
|
||||
Arrays.sort(content);
|
||||
for (File file : content)
|
||||
{
|
||||
if (file.isDirectory()) {
|
||||
log.finest(String.format("Recursing into package %s", path+file.getName()));
|
||||
foundAModClass|=attemptDirLoad(file,path+file.getName()+".", sourceType);
|
||||
continue;
|
||||
}
|
||||
Matcher fname = modClass.matcher(file.getName());
|
||||
if (!fname.find()) {
|
||||
continue;
|
||||
}
|
||||
String clazzName=path+fname.group(2);
|
||||
try
|
||||
{
|
||||
log.fine(String.format("Found a mod class %s in directory %s, attempting to load it", clazzName, modDir.getName()));
|
||||
loadModClass(modDir, file.getName(), clazzName, sourceType);
|
||||
log.fine(String.format("Successfully loaded mod class %s", file.getName()));
|
||||
foundAModClass = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.severe(String.format("File %s failed to read properly", file.getName()));
|
||||
log.throwing("fml.server.Loader", "attemptDirLoad", e);
|
||||
state = State.ERRORED;
|
||||
capturedError = e;
|
||||
}
|
||||
}
|
||||
|
||||
return foundAModClass;
|
||||
}
|
||||
|
||||
private void loadModClass(File classSource, String classFileName, String clazzName, SourceType sourceType)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> clazz = Class.forName(clazzName, false, modClassLoader);
|
||||
|
||||
ModContainer mod=null;
|
||||
if (clazz.isAnnotationPresent(Mod.class))
|
||||
{
|
||||
// an FML mod
|
||||
log.severe("Currently, the FML mod type is disabled");
|
||||
throw new LoaderException();
|
||||
// log.fine(String.format("FML mod class %s found, loading", clazzName));
|
||||
// mod = FMLModContainer.buildFor(clazz);
|
||||
// log.fine(String.format("FML mod class %s loaded", clazzName));
|
||||
}
|
||||
else if (FMLCommonHandler.instance().isModLoaderMod(clazz))
|
||||
{
|
||||
log.fine(String.format("ModLoader BaseMod class %s found, loading", clazzName));
|
||||
mod = FMLCommonHandler.instance().loadBaseModMod(clazz, classSource.getCanonicalFile());
|
||||
log.fine(String.format("ModLoader BaseMod class %s loaded", clazzName));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unrecognized
|
||||
}
|
||||
if (mod!=null) {
|
||||
mod.setSourceType(sourceType);
|
||||
FMLCommonHandler.instance().loadMetadataFor(mod);
|
||||
mods.add(mod);
|
||||
mod.nextState();
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
log.warning(String.format("Failed to load mod class %s in %s", classFileName, classSource.getAbsoluteFile()));
|
||||
log.throwing("fml.server.Loader", "attemptLoad", e);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void extendClassLoader(File file)
|
||||
{
|
||||
try
|
||||
{
|
||||
modClassLoader.addFile(file);
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean attemptFileLoad(File modFile, SourceType sourceType)
|
||||
{
|
||||
extendClassLoader(modFile);
|
||||
boolean foundAModClass = false;
|
||||
|
||||
ZipFile jar = null;
|
||||
try
|
||||
{
|
||||
jar = new ZipFile(modFile);
|
||||
|
||||
for (ZipEntry ze : Collections.list(jar.entries()))
|
||||
{
|
||||
Matcher match = modClass.matcher(ze.getName());
|
||||
|
||||
if (match.matches())
|
||||
{
|
||||
String pkg = match.group(1).replace('/', '.');
|
||||
String clazzName = pkg + match.group(2);
|
||||
log.fine(String.format("Found a mod class %s in file %s, attempting to load it", clazzName, modFile.getName()));
|
||||
loadModClass(modFile, ze.getName(), clazzName, sourceType);
|
||||
log.fine(String.format("Mod class %s loaded successfully", clazzName, modFile.getName()));
|
||||
foundAModClass = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.severe(String.format("Zip file %s failed to read properly", modFile.getName()));
|
||||
log.throwing("fml.server.Loader", "attemptFileLoad", e);
|
||||
state = State.ERRORED;
|
||||
capturedError = e;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (jar != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
jar.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return foundAModClass;
|
||||
}
|
||||
|
||||
public static List<ModContainer> getModList()
|
||||
{
|
||||
return instance().mods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the hook to start mod loading. We trigger the {@link #load()} and {@link #preModInit()} phases here.
|
||||
* Finally, the mod list is frozen completely and is consider immutable from then on.
|
||||
*/
|
||||
public void loadMods()
|
||||
{
|
||||
state = State.NOINIT;
|
||||
mods = new ArrayList<ModContainer>();
|
||||
namedMods = new HashMap<String, ModContainer>();
|
||||
load();
|
||||
preModInit();
|
||||
sortModList();
|
||||
// Make mod list immutable
|
||||
mods = Collections.unmodifiableList(mods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete the initialization of the mods {@link #initializeMods()} and {@link #postModInit()} and mark ourselves up and ready to run.
|
||||
*/
|
||||
public void initializeMods()
|
||||
{
|
||||
modInit();
|
||||
postModInit();
|
||||
for (ModContainer mod : getModList()) {
|
||||
mod.nextState();
|
||||
}
|
||||
state = State.UP;
|
||||
log.info(String.format("Forge Mod Loader load complete, %d mods loaded", mods.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Query if we know of a mod named modname
|
||||
*
|
||||
* @param modname
|
||||
* @return
|
||||
*/
|
||||
public static boolean isModLoaded(String modname)
|
||||
{
|
||||
return instance().namedMods.containsKey(modname);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public File getConfigDir()
|
||||
{
|
||||
return canonicalConfigDir;
|
||||
}
|
||||
|
||||
public String getCrashInformation()
|
||||
{
|
||||
StringBuffer ret = new StringBuffer();
|
||||
for (String brand : FMLCommonHandler.instance().getBrandingStrings(String.format("Forge Mod Loader version %s.%s.%s.%s for Minecraft %s", major, minor, rev, build, mcversion))) {
|
||||
ret.append(brand).append("\n");
|
||||
}
|
||||
for (ModContainer mod : mods)
|
||||
{
|
||||
ret.append(String.format("\t%s : %s (%s)\n",mod.getName(), mod.getModState(), mod.getSource().getName()));
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getFMLVersionString()
|
||||
{
|
||||
return String.format("FML v%s.%s.%s.%s", major, minor, rev, build);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public ClassLoader getModClassLoader()
|
||||
{
|
||||
return modClassLoader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
public class LoaderException extends RuntimeException
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5675297950958861378L;
|
||||
|
||||
public LoaderException(Throwable wrapped)
|
||||
{
|
||||
super(wrapped);
|
||||
}
|
||||
|
||||
public LoaderException()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* A possible future way to indicate mods to the system is to use an annotation style
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Mod
|
||||
{
|
||||
String name() default "";
|
||||
String version() default "";
|
||||
boolean wantsPreInit() default false;
|
||||
boolean wantsPostInit() default false;
|
||||
public @interface PreInit {}
|
||||
public @interface Init {}
|
||||
public @interface PostInit {}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
/**
|
||||
* A simple delegating class loader used to load mods into the system
|
||||
*
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ModClassLoader extends URLClassLoader
|
||||
{
|
||||
|
||||
public ModClassLoader()
|
||||
{
|
||||
super(new URL[0], ModClassLoader.class.getClassLoader());
|
||||
}
|
||||
|
||||
public ModClassLoader(ClassLoader parent) {
|
||||
super(new URL[0], null);
|
||||
}
|
||||
public void addFile(File modFile) throws MalformedURLException
|
||||
{
|
||||
ClassLoader cl=getParent();
|
||||
if (cl instanceof URLClassLoader) {
|
||||
URLClassLoader ucl=(URLClassLoader) cl;
|
||||
URL url = modFile.toURI().toURL();
|
||||
try {
|
||||
Method addUrl=URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
|
||||
addUrl.setAccessible(true);
|
||||
addUrl.invoke(ucl, url);
|
||||
} catch (Exception e) {
|
||||
Loader.log.severe("A fatal error occured attempting to load a file into the classloader");
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public File[] getParentSources() {
|
||||
ClassLoader cl=getParent();
|
||||
if (cl instanceof URLClassLoader) {
|
||||
URLClassLoader ucl=(URLClassLoader) cl;
|
||||
URL[] pUrl=ucl.getURLs();
|
||||
File[] sources=new File[pUrl.length];
|
||||
try
|
||||
{
|
||||
for (int i=0; i<pUrl.length; i++) {
|
||||
sources[i]=new File(pUrl[i].toURI());
|
||||
}
|
||||
return sources;
|
||||
}
|
||||
catch (URISyntaxException e)
|
||||
{
|
||||
Loader.log.throwing("ModClassLoader", "getParentSources", e);
|
||||
}
|
||||
}
|
||||
Loader.log.severe("Unable to process our input to locate the minecraft code");
|
||||
throw new LoaderException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cpw.mods.fml.common.ModContainer.SourceType;
|
||||
|
||||
/**
|
||||
* The container that wraps around mods in the system.
|
||||
* <p>The philosophy is that individual mod implementation technologies should not impact the actual loading and management
|
||||
* of mod code. This interface provides a mechanism by which we can wrap actual mod code so that the loader and other
|
||||
* facilities can treat mods at arms length.</p>
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
|
||||
public interface ModContainer
|
||||
{
|
||||
public enum ModState {
|
||||
UNLOADED("Unloaded"), LOADED("Loaded"), PREINITIALIZED("Pre-initialized"), INITIALIZED("Initialized"), POSTINITIALIZED("Post-initialized"), AVAILABLE("Available");
|
||||
private String label;
|
||||
|
||||
private ModState(String label) {
|
||||
this.label=label;
|
||||
}
|
||||
public String toString() {
|
||||
return this.label;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SourceType {
|
||||
JAR, CLASSPATH, DIR;
|
||||
}
|
||||
/**
|
||||
* The enclosed mod wants to be called during pre-initialization.
|
||||
* @return
|
||||
*/
|
||||
boolean wantsPreInit();
|
||||
/**
|
||||
* The enclosed mod wants to be called during post-initialization.
|
||||
* @return
|
||||
*/
|
||||
boolean wantsPostInit();
|
||||
/**
|
||||
* Called when pre-initialization occurs.
|
||||
*/
|
||||
void preInit();
|
||||
/**
|
||||
* Called when main initialization occurs.
|
||||
*/
|
||||
void init();
|
||||
/**
|
||||
* Called when post-initialization occurs.
|
||||
*/
|
||||
void postInit();
|
||||
/**
|
||||
* The name of the mod
|
||||
* @return
|
||||
*/
|
||||
String getName();
|
||||
/**
|
||||
* The state of the mod
|
||||
* @return
|
||||
*/
|
||||
ModState getModState();
|
||||
/**
|
||||
* Move to the next mod state
|
||||
*/
|
||||
void nextState();
|
||||
/**
|
||||
* Does this mod match the supplied mod?
|
||||
* @param mod
|
||||
* @return
|
||||
*/
|
||||
boolean matches(Object mod);
|
||||
/**
|
||||
* The source of this mod: the file on the file system
|
||||
* @return
|
||||
*/
|
||||
File getSource();
|
||||
/**
|
||||
* Returns the sorting rules as a string for printing
|
||||
* @return
|
||||
*/
|
||||
String getSortingRules();
|
||||
/**
|
||||
* The actual mod object itself
|
||||
* @return
|
||||
*/
|
||||
Object getMod();
|
||||
/**
|
||||
* Lookup the fuel value for the supplied item/damage with this mod.
|
||||
* @param itemId
|
||||
* @param itemDamage
|
||||
* @return
|
||||
*/
|
||||
int lookupFuelValue(int itemId, int itemDamage);
|
||||
/**
|
||||
* This mod wants to be notified when an object is picked up.
|
||||
* @return
|
||||
*/
|
||||
boolean wantsPickupNotification();
|
||||
/**
|
||||
* The pickup notifier for this mod.
|
||||
* @return
|
||||
*/
|
||||
IPickupNotifier getPickupNotifier();
|
||||
/**
|
||||
* This mod wants to have special dispenser handling.
|
||||
* @return
|
||||
*/
|
||||
boolean wantsToDispense();
|
||||
/**
|
||||
* The dispensing handler.
|
||||
* @return
|
||||
*/
|
||||
IDispenseHandler getDispenseHandler();
|
||||
/**
|
||||
* This mod wants notification of crafting and/or smelting events.
|
||||
* @return
|
||||
*/
|
||||
boolean wantsCraftingNotification();
|
||||
/**
|
||||
* The crafting and smelting handler for this mod.
|
||||
* @return
|
||||
*/
|
||||
ICraftingHandler getCraftingHandler();
|
||||
/**
|
||||
* The strong dependencies of this mod. If the named mods in this list are not present, the game will abort.
|
||||
* @return
|
||||
*/
|
||||
List<String> getDependencies();
|
||||
/**
|
||||
* Get a list of mods to load before this one. The special value "*" indicates to load <i>after</i> all other mods (except other "*" mods).
|
||||
* @return
|
||||
*/
|
||||
List<String> getPreDepends();
|
||||
/**
|
||||
* Get a list of mods to load after this one. The special value "*" indicates to load <i>before</i> all other mods (except other "*" mods).
|
||||
* @return
|
||||
*/
|
||||
List<String> getPostDepends();
|
||||
/**
|
||||
* This mod wants packets from the client, and wants them handled by FML.
|
||||
* @return
|
||||
*/
|
||||
boolean wantsNetworkPackets();
|
||||
/**
|
||||
* The network handler for this mod.
|
||||
* @return
|
||||
*/
|
||||
INetworkHandler getNetworkHandler();
|
||||
/**
|
||||
* Does this mod own this channel?
|
||||
* @param channel
|
||||
* @return
|
||||
*/
|
||||
boolean ownsNetworkChannel(String channel);
|
||||
|
||||
/**
|
||||
* Does this mod want commands from the console?
|
||||
* @return
|
||||
*/
|
||||
boolean wantsConsoleCommands();
|
||||
|
||||
IConsoleHandler getConsoleHandler();
|
||||
|
||||
boolean wantsPlayerTracking();
|
||||
|
||||
IPlayerTracker getPlayerTracker();
|
||||
|
||||
List<IKeyHandler> getKeys();
|
||||
|
||||
SourceType getSourceType();
|
||||
|
||||
void setSourceType(SourceType type);
|
||||
|
||||
ModMetadata getMetadata();
|
||||
void setMetadata(ModMetadata meta);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void gatherRenderers(Map renderers);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void requestAnimations();
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getVersion();
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
ProxyInjector findSidedProxy();
|
||||
|
||||
void keyBindEvent(Object keyBinding);
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ModMetadata
|
||||
{
|
||||
public enum ModType { MODLOADER, FML };
|
||||
public ModContainer mod;
|
||||
public ModType type;
|
||||
|
||||
public String name;
|
||||
public String description;
|
||||
|
||||
public String url="";
|
||||
public String updateUrl="";
|
||||
|
||||
public String logoFile="";
|
||||
public String version="";
|
||||
public List<String> authorList=new ArrayList<String>(1);
|
||||
public String credits="";
|
||||
public String parent="";
|
||||
public String[] screenshots;
|
||||
|
||||
public ModContainer parentMod;
|
||||
public List<ModContainer> childMods = new ArrayList<ModContainer>(1);
|
||||
|
||||
/**
|
||||
* @param mod2
|
||||
* @param type2
|
||||
*/
|
||||
public ModMetadata(ModContainer mod)
|
||||
{
|
||||
this.mod=mod;
|
||||
this.type=(mod instanceof FMLModContainer ? ModType.FML : ModType.MODLOADER);
|
||||
}
|
||||
|
||||
public void associate(Map<String, ModContainer> mods) {
|
||||
if (parent!=null && parent.length() > 0) {
|
||||
ModContainer mc=mods.get(parent);
|
||||
if (mc!=null && mc.getMetadata()!=null) {
|
||||
mc.getMetadata().childMods.add(mod);
|
||||
parentMod = mc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getChildModCountString()
|
||||
{
|
||||
return String.format("%d child mod%s", childMods.size(), childMods.size()!=1 ? "s" : "");
|
||||
}
|
||||
|
||||
public String getAuthorList() {
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for (int i=0; i<authorList.size(); i++) {
|
||||
sb.append(authorList.get(i));
|
||||
if (i<authorList.size()-1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String getChildModList()
|
||||
{
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for (int i=0; i<childMods.size(); i++) {
|
||||
sb.append(childMods.get(i).getMetadata().name);
|
||||
if (i<childMods.size()-1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ProxyInjector
|
||||
{
|
||||
private String clientName;
|
||||
private String serverName;
|
||||
private String bukkitName;
|
||||
private Field target;
|
||||
|
||||
public ProxyInjector(String clientName, String serverName, String bukkitName, Field target)
|
||||
{
|
||||
this.clientName = clientName;
|
||||
this.serverName = serverName;
|
||||
this.bukkitName = bukkitName;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public boolean isValidFor(Side type)
|
||||
{
|
||||
if (type == Side.CLIENT)
|
||||
{
|
||||
return !this.clientName.isEmpty();
|
||||
}
|
||||
else if (type == Side.SERVER)
|
||||
{
|
||||
return !this.serverName.isEmpty();
|
||||
}
|
||||
else if (type == Side.BUKKIT)
|
||||
{
|
||||
return this.bukkitName.isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void inject(ModContainer mod, Side side)
|
||||
{
|
||||
String targetType = side == Side.CLIENT ? clientName : serverName;
|
||||
try
|
||||
{
|
||||
Object proxy=Class.forName(targetType, false, Loader.instance().getModClassLoader()).newInstance();
|
||||
if (target.getType().isAssignableFrom(proxy.getClass()))
|
||||
{
|
||||
target.set(mod.getMod(), proxy);
|
||||
} else {
|
||||
FMLCommonHandler.instance().getFMLLogger().severe(String.format("Attempted to load a proxy type %s into %s, but the types don't match", targetType, target.getName()));
|
||||
throw new LoaderException();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().severe(String.format("An error occured trying to load a proxy type %s into %s", targetType, target.getName()));
|
||||
FMLCommonHandler.instance().getFMLLogger().throwing("ProxyInjector", "inject", e);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite. Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
/**
|
||||
* Some reflection helper code.
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ReflectionHelper
|
||||
{
|
||||
public static boolean obfuscation;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T, E> T getPrivateValue(Class <? super E > classToAccess, E instance, int fieldIndex)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field f = classToAccess.getDeclaredFields()[fieldIndex];
|
||||
f.setAccessible(true);
|
||||
return (T) f.get(instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem getting field %d from %s", fieldIndex, classToAccess.getName()));
|
||||
FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T, E> T getPrivateValue(Class <? super E > classToAccess, E instance, String fieldName)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field f = classToAccess.getDeclaredField(fieldName);
|
||||
f.setAccessible(true);
|
||||
return (T) f.get(instance);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if ((fieldName.length() > 3 && !obfuscation) || (fieldName.length() <= 3 && obfuscation)) {
|
||||
FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem getting field %s from %s", fieldName, classToAccess.getName()));
|
||||
FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, E> void setPrivateValue(Class <? super T > classToAccess, T instance, int fieldIndex, E value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field f = classToAccess.getDeclaredFields()[fieldIndex];
|
||||
f.setAccessible(true);
|
||||
f.set(instance, value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem setting field %d from %s", fieldIndex, classToAccess.getName()));
|
||||
FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, E> void setPrivateValue(Class <? super T > classToAccess, T instance, String fieldName, E value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field f = classToAccess.getDeclaredField(fieldName);
|
||||
f.setAccessible(true);
|
||||
f.set(instance, value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if ((fieldName.length() > 3 && !obfuscation) || (fieldName.length() <= 3 && obfuscation)) {
|
||||
FMLCommonHandler.instance().getFMLLogger().severe(String.format("There was a problem setting field %s from %s", fieldName, classToAccess.getName()));
|
||||
FMLCommonHandler.instance().getFMLLogger().throwing("ReflectionHelper", "getPrivateValue", e);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void detectObfuscation(Class<?> clazz)
|
||||
{
|
||||
obfuscation=!clazz.getSimpleName().equals("World");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
public enum Side {
|
||||
CLIENT, SERVER, BUKKIT;
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean isServer()
|
||||
{
|
||||
return !isClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean isClient()
|
||||
{
|
||||
return this == CLIENT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class SingleIntervalHandler implements IScheduledTickHandler
|
||||
{
|
||||
private ITickHandler wrapped;
|
||||
public SingleIntervalHandler(ITickHandler handler)
|
||||
{
|
||||
this.wrapped=handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
wrapped.tickStart(type, tickData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
wrapped.tickEnd(type, tickData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
return wrapped.ticks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return wrapped.getLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextTickSpacing()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public enum TickType {
|
||||
/**
|
||||
* Fired during the world evaluation loop
|
||||
* server and client side
|
||||
*
|
||||
* arg 0 : The world that is ticking
|
||||
*/
|
||||
WORLD,
|
||||
/**
|
||||
* client side
|
||||
* Fired during the render processing phase
|
||||
* arg 0 : float "partial render time"
|
||||
*/
|
||||
RENDER,
|
||||
/**
|
||||
* client side
|
||||
* Fired during the render processing phase if a GUI is open
|
||||
* arg 0 : float "partial render time"
|
||||
* arg 1 : the open gui
|
||||
*/
|
||||
GUI,
|
||||
/**
|
||||
* client side
|
||||
* Fired during the world evaluation loop if a gui is open
|
||||
* arg 0 : The open gui
|
||||
*/
|
||||
WORLDGUI,
|
||||
/**
|
||||
* client side
|
||||
* Fired once as the world loads from disk
|
||||
*/
|
||||
WORLDLOAD,
|
||||
/**
|
||||
* client side
|
||||
* Fired once as the world loads from disk
|
||||
* arg 0 : the open gui
|
||||
*/
|
||||
GUILOAD,
|
||||
/**
|
||||
* client and server side
|
||||
* Fired once per "global tick loop"
|
||||
*/
|
||||
GAME,
|
||||
/**
|
||||
* client and server side.
|
||||
* Fired whenever the players update loop runs.
|
||||
* arg 0 : the player
|
||||
* arg 1 : the world the player is in
|
||||
*/
|
||||
PLAYER,
|
||||
/**
|
||||
* This is a special internal tick type that is
|
||||
* not sent to mods. It resets the scheduler for
|
||||
* the next tick pass.
|
||||
*/
|
||||
RESETMARKER;
|
||||
|
||||
/**
|
||||
* Partner ticks that are also cancelled by returning false from onTickInGame
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public EnumSet<TickType> partnerTicks()
|
||||
{
|
||||
if (this==GAME) return EnumSet.of(RENDER);
|
||||
if (this==RENDER) return EnumSet.of(GAME);
|
||||
if (this==GUI) return EnumSet.of(WORLDGUI, GUILOAD);
|
||||
if (this==WORLDGUI) return EnumSet.of(GUI, GUILOAD);
|
||||
if (this==GUILOAD) return EnumSet.of(GUI, WORLDGUI);
|
||||
return EnumSet.noneOf(TickType.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import cpw.mods.fml.common.IConsoleHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IDispenseHandler;
|
||||
import cpw.mods.fml.common.INetworkHandler;
|
||||
import cpw.mods.fml.common.IPickupNotifier;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
/**
|
||||
*
|
||||
* Marker interface for BaseMod
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface BaseMod extends IWorldGenerator, IPickupNotifier, IDispenseHandler, ICraftingHandler, INetworkHandler, IConsoleHandler, IPlayerTracker
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void modsLoaded();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void load();
|
||||
|
||||
/**
|
||||
* @param tick
|
||||
* @param b
|
||||
* @param minecraftInstance
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
boolean doTickInGame(TickType tick, boolean b, Object minecraftInstance, Object... data);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getPriorities();
|
||||
|
||||
/**
|
||||
* @param itemId
|
||||
* @param itemDamage
|
||||
* @return
|
||||
*/
|
||||
int addFuel(int itemId, int itemDamage);
|
||||
|
||||
/**
|
||||
* @param renderers
|
||||
*/
|
||||
void onRenderHarvest(Map renderers);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void onRegisterAnimations();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
void keyBindingEvent(Object keybinding);
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class BaseModTicker implements ITickHandler
|
||||
{
|
||||
|
||||
private BaseMod mod;
|
||||
private EnumSet<TickType> ticks;
|
||||
private boolean clockTickTrigger;
|
||||
|
||||
|
||||
BaseModTicker(BaseMod mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
this.ticks = EnumSet.of(TickType.WORLDLOAD);
|
||||
}
|
||||
|
||||
BaseModTicker(EnumSet<TickType> ticks)
|
||||
{
|
||||
this.ticks = ticks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> types, Object... tickData)
|
||||
{
|
||||
tickBaseMod(types, false, tickData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> types, Object... tickData)
|
||||
{
|
||||
tickBaseMod(types, true, tickData);
|
||||
}
|
||||
|
||||
private void tickBaseMod(EnumSet<TickType> types, boolean end, Object... tickData)
|
||||
{
|
||||
if (FMLCommonHandler.instance().getSide().isClient() && ( ticks.contains(TickType.GAME) || ticks.contains(TickType.WORLDGUI)))
|
||||
{
|
||||
EnumSet cTypes=EnumSet.copyOf(types);
|
||||
if (end && ( types.contains(TickType.GAME) || types.contains(TickType.WORLDLOAD) || types.contains(TickType.WORLDGUI)))
|
||||
{
|
||||
clockTickTrigger = true;
|
||||
cTypes.remove(TickType.GAME);
|
||||
cTypes.remove(TickType.WORLDLOAD);
|
||||
cTypes.remove(TickType.WORLDGUI);
|
||||
}
|
||||
|
||||
if (end && clockTickTrigger && types.contains(TickType.RENDER))
|
||||
{
|
||||
clockTickTrigger = false;
|
||||
cTypes.remove(TickType.RENDER);
|
||||
if (ticks.contains(TickType.GAME)) cTypes.add(TickType.GAME);
|
||||
if (ticks.contains(TickType.WORLDGUI)) cTypes.add(TickType.WORLDGUI);
|
||||
}
|
||||
|
||||
sendTick(cTypes, end, tickData);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendTick(types, end, tickData);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTick(EnumSet<TickType> types, boolean end, Object... tickData)
|
||||
{
|
||||
for (TickType type : types)
|
||||
{
|
||||
if (!ticks.contains(type))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
boolean keepTicking=mod.doTickInGame(type, end, FMLCommonHandler.instance().getMinecraftInstance(), tickData);
|
||||
if (!keepTicking) {
|
||||
ticks.remove(type);
|
||||
ticks.removeAll(type.partnerTicks());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
return (clockTickTrigger ? EnumSet.of(TickType.RENDER) : ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return mod.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod2
|
||||
*/
|
||||
public void setMod(BaseMod mod)
|
||||
{
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ModLoaderHelper
|
||||
{
|
||||
private static Map<BaseMod, ModLoaderModContainer> notModCallbacks=new HashMap<BaseMod, ModLoaderModContainer>();
|
||||
|
||||
public static void updateStandardTicks(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderModContainer mlmc = findOrBuildModContainer(mod);
|
||||
BaseModTicker ticker = mlmc.getTickHandler();
|
||||
EnumSet<TickType> ticks = ticker.ticks();
|
||||
// If we're enabled we get render ticks
|
||||
if (enable && !useClock) {
|
||||
ticks.add(TickType.RENDER);
|
||||
} else {
|
||||
ticks.remove(TickType.RENDER);
|
||||
}
|
||||
// If we're enabled but we want clock ticks, or we're server side we get game ticks
|
||||
if (enable && (useClock || FMLCommonHandler.instance().getSide().isServer())) {
|
||||
ticks.add(TickType.GAME);
|
||||
} else {
|
||||
ticks.remove(TickType.GAME);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateGUITicks(BaseMod mod, boolean enable, boolean useClock)
|
||||
{
|
||||
ModLoaderModContainer mlmc = findOrBuildModContainer(mod);
|
||||
EnumSet<TickType> ticks = mlmc.getTickHandler().ticks();
|
||||
// If we're enabled and we don't want clock ticks we get render ticks
|
||||
if (enable && !useClock) {
|
||||
ticks.add(TickType.GUI);
|
||||
} else {
|
||||
ticks.remove(TickType.GUI);
|
||||
}
|
||||
// If we're enabled but we want clock ticks, or we're server side we get world ticks
|
||||
if (enable && (useClock || FMLCommonHandler.instance().getSide().isServer())) {
|
||||
ticks.add(TickType.WORLDGUI);
|
||||
} else {
|
||||
ticks.remove(TickType.WORLDGUI);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
* @return
|
||||
*/
|
||||
private static ModLoaderModContainer findOrBuildModContainer(BaseMod mod)
|
||||
{
|
||||
ModLoaderModContainer mlmc=(ModLoaderModContainer) FMLCommonHandler.instance().findContainerFor(mod);
|
||||
if (mlmc==null) {
|
||||
mlmc=notModCallbacks.get(mod);
|
||||
if (mlmc==null) {
|
||||
mlmc=new ModLoaderModContainer(mod);
|
||||
notModCallbacks.put(mod, mlmc);
|
||||
}
|
||||
}
|
||||
return mlmc;
|
||||
}
|
||||
|
||||
public static ModLoaderModContainer registerRenderHelper(BaseMod mod) {
|
||||
ModLoaderModContainer mlmc=findOrBuildModContainer(mod);
|
||||
return mlmc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mod
|
||||
* @return
|
||||
*/
|
||||
public static ModLoaderModContainer registerKeyHelper(BaseMod mod)
|
||||
{
|
||||
ModLoaderModContainer mlmc=findOrBuildModContainer(mod);
|
||||
return mlmc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,714 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.IConsoleHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IDispenseHandler;
|
||||
import cpw.mods.fml.common.IFMLSidedHandler;
|
||||
import cpw.mods.fml.common.IKeyHandler;
|
||||
import cpw.mods.fml.common.INetworkHandler;
|
||||
import cpw.mods.fml.common.IPickupNotifier;
|
||||
import cpw.mods.fml.common.IPlayerTracker;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.LoaderException;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModContainer.ModState;
|
||||
import cpw.mods.fml.common.ModContainer.SourceType;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
import cpw.mods.fml.common.ProxyInjector;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public class ModLoaderModContainer implements ModContainer
|
||||
{
|
||||
private static final ProxyInjector NULLPROXY = new ProxyInjector("","","",null);
|
||||
private Class <? extends BaseMod > modClazz;
|
||||
private BaseMod mod;
|
||||
private File modSource;
|
||||
private ArrayList<String> dependencies;
|
||||
private ArrayList<String> preDependencies;
|
||||
private ArrayList<String> postDependencies;
|
||||
private ArrayList<IKeyHandler> keyHandlers;
|
||||
private ModState state;
|
||||
private SourceType sourceType;
|
||||
private ModMetadata metadata;
|
||||
private ProxyInjector sidedProxy;
|
||||
private BaseModTicker tickHandler;
|
||||
|
||||
public ModLoaderModContainer(Class <? extends BaseMod > modClazz, File modSource)
|
||||
{
|
||||
this.modClazz = modClazz;
|
||||
this.modSource = modSource;
|
||||
// We are unloaded
|
||||
nextState();
|
||||
}
|
||||
|
||||
/**
|
||||
* We only instantiate this for "not mod mods"
|
||||
* @param instance
|
||||
*/
|
||||
ModLoaderModContainer(BaseMod instance) {
|
||||
FMLCommonHandler.instance().addAuxilliaryModContainer(this);
|
||||
this.mod=instance;
|
||||
this.tickHandler = new BaseModTicker(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsPreInit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsPostInit()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit()
|
||||
{
|
||||
try
|
||||
{
|
||||
EnumSet<TickType> ticks = EnumSet.noneOf(TickType.class);
|
||||
this.tickHandler = new BaseModTicker(ticks);
|
||||
configureMod();
|
||||
mod = modClazz.newInstance();
|
||||
this.tickHandler.setMod(mod);
|
||||
FMLCommonHandler.instance().registerTickHandler(this.tickHandler);
|
||||
FMLCommonHandler.instance().registerWorldGenerator(this.mod);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModState getModState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nextState()
|
||||
{
|
||||
if (state==null) {
|
||||
state=ModState.UNLOADED;
|
||||
return;
|
||||
}
|
||||
if (state.ordinal()+1<ModState.values().length) {
|
||||
state=ModState.values()[state.ordinal()+1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void configureMod()
|
||||
{
|
||||
IFMLSidedHandler sideHandler = FMLCommonHandler.instance().getSidedDelegate();
|
||||
File configDir = Loader.instance().getConfigDir();
|
||||
String modConfigName = modClazz.getSimpleName();
|
||||
File modConfig = new File(configDir, String.format("%s.cfg", modConfigName));
|
||||
Properties props = new Properties();
|
||||
|
||||
boolean existingConfigFound = false;
|
||||
boolean mlPropFound = false;
|
||||
|
||||
if (modConfig.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
Loader.log.fine(String.format("Reading existing configuration file for %s : %s", modConfigName, modConfig.getName()));
|
||||
FileReader configReader = new FileReader(modConfig);
|
||||
props.load(configReader);
|
||||
configReader.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Loader.log.severe(String.format("Error occured reading mod configuration file %s", modConfig.getName()));
|
||||
Loader.log.throwing("ModLoaderModContainer", "configureMod", e);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
existingConfigFound = true;
|
||||
}
|
||||
|
||||
StringBuffer comments = new StringBuffer();
|
||||
comments.append("MLProperties: name (type:default) min:max -- information\n");
|
||||
|
||||
try
|
||||
{
|
||||
for (Field f : modClazz.getDeclaredFields())
|
||||
{
|
||||
if (!Modifier.isStatic(f.getModifiers()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ModProperty property = sideHandler.getModLoaderPropertyFor(f);
|
||||
if (property == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String propertyName = property.name().length() > 0 ? property.name() : f.getName();
|
||||
String propertyValue = null;
|
||||
Object defaultValue = null;
|
||||
|
||||
try
|
||||
{
|
||||
defaultValue = f.get(null);
|
||||
propertyValue = props.getProperty(propertyName, extractValue(defaultValue));
|
||||
Object currentValue = parseValue(propertyValue, property, f.getType(), propertyName, modConfigName);
|
||||
Loader.log.finest(String.format("Configuration for %s.%s found values default: %s, configured: %s, interpreted: %s", modConfigName, propertyName, defaultValue, propertyValue, currentValue));
|
||||
|
||||
if (currentValue != null && !currentValue.equals(defaultValue))
|
||||
{
|
||||
Loader.log.finest(String.format("Configuration for %s.%s value set to: %s", modConfigName, propertyName, currentValue));
|
||||
f.set(null, currentValue);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Loader.log.severe(String.format("Invalid configuration found for %s in %s", propertyName, modConfig.getName()));
|
||||
Loader.log.throwing("ModLoaderModContainer", "configureMod", e);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
comments.append(String.format("MLProp : %s (%s:%s", propertyName, f.getType().getName(), defaultValue));
|
||||
|
||||
if (property.min() != Double.MIN_VALUE)
|
||||
{
|
||||
comments.append(",>=").append(String.format("%.1f", property.min()));
|
||||
}
|
||||
|
||||
if (property.max() != Double.MAX_VALUE)
|
||||
{
|
||||
comments.append(",<=").append(String.format("%.1f", property.max()));
|
||||
}
|
||||
|
||||
comments.append(")");
|
||||
|
||||
if (property.info().length() > 0)
|
||||
{
|
||||
comments.append(" -- ").append(property.info());
|
||||
}
|
||||
|
||||
if (propertyValue != null)
|
||||
{
|
||||
props.setProperty(propertyName, extractValue(propertyValue));
|
||||
}
|
||||
comments.append("\n");
|
||||
}
|
||||
mlPropFound = true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!mlPropFound && !existingConfigFound)
|
||||
{
|
||||
Loader.log.fine(String.format("No MLProp configuration for %s found or required. No file written", modConfigName));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mlPropFound && existingConfigFound)
|
||||
{
|
||||
File mlPropBackup = new File(modConfig.getParent(),modConfig.getName()+".bak");
|
||||
Loader.log.fine(String.format("MLProp configuration file for %s found but not required. Attempting to rename file to %s", modConfigName, mlPropBackup.getName()));
|
||||
boolean renamed = modConfig.renameTo(mlPropBackup);
|
||||
if (renamed)
|
||||
{
|
||||
Loader.log.fine(String.format("Unused MLProp configuration file for %s renamed successfully to %s", modConfigName, mlPropBackup.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Loader.log.fine(String.format("Unused MLProp configuration file for %s renamed UNSUCCESSFULLY to %s", modConfigName, mlPropBackup.getName()));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
FileWriter configWriter = new FileWriter(modConfig);
|
||||
props.store(configWriter, comments.toString());
|
||||
configWriter.close();
|
||||
Loader.log.fine(String.format("Configuration for %s written to %s", modConfigName, modConfig.getName()));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Loader.log.warning(String.format("Error trying to write the config file %s", modConfig.getName()));
|
||||
Loader.log.throwing("ModLoaderModContainer", "configureMod", e);
|
||||
throw new LoaderException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object parseValue(String val, ModProperty property, Class<?> type, String propertyName, String modConfigName)
|
||||
{
|
||||
if (type.isAssignableFrom(String.class))
|
||||
{
|
||||
return (String)val;
|
||||
}
|
||||
else if (type.isAssignableFrom(Boolean.TYPE) || type.isAssignableFrom(Boolean.class))
|
||||
{
|
||||
return Boolean.parseBoolean(val);
|
||||
}
|
||||
else if (Number.class.isAssignableFrom(type) || type.isPrimitive())
|
||||
{
|
||||
Number n = null;
|
||||
|
||||
if (type.isAssignableFrom(Double.TYPE) || Double.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Double.parseDouble(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Float.TYPE) || Float.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Float.parseFloat(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Long.TYPE) || Long.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Long.parseLong(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Integer.TYPE) || Integer.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Integer.parseInt(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Short.TYPE) || Short.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Short.parseShort(val);
|
||||
}
|
||||
else if (type.isAssignableFrom(Byte.TYPE) || Byte.class.isAssignableFrom(type))
|
||||
{
|
||||
n = Byte.parseByte(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException(String.format("MLProp declared on %s of type %s, an unsupported type",propertyName, type.getName()));
|
||||
}
|
||||
|
||||
if (n.doubleValue() < property.min() || n.doubleValue() > property.max())
|
||||
{
|
||||
Loader.log.warning(String.format("Configuration for %s.%s found value %s outside acceptable range %s,%s", modConfigName,propertyName, n, property.min(), property.max()));
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(String.format("MLProp declared on %s of type %s, an unsupported type",propertyName, type.getName()));
|
||||
}
|
||||
private String extractValue(Object value)
|
||||
{
|
||||
if (String.class.isInstance(value))
|
||||
{
|
||||
return (String)value;
|
||||
}
|
||||
else if (Number.class.isInstance(value) || Boolean.class.isInstance(value))
|
||||
{
|
||||
return String.valueOf(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("MLProp declared on non-standard type");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
mod.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
mod.modsLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return mod != null ? mod.getName() : modClazz.getSimpleName();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ModContainer findContainerFor(BaseMod mod)
|
||||
{
|
||||
return FMLCommonHandler.instance().findContainerFor(mod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSortingRules()
|
||||
{
|
||||
if (mod!=null) {
|
||||
return mod.getPriorities();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean matches(Object mod)
|
||||
{
|
||||
return modClazz.isInstance(mod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all the BaseMods in the system
|
||||
* @param <A>
|
||||
* @return
|
||||
*/
|
||||
public static <A extends BaseMod> List<A> findAll(Class<A> clazz)
|
||||
{
|
||||
ArrayList<A> modList = new ArrayList<A>();
|
||||
|
||||
for (ModContainer mc : Loader.getModList())
|
||||
{
|
||||
if (mc instanceof ModLoaderModContainer && mc.getMod()!=null)
|
||||
{
|
||||
modList.add((A)((ModLoaderModContainer)mc).mod);
|
||||
}
|
||||
}
|
||||
|
||||
return modList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getSource()
|
||||
{
|
||||
return modSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMod()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lookupFuelValue(int itemId, int itemDamage)
|
||||
{
|
||||
return mod.addFuel(itemId, itemDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsPickupNotification()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPickupNotifier getPickupNotifier()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsToDispense()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDispenseHandler getDispenseHandler()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsCraftingNotification()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingHandler getCraftingHandler()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
private void computeDependencies()
|
||||
{
|
||||
dependencies = new ArrayList<String>();
|
||||
preDependencies = new ArrayList<String>();
|
||||
postDependencies = new ArrayList<String>();
|
||||
|
||||
if (mod.getPriorities() == null || mod.getPriorities().length() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean parseFailure=false;
|
||||
StringTokenizer st = new StringTokenizer(mod.getPriorities(), ";");
|
||||
|
||||
for (; st.hasMoreTokens();)
|
||||
{
|
||||
String dep = st.nextToken();
|
||||
String[] depparts = dep.split(":");
|
||||
|
||||
if (depparts.length < 2)
|
||||
{
|
||||
parseFailure=true;
|
||||
continue;
|
||||
}
|
||||
else if ("required-before".equals(depparts[0]) || "required-after".equals(depparts[0]))
|
||||
{
|
||||
if (!depparts[1].trim().equals("*")) {
|
||||
dependencies.add(depparts[1]);
|
||||
} else {
|
||||
parseFailure=true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ("required-before".equals(depparts[0]) || "before".equals(depparts[0]))
|
||||
{
|
||||
postDependencies.add(depparts[1]);
|
||||
} else if ("required-after".equals(depparts[0]) || "after".equals(depparts[0]))
|
||||
{
|
||||
preDependencies.add(depparts[1]);
|
||||
} else {
|
||||
parseFailure=true;
|
||||
}
|
||||
}
|
||||
|
||||
if (parseFailure) {
|
||||
FMLCommonHandler.instance().getFMLLogger().warning(String.format("The mod %s has an incorrect dependency string {%s}", mod.getName(), mod.getPriorities()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDependencies()
|
||||
{
|
||||
if (dependencies == null)
|
||||
{
|
||||
computeDependencies();
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPostDepends()
|
||||
{
|
||||
if (dependencies == null)
|
||||
{
|
||||
computeDependencies();
|
||||
}
|
||||
|
||||
return postDependencies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPreDepends()
|
||||
{
|
||||
if (dependencies == null)
|
||||
{
|
||||
computeDependencies();
|
||||
}
|
||||
return preDependencies;
|
||||
}
|
||||
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return modClazz.getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsNetworkPackets()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkHandler getNetworkHandler()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ownsNetworkChannel(String channel)
|
||||
{
|
||||
return FMLCommonHandler.instance().getChannelListFor(this).contains(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsConsoleCommands()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConsoleHandler getConsoleHandler()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsPlayerTracking()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPlayerTracker getPlayerTracker()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param keyHandler
|
||||
* @param allowRepeat
|
||||
*/
|
||||
public void addKeyHandler(IKeyHandler handler)
|
||||
{
|
||||
if (keyHandlers==null) {
|
||||
keyHandlers=new ArrayList<IKeyHandler>();
|
||||
}
|
||||
|
||||
Iterator<IKeyHandler> itr = keyHandlers.iterator();
|
||||
while(itr.hasNext())
|
||||
{
|
||||
IKeyHandler old = itr.next();
|
||||
if (old.getKeyBinding() == handler.getKeyBinding())
|
||||
{
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
|
||||
keyHandlers.add(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IKeyHandler> getKeys()
|
||||
{
|
||||
if (keyHandlers==null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return keyHandlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSourceType(SourceType type) {
|
||||
this.sourceType=type;
|
||||
}
|
||||
@Override
|
||||
public SourceType getSourceType()
|
||||
{
|
||||
return sourceType;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getMetadata()
|
||||
*/
|
||||
@Override
|
||||
public ModMetadata getMetadata()
|
||||
{
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#setMetadata(cpw.mods.fml.common.ModMetadata)
|
||||
*/
|
||||
@Override
|
||||
public void setMetadata(ModMetadata meta)
|
||||
{
|
||||
this.metadata=meta;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#gatherRenderers(java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void gatherRenderers(Map renderers)
|
||||
{
|
||||
mod.onRenderHarvest(renderers);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#requestAnimations()
|
||||
*/
|
||||
@Override
|
||||
public void requestAnimations()
|
||||
{
|
||||
mod.onRegisterAnimations();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getVersion()
|
||||
*/
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
if (mod == null || mod.getVersion() == null)
|
||||
{
|
||||
return "Not available";
|
||||
}
|
||||
return mod.getVersion();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#findSidedProxy()
|
||||
*/
|
||||
@Override
|
||||
public ProxyInjector findSidedProxy()
|
||||
{
|
||||
if (sidedProxy==null) {
|
||||
sidedProxy = FMLCommonHandler.instance().getSidedDelegate().findSidedProxyOn(mod);
|
||||
if (sidedProxy == null)
|
||||
{
|
||||
sidedProxy = NULLPROXY;
|
||||
}
|
||||
}
|
||||
return sidedProxy == NULLPROXY ? null : sidedProxy;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#keyBindEvernt(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void keyBindEvent(Object keybinding)
|
||||
{
|
||||
mod.keyBindingEvent(keybinding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public BaseModTicker getTickHandler()
|
||||
{
|
||||
return this.tickHandler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common.modloader;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public class ModProperty
|
||||
{
|
||||
private String info;
|
||||
private double min;
|
||||
private double max;
|
||||
private String name;
|
||||
|
||||
public ModProperty(String info, double min, double max, String name)
|
||||
{
|
||||
this.info = info;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.name = name;
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String name()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public double min()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return min;
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public double max()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return max;
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String info()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return info;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 2191 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user