mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-14 17:14:46 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3978a068d1 | ||
|
|
9d2d0af432 | ||
|
|
d451309170 | ||
|
|
c82dd0fbfb | ||
|
|
803911e10a | ||
|
|
29eedf9011 | ||
|
|
882848a00f | ||
|
|
4d253e1dd6 | ||
|
|
f0c535f30a | ||
|
|
1d162bf5ca | ||
|
|
af036b64e8 | ||
|
|
06a86742bb | ||
|
|
e48fbe948e | ||
|
|
d4cd2153ef | ||
|
|
4887926994 | ||
|
|
9989451c1c | ||
|
|
ce3d891eaa | ||
|
|
e8c2223f01 | ||
|
|
714206d8c8 | ||
|
|
6593d75234 | ||
|
|
97a96b8f3f | ||
|
|
5bc0f0156e | ||
|
|
b922c89bb1 | ||
|
|
8eb601b6cf | ||
|
|
f86031f884 | ||
|
|
d59072b771 | ||
|
|
c780ec6aaf | ||
|
|
558d78bc63 | ||
|
|
0f61cea75e | ||
|
|
08a9badc54 | ||
|
|
d71b0e5646 | ||
|
|
8a870b9c76 | ||
|
|
59885f1916 | ||
|
|
7f54ddaa83 | ||
|
|
eb502ac0ca | ||
|
|
2b2370be43 | ||
|
|
0aec8b65e9 | ||
|
|
3de7766db6 | ||
|
|
671752d1cf | ||
|
|
b42837ef70 | ||
|
|
f5407f9e88 | ||
|
|
fc0ef3eef0 | ||
|
|
76ceb7a46c | ||
|
|
d169666f43 | ||
|
|
5802178bbd | ||
|
|
d30b2482df | ||
|
|
f4e9c61e3a | ||
|
|
7362286ead | ||
|
|
90b13eac1d | ||
|
|
f76af59569 | ||
|
|
5d12fa7550 | ||
|
|
16922e6b99 | ||
|
|
46b24745a4 | ||
|
|
4b355a6c4a | ||
|
|
9efe1a940e | ||
|
|
ee114f82ec | ||
|
|
12a81c5357 | ||
|
|
a149a29171 | ||
|
|
82556c850e | ||
|
|
e265ffe09e | ||
|
|
b9b71cf015 | ||
|
|
9536bf1b78 | ||
|
|
298795690e | ||
|
|
af59a2ad6a | ||
|
|
4d7988ee0f | ||
|
|
ab0952ac2b | ||
|
|
042b36a350 | ||
|
|
1ac0cf5489 | ||
|
|
5f8661a17f | ||
|
|
6a607e4551 | ||
|
|
172a2c00ac | ||
|
|
7dff774368 | ||
|
|
272152d48e | ||
|
|
2fce803456 | ||
|
|
a679d46c57 | ||
|
|
2b4dfcdae3 | ||
|
|
786dbd82c7 | ||
|
|
0848cfb891 | ||
|
|
7fc90fb76e | ||
|
|
08741959b3 | ||
|
|
93062955ba | ||
|
|
fd41fb9ff7 | ||
|
|
a9b90f4fef | ||
|
|
f5245e766b | ||
|
|
4d43e918f1 | ||
|
|
bf2da35086 | ||
|
|
e0737d2851 | ||
|
|
dceffe23c3 | ||
|
|
f6e1147271 | ||
|
|
7028a17649 | ||
|
|
b08a618baa | ||
|
|
433c516166 | ||
|
|
1ce2d45417 | ||
|
|
b18cee80cb | ||
|
|
62fcb24160 | ||
|
|
f6b92ad6ac | ||
|
|
c576f745fb | ||
|
|
870906188c | ||
|
|
9df241b1ac | ||
|
|
c218d6c9e1 | ||
|
|
ee55d90746 | ||
|
|
8597d67416 | ||
|
|
fcad67a1c2 | ||
|
|
1bd3b61df9 | ||
|
|
060ca1eb80 | ||
|
|
56dfae034d | ||
|
|
636201ce5a | ||
|
|
f6bbf33b7a | ||
|
|
9eec976f7b | ||
|
|
5b8b0c78b0 | ||
|
|
8e92d16320 | ||
|
|
853d69a0f1 | ||
|
|
97285cfcb2 | ||
|
|
d4f3f0d327 | ||
|
|
98a2d9c65e | ||
|
|
eb010094ca | ||
|
|
0b71684778 | ||
|
|
0f085e0691 | ||
|
|
c3f37a379a | ||
|
|
5a7bd9f57a | ||
|
|
e6cbced8a2 | ||
|
|
7ec3b8bf9b | ||
|
|
d300078227 | ||
|
|
dab217eab0 | ||
|
|
65c7f0242c | ||
|
|
c4140ef9c3 | ||
|
|
dffa845851 | ||
|
|
1aefd5863e | ||
|
|
389e5e01e7 | ||
|
|
a55b2645b7 | ||
|
|
9a36381ce0 | ||
|
|
8745f56f8b | ||
|
|
273dae3298 | ||
|
|
b1b877f530 | ||
|
|
6870dafe02 | ||
|
|
b3b1a6a415 | ||
|
|
953a84f346 | ||
|
|
3ac0ac9625 | ||
|
|
c6dae0318c | ||
|
|
7ace6d7faa | ||
|
|
8eb366997d | ||
|
|
dc1449855e | ||
|
|
f832025f6d | ||
|
|
b36d10308b | ||
|
|
195c8fc524 | ||
|
|
2565eea5ba | ||
|
|
13ae9ece47 | ||
|
|
d3e87b1aaf | ||
|
|
bdd386c431 | ||
|
|
1e9952e908 | ||
|
|
10678d6469 | ||
|
|
1601136304 | ||
|
|
e1758f63cd | ||
|
|
f46bcf228c | ||
|
|
baa70ece6d | ||
|
|
8977d04de0 | ||
|
|
2a35b05ec1 | ||
|
|
122af6d72d | ||
|
|
9cd3b9af5b | ||
|
|
61704192fe | ||
|
|
a3ae2b797f | ||
|
|
d94a688f28 | ||
|
|
b3fbadce84 | ||
|
|
04d6b979ab | ||
|
|
fae3b3d24e | ||
|
|
98372c3e08 | ||
|
|
0a68dc0307 | ||
|
|
4c72917c05 | ||
|
|
b41646540c | ||
|
|
8dc81b53d6 | ||
|
|
ec111e38c3 | ||
|
|
8edd081de6 | ||
|
|
852604e9d4 | ||
|
|
58a8b29bbf | ||
|
|
0fc61f46b0 | ||
|
|
92d53626ce | ||
|
|
24ca3d20f3 | ||
|
|
080e026285 | ||
|
|
e5979367ee | ||
|
|
960b322e86 | ||
|
|
d536d5cf46 | ||
|
|
3850b1b172 | ||
|
|
7981288250 | ||
|
|
e77f62d8e7 | ||
|
|
5326e41c9f | ||
|
|
f2395d27a8 | ||
|
|
ca9c99c283 | ||
|
|
8cbb94aed0 | ||
|
|
e00d96ff08 | ||
|
|
d436657556 | ||
|
|
f862485a05 | ||
|
|
9af62513e5 | ||
|
|
e8fa5ebca9 | ||
|
|
a9fbfbbe74 | ||
|
|
c54b7c40bb | ||
|
|
2b3b590cf4 | ||
|
|
291fa98639 | ||
|
|
a2938d8e55 | ||
|
|
0d1d8295b4 | ||
|
|
daa3ab13be | ||
|
|
17182cc2b2 | ||
|
|
8f1b1e03f4 | ||
|
|
d55b119019 | ||
|
|
00c444a46d | ||
|
|
e780215100 | ||
|
|
3c5c624251 | ||
|
|
36508a191a | ||
|
|
550462221c | ||
|
|
defbdc8e71 | ||
|
|
6346039f14 | ||
|
|
d32530caba | ||
|
|
f5a73db68d | ||
|
|
e23a38e1f1 | ||
|
|
6763619289 | ||
|
|
d652cd7a9b | ||
|
|
7183d734f0 | ||
|
|
7b93aca1e6 | ||
|
|
bcaaf251c6 | ||
|
|
eefd71ef56 | ||
|
|
f2d315c251 | ||
|
|
e4b8342e1c | ||
|
|
107047a04c | ||
|
|
1430becdff | ||
|
|
77295ab74e | ||
|
|
68f61ab9ab | ||
|
|
1c6d55931d | ||
|
|
8fe121f8b9 | ||
|
|
0fcd151776 | ||
|
|
52994b2a39 | ||
|
|
885fc1291e | ||
|
|
b23167d468 | ||
|
|
6d7f30ea6b | ||
|
|
70d8d76934 | ||
|
|
a449e1b3b2 | ||
|
|
ca64f88113 | ||
|
|
62261a5b8f | ||
|
|
20b2dcf9c3 | ||
|
|
98e62aa1e3 | ||
|
|
a4f7e4c583 | ||
|
|
305be1b979 | ||
|
|
43bd276389 | ||
|
|
eb20049b6d | ||
|
|
4432b0dac4 | ||
|
|
8d5b19787e | ||
|
|
d705f4f4db | ||
|
|
2f6969e141 | ||
|
|
26ff21f446 | ||
|
|
4cfa8f7338 | ||
|
|
e2fff11ea8 | ||
|
|
09df969bcf | ||
|
|
483a21cd7d | ||
|
|
71dcbdf0e4 | ||
|
|
d63377532c | ||
|
|
46348fca07 | ||
|
|
08555326b2 | ||
|
|
90f80da4da | ||
|
|
db0ab5feda | ||
|
|
06549d1e2d | ||
|
|
8406073107 | ||
|
|
e55b21028e | ||
|
|
a1cf0ddf77 | ||
|
|
2d8cadea26 | ||
|
|
4e963ca6e1 | ||
|
|
947717873d | ||
|
|
45f167754a | ||
|
|
35afdc66b8 | ||
|
|
89c3fb8bdf | ||
|
|
c7d88d73d3 | ||
|
|
344bb7514b | ||
|
|
db93c6e930 | ||
|
|
aaa00d0184 | ||
|
|
d4b8c6b503 | ||
|
|
ccdcce47cc | ||
|
|
990d4990db | ||
|
|
364ed4cf53 | ||
|
|
84da3cc939 | ||
|
|
344e842764 | ||
|
|
3d4ba15751 | ||
|
|
d8beaa92b9 | ||
|
|
a68cbc54e7 | ||
|
|
a8b7098f39 | ||
|
|
1b741eaac5 | ||
|
|
9cbb6e390b | ||
|
|
c4b3f7e9f1 | ||
|
|
792ab77a48 | ||
|
|
3326f4db03 | ||
|
|
5ea4770a2d | ||
|
|
5c4bd5307c | ||
|
|
2242dfdfb9 | ||
|
|
e26da52d21 | ||
|
|
dbf6202a90 | ||
|
|
ce232e808e | ||
|
|
31574a9c6e | ||
|
|
1d2266a524 | ||
|
|
a300e97aa0 | ||
|
|
76fe2b1c90 | ||
|
|
099f33549b | ||
|
|
e281cb4591 | ||
|
|
99f09b4037 | ||
|
|
cd9a4110ee | ||
|
|
6b35ff2ba1 | ||
|
|
23ffb78ab3 | ||
|
|
5133e721cc | ||
|
|
09ced92f5b | ||
|
|
12477a7711 | ||
|
|
b7dc4d9144 | ||
|
|
2cb1959421 | ||
|
|
da48d317ff | ||
|
|
5bfb11e952 | ||
|
|
4dffb9f352 | ||
|
|
beadb47539 | ||
|
|
6301d3c193 | ||
|
|
883863e047 | ||
|
|
2c14f02151 | ||
|
|
7ffb9d5c1d | ||
|
|
029604222c | ||
|
|
c6f205864f | ||
|
|
4cc318bc1d | ||
|
|
c010977a0b | ||
|
|
84e9673454 | ||
|
|
54e4aafc0e | ||
|
|
46256bac41 | ||
|
|
4f48cd5890 | ||
|
|
48d6230ed1 | ||
|
|
f3895aeaab | ||
|
|
4c6a461425 | ||
|
|
f6a166c87f | ||
|
|
8be4298ca9 | ||
|
|
fafee34803 | ||
|
|
4ab3e7ddb4 | ||
|
|
8ff72af9d2 | ||
|
|
b2d722a4c5 | ||
|
|
475d99eae8 | ||
|
|
d0244ece32 | ||
|
|
4f95ceab29 | ||
|
|
0105f36668 | ||
|
|
ab3ba0c4db | ||
|
|
38009bb32a | ||
|
|
d132a0ae62 | ||
|
|
d827a0f132 | ||
|
|
891c0c6133 | ||
|
|
f8a9bf44c3 | ||
|
|
874a49262d | ||
|
|
3636af5b9c | ||
|
|
00771b1a42 | ||
|
|
46ec2f2740 | ||
|
|
034cdf2860 | ||
|
|
3d765067cf | ||
|
|
9da092e6d4 | ||
|
|
0b5a5bc34d | ||
|
|
c17a6af267 | ||
|
|
3884fecf77 | ||
|
|
05a7ac6d93 | ||
|
|
7f5108f26c | ||
|
|
be82dd318b | ||
|
|
ce2930b1ab | ||
|
|
cc187d6b8b | ||
|
|
1d2c4e438d | ||
|
|
be0a62b831 | ||
|
|
8b37aa86ff | ||
|
|
9d70a1b0ec | ||
|
|
6ea4ab4491 | ||
|
|
10a5ba3eb8 | ||
|
|
8ce7e49d5f | ||
|
|
34c1956cc1 | ||
|
|
cfbde3eb83 | ||
|
|
328b9e8356 | ||
|
|
878fe51866 | ||
|
|
efe1236326 | ||
|
|
abe0563550 | ||
|
|
14b34e0b01 | ||
|
|
dba8b5448a | ||
|
|
91206dce35 | ||
|
|
6cdafc05de | ||
|
|
00924ccd68 | ||
|
|
e251d28893 | ||
|
|
0ec13d6966 | ||
|
|
07ba130dc6 | ||
|
|
6927c4d5fb | ||
|
|
e2144b140b | ||
|
|
aab26dca3e | ||
|
|
bb5f2b0977 | ||
|
|
eca3be2e63 | ||
|
|
feef3b8a63 | ||
|
|
6e33a55bcb | ||
|
|
53f512d7aa | ||
|
|
b6ba59f9f9 | ||
|
|
ae3f75e22a | ||
|
|
9dd73935d7 | ||
|
|
b69897ff3d | ||
|
|
4da4a7cf56 | ||
|
|
9ddb43e388 | ||
|
|
ead6b2c9b9 | ||
|
|
25a88df47c | ||
|
|
968ad8189e | ||
|
|
aba03f6364 | ||
|
|
70e8654adb | ||
|
|
8fe22130d3 | ||
|
|
79c7ae435c | ||
|
|
6a3d92e825 | ||
|
|
c2acb36c44 | ||
|
|
4609ebc754 | ||
|
|
aea3c55192 | ||
|
|
e7ae15c81d | ||
|
|
4a390fe967 | ||
|
|
2132c4457d | ||
|
|
267905ef3f | ||
|
|
e528609212 | ||
|
|
6fb07b9d40 |
No files matched your search
@@ -5,6 +5,7 @@
|
||||
!/forestry_techne
|
||||
!/gradle/wrapper
|
||||
!/src
|
||||
!/api
|
||||
|
||||
# files
|
||||
!/.gitignore
|
||||
@@ -12,6 +13,7 @@
|
||||
!/CLA.txt
|
||||
!/CONTRIBUTING.md
|
||||
!/LICENSE.txt
|
||||
!/license-header.txt
|
||||
!/README.md
|
||||
!/application.properties
|
||||
!/build.gradle
|
||||
|
||||
+5
-2
@@ -1,6 +1,9 @@
|
||||
[submodule "lang"]
|
||||
path = lang
|
||||
url = https://github.com/ForestryMC/Forestry-Localization.git
|
||||
[submodule "api"]
|
||||
path = api
|
||||
[submodule "api/redstoneflux"]
|
||||
path = api/redstoneflux
|
||||
url = https://github.com/CoFH/RedstoneFlux-API.git
|
||||
[submodule "api/forestry"]
|
||||
path = api/forestry
|
||||
url = https://github.com/ForestryMC/ForestryAPI.git
|
||||
@@ -1,6 +1,6 @@
|
||||
Forestry
|
||||
====================================
|
||||
|
||||
|
||||
### What is it?
|
||||
|
||||
Forestry is a modification for the game Minecraft and known primarily for its farms and bees.
|
||||
|
||||
-1
Submodule api deleted from 4f7ca82190.
Submodule
+1
Submodule api/forestry added at 3e5b83d1b9.
Submodule
+1
Submodule api/redstoneflux added at 10e10af214.
@@ -1,6 +1,5 @@
|
||||
mcversion=1.7.10
|
||||
forgeversion=10.13.0.1207
|
||||
forgeversion=10.13.2.1286
|
||||
version_major=3
|
||||
version_minor=2
|
||||
version_patch=0
|
||||
|
||||
version_minor=5
|
||||
version_patch=2
|
||||
+30
-34
@@ -31,7 +31,9 @@ archivesBaseName = "forestry_" + mcversion
|
||||
|
||||
ext.dirDest = './build/dist'
|
||||
ext.dirLang = "./lang"
|
||||
ext.dirApi = "./api"
|
||||
|
||||
ext.apiForestry = "./api/forestry"
|
||||
ext.apiRedstoneFlux = "./api/redstoneflux"
|
||||
|
||||
ext.CraftGuideRepo = "https://github.com/Uristqwerty/CraftGuide.git"
|
||||
ext.CraftGuideTmp = "build/tmp/CraftGuide"
|
||||
@@ -54,7 +56,8 @@ sourceSets {
|
||||
|
||||
main {
|
||||
java {
|
||||
srcDir project.dirApi
|
||||
srcDir project.apiForestry
|
||||
srcDir project.apiRedstoneFlux + "/src/main/java"
|
||||
}
|
||||
resources {
|
||||
srcDir project.dirLang
|
||||
@@ -70,13 +73,13 @@ repositories {
|
||||
}
|
||||
|
||||
configurations {
|
||||
apis
|
||||
compile.extendsFrom apis
|
||||
api
|
||||
compile.extendsFrom api
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api'
|
||||
apis 'com.mod-buildcraft:buildcraft:6.1.5:dev'
|
||||
api 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api'
|
||||
api 'com.mod-buildcraft:buildcraft:6.3.1:dev'
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -178,12 +181,15 @@ jar {
|
||||
destinationDir = file("build/tmp")
|
||||
archiveName = "main.jar"
|
||||
|
||||
from {
|
||||
configurations.apis.collect {
|
||||
it.isDirectory() ? it : zipTree(it).matching {
|
||||
include '**/api/**'
|
||||
}
|
||||
}
|
||||
// Copy various READMEs and Licensing files into the jar
|
||||
into ('forestry/api') {
|
||||
from project.apiForestry + "/LICENSE.txt"
|
||||
}
|
||||
into ('cofh/api') {
|
||||
from project.apiRedstoneFlux + "/LICENSE - LGPLv3.txt"
|
||||
}
|
||||
into ('buildcraft/api') {
|
||||
from "./src/main/java/buildcraft/LICENSE-API"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +197,6 @@ task mainJarSigned ( type: Jar, dependsOn: 'reobf' ) {
|
||||
from (zipTree(jar.getArchivePath())) {
|
||||
exclude '**/api/**'
|
||||
exclude '**/codechicken/**'
|
||||
exclude '**/old/lang/**'
|
||||
}
|
||||
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
@@ -218,7 +223,6 @@ task mainJar ( type: Zip, dependsOn: mainJarSigned ) {
|
||||
from (zipTree(jar.getArchivePath())) {
|
||||
include '**'
|
||||
exclude '**/codechicken/**'
|
||||
exclude '**/old/lang/**'
|
||||
}
|
||||
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
@@ -231,7 +235,6 @@ task devJarSigned ( type: Jar, dependsOn: 'classes' ) {
|
||||
from(sourceSets.main.output) {
|
||||
exclude '**/api/**'
|
||||
exclude '**/codechicken/**'
|
||||
exclude '**/old/lang/**'
|
||||
}
|
||||
|
||||
destinationDir = file("build/tmp")
|
||||
@@ -257,21 +260,11 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) {
|
||||
from(sourceSets.main.allSource) {
|
||||
include '**'
|
||||
exclude '**/codechicken/**'
|
||||
exclude '**/old/lang/**'
|
||||
}
|
||||
|
||||
from(sourceSets.main.output) {
|
||||
include '**'
|
||||
exclude '**/codechicken/**'
|
||||
exclude '**/old/lang/**'
|
||||
}
|
||||
|
||||
from {
|
||||
configurations.apis.collect {
|
||||
it.isDirectory() ? it : zipTree(it).matching {
|
||||
include '**/api/**'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
@@ -282,9 +275,7 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) {
|
||||
}
|
||||
|
||||
task apiJar(type: Jar, dependsOn: 'classes') {
|
||||
from (dirApi) {
|
||||
include '**'
|
||||
}
|
||||
from project.apiForestry
|
||||
|
||||
from (sourceSets.main.output) {
|
||||
include 'forestry/api/**'
|
||||
@@ -295,14 +286,19 @@ task apiJar(type: Jar, dependsOn: 'classes') {
|
||||
classifier = 'api'
|
||||
}
|
||||
|
||||
task release(dependsOn: [apiJar, devJar, mainJar]) {
|
||||
doLast {
|
||||
println '*************************************************************'
|
||||
println 'This build will be version: ' + project.version
|
||||
println '*************************************************************'
|
||||
}
|
||||
task releaseInit << {
|
||||
println '*************************************************************'
|
||||
println 'This build will be version: ' + rootProject.version
|
||||
println '*************************************************************'
|
||||
}
|
||||
|
||||
task release (dependsOn: [releaseInit, apiJar, devJar, mainJar]) {
|
||||
}
|
||||
|
||||
mainJar.shouldRunAfter releaseInit
|
||||
devJar.shouldRunAfter releaseInit
|
||||
apiJar.shouldRunAfter releaseInit
|
||||
|
||||
afterEvaluate {
|
||||
compileApiJava.dependsOn initCraftGuide
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Account;Email;Date;
|
||||
samtrion;[email protected];2015-01-18
|
||||
GenuineSounds;[email protected];2015-02-26
|
||||
Binary file not shown.
+1
-1
Submodule lang updated: 8ca6c91070...fa0f81998b.
Executable → Regular
+5
-7
@@ -1,14 +1,12 @@
|
||||
/*******************************************************************************
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.circuits;
|
||||
|
||||
public class CircuitBoardManager {
|
||||
}
|
||||
*******************************************************************************
|
||||
*/
|
||||
@@ -0,0 +1,21 @@
|
||||
BuildCraft API License
|
||||
|
||||
Copyright (c) 2011-2014 SpaceToad and the BuildCraft team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License.
|
||||
* Please check the contents of the license, which should be located
|
||||
* as "LICENSE.API" in the BuildCraft source code distribution.
|
||||
*/
|
||||
package buildcraft.api.tools;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
/***
|
||||
* Implement this interface on subclasses of Item to have that item work as a wrench for buildcraft
|
||||
*/
|
||||
public interface IToolWrench {
|
||||
|
||||
/***
|
||||
* Called to ensure that the wrench can be used. To get the ItemStack that is used, check player.inventory.getCurrentItem()
|
||||
*
|
||||
* @param player
|
||||
* - The player doing the wrenching
|
||||
* @param x
|
||||
* ,y,z - The coordinates for the block being wrenched
|
||||
*
|
||||
* @return true if wrenching is allowed, false if not
|
||||
*/
|
||||
boolean canWrench(EntityPlayer player, int x, int y, int z);
|
||||
|
||||
/***
|
||||
* Callback after the wrench has been used. This can be used to decrease durability or for other purposes. To get the ItemStack that was used, check
|
||||
* player.inventory.getCurrentItem()
|
||||
*
|
||||
* @param player
|
||||
* - The player doing the wrenching
|
||||
* @param x
|
||||
* ,y,z - The coordinates of the block being wrenched
|
||||
*/
|
||||
void wrenchUsed(EntityPlayer player, int x, int y, int z);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* The BuildCraft API is distributed under the terms of the MIT License.
|
||||
* Please check the contents of the license, which should be located
|
||||
* as "LICENSE.API" in the BuildCraft source code distribution.
|
||||
*/
|
||||
@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tools")
|
||||
package buildcraft.api.tools;
|
||||
import cpw.mods.fml.common.API;
|
||||
@@ -1,11 +0,0 @@
|
||||
package cofh.api;
|
||||
|
||||
public class CoFHAPIProps {
|
||||
|
||||
private CoFHAPIProps() {
|
||||
|
||||
}
|
||||
|
||||
public static final String VERSION = "1.7.10R1.0.1";
|
||||
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class EnergyStorage implements IEnergyStorage {
|
||||
|
||||
protected int energy;
|
||||
protected int capacity;
|
||||
protected int maxReceive;
|
||||
protected int maxExtract;
|
||||
|
||||
public EnergyStorage(int capacity) {
|
||||
|
||||
this(capacity, capacity, capacity);
|
||||
}
|
||||
|
||||
public EnergyStorage(int capacity, int maxTransfer) {
|
||||
|
||||
this(capacity, maxTransfer, maxTransfer);
|
||||
}
|
||||
|
||||
public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
|
||||
|
||||
this.capacity = capacity;
|
||||
this.maxReceive = maxReceive;
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public EnergyStorage readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
this.energy = nbt.getInteger("Energy");
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
if (energy < 0) {
|
||||
energy = 0;
|
||||
}
|
||||
nbt.setInteger("Energy", energy);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void setCapacity(int capacity) {
|
||||
|
||||
this.capacity = capacity;
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxTransfer(int maxTransfer) {
|
||||
|
||||
setMaxReceive(maxTransfer);
|
||||
setMaxExtract(maxTransfer);
|
||||
}
|
||||
|
||||
public void setMaxReceive(int maxReceive) {
|
||||
|
||||
this.maxReceive = maxReceive;
|
||||
}
|
||||
|
||||
public void setMaxExtract(int maxExtract) {
|
||||
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public int getMaxReceive() {
|
||||
|
||||
return maxReceive;
|
||||
}
|
||||
|
||||
public int getMaxExtract() {
|
||||
|
||||
return maxExtract;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers are
|
||||
* guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void setEnergyStored(int energy) {
|
||||
|
||||
this.energy = energy;
|
||||
|
||||
if (this.energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this
|
||||
* externally, as not all IEnergyHandlers are guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void modifyEnergyStored(int energy) {
|
||||
|
||||
this.energy += energy;
|
||||
|
||||
if (this.energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* IEnergyStorage */
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
|
||||
return capacity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
|
||||
* accept it; otherwise just use IEnergyHandler.
|
||||
*
|
||||
* Note that {@link IEnergyHandler} is an extension of this.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Returns TRUE if the TileEntity can connect on a given side.
|
||||
*/
|
||||
boolean canConnectEnergy(ForgeDirection from);
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Implement this interface on Item classes that support external manipulation of their internal energy storages.
|
||||
*
|
||||
* A reference implementation is provided {@link ItemEnergyContainer}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyContainerItem {
|
||||
|
||||
/**
|
||||
* Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged.
|
||||
*
|
||||
* @param container
|
||||
* ItemStack to be charged.
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to be sent into the item.
|
||||
* @param simulate
|
||||
* If TRUE, the charge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) received by the item.
|
||||
*/
|
||||
int receiveEnergy(ItemStack container, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally
|
||||
* discharged.
|
||||
*
|
||||
* @param container
|
||||
* ItemStack to be discharged.
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to be extracted from the item.
|
||||
* @param simulate
|
||||
* If TRUE, the discharge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted from the item.
|
||||
*/
|
||||
int extractEnergy(ItemStack container, int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Get the amount of energy currently stored in the container item.
|
||||
*/
|
||||
int getEnergyStored(ItemStack container);
|
||||
|
||||
/**
|
||||
* Get the max amount of energy that can be stored in the container item.
|
||||
*/
|
||||
int getMaxEnergyStored(ItemStack container);
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||
*
|
||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyHandler extends IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is received from.
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to receive.
|
||||
* @param simulate
|
||||
* If TRUE, the charge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) received.
|
||||
*/
|
||||
int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is extracted from.
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to extract.
|
||||
* @param simulate
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted.
|
||||
*/
|
||||
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored(ForgeDirection from);
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored(ForgeDirection from);
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
/**
|
||||
* An energy storage is the unit of interaction with Energy inventories.
|
||||
*
|
||||
* A reference implementation can be found at {@link EnergyStorage}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyStorage {
|
||||
|
||||
/**
|
||||
* Adds energy to the storage. Returns quantity of energy that was accepted.
|
||||
*
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to be inserted.
|
||||
* @param simulate
|
||||
* If TRUE, the insertion will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) accepted by the storage.
|
||||
*/
|
||||
int receiveEnergy(int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Removes energy from the storage. Returns quantity of energy that was removed.
|
||||
*
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to be extracted.
|
||||
* @param simulate
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted from the storage.
|
||||
*/
|
||||
int extractEnergy(int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored();
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored();
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||
|
||||
protected int capacity;
|
||||
protected int maxReceive;
|
||||
protected int maxExtract;
|
||||
|
||||
public ItemEnergyContainer() {
|
||||
|
||||
}
|
||||
|
||||
public ItemEnergyContainer(int capacity) {
|
||||
|
||||
this(capacity, capacity, capacity);
|
||||
}
|
||||
|
||||
public ItemEnergyContainer(int capacity, int maxTransfer) {
|
||||
|
||||
this(capacity, maxTransfer, maxTransfer);
|
||||
}
|
||||
|
||||
public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {
|
||||
|
||||
this.capacity = capacity;
|
||||
this.maxReceive = maxReceive;
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public ItemEnergyContainer setCapacity(int capacity) {
|
||||
|
||||
this.capacity = capacity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setMaxTransfer(int maxTransfer) {
|
||||
|
||||
setMaxReceive(maxTransfer);
|
||||
setMaxExtract(maxTransfer);
|
||||
}
|
||||
|
||||
public void setMaxReceive(int maxReceive) {
|
||||
|
||||
this.maxReceive = maxReceive;
|
||||
}
|
||||
|
||||
public void setMaxExtract(int maxExtract) {
|
||||
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
/* IEnergyContainerItem */
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||
|
||||
if (container.stackTagCompound == null) {
|
||||
container.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
int energy = container.stackTagCompound.getInteger("Energy");
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
container.stackTagCompound.setInteger("Energy", energy);
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
int energy = container.stackTagCompound.getInteger("Energy");
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
container.stackTagCompound.setInteger("Energy", energy);
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack container) {
|
||||
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
return container.stackTagCompound.getInteger("Energy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ItemStack container) {
|
||||
|
||||
return capacity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
|
||||
|
||||
protected EnergyStorage storage = new EnergyStorage(32000);
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
super.readFromNBT(nbt);
|
||||
storage.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
super.writeToNBT(nbt);
|
||||
storage.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
/* IEnergyHandler */
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
|
||||
return storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
|
||||
return storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
|
||||
return storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
|
||||
return storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
|
||||
* http://www.teamcofh.com
|
||||
*/
|
||||
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy")
|
||||
package cofh.api.energy;
|
||||
|
||||
import cofh.api.CoFHAPIProps;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/**
|
||||
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
|
||||
* http://www.teamcofh.com
|
||||
*/
|
||||
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI")
|
||||
package cofh.api;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
Executable → Regular
+39
-24
@@ -4,12 +4,19 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
@@ -22,6 +29,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.Type;
|
||||
|
||||
import forestry.api.fuels.EngineBronzeFuel;
|
||||
import forestry.api.fuels.EngineCopperFuel;
|
||||
import forestry.api.fuels.FermenterFuel;
|
||||
@@ -38,9 +46,6 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.FluidMap;
|
||||
import forestry.core.utils.ItemStackMap;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import java.io.File;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
/**
|
||||
* Forestry Minecraft Mod
|
||||
@@ -52,10 +57,11 @@ import net.minecraft.item.Item;
|
||||
name = "Forestry",
|
||||
version = Version.VERSION,
|
||||
dependencies = "required-after:Forge@[10.13.0.1207,);"
|
||||
+ "after:Buildcraft|Core;"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
+ "after:BiomesOPlenty;"
|
||||
+ "after:IC2")
|
||||
+ "after:Buildcraft|Core@[6.1.7,);"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
+ "after:BiomesOPlenty;"
|
||||
+ "after:IC2@[2.0.140,);"
|
||||
+ "after:Natura@[2.2.0,);")
|
||||
//, certificateFingerprint = Version.FINGERPRINT)
|
||||
public class Forestry {
|
||||
|
||||
@@ -63,6 +69,22 @@ public class Forestry {
|
||||
public static Forestry instance;
|
||||
private File configFolder;
|
||||
|
||||
private static final Map<String, ForestryItem> mappedItems = new HashMap<String, ForestryItem>();
|
||||
|
||||
static {
|
||||
mappedItems.put("Forestry:builderBackpack", ForestryItem.builderBackpack);
|
||||
mappedItems.put("Forestry:builderBackpackT2", ForestryItem.builderBackpackT2);
|
||||
mappedItems.put("Forestry:adventurerBackpack", ForestryItem.adventurerBackpack);
|
||||
mappedItems.put("Forestry:adventurerBackpackT2", ForestryItem.adventurerBackpackT2);
|
||||
mappedItems.put("Forestry:shortMead", ForestryItem.beverage);
|
||||
mappedItems.put("Forestry:waterCan", ForestryItem.canWater);
|
||||
mappedItems.put("Forestry:biofuelCan", ForestryItem.canEthanol);
|
||||
mappedItems.put("Forestry:biomassCan", ForestryItem.canBiomass);
|
||||
mappedItems.put("Forestry:bucketBiofuel", ForestryItem.bucketEthanol);
|
||||
mappedItems.put("Forestry:refractoryBiofuel", ForestryItem.refractoryEthanol);
|
||||
mappedItems.put("Forestry:waxCapsuleBiofuel", ForestryItem.waxCapsuleEthanol);
|
||||
}
|
||||
|
||||
public Forestry() {
|
||||
FuelManager.fermenterFuel = new ItemStackMap<FermenterFuel>();
|
||||
FuelManager.moistenerResource = new ItemStackMap<MoistenerFuel>();
|
||||
@@ -71,6 +93,7 @@ public class Forestry {
|
||||
FuelManager.copperEngineFuel = new ItemStackMap<EngineCopperFuel>();
|
||||
FuelManager.generatorFuel = new FluidMap<GeneratorFuel>();
|
||||
}
|
||||
|
||||
@SidedProxy(clientSide = "forestry.core.ForestryClient", serverSide = "forestry.core.ForestryCore")
|
||||
public static ForestryCore core = new ForestryCore();
|
||||
public static PacketHandler packetHandler;
|
||||
@@ -117,7 +140,7 @@ public class Forestry {
|
||||
|
||||
@EventHandler
|
||||
public void missingMapping(FMLMissingMappingsEvent event) {
|
||||
for (MissingMapping mapping : event.get())
|
||||
for (MissingMapping mapping : event.get()) {
|
||||
if (mapping.type == Type.BLOCK) {
|
||||
Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
|
||||
if (block != null) {
|
||||
@@ -129,22 +152,14 @@ public class Forestry {
|
||||
if (block != null) {
|
||||
mapping.remap(Item.getItemFromBlock(block));
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + StringUtil.cleanBlockName(block));
|
||||
} else if (mapping.name.equals("Forestry:builderBackpack")) {
|
||||
mapping.remap(ForestryItem.builderBackpack.item());
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpack.name());
|
||||
} else if (mapping.name.equals("Forestry:builderBackpackT2")) {
|
||||
mapping.remap(ForestryItem.builderBackpackT2.item());
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.builderBackpackT2.name());
|
||||
} else if (mapping.name.equals("Forestry:adventurerBackpack")) {
|
||||
mapping.remap(ForestryItem.adventurerBackpack.item());
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpack.name());
|
||||
} else if (mapping.name.equals("Forestry:adventurerBackpackT2")) {
|
||||
mapping.remap(ForestryItem.adventurerBackpackT2.item());
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.adventurerBackpackT2.name());
|
||||
} else if (mapping.name.equals("Forestry:shortMead")) {
|
||||
mapping.remap(ForestryItem.beverage.item());
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + ForestryItem.beverage.name());
|
||||
} else {
|
||||
ForestryItem mappedItem = mappedItems.get(mapping.name);
|
||||
if (mappedItem != null) {
|
||||
mapping.remap(mappedItem.item());
|
||||
Proxies.log.warning("Remapping item " + mapping.name + " to " + mappedItem.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -21,6 +21,7 @@ import forestry.api.apiculture.IApiaristTracker;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.EnumErrorCode;
|
||||
@@ -32,11 +33,11 @@ import forestry.plugins.PluginApiculture;
|
||||
public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
|
||||
private static final int MAX_POLLINATION_ATTEMPTS = 20;
|
||||
IBeeHousing housing;
|
||||
private final IBeeHousing housing;
|
||||
// Breeding
|
||||
private int breedingTime;
|
||||
private final int totalBreedingTime = Defaults.APIARY_BREEDING_TIME;
|
||||
private int throttle;
|
||||
private int queenWorkCycleThrottle;
|
||||
private IEffectData effectData[] = new IEffectData[2];
|
||||
private IBee queen;
|
||||
private IIndividual pollen;
|
||||
@@ -51,7 +52,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
breedingTime = nbttagcompound.getInteger("BreedingTime");
|
||||
throttle = nbttagcompound.getInteger("Throttle");
|
||||
queenWorkCycleThrottle = nbttagcompound.getInteger("Throttle");
|
||||
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Offspring", 10);
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
@@ -63,7 +64,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("BreedingTime", breedingTime);
|
||||
nbttagcompound.setInteger("Throttle", throttle);
|
||||
nbttagcompound.setInteger("Throttle", queenWorkCycleThrottle);
|
||||
|
||||
Stack<ItemStack> spawnCopy = new Stack<ItemStack>();
|
||||
spawnCopy.addAll(spawn);
|
||||
@@ -107,116 +108,186 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
resetQueen(null);
|
||||
this.queen = null;
|
||||
|
||||
// Still something to spawn, try it
|
||||
while (!spawn.isEmpty()) {
|
||||
ItemStack next = spawn.peek();
|
||||
if (housing.addProduct(next, true)) {
|
||||
spawn.pop();
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
} else
|
||||
housing.setErrorState(EnumErrorCode.NOSPACE.ordinal());
|
||||
if (!addPendingProducts()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tryBreedingPrincess() || !hasHealthyQueen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!queenCanWork()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// No queen? And no princess?
|
||||
if (housing.getQueen() == null) {
|
||||
housing.setErrorState(EnumErrorCode.NOQUEEN.ordinal());
|
||||
return;
|
||||
}
|
||||
|
||||
// Princess available? Try to breed!
|
||||
if (ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
|
||||
if (ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()))
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
else
|
||||
housing.setErrorState(EnumErrorCode.NODRONE.ordinal());
|
||||
tickBreed();
|
||||
return;
|
||||
}
|
||||
|
||||
// Can't continue if an item of the wrong type is in the queen slot.
|
||||
if (!ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
|
||||
housing.setErrorState(EnumErrorCode.NOQUEEN.ordinal());
|
||||
return;
|
||||
}
|
||||
|
||||
IBee queen = PluginApiculture.beeInterface.getMember(housing.getQueen());
|
||||
// Kill dying queens
|
||||
if (!queen.isAlive()) {
|
||||
killQueen(queen);
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
return;
|
||||
}
|
||||
|
||||
resetQueen(queen);
|
||||
|
||||
// Not while raining, at night or without light
|
||||
EnumErrorCode state = EnumErrorCode.values()[queen.isWorking(housing)];
|
||||
if (state != EnumErrorCode.OK) {
|
||||
housing.setErrorState(state.ordinal());
|
||||
return;
|
||||
} else if (housing.getErrorOrdinal() != EnumErrorCode.NOFLOWER.ordinal())
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
queenWorkTick();
|
||||
}
|
||||
|
||||
private void queenWorkTick() {
|
||||
// Effects only fire when queen can work.
|
||||
effectData = queen.doEffect(effectData, housing);
|
||||
|
||||
// We have a queen, work!
|
||||
throttle++;
|
||||
|
||||
if (throttle >= PluginApiculture.beeCycleTicks)
|
||||
throttle = 0;
|
||||
else
|
||||
return;
|
||||
|
||||
// Need a flower
|
||||
if (!queen.hasFlower(housing)) {
|
||||
housing.setErrorState(EnumErrorCode.NOFLOWER.ordinal());
|
||||
return;
|
||||
} else
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
// Work cycles are throttled, rather than occurring every game tick.
|
||||
queenWorkCycleThrottle++;
|
||||
if (queenWorkCycleThrottle >= PluginApiculture.ticksPerBeeWorkCycle) {
|
||||
queenWorkCycleThrottle = 0;
|
||||
|
||||
// Need a flower
|
||||
if (queen.hasFlower(housing)) {
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
doQueenWorkCycle();
|
||||
} else {
|
||||
housing.setErrorState(EnumErrorCode.NOFLOWER.ordinal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doQueenWorkCycle() {
|
||||
doProduction();
|
||||
queen.plantFlowerRandom(housing);
|
||||
doPollination();
|
||||
// Age the queen
|
||||
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
|
||||
updateQueenItemNBT();
|
||||
}
|
||||
|
||||
private void doProduction() {
|
||||
// Produce and add stacks
|
||||
ItemStack[] products = queen.produceStacks(housing);
|
||||
housing.wearOutEquipment(1);
|
||||
for (ItemStack stack : products) {
|
||||
housing.addProduct(stack, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Plant a flower
|
||||
queen.plantFlowerRandom(housing);
|
||||
private void doPollination() {
|
||||
// Get pollen if none available yet
|
||||
if (pollen == null) {
|
||||
pollen = queen.retrievePollen(housing);
|
||||
attemptedPollinations = 0;
|
||||
if (pollen != null) {
|
||||
if (housing.onPollenRetrieved(queen, pollen, false))
|
||||
if (housing.onPollenRetrieved(queen, pollen, false)) {
|
||||
pollen = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pollen != null) {
|
||||
attemptedPollinations++;
|
||||
if (queen.pollinateRandom(housing, pollen)
|
||||
|| attemptedPollinations >= MAX_POLLINATION_ATTEMPTS) {
|
||||
if (queen.pollinateRandom(housing, pollen) || attemptedPollinations >= MAX_POLLINATION_ATTEMPTS) {
|
||||
pollen = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Age the queen
|
||||
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
|
||||
|
||||
private void updateQueenItemNBT() {
|
||||
// Write the changed queen back into the item stack.
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
queen.writeToNBT(nbttagcompound);
|
||||
housing.getQueen().setTagCompound(nbttagcompound);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private void resetQueen(IBee bee) {
|
||||
this.queen = bee;
|
||||
private boolean addPendingProducts() {
|
||||
EnumErrorCode housingErrorState = null;
|
||||
|
||||
while (!spawn.isEmpty()) {
|
||||
ItemStack next = spawn.peek();
|
||||
if (housing.addProduct(next, true)) {
|
||||
spawn.pop();
|
||||
housingErrorState = EnumErrorCode.OK;
|
||||
} else {
|
||||
housingErrorState = EnumErrorCode.NOSPACE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (housingErrorState != null) {
|
||||
try {
|
||||
housing.setErrorState(housingErrorState);
|
||||
} catch (Error e) {
|
||||
housing.setErrorState(housingErrorState.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
return housingErrorState != EnumErrorCode.NOSPACE;
|
||||
}
|
||||
|
||||
private boolean hasHealthyQueen() {
|
||||
boolean hasQueen = true;
|
||||
EnumErrorCode housingErrorState = null;
|
||||
|
||||
if (housing.getQueen() == null || !ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
|
||||
housingErrorState = EnumErrorCode.NOQUEEN;
|
||||
hasQueen = false;
|
||||
} else {
|
||||
IBee queen = PluginApiculture.beeInterface.getMember(housing.getQueen());
|
||||
// Kill dying queens
|
||||
if (!queen.isAlive()) {
|
||||
killQueen(queen);
|
||||
housingErrorState = EnumErrorCode.OK;
|
||||
hasQueen = false;
|
||||
} else {
|
||||
this.queen = queen;
|
||||
}
|
||||
}
|
||||
if (housingErrorState != null) {
|
||||
try {
|
||||
housing.setErrorState(housingErrorState);
|
||||
} catch (Error e) {
|
||||
housing.setErrorState(housingErrorState.ordinal());
|
||||
}
|
||||
}
|
||||
return hasQueen;
|
||||
}
|
||||
|
||||
private boolean tryBreedingPrincess() {
|
||||
boolean isBreedingPrincess = false;
|
||||
|
||||
// Princess available? Try to breed!
|
||||
if (ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
|
||||
if (ForestryItem.beeDroneGE.isItemEqual(housing.getDrone())) {
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
} else {
|
||||
housing.setErrorState(EnumErrorCode.NODRONE.ordinal());
|
||||
}
|
||||
tickBreed();
|
||||
isBreedingPrincess = true;
|
||||
}
|
||||
|
||||
return isBreedingPrincess;
|
||||
}
|
||||
|
||||
private boolean queenCanWork() {
|
||||
try {
|
||||
boolean canWork = true;
|
||||
// Not while raining, at night or without light
|
||||
IErrorState state = queen.canWork(housing);
|
||||
if (state != EnumErrorCode.OK) {
|
||||
housing.setErrorState(state);
|
||||
canWork = false;
|
||||
} else if (housing.getErrorState() != EnumErrorCode.NOFLOWER) {
|
||||
housing.setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
return canWork;
|
||||
} catch (Error e) {
|
||||
Proxies.log.logErrorAPI("Forestry", e, IBee.class);
|
||||
return queenCanWorkDeprecated();
|
||||
}
|
||||
}
|
||||
|
||||
// fallback for outdated APIs
|
||||
private boolean queenCanWorkDeprecated() {
|
||||
boolean canWork = true;
|
||||
// Not while raining, at night or without light
|
||||
EnumErrorCode state = EnumErrorCode.values()[queen.isWorking(housing)];
|
||||
if (state != EnumErrorCode.OK) {
|
||||
housing.setErrorState(state.ordinal());
|
||||
canWork = false;
|
||||
} else if (housing.getErrorOrdinal() != EnumErrorCode.NOFLOWER.ordinal()) {
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
}
|
||||
return canWork;
|
||||
}
|
||||
|
||||
// / BREEDING
|
||||
@@ -226,14 +297,17 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
return;
|
||||
}
|
||||
|
||||
if (breedingTime < totalBreedingTime)
|
||||
if (breedingTime < totalBreedingTime) {
|
||||
breedingTime++;
|
||||
if (breedingTime < totalBreedingTime)
|
||||
}
|
||||
if (breedingTime < totalBreedingTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Breeding done, create new queen if slot available
|
||||
if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen()))
|
||||
if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace
|
||||
IBee princess = PluginApiculture.beeInterface.getMember(housing.getQueen());
|
||||
@@ -253,22 +327,26 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
|
||||
// Remove drone
|
||||
housing.getDrone().stackSize--;
|
||||
if (housing.getDrone().stackSize <= 0)
|
||||
if (housing.getDrone().stackSize <= 0) {
|
||||
housing.setDrone(null);
|
||||
}
|
||||
|
||||
// Reset breeding time
|
||||
breedingTime = 0;
|
||||
}
|
||||
|
||||
private boolean tryBreed() {
|
||||
if (housing.getDrone() == null || housing.getQueen() == null)
|
||||
if (housing.getDrone() == null || housing.getQueen() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen()))
|
||||
if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!housing.canBreed())
|
||||
if (!housing.canBreed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -303,11 +381,16 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
housing.onQueenDeath(getQueen());
|
||||
|
||||
// Princess
|
||||
IBee heiress = queen.spawnPrincess(housing);
|
||||
if (heiress != null) {
|
||||
ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
|
||||
breedingTracker.registerPrincess(heiress);
|
||||
offspring.push(princess);
|
||||
boolean secondPrincess = this.housing.getWorld().rand.nextInt(100) < PluginApiculture.getSecondPrincessChance();
|
||||
int count = secondPrincess ? 2 : 1;
|
||||
while (count > 0) {
|
||||
count--;
|
||||
IBee heiress = queen.spawnPrincess(housing);
|
||||
if (heiress != null) {
|
||||
ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
|
||||
breedingTracker.registerPrincess(heiress);
|
||||
offspring.push(princess);
|
||||
}
|
||||
}
|
||||
|
||||
// Drones
|
||||
@@ -320,8 +403,9 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
|
||||
while (!offspring.isEmpty()) {
|
||||
ItemStack spawned = offspring.pop();
|
||||
if (!housing.addProduct(spawned, true))
|
||||
if (!housing.addProduct(spawned, true)) {
|
||||
spawn.add(spawned);
|
||||
}
|
||||
}
|
||||
|
||||
housing.onPostQueenDeath(getQueen());
|
||||
|
||||
@@ -1,255 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IApiaristTracker;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.Version;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.CommandMC;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class CommandBeekeepingMode extends CommandMC {
|
||||
|
||||
String[] modeStrings;
|
||||
|
||||
public CommandBeekeepingMode() {
|
||||
modeStrings = new String[PluginApiculture.beeInterface.getBeekeepingModes().size()];
|
||||
for (int i = 0; i < PluginApiculture.beeInterface.getBeekeepingModes().size(); i++)
|
||||
modeStrings[i] = PluginApiculture.beeInterface.getBeekeepingModes().get(i).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object arg0) {
|
||||
return this.getCommandName().compareTo(((ICommand) arg0).getCommandName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "beekeeping";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "/" + this.getCommandName() + " help";
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List getCommandAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] arguments) {
|
||||
|
||||
if (arguments.length <= 0)
|
||||
throw new WrongUsageException(StringUtil.localizeAndFormat("chat.help", this.getCommandUsage(sender)));
|
||||
|
||||
if (arguments[0].matches("list"))
|
||||
listModes(sender, arguments);
|
||||
else if (arguments[0].matches("info"))
|
||||
listModeInfo(sender, arguments);
|
||||
else if (arguments[0].matches("set")) {
|
||||
if (arguments.length <= 1)
|
||||
throw new WrongUsageException("/" + this.getCommandName() + " set [<world-#>] <mode-name>");
|
||||
|
||||
World world = getWorld(sender, arguments);
|
||||
String desired = arguments[arguments.length - 1];
|
||||
|
||||
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired);
|
||||
if (mode == null)
|
||||
throw new CommandException(StringUtil.localize("chat.bees.command.beekeeping.error"), desired);
|
||||
|
||||
PluginApiculture.beeInterface.setBeekeepingMode(world, mode.getName());
|
||||
func_152373_a(sender, this, StringUtil.localize("chat.bees.command.beekeeping.set"), mode.getName());
|
||||
|
||||
} else if (arguments[0].matches("save")) {
|
||||
if (arguments.length <= 1)
|
||||
throw new WrongUsageException("/" + this.getCommandName() + " save <player-name>");
|
||||
|
||||
saveStatistics(sender, arguments);
|
||||
} else if (arguments[0].matches("help")) {
|
||||
sendChatMessage(sender, StringUtil.localizeAndFormat("chat.bees.command.help.0", this.getCommandName()));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.1"));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.2"));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.3"));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.4"));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.5"));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveStatistics(ICommandSender sender, String[] arguments) {
|
||||
|
||||
String newLine = System.getProperty("line.separator");
|
||||
World world = getWorld(sender, arguments);
|
||||
|
||||
String player = arguments[1];
|
||||
Collection<String> statistics = new ArrayList<String>();
|
||||
|
||||
statistics.add(String.format("Beekeeping statistics for %s on %s:", player, DateFormat.getInstance().format(new Date())));
|
||||
statistics.add("");
|
||||
statistics.add("MODE: " + PluginApiculture.beeInterface.getBeekeepingMode(world).getName());
|
||||
statistics.add("");
|
||||
|
||||
GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(player);
|
||||
IApiaristTracker tracker = PluginApiculture.beeInterface.getBreedingTracker(world, profile);
|
||||
if (tracker == null)
|
||||
statistics.add("No statistics found.");
|
||||
else {
|
||||
statistics.add("BRED:");
|
||||
statistics.add("-----");
|
||||
statistics.add("");
|
||||
|
||||
statistics.add("Queens:\t\t" + tracker.getQueenCount());
|
||||
statistics.add("Princesses:\t" + tracker.getPrincessCount());
|
||||
statistics.add("Drones:\t\t" + tracker.getDroneCount());
|
||||
statistics.add("");
|
||||
|
||||
Collection<IAlleleBeeSpecies> species = new ArrayList<IAlleleBeeSpecies>();
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
|
||||
if (allele instanceof IAlleleBeeSpecies)
|
||||
species.add((IAlleleBeeSpecies) allele);
|
||||
|
||||
statistics.add(String.format("SPECIES (%s):", species.size()));
|
||||
statistics.add("-------------");
|
||||
statistics.add("");
|
||||
|
||||
for (IAlleleBeeSpecies allele : species)
|
||||
statistics.add(generateSpeciesListEntry(allele, tracker));
|
||||
}
|
||||
|
||||
File file = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/stats/" + player + ".log");
|
||||
try {
|
||||
|
||||
if (file.getParentFile() != null)
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
if (!file.exists() && !file.createNewFile()) {
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.stats.error1"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.canWrite()) {
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.stats.error2"));
|
||||
return;
|
||||
}
|
||||
|
||||
FileOutputStream fileout = new FileOutputStream(file);
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileout, "UTF-8"));
|
||||
|
||||
writer.write("# " + Defaults.MOD + newLine + "# " + Version.getVersion() + newLine);
|
||||
|
||||
for (String line : statistics)
|
||||
writer.write(line + newLine);
|
||||
|
||||
writer.close();
|
||||
|
||||
} catch (Exception ex) {
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.stats.error3"));
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
sendChatMessage(sender, StringUtil.localizeAndFormat("chat.bees.command.stats.saved", player));
|
||||
}
|
||||
|
||||
private String generateSpeciesListEntry(IAlleleBeeSpecies species, IApiaristTracker tracker) {
|
||||
String discovered = "[ ]";
|
||||
if (tracker.isDiscovered(species))
|
||||
discovered = "[ X ]";
|
||||
String blacklisted = "[ ]";
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(species.getUID()))
|
||||
blacklisted = "[ BL ]";
|
||||
String notcounted = "[ ]";
|
||||
if (!species.isCounted())
|
||||
notcounted = "[ NC ]";
|
||||
|
||||
return String.format("%s %s %s\t%-40s %-20s %-20s", discovered, blacklisted, notcounted, species.getUID(), species.getName(), species.getAuthority());
|
||||
}
|
||||
|
||||
private void listModes(ICommandSender sender, String[] arguments) {
|
||||
World world = getWorld(sender, arguments);
|
||||
|
||||
String message = StringUtil.localize("chat.bees.command.mode.current");
|
||||
message = message.replaceAll("%MODE", PluginApiculture.beeInterface.getBeekeepingMode(world).getName());
|
||||
message = message.replaceAll("%WORLD", String.valueOf(world.getWorldInfo().getSaveVersion()));
|
||||
sendChatMessage(sender, message);
|
||||
|
||||
String help = "";
|
||||
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes()) {
|
||||
if (!help.isEmpty())
|
||||
help += ", ";
|
||||
help += mode.getName();
|
||||
}
|
||||
sendChatMessage(sender, StringUtil.localizeAndFormat("chat.bees.command.mode.help", help));
|
||||
return;
|
||||
}
|
||||
|
||||
private void listModeInfo(ICommandSender sender, String[] arguments) {
|
||||
if (arguments.length <= 1)
|
||||
throw new WrongUsageException("/" + this.getCommandName() + " info <mode-name>");
|
||||
|
||||
IBeekeepingMode found = null;
|
||||
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes())
|
||||
if (mode.getName().equalsIgnoreCase(arguments[1])) {
|
||||
found = mode;
|
||||
break;
|
||||
}
|
||||
|
||||
if (found == null)
|
||||
throw new CommandException("No beekeeping mode called '%s' is available.", arguments[1]);
|
||||
|
||||
sendChatMessage(sender, "\u00A7aMode: " + found.getName());
|
||||
for (String desc : found.getDescription())
|
||||
sendChatMessage(sender, StringUtil.localize(desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCommandSenderUseCommand(ICommandSender sender) {
|
||||
if (sender instanceof EntityPlayer)
|
||||
return Proxies.common.isOp((EntityPlayer) sender);
|
||||
else
|
||||
return sender.canCommandSenderUseCommand(4, getCommandName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] incomplete) {
|
||||
return getListOfStringsMatchingLastWord(incomplete, modeStrings);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.core.utils.CommandMC;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class CommandGiveBee extends CommandMC {
|
||||
|
||||
EnumBeeType type;
|
||||
|
||||
public CommandGiveBee(EnumBeeType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "give" + type.toString().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender par1ICommandSender) {
|
||||
return "/" + getCommandName() + " <player-name> <species-name>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] arguments) {
|
||||
if (arguments.length >= 2) {
|
||||
EntityPlayer player = getPlayer(sender, arguments[0]);
|
||||
|
||||
String parameter = arguments[1];
|
||||
|
||||
IAlleleBeeSpecies species = null;
|
||||
|
||||
search: for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
|
||||
|
||||
if (!uid.equals(parameter))
|
||||
continue;
|
||||
|
||||
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
|
||||
species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid);
|
||||
break search;
|
||||
}
|
||||
}
|
||||
|
||||
search: if (species == null)
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
|
||||
if (allele instanceof IAlleleBeeSpecies)
|
||||
if (((IAlleleBeeSpecies) allele).getName().equals(parameter)) {
|
||||
species = (IAlleleBeeSpecies) allele;
|
||||
break search;
|
||||
}
|
||||
|
||||
if (species == null)
|
||||
throw new SpeciesNotFoundException(parameter);
|
||||
|
||||
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
|
||||
|
||||
if (template == null)
|
||||
throw new TemplateNotFoundException(species);
|
||||
|
||||
IBeeGenome genome = PluginApiculture.beeInterface.templateAsGenome(template);
|
||||
|
||||
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, genome);
|
||||
|
||||
if(this.type == EnumBeeType.QUEEN)
|
||||
bee.mate(bee);
|
||||
|
||||
ItemStack beestack = PluginApiculture.beeInterface.getMemberStack(bee, type.ordinal());
|
||||
player.dropPlayerItemWithRandomChoice(beestack, true);
|
||||
func_152373_a(sender, this, "Player %s was given a %s bee.", player.getCommandSenderName(), ((IAlleleSpecies) template[0]).getName());
|
||||
} else
|
||||
throw new WrongUsageException("/" + getCommandName() + " <player-name> <species-name>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the strings available in this command to the given list of tab completion options.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] parameters) {
|
||||
if (parameters.length == 1)
|
||||
return getListOfStringsMatchingLastWord(parameters, this.getPlayers());
|
||||
else if (parameters.length == 2)
|
||||
return getListOfStringsMatchingLastWord(parameters, this.getSpecies());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String[] getSpecies() {
|
||||
List<String> species = new ArrayList<String>();
|
||||
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
|
||||
if (allele instanceof IAlleleBeeSpecies)
|
||||
species.add(((IAlleleSpecies) allele).getName());
|
||||
|
||||
return species.toArray(new String[] {});
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class FlowerProviderCacti implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// Specific check for flower pots.
|
||||
if (block == Blocks.flower_pot)
|
||||
return checkFlowerPot(world.getBlockMetadata(x, y, z));
|
||||
|
||||
return block == Blocks.cactus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
return pollinatable.getPlantType().contains(EnumPlantType.Desert);
|
||||
}
|
||||
|
||||
private boolean checkFlowerPot(int meta) {
|
||||
if (meta == 9)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0)
|
||||
return growInPot(world, x, y, z);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean growInPot(World world, int x, int y, int z) {
|
||||
if (world.rand.nextBoolean())
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 9, Defaults.FLAG_BLOCK_SYNCH);
|
||||
else
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 10, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.cacti");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.cactus) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class FlowerProviderEnd implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == Blocks.dragon_egg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.end");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.dragon_egg) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class FlowerProviderGourd implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == Blocks.pumpkin_stem || block == Blocks.melon_stem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// We only grow wheat, we don't plant it
|
||||
if (block != Blocks.pumpkin_stem && block != Blocks.melon_stem)
|
||||
return false;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta > 6)
|
||||
return false;
|
||||
|
||||
if (meta < 6)
|
||||
meta += 2;
|
||||
else
|
||||
meta = 7;
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.gourd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class FlowerProviderJungle implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
// Specific check for flower pots.
|
||||
if (block == Blocks.flower_pot)
|
||||
return checkFlowerPot(meta);
|
||||
|
||||
return block == Blocks.vine || (block == Blocks.tallgrass && meta == 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
private boolean checkFlowerPot(int meta) {
|
||||
if (meta == 11)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (block == Blocks.flower_pot)
|
||||
return growInPot(world, x, y, z);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean growInPot(World world, int x, int y, int z) {
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 11, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.jungle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.vine), new ItemStack(Blocks.tallgrass, 1, 2) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class FlowerProviderMushroom implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// Specific check for flower pots.
|
||||
if (block == Blocks.flower_pot)
|
||||
return checkFlowerPot(world.getBlockMetadata(x, y, z));
|
||||
|
||||
return block == Blocks.brown_mushroom || block == Blocks.red_mushroom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
private boolean checkFlowerPot(int meta) {
|
||||
if (meta == 7 || meta == 8)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (!block.isAir(world, x, y, z))
|
||||
if (block == Blocks.flower_pot)
|
||||
return growInPot(world, x, y, z);
|
||||
else
|
||||
return false;
|
||||
|
||||
// Check ground
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
|
||||
if (ground != Blocks.mycelium)
|
||||
return false;
|
||||
|
||||
Block mushroom;
|
||||
if (world.rand.nextBoolean())
|
||||
mushroom = Blocks.brown_mushroom;
|
||||
else
|
||||
mushroom = Blocks.red_mushroom;
|
||||
|
||||
world.setBlock(x, y, z, mushroom, 0, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean growInPot(World world, int x, int y, int z) {
|
||||
if (world.rand.nextBoolean())
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 7, Defaults.FLAG_BLOCK_SYNCH);
|
||||
else
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 8, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.mushroom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.brown_mushroom), new ItemStack(Blocks.red_mushroom) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class FlowerProviderNetherwart implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == Blocks.nether_wart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
return pollinatable.getPlantType().contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// We only grow netherwart, we don't plant it
|
||||
if (block != Blocks.nether_wart)
|
||||
return false;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta >= 3)
|
||||
return false;
|
||||
|
||||
if (meta == 2)
|
||||
meta = 3;
|
||||
else
|
||||
meta = 2;
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.nether");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.nether_wart) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class FlowerProviderVanilla implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
// Specific check for flower pots.
|
||||
if (block == Blocks.flower_pot)
|
||||
return checkFlowerPot(meta);
|
||||
|
||||
ItemStack flower = new ItemStack(block, 1, meta);
|
||||
|
||||
for (ItemStack stack : FlowerManager.plainFlowers)
|
||||
if (flower.isItemEqual(stack))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
private boolean checkFlowerPot(int meta) {
|
||||
if (meta == 1 || meta == 2)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (!block.isAir(world, x, y, z))
|
||||
if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0)
|
||||
return growInPot(world, x, y, z);
|
||||
else
|
||||
return false;
|
||||
|
||||
// Check ground
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
|
||||
if (ground != Blocks.dirt && ground != Blocks.grass)
|
||||
return false;
|
||||
|
||||
// Determine flower to plant
|
||||
Collections.shuffle(FlowerManager.plainFlowers);
|
||||
ItemStack flower = FlowerManager.plainFlowers.get(world.rand.nextInt(FlowerManager.plainFlowers.size() - 1));
|
||||
world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean growInPot(World world, int x, int y, int z) {
|
||||
if (world.rand.nextBoolean())
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 1, Defaults.FLAG_BLOCK_SYNCH);
|
||||
else
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 2, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.vanilla");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return FlowerManager.plainFlowers.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -26,7 +26,6 @@ import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
|
||||
import forestry.apiculture.gui.ContainerAlvearySieve;
|
||||
import forestry.apiculture.gui.ContainerAlvearySwarmer;
|
||||
import forestry.apiculture.gui.ContainerApiary;
|
||||
import forestry.apiculture.gui.ContainerBeealyzer;
|
||||
import forestry.apiculture.gui.ContainerHabitatLocator;
|
||||
import forestry.apiculture.gui.ContainerImprinter;
|
||||
import forestry.apiculture.gui.GuiAlveary;
|
||||
@@ -38,9 +37,10 @@ import forestry.apiculture.gui.GuiBeealyzer;
|
||||
import forestry.apiculture.gui.GuiHabitatLocator;
|
||||
import forestry.apiculture.gui.GuiImprinter;
|
||||
import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory;
|
||||
import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory;
|
||||
import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory;
|
||||
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
|
||||
import forestry.core.GuiHandlerBase;
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
@@ -51,53 +51,60 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
|
||||
int cleanId = decodeGuiID(id);
|
||||
int guiData = decodeGuiData(id);
|
||||
|
||||
if (cleanId >= GuiId.values().length)
|
||||
if (cleanId >= GuiId.values().length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack equipped;
|
||||
switch (GuiId.values()[cleanId]) {
|
||||
|
||||
case AlvearyGUI:
|
||||
return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
|
||||
case AlvearyGUI:
|
||||
return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
|
||||
|
||||
case AlvearySieveGUI:
|
||||
return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
|
||||
case AlvearySieveGUI:
|
||||
return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
|
||||
|
||||
case AlvearySwarmerGUI:
|
||||
return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
|
||||
case AlvearySwarmerGUI:
|
||||
return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
|
||||
|
||||
case ApiaristChestGUI:
|
||||
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
|
||||
case ApiaristChestGUI:
|
||||
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
|
||||
|
||||
case ApiaryGUI:
|
||||
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
|
||||
case ApiaryGUI:
|
||||
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
|
||||
|
||||
case BeealyzerGUI:
|
||||
equipped = getEquippedItem(player);
|
||||
if (equipped == null)
|
||||
case BeealyzerGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
|
||||
|
||||
case BeehouseGUI:
|
||||
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
|
||||
|
||||
case HabitatLocatorGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new GuiHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
|
||||
|
||||
case HygroregulatorGUI:
|
||||
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
|
||||
|
||||
case ImprinterGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped));
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
|
||||
|
||||
case BeehouseGUI:
|
||||
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
|
||||
|
||||
case HabitatLocatorGUI:
|
||||
equipped = getEquippedItem(player);
|
||||
if (equipped == null)
|
||||
return null;
|
||||
|
||||
return new GuiHabitatLocator(player.inventory, new BiomefinderInventory(equipped));
|
||||
|
||||
case HygroregulatorGUI:
|
||||
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
|
||||
|
||||
case ImprinterGUI:
|
||||
return new GuiImprinter(player.inventory, new ImprinterInventory(player));
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,58 +113,65 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
|
||||
int cleanId = decodeGuiID(id);
|
||||
int guiData = decodeGuiData(id);
|
||||
|
||||
if (cleanId >= GuiId.values().length)
|
||||
if (cleanId >= GuiId.values().length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack equipped;
|
||||
switch (GuiId.values()[cleanId]) {
|
||||
|
||||
case AlvearyGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
|
||||
case AlvearyGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
|
||||
|
||||
case AlvearySieveGUI:
|
||||
return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
|
||||
case AlvearySieveGUI:
|
||||
return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
|
||||
|
||||
case AlvearySwarmerGUI:
|
||||
return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
|
||||
case AlvearySwarmerGUI:
|
||||
return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
|
||||
|
||||
case ApiaristChestGUI:
|
||||
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
|
||||
case ApiaristChestGUI:
|
||||
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
|
||||
|
||||
case ApiaryGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
|
||||
case ApiaryGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
|
||||
|
||||
case BeealyzerGUI:
|
||||
equipped = getEquippedItem(player);
|
||||
if (equipped == null)
|
||||
case BeealyzerGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerAlyzer(new BeealyzerInventory(player, equipped), player);
|
||||
|
||||
case BeehouseGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false);
|
||||
|
||||
case HabitatLocatorGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ContainerHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
|
||||
|
||||
case HygroregulatorGUI:
|
||||
return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
|
||||
|
||||
case ImprinterGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped));
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerBeealyzer(player.inventory, new BeealyzerInventory(player, equipped));
|
||||
|
||||
case BeehouseGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false);
|
||||
|
||||
case HabitatLocatorGUI:
|
||||
equipped = getEquippedItem(player);
|
||||
if (equipped == null)
|
||||
return null;
|
||||
|
||||
return new ContainerHabitatLocator(player.inventory, new BiomefinderInventory(equipped));
|
||||
|
||||
case HygroregulatorGUI:
|
||||
return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
|
||||
|
||||
case ImprinterGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerImprinter(player.inventory, new ImprinterInventory(player));
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -17,8 +17,9 @@ public class MaterialBeehive extends Material {
|
||||
|
||||
public MaterialBeehive(boolean noHarvest) {
|
||||
super(MapColor.stoneColor);
|
||||
if (noHarvest)
|
||||
if (noHarvest) {
|
||||
this.setRequiresTool();
|
||||
}
|
||||
setImmovableMobility();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@@ -23,29 +24,27 @@ import forestry.core.proxy.Proxies;
|
||||
public class PacketHandlerApiculture implements IPacketHandler {
|
||||
|
||||
@Override
|
||||
public void onPacketData(int packetID, DataInputStream data, EntityPlayer player) {
|
||||
public boolean onPacketData(int packetID, DataInputStream data, EntityPlayer player) throws IOException {
|
||||
|
||||
try {
|
||||
|
||||
switch (packetID) {
|
||||
switch (packetID) {
|
||||
case PacketIds.HABITAT_BIOME_POINTER:
|
||||
PacketCoordinates packetC = new PacketCoordinates();
|
||||
packetC.readData(data);
|
||||
Proxies.common.setBiomefinderCoordinates(player, packetC.getCoordinates());
|
||||
break;
|
||||
Proxies.common.setHabitatLocatorCoordinates(player, packetC.getCoordinates());
|
||||
return true;
|
||||
case PacketIds.IMPRINT_SELECTION_GET:
|
||||
onImprintSelectionGet(player);
|
||||
break;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void onImprintSelectionGet(EntityPlayer playerEntity) {
|
||||
|
||||
if (!(playerEntity.openContainer instanceof ContainerImprinter))
|
||||
if (!(playerEntity.openContainer instanceof ContainerImprinter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerImprinter) playerEntity.openContainer).sendSelection(playerEntity);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -33,6 +33,7 @@ import forestry.apiculture.worldgen.ComponentVillageBeeHouse;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler {
|
||||
@@ -41,6 +42,7 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla
|
||||
try {
|
||||
MapGenStructureIO.func_143031_a(ComponentVillageBeeHouse.class, "Forestry:BeeHouse");
|
||||
} catch (Throwable e) {
|
||||
Proxies.log.severe("Failed to register village beehouse.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +61,7 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int size) {
|
||||
return new StructureVillagePieces.PieceWeight(ComponentVillageBeeHouse.class, 15, MathHelper.getRandomIntegerInRange(random, 0 + size, 1 + size));
|
||||
return new StructureVillagePieces.PieceWeight(ComponentVillageBeeHouse.class, 15, MathHelper.getRandomIntegerInRange(random, size, 1 + size));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.core.commands.ICommandModeHelper;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class BeeModeHelper implements ICommandModeHelper {
|
||||
|
||||
@Override
|
||||
public String[] getModeNames() {
|
||||
ArrayList<IBeekeepingMode> beekeepingModes = PluginApiculture.beeInterface.getBeekeepingModes();
|
||||
int modeStringCount = beekeepingModes.size();
|
||||
List<String> modeStrings = new ArrayList<String>(modeStringCount);
|
||||
for (IBeekeepingMode mode : beekeepingModes) {
|
||||
modeStrings.add(mode.getName());
|
||||
}
|
||||
|
||||
return modeStrings.toArray(new String[modeStringCount]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModeNameMatching(String desired) {
|
||||
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired);
|
||||
if (mode == null) {
|
||||
return null;
|
||||
}
|
||||
return mode.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModeName(World world) {
|
||||
return PluginApiculture.beeInterface.getBeekeepingMode(world).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMode(World world, String modeName) {
|
||||
PluginApiculture.beeInterface.setBeekeepingMode(world, modeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> getDescription(String modeName) {
|
||||
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(modeName);
|
||||
return mode.getDescription();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IApiaristTracker;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.core.commands.IStatsSaveHelper;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class BeeStatsSaveHelper implements IStatsSaveHelper {
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedSaveStatsString() {
|
||||
return "for.chat.command.forestry.bee.save.stats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExtraInfo(Collection<String> statistics, IBreedingTracker breedingTracker) {
|
||||
IApiaristTracker tracker = (IApiaristTracker) breedingTracker;
|
||||
String discoveredLine = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.discovered") + ":";
|
||||
statistics.add(discoveredLine);
|
||||
statistics.add(StringUtil.line(discoveredLine.length()));
|
||||
|
||||
String queen = StatCollector.translateToLocal("for.bees.grammar.queen.type");
|
||||
String princess = StatCollector.translateToLocal("for.bees.grammar.princess.type");
|
||||
String drone = StatCollector.translateToLocal("for.bees.grammar.drone.type");
|
||||
statistics.add(queen + ":\t\t" + tracker.getQueenCount());
|
||||
statistics.add(princess + ":\t" + tracker.getPrincessCount());
|
||||
statistics.add(drone + ":\t\t" + tracker.getDroneCount());
|
||||
statistics.add("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IAlleleSpecies> getSpecies() {
|
||||
Collection<IAlleleSpecies> species = new ArrayList<IAlleleSpecies>();
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
|
||||
if (allele instanceof IAlleleBeeSpecies) {
|
||||
species.add((IAlleleBeeSpecies) allele);
|
||||
}
|
||||
}
|
||||
return species;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileSuffix() {
|
||||
return "bees";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBreedingTracker getBreedingTracker(World world, GameProfile gameProfile) {
|
||||
return PluginApiculture.beeInterface.getBreedingTracker(world, gameProfile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import forestry.core.commands.CommandMode;
|
||||
import forestry.core.commands.CommandSaveStats;
|
||||
import forestry.core.commands.ICommandModeHelper;
|
||||
import forestry.core.commands.IStatsSaveHelper;
|
||||
import forestry.core.commands.SubCommand;
|
||||
|
||||
public class CommandBee extends SubCommand {
|
||||
|
||||
public CommandBee() {
|
||||
super("bee");
|
||||
addAlias("beekeeping");
|
||||
|
||||
IStatsSaveHelper saveHelper = new BeeStatsSaveHelper();
|
||||
ICommandModeHelper modeHelper = new BeeModeHelper();
|
||||
|
||||
addChildCommand(new CommandMode(modeHelper));
|
||||
addChildCommand(new CommandSaveStats(saveHelper, modeHelper));
|
||||
addChildCommand(new CommandBeeGive());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.core.commands.CommandHelpers;
|
||||
import forestry.core.commands.SpeciesNotFoundException;
|
||||
import forestry.core.commands.SubCommand;
|
||||
import forestry.core.commands.TemplateNotFoundException;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class CommandBeeGive extends SubCommand {
|
||||
|
||||
private final String beeTypeHelpString;
|
||||
private final String[] beeTypeArr;
|
||||
|
||||
public CommandBeeGive() {
|
||||
super("give");
|
||||
setPermLevel(PermLevel.ADMIN);
|
||||
|
||||
List<String> beeTypeStrings = new ArrayList<String>();
|
||||
for (EnumBeeType type : EnumBeeType.values()) {
|
||||
if (type == EnumBeeType.NONE) {
|
||||
continue;
|
||||
}
|
||||
beeTypeStrings.add(type.getName());
|
||||
}
|
||||
|
||||
beeTypeArr = beeTypeStrings.toArray(new String[beeTypeStrings.size()]);
|
||||
|
||||
StringBuilder beeTypeHelp = new StringBuilder();
|
||||
String separator = ", ";
|
||||
|
||||
Iterator<String> iter = beeTypeStrings.iterator();
|
||||
while (iter.hasNext()) {
|
||||
beeTypeHelp.append(iter.next());
|
||||
if (iter.hasNext()) {
|
||||
beeTypeHelp.append(separator);
|
||||
}
|
||||
}
|
||||
beeTypeHelpString = beeTypeHelp.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSubCommand(ICommandSender sender, String[] arguments) {
|
||||
if (arguments.length < 2) {
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
IBeeGenome beeGenome = getBeeGenome(arguments[0]);
|
||||
EnumBeeType beeType = getBeeType(arguments[1]);
|
||||
if (beeType == EnumBeeType.NONE) {
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player;
|
||||
if (arguments.length == 3) {
|
||||
player = CommandHelpers.getPlayer(sender, arguments[2]);
|
||||
} else {
|
||||
player = CommandHelpers.getPlayer(sender, sender.getCommandSenderName());
|
||||
}
|
||||
if (player == null) {
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, beeGenome);
|
||||
|
||||
if (beeType == EnumBeeType.QUEEN) {
|
||||
bee.mate(bee);
|
||||
}
|
||||
|
||||
ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal());
|
||||
player.dropPlayerItemWithRandomChoice(beeStack, true);
|
||||
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.bee.give.given", player.getCommandSenderName(), bee.getGenome().getPrimary().getName(), beeType.getName());
|
||||
}
|
||||
|
||||
private static IBeeGenome getBeeGenome(String speciesName) {
|
||||
IAlleleBeeSpecies species = null;
|
||||
|
||||
for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
|
||||
|
||||
if (!uid.equals(speciesName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
|
||||
species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (species == null) {
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
|
||||
if (allele instanceof IAlleleBeeSpecies && allele.getName().equals(speciesName)) {
|
||||
species = (IAlleleBeeSpecies) allele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (species == null) {
|
||||
throw new SpeciesNotFoundException(speciesName);
|
||||
}
|
||||
|
||||
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
|
||||
|
||||
if (template == null) {
|
||||
throw new TemplateNotFoundException(species);
|
||||
}
|
||||
|
||||
return PluginApiculture.beeInterface.templateAsGenome(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> addTabCompletionOptions(ICommandSender sender, String[] parameters) {
|
||||
if (parameters.length == 1) {
|
||||
List<String> tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies());
|
||||
tabCompletion.add("help");
|
||||
return tabCompletion;
|
||||
} else if (parameters.length == 2) {
|
||||
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, beeTypeArr);
|
||||
} else if (parameters.length == 3) {
|
||||
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] getSpecies() {
|
||||
List<String> species = new ArrayList<String>();
|
||||
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
|
||||
if (allele instanceof IAlleleBeeSpecies) {
|
||||
species.add(allele.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return species.toArray(new String[species.size()]);
|
||||
}
|
||||
|
||||
EnumBeeType getBeeType(String beeTypeName) {
|
||||
for (EnumBeeType beeType : EnumBeeType.values()) {
|
||||
if (beeType.getName().equalsIgnoreCase(beeTypeName)) {
|
||||
return beeType;
|
||||
}
|
||||
}
|
||||
return EnumBeeType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHelp(ICommandSender sender) {
|
||||
super.printHelp(sender);
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.give.available", beeTypeHelpString);
|
||||
}
|
||||
}
|
||||
@@ -45,10 +45,11 @@ public class EntityBee extends EntityCreature implements IAnimals {
|
||||
}
|
||||
|
||||
public EntityBee setIndividual(IBee bee) {
|
||||
if (bee != null)
|
||||
if (bee != null) {
|
||||
contained = bee;
|
||||
else
|
||||
} else {
|
||||
contained = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate());
|
||||
}
|
||||
|
||||
//isImmuneToFire = contained.getGenome().getFireResist();
|
||||
setSpecies(contained.getGenome().getPrimary());
|
||||
@@ -83,8 +84,9 @@ public class EntityBee extends EntityCreature implements IAnimals {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ResourceLocation getTexture() {
|
||||
if (textureResource == null || lastTextureUpdate != lastUpdate)
|
||||
if (textureResource == null || lastTextureUpdate != lastUpdate) {
|
||||
textureResource = new ForestryResource(beeTexture);
|
||||
}
|
||||
|
||||
return textureResource;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
|
||||
final class Flower implements IFlower {
|
||||
|
||||
private final Block block;
|
||||
private final int meta;
|
||||
private Double weight;
|
||||
|
||||
public Flower(Block block, int meta, double weight) {
|
||||
this.block = block;
|
||||
this.meta = meta;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public boolean isPlantable() {
|
||||
return this.weight != 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof IFlower)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFlower flower = (IFlower) obj;
|
||||
|
||||
return Block.isEqualTo(this.block, flower.getBlock()) && (this.meta == OreDictionary.WILDCARD_VALUE || flower.getMeta() == OreDictionary.WILDCARD_VALUE || this.meta == flower.getMeta());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IFlower other) {
|
||||
return this.weight.compareTo(other.getWeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeight(double weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
}
|
||||
Executable → Regular
+29
-31
@@ -4,66 +4,64 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class FlowerProviderWheat implements IFlowerProvider {
|
||||
public class FlowerProvider implements IFlowerProvider {
|
||||
|
||||
private final String flowerType;
|
||||
private final String description;
|
||||
|
||||
public FlowerProvider(String flowerType, String description) {
|
||||
this.flowerType = flowerType;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == Blocks.wheat;
|
||||
return FlowerManager.flowerRegistry.isAcceptedFlower(this.flowerType, world, individual, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
|
||||
EnumSet<EnumPlantType> plantTypes = pollinatable.getPlantType();
|
||||
|
||||
if (flowerType.equals(FlowerManager.FlowerTypeNether)) {
|
||||
return plantTypes.contains(EnumPlantType.Nether);
|
||||
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
|
||||
return plantTypes.contains(EnumPlantType.Desert);
|
||||
} else {
|
||||
return plantTypes.size() > 1 || !plantTypes.contains(EnumPlantType.Nether);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// We only grow wheat, we don't plant it
|
||||
if (block != Blocks.wheat)
|
||||
return false;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta > 6)
|
||||
return false;
|
||||
|
||||
if (meta < 6)
|
||||
meta += 2;
|
||||
else
|
||||
meta = 7;
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
return FlowerManager.flowerRegistry.growFlower(this.flowerType, world, individual, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.wheat");
|
||||
return StringUtil.localize(this.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,8 +70,8 @@ public class FlowerProviderWheat implements IFlowerProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) };
|
||||
public List<IFlower> getFlowers() {
|
||||
return FlowerManager.flowerRegistry.getAcceptableFlowers(this.flowerType);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFlowerPot;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public final class FlowerRegistry implements IFlowerRegistry {
|
||||
|
||||
private final ArrayListMultimap<String, IFlower> registeredFlowers;
|
||||
private final ArrayListMultimap<String, IFlowerGrowthRule> growthRules;
|
||||
private final Map<String, TreeMap<Double, IFlower>> chances;
|
||||
|
||||
private boolean hasDeprecatedFlowersImported;
|
||||
|
||||
public FlowerRegistry() {
|
||||
this.registeredFlowers = ArrayListMultimap.create();
|
||||
this.growthRules = ArrayListMultimap.create();
|
||||
this.chances = new HashMap<String, TreeMap<Double, IFlower>>();
|
||||
|
||||
this.hasDeprecatedFlowersImported = false;
|
||||
|
||||
registerVanillaFlowers();
|
||||
registerVanillaGrowthRules();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAcceptableFlower(Block block, String... flowerTypes) {
|
||||
registerFlower(block, OreDictionary.WILDCARD_VALUE, 0.0, flowerTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAcceptableFlower(Block block, int meta, String... flowerTypes) {
|
||||
registerFlower(block, meta, 0.0, flowerTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPlantableFlower(Block block, int meta, double weight, String... flowerTypes) {
|
||||
registerFlower(block, meta, weight, flowerTypes);
|
||||
}
|
||||
|
||||
private void registerFlower(Block block, int meta, double weight, String... flowerTypes) {
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
if (weight <= 0.0) {
|
||||
weight = 0.0;
|
||||
}
|
||||
if (weight >= 1.0) {
|
||||
weight = 1.0;
|
||||
}
|
||||
|
||||
Flower newFlower = new Flower(block, meta, weight);
|
||||
Integer index;
|
||||
|
||||
for (String flowerType : flowerTypes) {
|
||||
List<IFlower> flowers = this.registeredFlowers.get(flowerType);
|
||||
|
||||
index = flowers.indexOf(newFlower);
|
||||
if (index == -1) {
|
||||
flowers.add(newFlower);
|
||||
} else if (flowers.get(index).getWeight() > newFlower.getWeight()) {
|
||||
flowers.get(index).setWeight(newFlower.getWeight());
|
||||
}
|
||||
|
||||
if (this.chances.containsKey(flowerType)) {
|
||||
this.chances.remove(flowerType);
|
||||
}
|
||||
|
||||
Collections.sort(this.registeredFlowers.get(flowerType));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
internalInitialize();
|
||||
if (!this.registeredFlowers.containsKey(flowerType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (block.isAir(world, x, y, z) || block.equals(Blocks.bedrock) || block.equals(Blocks.dirt) || block.equals(Blocks.grass)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int meta;
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityFlowerPot) {
|
||||
TileEntityFlowerPot tileFlowerPot = (TileEntityFlowerPot) tile;
|
||||
Item item = tileFlowerPot.getFlowerPotItem();
|
||||
block = Block.getBlockFromItem(item);
|
||||
meta = tileFlowerPot.getFlowerPotData();
|
||||
} else {
|
||||
meta = world.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
Flower flower = new Flower(block, meta, 0);
|
||||
List<IFlower> acceptedFlowers = this.registeredFlowers.get(flowerType);
|
||||
return acceptedFlowers.contains(flower);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
internalInitialize();
|
||||
if (!this.growthRules.containsKey(flowerType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) {
|
||||
if (rule.growFlower(this, flowerType, world, individual, x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IFlower> getAcceptableFlowers(String flowerType) {
|
||||
internalInitialize();
|
||||
|
||||
return this.registeredFlowers.get(flowerType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes) {
|
||||
if (rule == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String flowerType : flowerTypes) {
|
||||
this.growthRules.get(flowerType).add(rule);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlower getRandomPlantableFlower(String flowerType, Random rand) {
|
||||
TreeMap<Double, IFlower> chancesMap = getChancesMap(flowerType);
|
||||
double maxKey = chancesMap.lastKey() + 1.0;
|
||||
return chancesMap.get(chancesMap.lowerKey(rand.nextDouble() * maxKey));
|
||||
}
|
||||
|
||||
private TreeMap<Double, IFlower> getChancesMap(String flowerType) {
|
||||
if (!this.chances.containsKey(flowerType)) {
|
||||
TreeMap<Double, IFlower> flowerChances = new TreeMap<Double, IFlower>();
|
||||
double count = 0.0;
|
||||
for (IFlower flower : this.registeredFlowers.get(flowerType)) {
|
||||
if (flower.isPlantable()) {
|
||||
flowerChances.put(count, flower);
|
||||
count += flower.getWeight();
|
||||
}
|
||||
}
|
||||
this.chances.put(flowerType, flowerChances);
|
||||
}
|
||||
return this.chances.get(flowerType);
|
||||
}
|
||||
|
||||
/*
|
||||
* Method to support deprecated FlowerManager.plainFlowers
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private void internalInitialize() {
|
||||
if (!hasDeprecatedFlowersImported) {
|
||||
for (ItemStack plainFlower : FlowerManager.plainFlowers) {
|
||||
Block flowerBlock = Block.getBlockFromItem(plainFlower.getItem());
|
||||
int meta = plainFlower.getItemDamage();
|
||||
registerPlantableFlower(flowerBlock, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
}
|
||||
|
||||
hasDeprecatedFlowersImported = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void registerVanillaFlowers() {
|
||||
// Register plantable plants
|
||||
for (int meta = 0; meta <= 8; meta++) {
|
||||
registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
}
|
||||
|
||||
registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
|
||||
registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
|
||||
registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti);
|
||||
|
||||
// Register acceptable plants
|
||||
registerAcceptableFlower(Blocks.red_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.yellow_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.brown_mushroom, FlowerManager.FlowerTypeMushrooms);
|
||||
registerAcceptableFlower(Blocks.red_mushroom, FlowerManager.FlowerTypeMushrooms);
|
||||
registerAcceptableFlower(Blocks.cactus, FlowerManager.FlowerTypeCacti);
|
||||
|
||||
registerAcceptableFlower(Blocks.dragon_egg, FlowerManager.FlowerTypeEnd);
|
||||
registerAcceptableFlower(Blocks.vine, FlowerManager.FlowerTypeJungle);
|
||||
registerAcceptableFlower(Blocks.tallgrass, FlowerManager.FlowerTypeJungle);
|
||||
registerAcceptableFlower(Blocks.wheat, FlowerManager.FlowerTypeWheat);
|
||||
registerAcceptableFlower(Blocks.pumpkin_stem, FlowerManager.FlowerTypeGourd);
|
||||
registerAcceptableFlower(Blocks.melon_stem, FlowerManager.FlowerTypeGourd);
|
||||
registerAcceptableFlower(Blocks.nether_wart, FlowerManager.FlowerTypeNether);
|
||||
|
||||
registerAcceptableFlower(Blocks.double_plant, 0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.double_plant, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.double_plant, 4, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.double_plant, 5, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
}
|
||||
|
||||
private void registerVanillaGrowthRules() {
|
||||
registerGrowthRule(new VanillaDirtGrassGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerGrowthRule(new VanillaSnowGrowthRule(), FlowerManager.FlowerTypeSnow);
|
||||
registerGrowthRule(new VanillaFlowerPotGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow, FlowerManager.FlowerTypeMushrooms, FlowerManager.FlowerTypeCacti,
|
||||
FlowerManager.FlowerTypeJungle);
|
||||
registerGrowthRule(new VanillaMyceliumGrowthRule(), FlowerManager.FlowerTypeMushrooms);
|
||||
registerGrowthRule(new VanillaDefaultGrowthRule(), FlowerManager.FlowerTypeEnd);
|
||||
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.melon_stem, Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd);
|
||||
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.wheat), FlowerManager.FlowerTypeWheat);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VanillaDefaultGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Defaults;
|
||||
|
||||
public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
if (ground != Blocks.dirt && ground != Blocks.grass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFlower flower = flowerRegistry.getRandomPlantableFlower(flowerType, world.rand);
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
private final List<Block> allowedItems;
|
||||
|
||||
public VanillaFertilizeGrowthRule(Block... allowedItems) {
|
||||
this.allowedItems = Arrays.asList(allowedItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
Block ground = world.getBlock(x, y, z);
|
||||
int groundMeta;
|
||||
for (Block b : this.allowedItems) {
|
||||
if (b == ground) {
|
||||
groundMeta = world.getBlockMetadata(x, y, z);
|
||||
if (groundMeta > 6) {
|
||||
return false;
|
||||
}
|
||||
if (groundMeta < 6) {
|
||||
groundMeta += world.rand.nextInt(2) + 1;
|
||||
} else {
|
||||
groundMeta = 7;
|
||||
}
|
||||
|
||||
return world.setBlockMetadataWithNotify(x, y, z, groundMeta, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFlowerPot;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFlowerPot;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (!(tile instanceof TileEntityFlowerPot)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntityFlowerPot flowerPotTile = (TileEntityFlowerPot) tile;
|
||||
if (flowerPotTile.getFlowerPotItem() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (!(block instanceof BlockFlowerPot)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockFlowerPot flowerPot = (BlockFlowerPot) block;
|
||||
|
||||
int flower;
|
||||
if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) {
|
||||
flower = world.rand.nextInt(2) + 1;
|
||||
} else if (flowerType.equals(FlowerManager.FlowerTypeJungle)) {
|
||||
flower = 6;
|
||||
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
|
||||
flower = world.rand.nextInt(2) + 9;
|
||||
} else if (flowerType.equals(FlowerManager.FlowerTypeMushrooms)) {
|
||||
flower = world.rand.nextInt(2) + 7;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntityFlowerPot newTile = (TileEntityFlowerPot) flowerPot.createNewTileEntity(world, flower);
|
||||
|
||||
flowerPotTile.func_145964_a(newTile.getFlowerPotItem(), newTile.getFlowerPotData());
|
||||
flowerPotTile.markDirty();
|
||||
|
||||
if (!world.setBlockMetadataWithNotify(x, y, z, 1, 2)) {
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Defaults;
|
||||
|
||||
public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
if (ground != Blocks.mycelium) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Defaults;
|
||||
|
||||
public class VanillaSnowGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
if (world.getBlock(x, y, z) != Blocks.snow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
if (ground != Blocks.dirt && ground != Blocks.grass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -39,13 +39,14 @@ public class BlockAlveary extends BlockStructure {
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (i == 1)
|
||||
if (i == 1) {
|
||||
continue;
|
||||
}
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
@@ -77,20 +78,20 @@ public class BlockAlveary extends BlockStructure {
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
switch (metadata) {
|
||||
case TileAlvearySwarmer.BLOCK_META:
|
||||
return new TileAlvearySwarmer();
|
||||
case TileAlvearyFan.BLOCK_META:
|
||||
return new TileAlvearyFan();
|
||||
case TileAlvearyHeater.BLOCK_META:
|
||||
return new TileAlvearyHeater();
|
||||
case TileAlvearyHygroregulator.BLOCK_META:
|
||||
return new TileAlvearyHygroregulator();
|
||||
case TileAlvearyStabiliser.BLOCK_META:
|
||||
return new TileAlvearyStabiliser();
|
||||
case TileAlvearySieve.BLOCK_META:
|
||||
return new TileAlvearySieve();
|
||||
default:
|
||||
return new TileAlvearyPlain();
|
||||
case TileAlvearySwarmer.BLOCK_META:
|
||||
return new TileAlvearySwarmer();
|
||||
case TileAlvearyFan.BLOCK_META:
|
||||
return new TileAlvearyFan();
|
||||
case TileAlvearyHeater.BLOCK_META:
|
||||
return new TileAlvearyHeater();
|
||||
case TileAlvearyHygroregulator.BLOCK_META:
|
||||
return new TileAlvearyHygroregulator();
|
||||
case TileAlvearyStabiliser.BLOCK_META:
|
||||
return new TileAlvearyStabiliser();
|
||||
case TileAlvearySieve.BLOCK_META:
|
||||
return new TileAlvearySieve();
|
||||
default:
|
||||
return new TileAlvearyPlain();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,13 +106,13 @@ public class BlockAlveary extends BlockStructure {
|
||||
public static final int BOTTOM = 2;
|
||||
public static final int LEFT = 3;
|
||||
public static final int RIGHT = 4;
|
||||
public static final int TX_55_SWOF = 5;
|
||||
public static final int TX_56_SWON = 6;
|
||||
public static final int TX_57_HTOF = 7;
|
||||
public static final int TX_58_HTON = 8;
|
||||
public static final int TX_71_FNOF = 9;
|
||||
public static final int TX_72_FNON = 10;
|
||||
public static final int TX_73_VLVE = 11;
|
||||
public static final int ALVEARY_SWARMER_OFF = 5;
|
||||
public static final int ALVEARY_SWARMER_ON = 6;
|
||||
public static final int ALVEARY_HEATER_OFF = 7;
|
||||
public static final int ALVEARY_HEATER_ON = 8;
|
||||
public static final int ALVEARY_FAN_OFF = 9;
|
||||
public static final int ALVEARY_FAN_ON = 10;
|
||||
public static final int ALVEARY_HYGRO = 11;
|
||||
public static final int STABILISER = 12;
|
||||
public static final int SIEVE = 13;
|
||||
|
||||
@@ -143,28 +144,29 @@ public class BlockAlveary extends BlockStructure {
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if ((metadata <= 1
|
||||
|| metadata == TileAlvearySieve.BLOCK_META || metadata == TileAlvearySwarmer.BLOCK_META || metadata == TileAlvearyStabiliser.BLOCK_META)
|
||||
&& (side == 1 || side == 0))
|
||||
&& (side == 1 || side == 0)) {
|
||||
return icons[BOTTOM];
|
||||
}
|
||||
|
||||
switch (metadata) {
|
||||
case TileAlvearyPlain.BLOCK_META:
|
||||
return icons[PLAIN];
|
||||
case 1:
|
||||
return icons[ENTRANCE];
|
||||
case TileAlvearySwarmer.BLOCK_META:
|
||||
return icons[TX_55_SWOF];
|
||||
case TileAlvearyFan.BLOCK_META:
|
||||
return icons[TX_71_FNOF];
|
||||
case TileAlvearyHeater.BLOCK_META:
|
||||
return icons[TX_57_HTOF];
|
||||
case TileAlvearyHygroregulator.BLOCK_META:
|
||||
return icons[TX_73_VLVE];
|
||||
case TileAlvearyStabiliser.BLOCK_META:
|
||||
return icons[STABILISER];
|
||||
case TileAlvearySieve.BLOCK_META:
|
||||
return icons[SIEVE];
|
||||
default:
|
||||
return null;
|
||||
case TileAlvearyPlain.BLOCK_META:
|
||||
return icons[PLAIN];
|
||||
case 1:
|
||||
return icons[ENTRANCE];
|
||||
case TileAlvearySwarmer.BLOCK_META:
|
||||
return icons[ALVEARY_SWARMER_OFF];
|
||||
case TileAlvearyFan.BLOCK_META:
|
||||
return icons[ALVEARY_FAN_OFF];
|
||||
case TileAlvearyHeater.BLOCK_META:
|
||||
return icons[ALVEARY_HEATER_OFF];
|
||||
case TileAlvearyHygroregulator.BLOCK_META:
|
||||
return icons[ALVEARY_HYGRO];
|
||||
case TileAlvearyStabiliser.BLOCK_META:
|
||||
return icons[STABILISER];
|
||||
case TileAlvearySieve.BLOCK_META:
|
||||
return icons[SIEVE];
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -174,10 +176,11 @@ public class BlockAlveary extends BlockStructure {
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (meta == 1)
|
||||
if (meta == 1) {
|
||||
return this.getIcon(side, meta);
|
||||
else if (meta > 1)
|
||||
} else if (meta > 1) {
|
||||
return getBlockTextureFromSideAndTile(world, x, y, z, side);
|
||||
}
|
||||
|
||||
Block blockXP = world.getBlock(x + 1, y, z);
|
||||
Block blockXM = world.getBlock(x - 1, y, z);
|
||||
@@ -186,24 +189,29 @@ public class BlockAlveary extends BlockStructure {
|
||||
|
||||
if (world.getBlockMetadata(x + 1, y, z) == 1) {
|
||||
|
||||
if (world.getBlock(x, y, z + 1) != this)
|
||||
if (world.getBlock(x, y, z + 1) != this) {
|
||||
return switchForSide(42, side);
|
||||
else
|
||||
} else {
|
||||
return switchForSide(41, side);
|
||||
}
|
||||
|
||||
} else
|
||||
} else {
|
||||
return this.getIcon(side, meta);
|
||||
}
|
||||
|
||||
} else if (blockXP != this && blockXM == this)
|
||||
} else if (blockXP != this && blockXM == this) {
|
||||
if (world.getBlockMetadata(x - 1, y, z) == 1) {
|
||||
|
||||
if (world.getBlock(x, y, z + 1) != this)
|
||||
if (world.getBlock(x, y, z + 1) != this) {
|
||||
return switchForSide(41, side);
|
||||
else
|
||||
} else {
|
||||
return switchForSide(42, side);
|
||||
}
|
||||
|
||||
} else
|
||||
} else {
|
||||
return this.getIcon(side, meta);
|
||||
}
|
||||
}
|
||||
|
||||
return this.getIcon(side, meta);
|
||||
}
|
||||
@@ -211,8 +219,9 @@ public class BlockAlveary extends BlockStructure {
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon getBlockTextureFromSideAndTile(IBlockAccess world, int x, int y, int z, int side) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile == null || !(tile instanceof TileAlveary))
|
||||
if (tile == null || !(tile instanceof TileAlveary)) {
|
||||
return getIcon(side, 0);
|
||||
}
|
||||
|
||||
return icons[((TileAlveary) tile).getIcon(side, world.getBlockMetadata(x, y, z))];
|
||||
}
|
||||
@@ -221,14 +230,16 @@ public class BlockAlveary extends BlockStructure {
|
||||
private IIcon switchForSide(int textureId, int side) {
|
||||
|
||||
if (side == 4 || side == 5) {
|
||||
if (textureId == 41)
|
||||
if (textureId == 41) {
|
||||
return icons[LEFT];
|
||||
else
|
||||
} else {
|
||||
return icons[RIGHT];
|
||||
} else if (textureId == 41)
|
||||
}
|
||||
} else if (textureId == 41) {
|
||||
return icons[RIGHT];
|
||||
else
|
||||
} else {
|
||||
return icons[LEFT];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -29,13 +29,15 @@ import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IHiveDrop;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.MaterialBeehive;
|
||||
import forestry.apiculture.worldgen.HiveRegistry;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class BlockBeehives extends BlockContainer {
|
||||
|
||||
@@ -44,6 +46,7 @@ public class BlockBeehives extends BlockContainer {
|
||||
setLightLevel(0.8f);
|
||||
setHardness(1.0f);
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
setHarvestLevel("scoop", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,17 +60,20 @@ public class BlockBeehives extends BlockContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
|
||||
if (canHarvestBlock(player, world.getBlockMetadata(x, y, z))) {
|
||||
// Handle TE'd beehives
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileSwarm) {
|
||||
TileSwarm swarm = (TileSwarm) tile;
|
||||
if (swarm.containsBees())
|
||||
for (ItemStack beeStack : swarm.contained.getStacks())
|
||||
if (beeStack != null)
|
||||
if (swarm.containsBees()) {
|
||||
for (ItemStack beeStack : InvTools.getStacks(swarm.contained)) {
|
||||
if (beeStack != null) {
|
||||
StackUtils.dropItemStackAsEntity(beeStack, world, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +90,7 @@ public class BlockBeehives extends BlockContainer {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ArrayList<IHiveDrop> dropList = BeeManager.hiveDrops[metadata - 1];
|
||||
List<IHiveDrop> dropList = getDropsForHive(metadata);
|
||||
|
||||
Collections.shuffle(dropList);
|
||||
// Grab a princess
|
||||
@@ -93,26 +99,29 @@ public class BlockBeehives extends BlockContainer {
|
||||
while (tries <= 10 && !hasPrincess) {
|
||||
tries++;
|
||||
|
||||
for (IHiveDrop drop : dropList)
|
||||
for (IHiveDrop drop : dropList) {
|
||||
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
|
||||
ret.add(drop.getPrincess(world, x, y, z, fortune));
|
||||
hasPrincess = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Grab drones
|
||||
for (IHiveDrop drop : dropList)
|
||||
for (IHiveDrop drop : dropList) {
|
||||
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
|
||||
ret.addAll(drop.getDrones(world, x, y, z, fortune));
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Grab anything else on offer
|
||||
for (IHiveDrop drop : dropList)
|
||||
for (IHiveDrop drop : dropList) {
|
||||
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
|
||||
ret.addAll(drop.getAdditional(world, x, y, z, fortune));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -123,7 +132,35 @@ public class BlockBeehives extends BlockContainer {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private List<IHiveDrop> getDropsForHive(int meta) {
|
||||
String hiveName = getHiveNameForMeta(meta);
|
||||
if (hiveName == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return PluginApiculture.hiveRegistry.getDrops(hiveName);
|
||||
}
|
||||
|
||||
private String getHiveNameForMeta(int meta) {
|
||||
switch (meta) {
|
||||
case 1:
|
||||
return HiveRegistry.forest;
|
||||
case 2:
|
||||
return HiveRegistry.meadows;
|
||||
case 3:
|
||||
return HiveRegistry.desert;
|
||||
case 4:
|
||||
return HiveRegistry.jungle;
|
||||
case 5:
|
||||
return HiveRegistry.end;
|
||||
case 6:
|
||||
return HiveRegistry.snow;
|
||||
case 7:
|
||||
return HiveRegistry.swamp;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
itemList.add(new ItemStack(this, 1, 1));
|
||||
@@ -131,7 +168,7 @@ public class BlockBeehives extends BlockContainer {
|
||||
itemList.add(new ItemStack(this, 1, 3));
|
||||
itemList.add(new ItemStack(this, 1, 4));
|
||||
if (Config.isDebug) {
|
||||
itemList.add(new ItemStack(this, 1 ,5));
|
||||
itemList.add(new ItemStack(this, 1, 5));
|
||||
}
|
||||
itemList.add(new ItemStack(this, 1, 6));
|
||||
itemList.add(new ItemStack(this, 1, 7));
|
||||
@@ -155,18 +192,21 @@ public class BlockBeehives extends BlockContainer {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int i, int j) {
|
||||
if (j == 0 || j >= 8)
|
||||
if (j == 0 || j > 8) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (i == 0 || i == 1) {
|
||||
if (j * 2 < icons.length && icons[j * 2] != null)
|
||||
if (j * 2 < icons.length && icons[j * 2] != null) {
|
||||
return icons[j * 2];
|
||||
else
|
||||
} else {
|
||||
return icons[2];
|
||||
} else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null)
|
||||
}
|
||||
} else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null) {
|
||||
return icons[j * 2 + 1];
|
||||
else
|
||||
} else {
|
||||
return icons[3];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -30,12 +30,12 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.ForestryClient;
|
||||
import forestry.core.config.Defaults;
|
||||
@@ -96,7 +96,7 @@ public class BlockCandle extends BlockTorch {
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
return (isLit(meta))? 14 : 0;
|
||||
return (isLit(meta)) ? 14 : 0;
|
||||
}
|
||||
|
||||
/*@SideOnly(Side.CLIENT)
|
||||
@@ -111,20 +111,17 @@ public class BlockCandle extends BlockTorch {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getTextureFromPassAndMeta(int meta, int pass) {
|
||||
IIcon i = this.unlitStump;
|
||||
IIcon i;
|
||||
if (pass == 0) {
|
||||
if (isLit(meta)) {
|
||||
i = this.litTip;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
i = this.unlitTip;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (isLit(meta)) {
|
||||
i = this.litStump;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
i = this.unlitStump;
|
||||
}
|
||||
}
|
||||
@@ -140,22 +137,22 @@ public class BlockCandle extends BlockTorch {
|
||||
return colour;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
itemList.add(new ItemStack(this, 1, 0));
|
||||
}
|
||||
|
||||
// Dye names correspond to colour values as below.
|
||||
private static final String[] dyes = { "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue",
|
||||
"dyeYellow", "dyeLime", "dyePink", "dyeGray",
|
||||
"dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue",
|
||||
"dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" };
|
||||
private static final String[] dyes = {"dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue",
|
||||
"dyeYellow", "dyeLime", "dyePink", "dyeGray",
|
||||
"dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue",
|
||||
"dyeBrown", "dyeGreen", "dyeRed", "dyeBlack"};
|
||||
|
||||
private static final int[][] colours = { { 255, 255, 255 } , { 219, 125, 62 } , { 255, 20, 255 } , { 107, 138, 201 } ,
|
||||
{ 255, 255, 20 } , { 20, 255, 20 } , { 208, 132, 153 } , { 74, 74, 74 } ,
|
||||
{ 154, 161, 161 } , { 20, 255, 255 } , { 126, 61, 181 } , { 20, 20, 255 } ,
|
||||
{ 79, 50, 31 } , { 53, 70, 27 } , { 150, 52, 48 } , { 20, 20, 20 } };
|
||||
private static final int[][] colours = {{255, 255, 255}, {219, 125, 62}, {255, 20, 255}, {107, 138, 201},
|
||||
{255, 255, 20}, {20, 255, 20}, {208, 132, 153}, {74, 74, 74},
|
||||
{154, 161, 161}, {20, 255, 255}, {126, 61, 181}, {20, 20, 255},
|
||||
{79, 50, 31}, {53, 70, 27}, {150, 52, 48}, {20, 20, 20}};
|
||||
|
||||
public static final String colourTagName = "colour";
|
||||
|
||||
@@ -169,17 +166,17 @@ public class BlockCandle extends BlockTorch {
|
||||
if (!isLit(meta)) {
|
||||
if (held == null || !lightingItems.contains(held.getItem())) {
|
||||
toggleLitState = false;
|
||||
}
|
||||
else if (StackUtils.equals(this, held) && isLit(held)) {
|
||||
} else if (StackUtils.equals(this, held) && isLit(held)) {
|
||||
toggleLitState = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (held != null) {
|
||||
// Ensure a TileEntity exists. May be able to remove this in future versions.
|
||||
TileCandle te = (TileCandle)world.getTileEntity(x, y, z);
|
||||
TileCandle te = (TileCandle) world.getTileEntity(x, y, z);
|
||||
if (te == null) {
|
||||
world.setTileEntity(x, y, z, this.createTileEntity(world, meta));
|
||||
te = (TileCandle) world.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
if (StackUtils.equals(this, held)) {
|
||||
@@ -187,18 +184,15 @@ public class BlockCandle extends BlockTorch {
|
||||
// Copy the colour of an unlit, coloured candle.
|
||||
if (held.hasTagCompound() && held.getTagCompound().hasKey(colourTagName)) {
|
||||
te.setColour(held.getTagCompound().getInteger(colourTagName));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Reset to white if item has no
|
||||
te.setColour(0xffffff);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
toggleLitState = true;
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Check for dye-able ness.
|
||||
boolean matched = false;
|
||||
for (int i = 0; i < dyes.length; ++i) {
|
||||
@@ -206,8 +200,7 @@ public class BlockCandle extends BlockTorch {
|
||||
if (OreDictionary.itemMatches(stack, held, true)) {
|
||||
if (isLit(meta)) {
|
||||
te.setColour(colours[i][0], colours[i][1], colours[i][2]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
te.addColour(colours[i][0], colours[i][1], colours[i][2]);
|
||||
}
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
@@ -235,7 +228,7 @@ public class BlockCandle extends BlockTorch {
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
|
||||
if (!world.isRemote) {
|
||||
TileCandle tc = (TileCandle)world.getTileEntity(x, y, z);
|
||||
TileCandle tc = (TileCandle) world.getTileEntity(x, y, z);
|
||||
int newMeta = isLit(meta) ? 1 : 0;
|
||||
ItemStack stack = new ItemStack(this, 1, newMeta);
|
||||
if (tc != null && tc.getColour() != 0xffffff) {
|
||||
@@ -251,7 +244,7 @@ public class BlockCandle extends BlockTorch {
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||
TileCandle tc = (TileCandle)(world.getTileEntity(x, y, z));
|
||||
TileCandle tc = (TileCandle) (world.getTileEntity(x, y, z));
|
||||
tc.setColour(this.getColourValueFromItemStack(itemStack));
|
||||
if (isLit(itemStack)) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
@@ -277,8 +270,7 @@ public class BlockCandle extends BlockTorch {
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -294,28 +286,19 @@ public class BlockCandle extends BlockTorch {
|
||||
double d3 = 0.2199999988079071D;
|
||||
double d4 = 0.27000001072883606D;
|
||||
|
||||
if (l == 1)
|
||||
{
|
||||
if (l == 1) {
|
||||
world.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (l == 2)
|
||||
{
|
||||
} else if (l == 2) {
|
||||
world.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (l == 3)
|
||||
{
|
||||
} else if (l == 3) {
|
||||
world.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else if (l == 4)
|
||||
{
|
||||
} else if (l == 4) {
|
||||
world.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
@@ -323,64 +306,48 @@ public class BlockCandle extends BlockTorch {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block)
|
||||
{
|
||||
if (this.func_150109_e(par1World, par2, par3, par4))
|
||||
{
|
||||
protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block) {
|
||||
if (this.func_150109_e(par1World, par2, par3, par4)) {
|
||||
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 0x07;
|
||||
boolean flag = false;
|
||||
|
||||
if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4)
|
||||
{
|
||||
if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5)
|
||||
{
|
||||
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5) {
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
|
||||
par1World.setBlockToAir(par2, par3, par4);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Yes, function hiding. Go away.
|
||||
public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4))
|
||||
{
|
||||
public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4) {
|
||||
if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4)) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Block block = par1World.getBlock(par2, par3, par4);
|
||||
return block.canPlaceTorchOnTop(par1World, par2, par3, par4);
|
||||
}
|
||||
@@ -410,7 +377,9 @@ public class BlockCandle extends BlockTorch {
|
||||
}
|
||||
|
||||
public void addItemToLightingList(Item item) {
|
||||
if (item == null) throw new NullPointerException();
|
||||
if (item == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
if (!this.lightingItems.contains(item)) {
|
||||
this.lightingItems.add(item);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -48,7 +48,7 @@ public class BlockStump extends BlockTorch {
|
||||
this.blockIcon = TextureManager.getInstance().registerTex(register, StringUtil.cleanBlockName(this));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
itemList.add(new ItemStack(this, 1, 0));
|
||||
@@ -60,8 +60,8 @@ public class BlockStump extends BlockTorch {
|
||||
ItemStack held = player.getCurrentEquippedItem();
|
||||
if (held != null &&
|
||||
(held.getItem() == Items.flint_and_steel ||
|
||||
held.getItem() == Items.flint ||
|
||||
StackUtils.equals(Blocks.torch, held))) {
|
||||
held.getItem() == Items.flint ||
|
||||
StackUtils.equals(Blocks.torch, held))) {
|
||||
world.setBlock(x, y, z, ForestryBlock.candle.block(), world.getBlockMetadata(x, y, z) | 0x08, Defaults.FLAG_BLOCK_SYNCH);
|
||||
TileCandle tc = new TileCandle();
|
||||
tc.setColour(0); // default to white
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -23,7 +23,7 @@ import forestry.core.gadgets.BlockStructure.EnumStructureState;
|
||||
import forestry.core.gadgets.StructureLogic;
|
||||
import forestry.core.utils.Schemata;
|
||||
import forestry.core.utils.Schemata.EnumStructureBlock;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
public class StructureLogicAlveary extends StructureLogic {
|
||||
|
||||
@@ -34,19 +34,18 @@ public class StructureLogicAlveary extends StructureLogic {
|
||||
"FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF").setOffsets(-2, -3, -2);
|
||||
|
||||
public static final HashSet<Block> slabBlocks = new HashSet<Block>();
|
||||
|
||||
static {
|
||||
slabBlocks.add(Blocks.stone_slab);
|
||||
slabBlocks.add(Blocks.wooden_slab);
|
||||
slabBlocks.add(ForestryBlock.slabs1.block());
|
||||
slabBlocks.add(ForestryBlock.slabs2.block());
|
||||
slabBlocks.add(ForestryBlock.slabs3.block());
|
||||
if (ForestryBlock.slabs4 != null)
|
||||
slabBlocks.add(ForestryBlock.slabs4.block());
|
||||
slabBlocks.add(ForestryBlock.slabs4.block());
|
||||
}
|
||||
|
||||
public StructureLogicAlveary(ITileStructure structure) {
|
||||
super(UID_ALVEARY, structure);
|
||||
schematas = new Schemata[] { SCHEMATA_ALVEARY };
|
||||
schematas = new Schemata[]{SCHEMATA_ALVEARY};
|
||||
metaOnValid.put(EnumStructureBlock.BLOCK_B, 1);
|
||||
}
|
||||
|
||||
@@ -61,57 +60,69 @@ public class StructureLogicAlveary extends StructureLogic {
|
||||
offsetZ = schemata.getxOffset();
|
||||
}
|
||||
|
||||
for (int i = 0; i < dimensions.x; i++)
|
||||
for (int j = 0; j < schemata.getHeight(); j++)
|
||||
for (int i = 0; i < dimensions.x; i++) {
|
||||
for (int j = 0; j < schemata.getHeight(); j++) {
|
||||
for (int k = 0; k < dimensions.z; k++) {
|
||||
int x = structureTile.xCoord + i + offsetX;
|
||||
int y = structureTile.yCoord + j + schemata.getyOffset();
|
||||
int z = structureTile.zCoord + k + offsetZ;
|
||||
|
||||
if (!structureTile.getWorldObj().blockExists(x, y, z))
|
||||
if (!structureTile.getWorldObj().blockExists(x, y, z)) {
|
||||
return EnumStructureState.INDETERMINATE;
|
||||
}
|
||||
|
||||
EnumStructureBlock required = schemata.getAt(i, j, k, rotate);
|
||||
if (required == EnumStructureBlock.ANY)
|
||||
if (required == EnumStructureBlock.ANY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z);
|
||||
Block block = structureTile.getWorldObj().getBlock(x, y, z);
|
||||
|
||||
switch (required) {
|
||||
case AIR:
|
||||
if (!block.isAir(structureTile.getWorldObj(), x, y, z))
|
||||
return EnumStructureState.INVALID;
|
||||
break;
|
||||
case BLOCK_A:
|
||||
if (tile == null || !(tile instanceof IAlvearyComponent))
|
||||
return EnumStructureState.INVALID;
|
||||
if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY))
|
||||
return EnumStructureState.INVALID;
|
||||
break;
|
||||
case MASTER:
|
||||
case BLOCK_B:
|
||||
if (tile == null || !(tile instanceof TileAlvearyPlain))
|
||||
return EnumStructureState.INVALID;
|
||||
break;
|
||||
case BLOCK_C:
|
||||
if (!slabBlocks.contains(block))
|
||||
return EnumStructureState.INVALID;
|
||||
if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0)
|
||||
return EnumStructureState.INVALID;
|
||||
break;
|
||||
case BLOCK_D:
|
||||
if (block != Blocks.spruce_stairs)
|
||||
return EnumStructureState.INVALID;
|
||||
break;
|
||||
case FOREIGN:
|
||||
if (tile instanceof ITileStructure)
|
||||
return EnumStructureState.INVALID;
|
||||
break;
|
||||
default:
|
||||
return EnumStructureState.INDETERMINATE;
|
||||
case AIR:
|
||||
if (!block.isAir(structureTile.getWorldObj(), x, y, z)) {
|
||||
return EnumStructureState.INVALID;
|
||||
}
|
||||
break;
|
||||
case BLOCK_A:
|
||||
if (tile == null || !(tile instanceof IAlvearyComponent)) {
|
||||
return EnumStructureState.INVALID;
|
||||
}
|
||||
if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY)) {
|
||||
return EnumStructureState.INVALID;
|
||||
}
|
||||
break;
|
||||
case MASTER:
|
||||
case BLOCK_B:
|
||||
if (tile == null || !(tile instanceof TileAlvearyPlain)) {
|
||||
return EnumStructureState.INVALID;
|
||||
}
|
||||
break;
|
||||
case BLOCK_C:
|
||||
if (!slabBlocks.contains(block)) {
|
||||
return EnumStructureState.INVALID;
|
||||
}
|
||||
if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0) {
|
||||
return EnumStructureState.INVALID;
|
||||
}
|
||||
break;
|
||||
case BLOCK_D:
|
||||
if (block != Blocks.spruce_stairs) {
|
||||
return EnumStructureState.INVALID;
|
||||
}
|
||||
break;
|
||||
case FOREIGN:
|
||||
if (tile instanceof ITileStructure) {
|
||||
return EnumStructureState.INVALID;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return EnumStructureState.INDETERMINATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EnumStructureState.VALID;
|
||||
}
|
||||
|
||||
@@ -4,36 +4,44 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.core.IStructureLogic;
|
||||
import forestry.api.core.ITileStructure;
|
||||
import forestry.apiculture.trigger.ApicultureTriggers;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.triggers.ForestryTrigger;
|
||||
import forestry.core.utils.TileInventoryAdapter;
|
||||
import forestry.core.utils.Utils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
public abstract class TileAlveary extends TileForestry implements IAlvearyComponent {
|
||||
|
||||
protected TileInventoryAdapter inventory;
|
||||
private final IStructureLogic structureLogic;
|
||||
private boolean isMaster;
|
||||
protected int masterX, masterZ;
|
||||
protected int masterY = -99;
|
||||
protected final int componentBlockMeta;
|
||||
|
||||
public TileAlveary(int componentBlockMeta) {
|
||||
@@ -54,17 +62,15 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!Proxies.common.isSimulating(worldObj))
|
||||
updateClientSide();
|
||||
else {
|
||||
if (!isInited) {
|
||||
initialize();
|
||||
isInited = true;
|
||||
}
|
||||
super.updateEntity();
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
updateClientSide();
|
||||
} else {
|
||||
// Periodic validation if needed
|
||||
if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster()))
|
||||
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
|
||||
validateStructure();
|
||||
}
|
||||
|
||||
updateServerSide();
|
||||
}
|
||||
@@ -84,16 +90,17 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
/* LOADING & SAVING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
this.isMaster = nbttagcompound.getBoolean("IsMaster");
|
||||
this.masterX = nbttagcompound.getInteger("MasterX");
|
||||
this.masterY = nbttagcompound.getInteger("MasterY");
|
||||
this.masterZ = nbttagcompound.getInteger("MasterZ");
|
||||
|
||||
// Init for master state
|
||||
if (isMaster)
|
||||
if (isMaster) {
|
||||
makeMaster();
|
||||
}
|
||||
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
structureLogic.readFromNBT(nbttagcompound);
|
||||
}
|
||||
@@ -114,21 +121,27 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromPacketPayload(PacketPayload payload) {
|
||||
public PacketPayload getPacketPayload() {
|
||||
PacketPayload payload = new PacketPayload(0, 2);
|
||||
payload.shortPayload[0] = (short) (isMaster() ? 1 : 0);
|
||||
|
||||
// so the client can know if it is part of an integrated structure
|
||||
payload.shortPayload[1] = (short) this.masterY;
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPayload getPacketPayload() {
|
||||
return null;
|
||||
public void fromPacketPayload(PacketPayload payload) {
|
||||
if (payload.shortPayload[0] > 0) {
|
||||
makeMaster();
|
||||
}
|
||||
|
||||
// so the client can know if it is part of an integrated structure
|
||||
this.masterY = payload.shortPayload[1];
|
||||
}
|
||||
|
||||
/* ITILESTRUCTURE */
|
||||
IStructureLogic structureLogic;
|
||||
|
||||
private boolean isMaster;
|
||||
protected int masterX, masterZ;
|
||||
protected int masterY = -99;
|
||||
|
||||
@Override
|
||||
public String getTypeUID() {
|
||||
return structureLogic.getTypeUID();
|
||||
@@ -144,15 +157,17 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
setCentralTE(null);
|
||||
isMaster = true;
|
||||
|
||||
if (inventory == null)
|
||||
if (getInternalInventory() instanceof FakeInventoryAdapter) {
|
||||
createInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStructureReset() {
|
||||
setCentralTE(null);
|
||||
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1)
|
||||
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1) {
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 0);
|
||||
}
|
||||
isMaster = false;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
@@ -160,21 +175,25 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
@Override
|
||||
public ITileStructure getCentralTE() {
|
||||
|
||||
if (!isIntegratedIntoStructure())
|
||||
if (!isIntegratedIntoStructure()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isMaster()) {
|
||||
TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ);
|
||||
if (tile instanceof ITileStructure) {
|
||||
ITileStructure master = (ITileStructure) worldObj.getTileEntity(masterX, masterY, masterZ);
|
||||
if (master.isMaster())
|
||||
if (master.isMaster()) {
|
||||
return master;
|
||||
else
|
||||
} else {
|
||||
return null;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -211,8 +230,13 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventory() {
|
||||
return inventory;
|
||||
public final IInventoryAdapter getInventory() {
|
||||
return getStructureInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventoryAdapter getStructureInventory() {
|
||||
return getInternalInventory();
|
||||
}
|
||||
|
||||
/* IALVEARY COMPONENT */
|
||||
@@ -245,18 +269,14 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
public void removeBeeListener(IBeeListener event) {
|
||||
}
|
||||
|
||||
// / ITRIGGERPROVIDER
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public LinkedList<ITriggerExternal> getCustomTriggers() {
|
||||
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
|
||||
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
|
||||
res.add(ForestryTrigger.missingQueen);
|
||||
res.add(ForestryTrigger.missingDrone);
|
||||
res.add(ApicultureTriggers.missingQueen);
|
||||
res.add(ApicultureTriggers.missingDrone);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return Utils.isUseableByPlayer(player, this, worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,19 +4,21 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.energy.EnergyManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler {
|
||||
|
||||
@@ -32,56 +34,48 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
this.boundaryUp = boundaryUp;
|
||||
}
|
||||
}
|
||||
protected EnergyManager energyManager;
|
||||
ClimateControl climateControl;
|
||||
private int transferTime = 0;
|
||||
private int animationDelay = 0;
|
||||
|
||||
protected final EnergyManager energyManager;
|
||||
private final ClimateControl climateControl;
|
||||
private int workingTime = 0;
|
||||
private final int textureOff;
|
||||
private final int textureOn;
|
||||
|
||||
public TileAlvearyClimatiser(ClimateControl control, int textureOff, int textureOn, int componentBlockMeta) {
|
||||
super(componentBlockMeta);
|
||||
this.climateControl = control;
|
||||
energyManager = new EnergyManager(1000, 250, 2000);
|
||||
energyManager = new EnergyManager(1000, 50, 2000);
|
||||
energyManager.setReceiveOnly();
|
||||
this.textureOff = textureOff;
|
||||
this.textureOn = textureOn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player) {
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!this.hasMaster())
|
||||
if (!this.hasMaster()) {
|
||||
return;
|
||||
|
||||
if (energyManager.consumeEnergyToDoWork()) {
|
||||
|
||||
transferTime = energyManager.getEnergyPerWork();
|
||||
|
||||
if (animationDelay <= 0) {
|
||||
animationDelay = 100;
|
||||
sendNetworkUpdate();
|
||||
} else
|
||||
animationDelay = 100;
|
||||
}
|
||||
|
||||
if (transferTime > 0) {
|
||||
transferTime--;
|
||||
boolean wasInactive = (workingTime == 0);
|
||||
|
||||
if (workingTime < 20 && energyManager.consumeEnergyToDoWork()) {
|
||||
// consume 10 RF per tick of work
|
||||
workingTime += energyManager.getEnergyPerWork() / 10;
|
||||
}
|
||||
|
||||
if (workingTime > 0) {
|
||||
workingTime--;
|
||||
IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE();
|
||||
if (component != null)
|
||||
if (component != null) {
|
||||
component.addTemperatureChange(climateControl.changePerTransfer, climateControl.boundaryDown, climateControl.boundaryUp);
|
||||
}
|
||||
}
|
||||
|
||||
if (animationDelay > 0) {
|
||||
animationDelay--;
|
||||
if (animationDelay <= 0)
|
||||
sendNetworkUpdate();
|
||||
if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,10 +87,11 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
/* TEXTURES */
|
||||
@Override
|
||||
public int getIcon(int side, int metadata) {
|
||||
if (animationDelay > 0)
|
||||
if (workingTime > 0) {
|
||||
return textureOn;
|
||||
else
|
||||
} else {
|
||||
return textureOff;
|
||||
}
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@@ -104,23 +99,23 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
energyManager.readFromNBT(nbttagcompound);
|
||||
transferTime = nbttagcompound.getInteger("Heating");
|
||||
workingTime = nbttagcompound.getInteger("Heating");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
energyManager.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setInteger("Heating", transferTime);
|
||||
nbttagcompound.setInteger("Heating", workingTime);
|
||||
}
|
||||
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void fromPacketPayload(PacketPayload payload) {
|
||||
short delay = payload.shortPayload[0];
|
||||
if (animationDelay != delay) {
|
||||
animationDelay = delay;
|
||||
short workingTime = payload.shortPayload[0];
|
||||
if (this.workingTime != workingTime) {
|
||||
this.workingTime = workingTime;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -128,7 +123,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
@Override
|
||||
public PacketPayload getPacketPayload() {
|
||||
PacketPayload payload = new PacketPayload(0, 1);
|
||||
payload.shortPayload[0] = (short) animationDelay;
|
||||
payload.shortPayload[0] = (short) workingTime;
|
||||
return payload;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -16,7 +16,7 @@ public class TileAlvearyFan extends TileAlvearyClimatiser {
|
||||
public static final int BLOCK_META = 3;
|
||||
|
||||
public TileAlvearyFan() {
|
||||
super(new ClimateControl(-0.01f, 0.05f, 2.5f), BlockAlveary.TX_71_FNOF, BlockAlveary.TX_72_FNON, BLOCK_META);
|
||||
super(new ClimateControl(-0.01f, 0.05f, 2.5f), BlockAlveary.ALVEARY_FAN_OFF, BlockAlveary.ALVEARY_FAN_ON, BLOCK_META);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -12,14 +12,11 @@ package forestry.apiculture.gadgets;
|
||||
|
||||
public class TileAlvearyHeater extends TileAlvearyClimatiser {
|
||||
|
||||
public static final int TEXTURE_OFF = 57;
|
||||
public static final int TEXTURE_ON = 58;
|
||||
|
||||
/* CONSTANTS */
|
||||
public static final int BLOCK_META = 4;
|
||||
|
||||
public TileAlvearyHeater() {
|
||||
super(new ClimateControl(0.01f, 0.0f, 2.5f), BlockAlveary.TX_57_HTOF, BlockAlveary.TX_58_HTON, BLOCK_META);
|
||||
super(new ClimateControl(0.01f, 0.0f, 2.5f), BlockAlveary.ALVEARY_HEATER_OFF, BlockAlveary.ALVEARY_HEATER_ON, BLOCK_META);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -19,22 +19,20 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
import forestry.core.utils.StackUtils;
|
||||
|
||||
public class TileAlvearyHygroregulator extends TileAlveary implements IInventory, ILiquidTankContainer {
|
||||
|
||||
@@ -43,6 +41,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
|
||||
/* RECIPE MANAGMENT */
|
||||
private static class HygroregulatorRecipe {
|
||||
|
||||
public final FluidStack liquid;
|
||||
public final int transferTime;
|
||||
public final float humidChange;
|
||||
@@ -56,12 +55,13 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
}
|
||||
}
|
||||
|
||||
public static final short SLOT_INPUT = 0;
|
||||
|
||||
private final HygroregulatorRecipe[] recipes;
|
||||
|
||||
/* MEMBERS */
|
||||
InventoryAdapter canInventory = new InventoryAdapter(1, "CanInv");
|
||||
private final TankManager tankManager;
|
||||
private FilteredTank liquidTank;
|
||||
private final FilteredTank liquidTank;
|
||||
|
||||
private HygroregulatorRecipe currentRecipe;
|
||||
private int transferTime;
|
||||
@@ -69,16 +69,27 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
public TileAlvearyHygroregulator() {
|
||||
super(BLOCK_META);
|
||||
|
||||
Fluid water = LiquidHelper.getFluid(Defaults.LIQUID_WATER);
|
||||
Fluid lava = LiquidHelper.getFluid(Defaults.LIQUID_LAVA);
|
||||
Fluid liquidIce = LiquidHelper.getFluid(Defaults.LIQUID_ICE);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 1, "CanInv") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return liquidTank.accepts(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Fluid water = Fluids.WATER.getFluid();
|
||||
Fluid lava = Fluids.LAVA.getFluid();
|
||||
Fluid liquidIce = Fluids.ICE.getFluid();
|
||||
|
||||
liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, water, lava, liquidIce);
|
||||
tankManager = new TankManager(liquidTank);
|
||||
|
||||
recipes = new HygroregulatorRecipe[] { new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
|
||||
recipes = new HygroregulatorRecipe[]{new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
|
||||
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f) };
|
||||
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f)};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,19 +97,15 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
player.openGui(ForestryAPI.instance, GuiId.HygroregulatorGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
private HygroregulatorRecipe getRecipe(FluidStack liquid) {
|
||||
HygroregulatorRecipe recipe = null;
|
||||
for (HygroregulatorRecipe rec : recipes)
|
||||
for (HygroregulatorRecipe rec : recipes) {
|
||||
if (rec.liquid.isFluidEqual(liquid)) {
|
||||
recipe = rec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@@ -124,23 +131,20 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
component.addHumidityChange(currentRecipe.humidChange, 0.0f, 1.0f);
|
||||
component.addTemperatureChange(currentRecipe.tempChange, 0.0f, 2.0f);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
transferTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IInventoryAdapter canInventory = getInternalInventory();
|
||||
|
||||
// Check if we have suitable items waiting in the item slot
|
||||
if (canInventory.getStackInSlot(0) != null) {
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(canInventory.getStackInSlot(0));
|
||||
if (container != null &&
|
||||
(container.fluid.getFluid() == FluidRegistry.WATER || container.fluid.getFluid() == FluidRegistry.LAVA)) {
|
||||
|
||||
canInventory.setInventorySlotContents(0, StackUtils.replenishByContainer(this, canInventory.getStackInSlot(0), container, liquidTank));
|
||||
if (canInventory.getStackInSlot(0).stackSize <= 0)
|
||||
canInventory.setInventorySlotContents(0, null);
|
||||
}
|
||||
FluidHelper.drainContainers(tankManager, canInventory, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -154,9 +158,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
canInventory.readFromNBT(nbttagcompound);
|
||||
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
|
||||
transferTime = nbttagcompound.getInteger("TransferTime");
|
||||
@@ -170,9 +171,6 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
canInventory.writeToNBT(nbttagcompound);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setInteger("TransferTime", transferTime);
|
||||
@@ -187,102 +185,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
/* TEXTURES */
|
||||
@Override
|
||||
public int getIcon(int side, int metadata) {
|
||||
return BlockAlveary.TX_73_VLVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventory() {
|
||||
return canInventory;
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
if (canInventory != null)
|
||||
return canInventory.getSizeInventory();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIndex) {
|
||||
if (canInventory != null)
|
||||
return canInventory.getStackInSlot(slotIndex);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotIndex, int amount) {
|
||||
if (canInventory != null)
|
||||
return canInventory.decrStackSize(slotIndex, amount);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex) {
|
||||
if (canInventory != null)
|
||||
return canInventory.getStackInSlotOnClosing(slotIndex);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
|
||||
// Client side handling for container synch
|
||||
if (canInventory == null && !Proxies.common.isSimulating(worldObj))
|
||||
createInventory();
|
||||
|
||||
if (canInventory != null)
|
||||
canInventory.setInventorySlotContents(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
if (canInventory != null)
|
||||
return canInventory.getInventoryStackLimit();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
if (slotIndex == 0) {
|
||||
FluidStack fluid = LiquidHelper.getFluidStackInContainer(itemstack);
|
||||
if (fluid == null || fluid.amount <= 0)
|
||||
return false;
|
||||
return liquidTank.accepts(fluid.getFluid());
|
||||
}
|
||||
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
return BlockAlveary.ALVEARY_HYGRO;
|
||||
}
|
||||
|
||||
/* ILIQUIDTANKCONTAINER */
|
||||
@@ -296,6 +199,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
@@ -321,8 +225,10 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGUINetworkData(int messageId, int data) {}
|
||||
public void getGUINetworkData(int messageId, int data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {}
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -13,8 +13,6 @@ package forestry.apiculture.gadgets;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -23,31 +21,39 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.*;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.core.ITileStructure;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.gui.ContainerAlveary;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketIds;
|
||||
import forestry.core.network.PacketInventoryStack;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.TileInventoryAdapter;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, ISpecialInventory, IBeeHousing, IClimatised, IHintSource {
|
||||
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IBeeHousing, IClimatised, IHintSource {
|
||||
|
||||
// / CONSTANTS
|
||||
public static final int SLOT_QUEEN = 0;
|
||||
@@ -58,9 +64,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
// / MEMBERS
|
||||
protected IBeekeepingLogic beekeepingLogic;
|
||||
protected int biomeId;
|
||||
protected float temperature;
|
||||
protected float humidity;
|
||||
protected BiomeGenBase biome;
|
||||
protected float tempChange = 0.0f;
|
||||
protected float humidChange = 0.0f;
|
||||
private int displayHealthMax = 0;
|
||||
@@ -72,10 +76,22 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player) {
|
||||
if (isMaster())
|
||||
if (isMaster()) {
|
||||
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
|
||||
else if (this.hasMaster())
|
||||
} else if (this.hasMaster()) {
|
||||
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, masterX, masterY, masterZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
setBiomeInformation();
|
||||
}
|
||||
|
||||
private void setBiomeInformation() {
|
||||
this.biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@@ -86,10 +102,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
this.tempChange = nbttagcompound.getFloat("TempChange");
|
||||
this.humidChange = nbttagcompound.getFloat("HumidChange");
|
||||
|
||||
if (inventory != null)
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
if (beekeepingLogic != null)
|
||||
if (beekeepingLogic != null) {
|
||||
beekeepingLogic.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,10 +115,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
nbttagcompound.setFloat("TempChange", tempChange);
|
||||
nbttagcompound.setFloat("HumidChange", humidChange);
|
||||
|
||||
if (inventory != null)
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
if (beekeepingLogic != null)
|
||||
if (beekeepingLogic != null) {
|
||||
beekeepingLogic.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -111,20 +125,18 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
BiomeGenBase biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
|
||||
this.biomeId = biome.biomeID;
|
||||
this.temperature = biome.temperature;
|
||||
this.humidity = biome.rainfall;
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
setBiomeInformation();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
|
||||
if (beekeepingLogic == null)
|
||||
if (beekeepingLogic == null) {
|
||||
return;
|
||||
if (!isMaster())
|
||||
}
|
||||
if (!isMaster()) {
|
||||
return;
|
||||
}
|
||||
|
||||
beekeepingLogic.update();
|
||||
|
||||
@@ -133,16 +145,23 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
equalizeHumidity();
|
||||
|
||||
IBee queen = beekeepingLogic.getQueen();
|
||||
if (queen == null)
|
||||
if (queen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add swarm effects
|
||||
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
|
||||
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
if (getErrorState() == EnumErrorCode.OK)
|
||||
queen.doFX(beekeepingLogic.getEffectData(), this);
|
||||
if (updateOnInterval(200)) {
|
||||
ISidedInventory inventory = getStructureInventory();
|
||||
if (inventory != null) {
|
||||
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
}
|
||||
}
|
||||
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) {
|
||||
if (getErrorState() == EnumErrorCode.OK) {
|
||||
queen.doFX(beekeepingLogic.getEffectData(), this);
|
||||
}
|
||||
|
||||
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(50)) {
|
||||
float f = xCoord + 0.5F;
|
||||
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
|
||||
float f2 = zCoord + 0.5F;
|
||||
@@ -160,91 +179,113 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
@Override
|
||||
protected void updateClientSide() {
|
||||
|
||||
if (!isMaster())
|
||||
if (!isMaster()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (inventory == null)
|
||||
ISidedInventory inventory = getStructureInventory();
|
||||
if (inventory == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// / Multiplayer FX
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN);
|
||||
if (PluginApiculture.beeInterface.isMated(queenStack)) {
|
||||
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(queenStack);
|
||||
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void equalizeTemperature() {
|
||||
if (tempChange == 0)
|
||||
if (tempChange == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
tempChange -= 0.05f * tempChange;
|
||||
if (tempChange <= 0.001f && tempChange >= -0.001f)
|
||||
if (tempChange <= 0.001f && tempChange >= -0.001f) {
|
||||
tempChange = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void equalizeHumidity() {
|
||||
if (humidChange == 0)
|
||||
if (humidChange == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
humidChange -= 0.05f * humidChange;
|
||||
if (humidChange <= 0.001f && humidChange >= 0.001f)
|
||||
if (humidChange <= 0.001f && humidChange >= 0.001f) {
|
||||
humidChange = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* STATE INFORMATION */
|
||||
private int getHealthDisplay() {
|
||||
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
|
||||
IInventory inventory = getStructureInventory();
|
||||
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
|
||||
else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
} else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
return displayHealth;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private int getMaxHealthDisplay() {
|
||||
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
|
||||
IInventory inventory = getStructureInventory();
|
||||
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
|
||||
else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
} else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
return displayHealthMax;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getHealthScaled(int i) {
|
||||
if (getMaxHealthDisplay() == 0)
|
||||
if (getMaxHealthDisplay() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (getHealthDisplay() * i) / getMaxHealthDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsInteraction(EntityPlayer player) {
|
||||
if (!super.allowsInteraction(player))
|
||||
return false;
|
||||
|
||||
return this.isIntegratedIntoStructure();
|
||||
}
|
||||
|
||||
/* STRUCTURE MANAGMENT */
|
||||
@Override
|
||||
protected void createInventory() {
|
||||
this.inventory = new TileInventoryAdapter(this, 9, "Items");
|
||||
setInternalInventory(new TileInventoryAdapter(this, 9, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_QUEEN) {
|
||||
return PluginApiculture.beeInterface.isMember(itemStack) && !PluginApiculture.beeInterface.isDrone(itemStack);
|
||||
} else if (slotIndex == SLOT_DRONE) {
|
||||
return PluginApiculture.beeInterface.isDrone(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeMaster() {
|
||||
super.makeMaster();
|
||||
if (beekeepingLogic == null)
|
||||
if (beekeepingLogic == null) {
|
||||
this.beekeepingLogic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -280,11 +321,13 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
|
||||
float temperature = biome.temperature;
|
||||
tempChange = Math.min(boundaryUp - temperature, Math.max(boundaryDown - temperature, tempChange + change));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
|
||||
float humidity = biome.rainfall;
|
||||
humidChange = Math.min(boundaryUp - humidity, Math.max(boundaryDown - humidity, humidChange + change));
|
||||
}
|
||||
|
||||
@@ -326,13 +369,19 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public int getBiomeId() {
|
||||
return this.biomeId;
|
||||
return biome.biomeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
if (EnumTemperature.isBiomeHellish(biomeId) && tempChange >= 0)
|
||||
if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0) {
|
||||
return EnumTemperature.HELLISH;
|
||||
}
|
||||
|
||||
return EnumTemperature.getFromValue(getExactTemperature());
|
||||
}
|
||||
@@ -408,7 +457,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public int getErrorOrdinal() {
|
||||
return getErrorState().ordinal();
|
||||
return getErrorState().getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -418,10 +467,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
if (inventory == null)
|
||||
IInventoryAdapter inventory = getStructureInventory();
|
||||
if (inventory == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return inventory.tryAddStack(product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all);
|
||||
return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -433,8 +484,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public void onQueenChange(ItemStack queenStack) {
|
||||
if (!Proxies.common.isSimulating(worldObj))
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
|
||||
zCoord);
|
||||
@@ -462,8 +514,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
|
||||
|
||||
for (IBeeListener eventHandler : eventHandlers) {
|
||||
if (eventHandler.onPollenRetrieved(queen, pollen, isHandled))
|
||||
if (eventHandler.onPollenRetrieved(queen, pollen, isHandled)) {
|
||||
isHandled = true;
|
||||
}
|
||||
}
|
||||
|
||||
return isHandled;
|
||||
@@ -472,8 +525,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
@Override
|
||||
public boolean onEggLaid(IBee queen) {
|
||||
for (IBeeListener eventHandler : eventHandlers) {
|
||||
if (eventHandler.onEggLaid(queen))
|
||||
if (eventHandler.onEggLaid(queen)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -482,8 +536,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
@Override
|
||||
public boolean isSealed() {
|
||||
for (IBeeModifier modifier : modifiers) {
|
||||
if (modifier.isSealed())
|
||||
if (modifier.isSealed()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -491,8 +546,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
@Override
|
||||
public boolean isSelfLighted() {
|
||||
for (IBeeModifier modifier : modifiers) {
|
||||
if (modifier.isSelfLighted())
|
||||
if (modifier.isSelfLighted()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -500,8 +556,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
@Override
|
||||
public boolean isSunlightSimulated() {
|
||||
for (IBeeModifier modifier : modifiers) {
|
||||
if (modifier.isSunlightSimulated())
|
||||
if (modifier.isSunlightSimulated()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -509,296 +566,71 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
@Override
|
||||
public boolean isHellish() {
|
||||
for (IBeeModifier modifier : modifiers) {
|
||||
if (modifier.isHellish())
|
||||
if (modifier.isHellish()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@Override
|
||||
public InventoryAdapter getInternalInventory() {
|
||||
return (InventoryAdapter) getStructureInventory();
|
||||
}
|
||||
|
||||
private IInventory getStructureInventory() {
|
||||
|
||||
if (inventory != null) {
|
||||
if (isMaster() || !Proxies.common.isSimulating(worldObj))
|
||||
return inventory;
|
||||
public IInventoryAdapter getInternalInventory() {
|
||||
IInventoryAdapter inventory = super.getInternalInventory();
|
||||
if (isMaster()) {
|
||||
return inventory;
|
||||
} else if (hasMaster()) {
|
||||
ITileStructure central = getCentralTE();
|
||||
if (central != null)
|
||||
return central.getInventory();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
IInventory inv = getStructureInventory();
|
||||
if (inv != null)
|
||||
return inv.getSizeInventory();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIndex) {
|
||||
IInventory inv = getStructureInventory();
|
||||
if (inv != null)
|
||||
return inv.getStackInSlot(slotIndex);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotIndex, int amount) {
|
||||
IInventory inv = getStructureInventory();
|
||||
if (inv != null)
|
||||
return inv.decrStackSize(slotIndex, amount);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex) {
|
||||
IInventory inv = getStructureInventory();
|
||||
if (inv != null)
|
||||
return inv.getStackInSlotOnClosing(slotIndex);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
|
||||
// Client side handling for container synch
|
||||
if (inventory == null && !Proxies.common.isSimulating(worldObj))
|
||||
createInventory();
|
||||
|
||||
IInventory inv = getStructureInventory();
|
||||
if (inv != null)
|
||||
inv.setInventorySlotContents(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
IInventory inv = getStructureInventory();
|
||||
if (inv != null)
|
||||
return inv.getInventoryStackLimit();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
|
||||
if (!super.canTakeStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
if (slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
|
||||
if (!super.canPutStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack)
|
||||
&& !PluginApiculture.beeInterface.isDrone(itemstack))
|
||||
return true;
|
||||
if (slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canInsertItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canExtractItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return super.getAccessibleSlotsFromSide(side);
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
@Override
|
||||
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
|
||||
|
||||
IInventory inv = getStructureInventory();
|
||||
if (inv == null)
|
||||
return 0;
|
||||
|
||||
// Princesses && Queens
|
||||
if (ForestryItem.beePrincessGE.isItemEqual(stack) || ForestryItem.beeQueenGE.isItemEqual(stack))
|
||||
if (inv.getStackInSlot(SLOT_QUEEN) == null) {
|
||||
if (doAdd) {
|
||||
inv.setInventorySlotContents(SLOT_QUEEN, stack.copy());
|
||||
inv.getStackInSlot(SLOT_QUEEN).stackSize = 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Drones
|
||||
if (ForestryItem.beeDroneGE.isItemEqual(stack)) {
|
||||
|
||||
ItemStack droneStack = inv.getStackInSlot(SLOT_DRONE);
|
||||
if (droneStack == null) {
|
||||
if (doAdd)
|
||||
inv.setInventorySlotContents(SLOT_DRONE, stack.copy());
|
||||
return stack.stackSize;
|
||||
} else {
|
||||
if (!droneStack.isItemEqual(stack))
|
||||
return 0;
|
||||
if (!ItemStack.areItemStackTagsEqual(droneStack, stack))
|
||||
return 0;
|
||||
int space = droneStack.getMaxStackSize() - droneStack.stackSize;
|
||||
if (space <= 0)
|
||||
return 0;
|
||||
|
||||
int added = space > stack.stackSize ? stack.stackSize : space;
|
||||
if (doAdd)
|
||||
droneStack.stackSize += added;
|
||||
return added;
|
||||
if (central instanceof TileAlveary) {
|
||||
return ((TileAlveary) central).getInternalInventory();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
|
||||
IInventory inv = getStructureInventory();
|
||||
if (inv == null)
|
||||
return new ItemStack[0];
|
||||
|
||||
ItemStack product = null;
|
||||
|
||||
for (int i = SLOT_PRODUCT_1; i < inv.getSizeInventory(); i++) {
|
||||
if (inv.getStackInSlot(i) == null)
|
||||
continue;
|
||||
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
|
||||
if (doRemove)
|
||||
product = inv.decrStackSize(i, 1);
|
||||
else {
|
||||
product = stack.copy();
|
||||
product.stackSize = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return new ItemStack[] { product };
|
||||
return inventory;
|
||||
}
|
||||
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
displayHealth = j;
|
||||
break;
|
||||
case 1:
|
||||
displayHealthMax = j;
|
||||
break;
|
||||
case 2:
|
||||
this.temperature = (float) j / 100;
|
||||
break;
|
||||
case 3:
|
||||
this.humidity = (float) j / 100;
|
||||
break;
|
||||
case 4:
|
||||
this.tempChange = (float) j / 100;
|
||||
break;
|
||||
case 5:
|
||||
this.humidChange = (float) j / 100;
|
||||
break;
|
||||
case 6:
|
||||
this.biomeId = j;
|
||||
break;
|
||||
case 0:
|
||||
displayHealth = j;
|
||||
break;
|
||||
case 1:
|
||||
displayHealthMax = j;
|
||||
break;
|
||||
case 4:
|
||||
this.tempChange = (float) j / 100;
|
||||
break;
|
||||
case 5:
|
||||
this.humidChange = (float) j / 100;
|
||||
break;
|
||||
case 6: {
|
||||
this.biome = BiomeGenBase.getBiome(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(ContainerAlveary container, ICrafting iCrafting) {
|
||||
if (beekeepingLogic == null)
|
||||
if (beekeepingLogic == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
iCrafting.sendProgressBarUpdate(container, 0, beekeepingLogic.getBreedingTime());
|
||||
iCrafting.sendProgressBarUpdate(container, 1, beekeepingLogic.getTotalBreedingTime());
|
||||
iCrafting.sendProgressBarUpdate(container, 2, Math.round(temperature * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 3, Math.round(humidity * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 4, Math.round(tempChange * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 5, Math.round(humidChange * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 6, biomeId);
|
||||
iCrafting.sendProgressBarUpdate(container, 6, biome.biomeID);
|
||||
}
|
||||
|
||||
/* IERRORSOURCE */
|
||||
@Override
|
||||
public EnumErrorCode getErrorState() {
|
||||
public IErrorState getErrorState() {
|
||||
if (hasMaster()) {
|
||||
ITileStructure tile = this.getCentralTE();
|
||||
if (tile != null)
|
||||
if (tile != null) {
|
||||
return ((IErrorSource) tile).getErrorState();
|
||||
}
|
||||
}
|
||||
|
||||
return errorState;
|
||||
@@ -812,12 +644,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return this.temperature + this.tempChange;
|
||||
return biome.temperature + this.tempChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return this.humidity + this.humidChange;
|
||||
return biome.rainfall + this.humidChange;
|
||||
}
|
||||
|
||||
/* IHINTSOURCE */
|
||||
@@ -836,7 +668,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
public boolean isOwnable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* IHousing */
|
||||
@Override
|
||||
public GameProfile getOwnerName() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -12,7 +12,6 @@ package forestry.apiculture.gadgets;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBee;
|
||||
@@ -21,9 +20,13 @@ import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.interfaces.ICrafter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
|
||||
public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener {
|
||||
|
||||
@@ -33,11 +36,15 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
public static final int SLOT_POLLEN_1 = 0;
|
||||
public static final int SLOTS_POLLEN_COUNT = 4;
|
||||
public static final int SLOT_SIEVE = 4;
|
||||
|
||||
InventoryAdapter inventory = new InventoryAdapter(5, "Items", 1);
|
||||
|
||||
public TileAlvearySieve() {
|
||||
super(BLOCK_META);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 5, "Items", 1) {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return StackUtils.isIdenticalItem(ForestryItem.craftingMaterial.getItemStack(1, 3), itemStack);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +52,6 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
player.openGui(ForestryAPI.instance, GuiId.AlvearySieveGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasFunction() {
|
||||
return true;
|
||||
@@ -56,80 +62,72 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if(!hasMaster() || !isIntegratedIntoStructure())
|
||||
if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
|
||||
((IAlvearyComponent) getCentralTE()).registerBeeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
if(worldObj.getTotalWorldTime() % 200 != 0)
|
||||
if (!updateOnInterval(200)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!hasMaster() || !isIntegratedIntoStructure())
|
||||
if (!hasMaster() || !isIntegratedIntoStructure()) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
((IAlvearyComponent) getCentralTE()).registerBeeListener(this);
|
||||
}
|
||||
|
||||
/* TEXTURES & INTERNAL */
|
||||
@Override
|
||||
public int getIcon(int side, int metadata) {
|
||||
if(side == 0 || side == 1)
|
||||
if (side == 0 || side == 1) {
|
||||
return BlockAlveary.BOTTOM;
|
||||
}
|
||||
return BlockAlveary.SIEVE;
|
||||
}
|
||||
|
||||
private void destroySieve() {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
inventory.setInventorySlotContents(SLOT_SIEVE, null);
|
||||
}
|
||||
|
||||
private void destroyPollen() {
|
||||
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
|
||||
inventory.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canStorePollen() {
|
||||
if(inventory.getStackInSlot(SLOT_SIEVE) == null)
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if (inventory.getStackInSlot(SLOT_SIEVE) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
|
||||
if(inventory.getStackInSlot(i) == null)
|
||||
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void storePollenStack(ItemStack itemstack) {
|
||||
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
|
||||
if(inventory.getStackInSlot(i) == null) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
inventory.setInventorySlotContents(i, itemstack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* INVENTORY */
|
||||
public InventoryAdapter getInternalInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
/* ICRAFTER */
|
||||
@Override
|
||||
@@ -138,8 +136,9 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) {
|
||||
if(slotIndex == SLOT_SIEVE) {
|
||||
public ItemStack takenFromSlot(int slotIndex, EntityPlayer player) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if (slotIndex == SLOT_SIEVE) {
|
||||
destroyPollen();
|
||||
return inventory.getStackInSlot(SLOT_SIEVE);
|
||||
} else {
|
||||
@@ -154,18 +153,31 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
}
|
||||
|
||||
/* IBEELISTENER */
|
||||
@Override public void onQueenChange(ItemStack queen) {}
|
||||
@Override public void wearOutEquipment(int amount) {}
|
||||
@Override public void onQueenDeath(IBee queen) {}
|
||||
@Override public void onPostQueenDeath(IBee queen) {}
|
||||
@Override
|
||||
public void onQueenChange(ItemStack queen) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueenDeath(IBee queen) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostQueenDeath(IBee queen) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
|
||||
|
||||
if(isHandled)
|
||||
return isHandled;
|
||||
if(!canStorePollen())
|
||||
if (isHandled) {
|
||||
return true;
|
||||
}
|
||||
if (!canStorePollen()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
storePollenStack(AlleleManager.alleleRegistry.getSpeciesRoot(pollen.getClass()).getMemberStack(pollen, EnumGermlingType.POLLEN.ordinal()));
|
||||
return true;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -13,6 +13,7 @@ package forestry.apiculture.gadgets;
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
|
||||
|
||||
@@ -27,23 +28,26 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if(!hasMaster() || !isIntegratedIntoStructure())
|
||||
if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
|
||||
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
if(worldObj.getTotalWorldTime() % 200 != 0)
|
||||
if (!updateOnInterval(200)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!hasMaster() || !isIntegratedIntoStructure())
|
||||
if (!hasMaster() || !isIntegratedIntoStructure()) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
|
||||
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +57,11 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
|
||||
}
|
||||
|
||||
/* TEXTURES */
|
||||
@Override
|
||||
public int getIcon(int side, int metadata) {
|
||||
if(side == 0 || side == 1)
|
||||
if (side == 0 || side == 1) {
|
||||
return BlockAlveary.BOTTOM;
|
||||
}
|
||||
|
||||
return BlockAlveary.STABILISER;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -14,44 +14,44 @@ import java.util.Map.Entry;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
import forestry.apiculture.worldgen.WorldGenHive;
|
||||
import forestry.apiculture.worldgen.WorldGenHiveSwamer;
|
||||
import forestry.apiculture.worldgen.Hive;
|
||||
import forestry.apiculture.worldgen.HiveDecorator;
|
||||
import forestry.apiculture.worldgen.HiveDescriptionSwarmer;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.inventory.wrappers.IInvSlot;
|
||||
import forestry.core.inventory.wrappers.InventoryIterator;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.TileInventoryAdapter;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory {
|
||||
public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
|
||||
|
||||
/* CONSTANTS */
|
||||
public static final int BLOCK_META = 2;
|
||||
|
||||
TileInventoryAdapter swarmerInventory;
|
||||
private final Stack<ItemStack> pendingSpawns = new Stack<ItemStack>();
|
||||
private boolean isActive;
|
||||
|
||||
public TileAlvearySwarmer() {
|
||||
super(BLOCK_META);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
if (swarmerInventory == null)
|
||||
createInventory();
|
||||
setInternalInventory(new TileInventoryAdapter(this, 4, "SwarmInv") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return StackUtils.containsItemStack(BeeManager.inducers.keySet(), itemStack);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,86 +64,113 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 100 != 0)
|
||||
if (pendingSpawns.size() > 0)
|
||||
if (pendingSpawns.size() > 0) {
|
||||
setIsActive(true);
|
||||
if (updateOnInterval(1000)) {
|
||||
trySpawnSwarm();
|
||||
}
|
||||
} else {
|
||||
setIsActive(false);
|
||||
}
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 500 != 0)
|
||||
if (!updateOnInterval(500)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.hasMaster())
|
||||
ItemStack princessStack = getPrincessStack();
|
||||
if (princessStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
|
||||
if (!(master instanceof IBeeHousing))
|
||||
int chance = consumeInducerAndGetChance();
|
||||
if (chance == 0) {
|
||||
return;
|
||||
|
||||
IBeeHousing housing = (IBeeHousing) master;
|
||||
ItemStack queenstack = housing.getQueen();
|
||||
if (queenstack == null)
|
||||
return;
|
||||
if (!PluginApiculture.beeInterface.isMated(queenstack))
|
||||
return;
|
||||
|
||||
// Calculate chance
|
||||
int slot = getInducerSlot();
|
||||
if (slot < 0)
|
||||
return;
|
||||
int chance = getChanceFor(swarmerInventory.getStackInSlot(slot));
|
||||
|
||||
// Remove resource
|
||||
swarmerInventory.decrStackSize(slot, 1);
|
||||
}
|
||||
|
||||
// Try to spawn princess
|
||||
if (worldObj.rand.nextInt(1000) >= chance)
|
||||
if (worldObj.rand.nextInt(1000) >= chance) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Queue swarm spawn
|
||||
IBee spawn = PluginApiculture.beeInterface.getMember(queenstack);
|
||||
spawn.setIsNatural(false);
|
||||
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(spawn, EnumBeeType.PRINCESS.ordinal()));
|
||||
|
||||
IBee princess = PluginApiculture.beeInterface.getMember(princessStack);
|
||||
princess.setIsNatural(false);
|
||||
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(princess, EnumBeeType.PRINCESS.ordinal()));
|
||||
}
|
||||
|
||||
private int getChanceFor(ItemStack stack) {
|
||||
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(stack))
|
||||
return entry.getValue();
|
||||
private ItemStack getPrincessStack() {
|
||||
if (!this.hasMaster()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
|
||||
if (!(master instanceof IBeeHousing)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IBeeHousing housing = (IBeeHousing) master;
|
||||
ItemStack princessStack = housing.getQueen();
|
||||
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return princessStack;
|
||||
}
|
||||
|
||||
private int consumeInducerAndGetChance() {
|
||||
if (getInternalInventory() == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (IInvSlot slot : InventoryIterator.getIterable(getInternalInventory())) {
|
||||
ItemStack stack = slot.getStackInSlot();
|
||||
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
|
||||
if (StackUtils.isIdenticalItem(entry.getKey(), stack)) {
|
||||
slot.decreaseStackInSlot();
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getInducerSlot() {
|
||||
for (int i = 0; i < swarmerInventory.getSizeInventory(); i++) {
|
||||
if (swarmerInventory.getStackInSlot(i) == null)
|
||||
continue;
|
||||
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(swarmerInventory.getStackInSlot(i)))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void trySpawnSwarm() {
|
||||
|
||||
ItemStack toSpawn = pendingSpawns.peek();
|
||||
WorldGenHive generator = new WorldGenHiveSwamer(new ItemStack[] { toSpawn });
|
||||
HiveDescriptionSwarmer hiveDescription = new HiveDescriptionSwarmer(toSpawn);
|
||||
Hive hive = new Hive(hiveDescription);
|
||||
|
||||
int i = 0;
|
||||
while (i < 10) {
|
||||
i++;
|
||||
int spawnX = xCoord + worldObj.rand.nextInt(40 * 2) - 40;
|
||||
int spawnY = yCoord + worldObj.rand.nextInt(40);
|
||||
int spawnZ = zCoord + worldObj.rand.nextInt(40 * 2) - 40;
|
||||
if (generator.generate(worldObj, worldObj.rand, spawnX, spawnY, spawnZ)) {
|
||||
pendingSpawns.pop();
|
||||
break;
|
||||
}
|
||||
int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
|
||||
int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
|
||||
|
||||
if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive)) {
|
||||
pendingSpawns.pop();
|
||||
}
|
||||
}
|
||||
|
||||
private void setIsActive(boolean isActive) {
|
||||
if (this.isActive != isActive) {
|
||||
this.isActive = isActive;
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void fromPacketPayload(PacketPayload payload) {
|
||||
boolean act = payload.shortPayload[0] > 0;
|
||||
if (this.isActive != act) {
|
||||
this.isActive = act;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPayload getPacketPayload() {
|
||||
PacketPayload payload = new PacketPayload(0, 1);
|
||||
payload.shortPayload[0] = (short) (isActive ? 1 : 0);
|
||||
return payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,22 +181,21 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
|
||||
/* TEXTURES */
|
||||
@Override
|
||||
public int getIcon(int side, int metadata) {
|
||||
if(side == 0 || side == 1)
|
||||
if (side == 0 || side == 1) {
|
||||
return BlockAlveary.BOTTOM;
|
||||
}
|
||||
|
||||
if (pendingSpawns.size() > 0)
|
||||
return BlockAlveary.TX_56_SWON;
|
||||
else
|
||||
return BlockAlveary.TX_55_SWOF;
|
||||
if (isActive) {
|
||||
return BlockAlveary.ALVEARY_SWARMER_ON;
|
||||
} else {
|
||||
return BlockAlveary.ALVEARY_SWARMER_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
if (swarmerInventory == null)
|
||||
createInventory();
|
||||
swarmerInventory.readFromNBT(nbttagcompound);
|
||||
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("PendingSpawns", 10);
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
@@ -182,126 +208,18 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
if (swarmerInventory != null)
|
||||
swarmerInventory.writeToNBT(nbttagcompound);
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
ItemStack[] offspring = pendingSpawns.toArray(new ItemStack[pendingSpawns.size()]);
|
||||
for (int i = 0; i < offspring.length; i++)
|
||||
for (int i = 0; i < offspring.length; i++) {
|
||||
if (offspring[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
offspring[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
nbttagcompound.setTag("PendingSpawns", nbttaglist);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createInventory() {
|
||||
swarmerInventory = new TileInventoryAdapter(this, 4, "SwarmInv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventory() {
|
||||
return swarmerInventory;
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
@Override
|
||||
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
|
||||
if (swarmerInventory != null)
|
||||
return swarmerInventory.addStack(stack, false, doAdd);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
if (swarmerInventory != null)
|
||||
return swarmerInventory.getSizeInventory();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIndex) {
|
||||
if (swarmerInventory != null)
|
||||
return swarmerInventory.getStackInSlot(slotIndex);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotIndex, int amount) {
|
||||
if (swarmerInventory != null)
|
||||
return swarmerInventory.decrStackSize(slotIndex, amount);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotIndex) {
|
||||
if (swarmerInventory != null)
|
||||
return swarmerInventory.getStackInSlotOnClosing(slotIndex);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
|
||||
// Client side handling for container synch
|
||||
if (swarmerInventory == null && !Proxies.common.isSimulating(worldObj))
|
||||
createInventory();
|
||||
|
||||
if (swarmerInventory != null)
|
||||
swarmerInventory.setInventorySlotContents(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
if (swarmerInventory != null)
|
||||
return swarmerInventory.getInventoryStackLimit();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public void openInventory() {}
|
||||
@Override public void closeInventory() {}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
|
||||
@@ -4,31 +4,37 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.apiculture.trigger.ApicultureTriggers;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.triggers.ForestryTrigger;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
public class TileApiary extends TileBeehouse {
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getUnlocalizedName();
|
||||
public TileApiary() {
|
||||
setInternalInventory(new BeehouseInventoryAdapter(this, 12, "Items"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,85 +45,106 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
/* IBEEHOUSING */
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1.0f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
continue;
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
|
||||
}
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
|
||||
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getTerritoryModifier(genome, mod);
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 0.1f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
continue;
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
|
||||
}
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
|
||||
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getProductionModifier(genome, mod);
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1.0f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
continue;
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
|
||||
}
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
|
||||
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getMutationModifier(genome, mate, mod);
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1.0f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
continue;
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
|
||||
}
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
|
||||
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getLifespanModifier(genome, mate, mod);
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
continue;
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
|
||||
}
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
|
||||
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getFloweringModifier(genome, mod);
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
float mod = 1f;
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
continue;
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
|
||||
}
|
||||
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
|
||||
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getGeneticDecay(genome, mod);
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier());
|
||||
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
continue;
|
||||
if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame))
|
||||
}
|
||||
if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
inventory.setInventorySlotContents(
|
||||
i,
|
||||
@@ -126,128 +153,6 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
}
|
||||
}
|
||||
|
||||
/* IINVENTORY */
|
||||
@Override
|
||||
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (!super.canTakeStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
switch (slotIndex) {
|
||||
case SLOT_QUEEN:
|
||||
case SLOT_DRONE:
|
||||
case SLOT_FRAMES_1:
|
||||
case SLOT_FRAMES_2:
|
||||
case SLOT_FRAMES_3:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (!super.canPutStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
if (slotIndex == SLOT_QUEEN && PluginApiculture.beeInterface.isMember(itemstack)
|
||||
&& !PluginApiculture.beeInterface.isDrone(itemstack))
|
||||
return true;
|
||||
|
||||
if (slotIndex == SLOT_DRONE && PluginApiculture.beeInterface.isDrone(itemstack))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return super.getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
super.setSlotContents(i, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
return inventory.decrStackSize(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return inventory.getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return super.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return super.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canInsertItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canExtractItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
*/
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return super.getAccessibleSlotsFromSide(side);
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
// @Override
|
||||
// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
@@ -342,12 +247,13 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
// }
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public LinkedList<ITriggerExternal> getCustomTriggers() {
|
||||
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
|
||||
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
|
||||
res.add(ForestryTrigger.missingQueen);
|
||||
res.add(ForestryTrigger.missingDrone);
|
||||
res.add(PluginApiculture.triggerNoFrames);
|
||||
res.add(ApicultureTriggers.missingQueen);
|
||||
res.add(ApicultureTriggers.missingDrone);
|
||||
res.add(ApicultureTriggers.noFrames);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,12 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -19,10 +17,14 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
@@ -31,41 +33,63 @@ import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketIds;
|
||||
import forestry.core.network.PacketInventoryStack;
|
||||
import forestry.core.network.PacketTileUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.GuiUtil;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
protected static class BeehouseInventoryAdapter extends TileInventoryAdapter {
|
||||
public BeehouseInventoryAdapter(TileForestry tile, int size, String name) {
|
||||
super(tile, size, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_QUEEN) {
|
||||
return PluginApiculture.beeInterface.isMember(itemStack) && !PluginApiculture.beeInterface.isDrone(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) {
|
||||
return itemStack.getItem() instanceof IHiveFrame;
|
||||
} else if (slotIndex == SLOT_DRONE) {
|
||||
return PluginApiculture.beeInterface.isDrone(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
// CONSTANTS
|
||||
public static final int SLOT_QUEEN = 0;
|
||||
public static final int SLOT_DRONE = 1;
|
||||
public static final int SLOT_INVENTORY_1 = 2;
|
||||
protected static int SLOT_PRODUCT_1 = 2;
|
||||
protected static int SLOT_PRODUCT_COUNT = 7;
|
||||
public static final int SLOT_PRODUCT_1 = 2;
|
||||
public static final int SLOT_PRODUCT_COUNT = 7;
|
||||
public static final int SLOT_FRAMES_1 = 9;
|
||||
public static final int SLOT_FRAMES_2 = 10;
|
||||
public static final int SLOT_FRAMES_3 = 11;
|
||||
public static final int SLOT_INVENTORY_COUNT = 7;
|
||||
public static final int SLOT_FRAMES_COUNT = 3;
|
||||
// Inventory
|
||||
protected InventoryAdapter inventory = new InventoryAdapter(12, "Items");
|
||||
private final IBeekeepingLogic logic;
|
||||
private int biomeId = -1;
|
||||
private float temperature;
|
||||
private float humidity;
|
||||
private BiomeGenBase biome;
|
||||
private int displayHealthMax = 0;
|
||||
private int displayHealth = 0;
|
||||
|
||||
public TileBeehouse() {
|
||||
setHints(Config.hints.get("apiary"));
|
||||
logic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
|
||||
setInternalInventory(new BeehouseInventoryAdapter(this, 12, "Items").disableAutomation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,24 +102,18 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setFloat("Temp", temperature);
|
||||
nbttagcompound.setFloat("Humidity", humidity);
|
||||
nbttagcompound.setInteger("BiomeId", biomeId);
|
||||
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
if (logic != null)
|
||||
nbttagcompound.setInteger("BiomeId", biome.biomeID);
|
||||
if (logic != null) {
|
||||
logic.writeToNBT(nbttagcompound);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
temperature = nbttagcompound.getFloat("Temp");
|
||||
humidity = nbttagcompound.getFloat("Humidity");
|
||||
biomeId = nbttagcompound.getInteger("BiomeId");
|
||||
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
int biomeId = nbttagcompound.getInteger("BiomeId");
|
||||
biome = BiomeGenBase.getBiome(biomeId);
|
||||
logic.readFromNBT(nbttagcompound);
|
||||
|
||||
}
|
||||
@@ -119,24 +137,22 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
if (EnumTemperature.isBiomeHellish(biomeId))
|
||||
return EnumTemperature.HELLISH;
|
||||
return EnumTemperature.getFromValue(temperature);
|
||||
return EnumTemperature.getFromBiome(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(humidity);
|
||||
return EnumHumidity.getFromValue(getExactHumidity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return this.temperature;
|
||||
return biome.temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return this.humidity;
|
||||
return biome.rainfall;
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@@ -144,12 +160,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public void updateClientSide() {
|
||||
|
||||
// / Multiplayer FX
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) {
|
||||
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN));
|
||||
displayQueen.doFX(logic.getEffectData(), this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -159,29 +175,14 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
logic.update();
|
||||
|
||||
IBee queen = logic.getQueen();
|
||||
if (queen == null)
|
||||
if (queen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add swarm effects
|
||||
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
|
||||
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
/* These should get already done on the client / doesn't work server-side anyway
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0)
|
||||
queen.doFX(logic.getEffectData(), this);
|
||||
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) {
|
||||
float f = xCoord + 0.5F;
|
||||
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
|
||||
float f2 = zCoord + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F;
|
||||
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f - f3), f1, (f2 + f4), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f3), f1, (f2 + f4), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 - f3), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 + f3), 0F, 0F, 0F);
|
||||
}*/
|
||||
|
||||
if (updateOnInterval(200)) {
|
||||
onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN));
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
@@ -191,14 +192,15 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
return inventory.tryAddStack(product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true);
|
||||
return InvTools.tryAddStack(getInternalInventory(), product, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, all, true);
|
||||
}
|
||||
|
||||
/* NETWORK SYNCH */
|
||||
@Override
|
||||
public void onQueenChange(ItemStack queenStack) {
|
||||
if (!Proxies.common.isSimulating(worldObj))
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
|
||||
zCoord);
|
||||
@@ -207,57 +209,59 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
/* STATE INFORMATION */
|
||||
private int getHealthDisplay() {
|
||||
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if (inventory.getStackInSlot(SLOT_QUEEN) == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
|
||||
else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
} else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
return displayHealth;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private int getMaxHealthDisplay() {
|
||||
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if (inventory.getStackInSlot(SLOT_QUEEN) == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
|
||||
else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
} else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
return displayHealthMax;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns scaled queen health or breeding progress
|
||||
*
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
public int getHealthScaled(int i) {
|
||||
if (getMaxHealthDisplay() == 0)
|
||||
if (getMaxHealthDisplay() == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (getHealthDisplay() * i) / getMaxHealthDisplay();
|
||||
}
|
||||
|
||||
public int getTemperatureScaled(int i) {
|
||||
return Math.round(i * (temperature / 2));
|
||||
return Math.round(i * (getExactTemperature() / 2));
|
||||
}
|
||||
|
||||
public int getHumidityScaled(int i) {
|
||||
return Math.round(i * humidity);
|
||||
return Math.round(i * getExactHumidity());
|
||||
}
|
||||
|
||||
public void updateBiome() {
|
||||
if (worldObj != null) {
|
||||
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
if (biome != null) {
|
||||
this.biomeId = biome.biomeID;
|
||||
this.temperature = biome.temperature;
|
||||
this.humidity = biome.rainfall;
|
||||
this.biome = biome;
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
}
|
||||
@@ -266,42 +270,30 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
/* SMP */
|
||||
// @Override
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
if (logic == null)
|
||||
if (logic == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
displayHealth = j;
|
||||
break;
|
||||
case 1:
|
||||
displayHealthMax = j;
|
||||
break;
|
||||
case 0:
|
||||
displayHealth = j;
|
||||
break;
|
||||
case 1:
|
||||
displayHealthMax = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
if (logic == null)
|
||||
if (logic == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime());
|
||||
iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime());
|
||||
}
|
||||
|
||||
/* INVENTORY MANAGMENT */
|
||||
@Override
|
||||
public InventoryAdapter getInternalInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return inventory.getStackInSlot(i);
|
||||
}
|
||||
|
||||
public void setSlotContents(int i, ItemStack itemstack) {
|
||||
inventory.setInventorySlotContents(i, itemstack);
|
||||
}
|
||||
|
||||
// / IBEEHOUSING
|
||||
@Override
|
||||
public int getXCoord() {
|
||||
@@ -320,7 +312,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@Override
|
||||
public int getBiomeId() {
|
||||
return this.biomeId;
|
||||
return biome.biomeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -335,12 +332,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@Override
|
||||
public void setQueen(ItemStack itemstack) {
|
||||
setSlotContents(SLOT_QUEEN, itemstack);
|
||||
setInventorySlotContents(SLOT_QUEEN, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrone(ItemStack itemstack) {
|
||||
setSlotContents(SLOT_DRONE, itemstack);
|
||||
setInventorySlotContents(SLOT_DRONE, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -355,7 +352,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@Override
|
||||
public int getErrorOrdinal() {
|
||||
return getErrorState().ordinal();
|
||||
return getErrorState().getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -434,7 +431,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public boolean onEggLaid(IBee queen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* IHousing */
|
||||
@Override
|
||||
public GameProfile getOwnerName() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
|
||||
Executable → Regular
+27
-8
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -13,29 +13,48 @@ package forestry.apiculture.gadgets;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
|
||||
public class TileSwarm extends TileEntity {
|
||||
|
||||
public InventoryAdapter contained = new InventoryAdapter(2, "Contained");
|
||||
public final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Hack to make sure that hives glow.
|
||||
// TODO: remove when Mojang fixes this bug: https://bugs.mojang.com/browse/MC-3329
|
||||
// Hives should not need to tick normally.
|
||||
private boolean updatedLight;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (worldObj.isRemote && !updatedLight && worldObj.getWorldTime() % 20 == 0) {
|
||||
updatedLight = worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public TileSwarm setContained(ItemStack[] bees) {
|
||||
for (ItemStack itemstack : bees)
|
||||
contained.addStack(itemstack, false, true);
|
||||
for (ItemStack itemstack : bees) {
|
||||
InvTools.addStack(contained, itemstack, true);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean containsBees() {
|
||||
for (int i = 0; i < contained.getSizeInventory(); i++)
|
||||
if (contained.getStackInSlot(i) != null)
|
||||
for (int i = 0; i < contained.getSizeInventory(); i++) {
|
||||
if (contained.getStackInSlot(i) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -46,23 +46,27 @@ public class AIAvoidPlayers extends EntityAIBase {
|
||||
|
||||
player = mob.worldObj.getClosestPlayerToEntity(mob, minDistance);
|
||||
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mob.getEntitySenses().canSee(player))
|
||||
if (!mob.getEntitySenses().canSee(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vec3 randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 16, 7,
|
||||
Vec3.createVectorHelper(player.posX, player.posY, player.posZ));
|
||||
|
||||
if (randomTarget == null)
|
||||
if (randomTarget == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob))
|
||||
if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pathing = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord);
|
||||
return pathing == null ? false : pathing.isDestinationSame(randomTarget);
|
||||
return pathing != null && pathing.isDestinationSame(randomTarget);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,9 +86,10 @@ public class AIAvoidPlayers extends EntityAIBase {
|
||||
|
||||
@Override
|
||||
public void updateTask() {
|
||||
if (mob.getDistanceSqToEntity(player) < 49.0D)
|
||||
if (mob.getDistanceSqToEntity(player) < 49.0D) {
|
||||
mob.getNavigator().setSpeed(nearSpeed);
|
||||
else
|
||||
} else {
|
||||
mob.getNavigator().setSpeed(farSpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,14 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -19,11 +20,11 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
@@ -54,7 +55,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
private final int primaryColour;
|
||||
private final int secondaryColour;
|
||||
|
||||
private final String iconType = "default";
|
||||
private static final String iconType = "default";
|
||||
|
||||
public AlleleBeeSpecies(String uid, boolean dominant, String name, IClassification branch, int primaryColor, int secondaryColor) {
|
||||
this(uid, dominant, name, branch, null, primaryColor, secondaryColor);
|
||||
@@ -68,7 +69,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
IJubilanceProvider jubilanceProvider) {
|
||||
super(uid, dominant, name, branch, binomial);
|
||||
|
||||
this.root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
|
||||
this.root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
|
||||
this.primaryColour = primaryColor;
|
||||
this.secondaryColour = secondaryColor;
|
||||
this.jubilanceProvider = jubilanceProvider;
|
||||
@@ -86,8 +87,9 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
}
|
||||
|
||||
public AlleleBeeSpecies addProduct(ItemStack product, int chance) {
|
||||
if (product == null || product.getItem() == null)
|
||||
if (product == null || product.getItem() == null) {
|
||||
throw new IllegalArgumentException("Tried to add null product");
|
||||
}
|
||||
this.products.put(product, chance);
|
||||
return this;
|
||||
}
|
||||
@@ -114,16 +116,18 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
int highest = 0;
|
||||
exclude.add(species);
|
||||
|
||||
for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES.ordinal())) {
|
||||
if(!exclude.contains(mutation.getAllele0())) {
|
||||
for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) {
|
||||
if (!exclude.contains(mutation.getAllele0())) {
|
||||
int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude);
|
||||
if(otherAdvance > highest)
|
||||
if (otherAdvance > highest) {
|
||||
highest = otherAdvance;
|
||||
}
|
||||
}
|
||||
if(!exclude.contains(mutation.getAllele1())) {
|
||||
if (!exclude.contains(mutation.getAllele1())) {
|
||||
int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude);
|
||||
if(otherAdvance > highest)
|
||||
if (otherAdvance > highest) {
|
||||
highest = otherAdvance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,15 +136,20 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
|
||||
@Override
|
||||
public float getResearchSuitability(ItemStack itemstack) {
|
||||
if(itemstack == null)
|
||||
if (itemstack == null) {
|
||||
return 0f;
|
||||
}
|
||||
|
||||
for(ItemStack stack : products.keySet())
|
||||
if(stack.isItemEqual(itemstack))
|
||||
for (ItemStack stack : products.keySet()) {
|
||||
if (stack.isItemEqual(itemstack)) {
|
||||
return 1.0f;
|
||||
for(ItemStack stack : specialty.keySet())
|
||||
if(stack.isItemEqual(itemstack))
|
||||
}
|
||||
}
|
||||
for (ItemStack stack : specialty.keySet()) {
|
||||
if (stack.isItemEqual(itemstack)) {
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
return super.getResearchSuitability(itemstack);
|
||||
}
|
||||
@@ -148,18 +157,17 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
@Override
|
||||
public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
|
||||
ArrayList<ItemStack> bounty = new ArrayList<ItemStack>();
|
||||
for(ItemStack stack : super.getResearchBounty(world, researcher, individual, bountyLevel))
|
||||
bounty.add(stack);
|
||||
Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel));
|
||||
|
||||
if(bountyLevel > 10) {
|
||||
for(ItemStack stack : specialty.keySet()) {
|
||||
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
|
||||
if (bountyLevel > 10) {
|
||||
for (ItemStack stack : specialty.keySet()) {
|
||||
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
|
||||
}
|
||||
}
|
||||
for(ItemStack stack : products.keySet()) {
|
||||
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
|
||||
for (ItemStack stack : products.keySet()) {
|
||||
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
|
||||
}
|
||||
return bounty.toArray(StackUtils.EMPTY_STACK_ARRAY);
|
||||
return bounty.toArray(new ItemStack[bounty.size()]);
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
@@ -190,10 +198,12 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
|
||||
@Override
|
||||
public int getIconColour(int renderPass) {
|
||||
if (renderPass == 0)
|
||||
if (renderPass == 0) {
|
||||
return primaryColour;
|
||||
if (renderPass == 1)
|
||||
}
|
||||
if (renderPass == 1) {
|
||||
return secondaryColour;
|
||||
}
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
@@ -208,10 +218,11 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
IIcon body1 = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/body1");
|
||||
|
||||
for (int i = 0; i < EnumBeeType.values().length; i++) {
|
||||
if(EnumBeeType.values()[i] == EnumBeeType.NONE)
|
||||
if (EnumBeeType.values()[i] == EnumBeeType.NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");;
|
||||
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");
|
||||
icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1
|
||||
: TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body");
|
||||
icons[i][2] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body2");
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -25,7 +25,7 @@ import forestry.core.utils.DamageSourceForestry;
|
||||
|
||||
public class AlleleEffectAggressive extends AlleleEffectThrottled {
|
||||
|
||||
public static DamageSource damageSourceBeeAggressive = new DamageSourceForestry("bee.aggressive");
|
||||
public static final DamageSource damageSourceBeeAggressive = new DamageSourceForestry("bee.aggressive");
|
||||
|
||||
public AlleleEffectAggressive(String uid) {
|
||||
super(uid, "aggressive", true, 40, false, false);
|
||||
@@ -34,8 +34,9 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled {
|
||||
@Override
|
||||
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -51,14 +52,15 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3)
|
||||
if (count > 3) {
|
||||
continue;
|
||||
else if (count > 2)
|
||||
} else if (count > 2) {
|
||||
damage = 1;
|
||||
else if (count > 1)
|
||||
} else if (count > 1) {
|
||||
damage = 2;
|
||||
else if (count > 0)
|
||||
} else if (count > 0) {
|
||||
damage = 3;
|
||||
}
|
||||
}
|
||||
|
||||
entity.attackEntityFrom(damageSourceBeeAggressive, damage);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -24,10 +24,10 @@ import forestry.core.genetics.EffectData;
|
||||
|
||||
public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
|
||||
private final int explosionChance = 50;
|
||||
byte defaultForce = 12;
|
||||
byte indexExplosionTimer = 1;
|
||||
byte indexExplosionForce = 2;
|
||||
private static final int explosionChance = 50;
|
||||
private static final byte defaultForce = 12;
|
||||
private final byte indexExplosionTimer = 1;
|
||||
private final byte indexExplosionForce = 2;
|
||||
|
||||
public AlleleEffectCreeper(String uid) {
|
||||
super(uid, "creeper", true, 20, false, true);
|
||||
@@ -35,11 +35,13 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
if (!(storedData instanceof EffectData))
|
||||
if (!(storedData instanceof EffectData)) {
|
||||
return new EffectData(3, 0);
|
||||
}
|
||||
|
||||
if (((EffectData) storedData).getIntSize() < 3)
|
||||
if (((EffectData) storedData).getIntSize() < 3) {
|
||||
return new EffectData(3, 0);
|
||||
}
|
||||
|
||||
return storedData;
|
||||
}
|
||||
@@ -49,8 +51,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
|
||||
World world = housing.getWorld();
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
// If we are already triggered, we continue the explosion sequence.
|
||||
if (storedData.getInteger(indexExplosionTimer) > 0) {
|
||||
@@ -74,9 +77,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
// armor.
|
||||
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3)
|
||||
if (count > 3) {
|
||||
continue;
|
||||
else if (count > 2) {
|
||||
} else if (count > 2) {
|
||||
chance = 5;
|
||||
storedData.setInteger(indexExplosionForce, 6);
|
||||
} else if (count > 1) {
|
||||
@@ -87,8 +90,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
storedData.setInteger(indexExplosionForce, 10);
|
||||
}
|
||||
|
||||
if (world.rand.nextInt(1000) >= chance)
|
||||
if (world.rand.nextInt(1000) >= chance) {
|
||||
continue;
|
||||
}
|
||||
|
||||
world.playSoundEffect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), "mob.creeper", 4F,
|
||||
(1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
|
||||
@@ -105,8 +109,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
explosionTimer--;
|
||||
storedData.setInteger(indexExplosionTimer, explosionTimer);
|
||||
|
||||
if (explosionTimer > 0)
|
||||
if (explosionTimer > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
world.createExplosion(null, x, y, z, storedData.getInteger(indexExplosionForce), false);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -28,8 +28,9 @@ public class AlleleEffectExploration extends AlleleEffectThrottled {
|
||||
@Override
|
||||
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
|
||||
public class AlleleEffectFertile extends AlleleEffectThrottled {
|
||||
|
||||
public static final int MAX_BLOCK_FIND_TRIES = 5;
|
||||
|
||||
public AlleleEffectFertile(String uid) {
|
||||
super(uid, "fertile", false, 6, true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
World world = housing.getWorld();
|
||||
int territorySize[] = getModifiedArea(genome, housing);
|
||||
|
||||
int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
|
||||
int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
|
||||
int blockMaxY = housing.getYCoord() + territorySize[1] / 2 + 1;
|
||||
int blockMinY = housing.getYCoord() - (territorySize[1] / 2) - 1;
|
||||
|
||||
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
|
||||
if (tryTickColumn(world, blockX, blockZ, blockMaxY, blockMinY)) {
|
||||
break;
|
||||
}
|
||||
blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
|
||||
blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
|
||||
}
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
private int getRandomOffset(Random random, int centrePos, int offset) {
|
||||
return centrePos + random.nextInt(offset) - (offset / 2);
|
||||
}
|
||||
|
||||
private boolean tryTickColumn(World world, int x, int z, int maxY, int minY) {
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
world.scheduleBlockUpdate(x, y, z, block, 5);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.passive.EntityCow;
|
||||
import net.minecraft.entity.passive.EntityMooshroom;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.genetics.EffectData;
|
||||
|
||||
public class AlleleEffectFungification extends AlleleEffectThrottled {
|
||||
|
||||
public static final int MAX_BLOCK_FIND_TRIES = 10;
|
||||
public static final int ENTITY_THROTTLE = 6;
|
||||
|
||||
public AlleleEffectFungification(String uid) {
|
||||
super(uid, "mycophilic", true, 10, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
if (storedData instanceof EffectData && ((EffectData) storedData).getIntSize() == 2) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
return new EffectData(2, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
doBlockEffect(genome, housing);
|
||||
|
||||
int entityThrottle = storedData.getInteger(1);
|
||||
if (entityThrottle >= ENTITY_THROTTLE) {
|
||||
doEntityEffect(genome, housing);
|
||||
entityThrottle = 0;
|
||||
} else {
|
||||
++entityThrottle;
|
||||
}
|
||||
storedData.setInteger(1, entityThrottle);
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
private void doBlockEffect(IBeeGenome genome, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
int territorySize[] = getModifiedArea(genome, housing);
|
||||
|
||||
int blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
|
||||
int blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]);
|
||||
int blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
|
||||
|
||||
for (int attempt = 0; attempt < MAX_BLOCK_FIND_TRIES; ++attempt) {
|
||||
Block block = world.getBlock(blockX, blockY, blockZ);
|
||||
if (isSuitableForMycelium(world, block, blockX, blockY, blockZ)) {
|
||||
world.setBlock(blockX, blockY, blockZ, Blocks.mycelium);
|
||||
break;
|
||||
} else if (isSuitableForGrowth(block)) {
|
||||
doMushroomGrowth(block, world, blockX, blockY, blockZ);
|
||||
break;
|
||||
}
|
||||
blockX = getRandomOffset(world.rand, housing.getXCoord(), territorySize[0]);
|
||||
blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]);
|
||||
blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void doEntityEffect(IBeeGenome genome, IBeeHousing housing) {
|
||||
AxisAlignedBB aabb = this.getBounding(genome, housing, 1f);
|
||||
World world = housing.getWorld();
|
||||
|
||||
List entities = world.getEntitiesWithinAABB(EntityCow.class, aabb);
|
||||
for (Object entity : entities) {
|
||||
if (entity instanceof EntityCow && !(entity instanceof EntityMooshroom)) {
|
||||
convertCowToMooshroom((EntityCow) entity);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getRandomOffset(Random random, int centrePos, int offset) {
|
||||
return centrePos + random.nextInt(offset) - (offset / 2);
|
||||
}
|
||||
|
||||
private boolean isSuitableForMycelium(World world, Block block, int blockX, int blockY, int blockZ) {
|
||||
return block == Blocks.grass || (block == Blocks.dirt && world.canBlockSeeTheSky(blockX, blockY, blockZ));
|
||||
}
|
||||
|
||||
private boolean isSuitableForGrowth(Block block) {
|
||||
return block == Blocks.red_mushroom || block == Blocks.brown_mushroom;
|
||||
}
|
||||
|
||||
private static void convertCowToMooshroom(EntityCow cow) {
|
||||
World worldObj = cow.worldObj;
|
||||
cow.setDead();
|
||||
EntityMooshroom mooshroom = new EntityMooshroom(worldObj);
|
||||
mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch);
|
||||
mooshroom.setHealth(cow.getHealth());
|
||||
mooshroom.renderYawOffset = cow.renderYawOffset;
|
||||
worldObj.spawnEntityInWorld(mooshroom);
|
||||
worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double) (cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
private void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) {
|
||||
WorldGenBigMushroom giantMushroomGenerator;
|
||||
|
||||
if (block == Blocks.brown_mushroom) {
|
||||
giantMushroomGenerator = new WorldGenBigMushroom(0);
|
||||
} else {
|
||||
giantMushroomGenerator = new WorldGenBigMushroom(1);
|
||||
}
|
||||
|
||||
world.setBlockToAir(blockX, blockY, blockZ);
|
||||
giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -20,7 +20,7 @@ import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
public class AlleleEffectGlacial extends AlleleEffectThrottled {
|
||||
|
||||
@@ -33,17 +33,18 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
|
||||
|
||||
World world = housing.getWorld();
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
|
||||
|
||||
switch (temp) {
|
||||
case HELLISH:
|
||||
case HOT:
|
||||
case WARM:
|
||||
return storedData;
|
||||
default:
|
||||
case HELLISH:
|
||||
case HOT:
|
||||
case WARM:
|
||||
return storedData;
|
||||
default:
|
||||
}
|
||||
|
||||
int[] areaAr = genome.getTerritory();
|
||||
@@ -59,11 +60,13 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
|
||||
|
||||
// Freeze water
|
||||
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
|
||||
if (block != Blocks.water)
|
||||
if (block != Blocks.water) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z))
|
||||
if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.ice);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -29,8 +29,9 @@ public class AlleleEffectHeroic extends AlleleEffectThrottled {
|
||||
@Override
|
||||
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -25,8 +25,8 @@ import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class AlleleEffectIgnition extends AlleleEffectThrottled {
|
||||
|
||||
int ignitionChance = 50;
|
||||
int fireDuration = 500;
|
||||
private static final int ignitionChance = 50;
|
||||
private static final int fireDuration = 500;
|
||||
|
||||
public AlleleEffectIgnition(String uid) {
|
||||
super(uid, "ignition", false, 20, false, true);
|
||||
@@ -37,8 +37,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
|
||||
|
||||
World world = housing.getWorld();
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -55,9 +56,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3)
|
||||
if (count > 3) {
|
||||
continue;
|
||||
else if (count > 2) {
|
||||
} else if (count > 2) {
|
||||
chance = 5;
|
||||
duration = 50;
|
||||
} else if (count > 1) {
|
||||
@@ -69,8 +70,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
|
||||
}
|
||||
}
|
||||
|
||||
if (world.rand.nextInt(1000) >= chance)
|
||||
if (world.rand.nextInt(1000) >= chance) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entity.setFire(duration);
|
||||
}
|
||||
@@ -83,12 +85,13 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
|
||||
|
||||
int[] area = getModifiedArea(genome, housing);
|
||||
|
||||
if (housing.getWorld().rand.nextBoolean())
|
||||
if (housing.getWorld().rand.nextBoolean()) {
|
||||
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
|
||||
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
|
||||
else
|
||||
} else {
|
||||
PluginApiculture.proxy.addBeeHiveFX("particles/ember", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
|
||||
housing.getZCoord(), 0xffffff, area[0], area[1], area[2]);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -26,7 +26,7 @@ import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class AlleleEffectMiasmic extends AlleleEffectThrottled {
|
||||
|
||||
private final int infectionChance = 50;
|
||||
private static final int infectionChance = 50;
|
||||
|
||||
public AlleleEffectMiasmic(String uid) {
|
||||
super(uid, "misasmic", false, 50, false, false);
|
||||
@@ -37,8 +37,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
|
||||
|
||||
World world = housing.getWorld();
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB infectionBox = getBounding(genome, housing, 1.0f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -46,8 +47,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
|
||||
|
||||
for (Object obj : list) {
|
||||
|
||||
if (world.rand.nextInt(1000) >= infectionChance)
|
||||
if (world.rand.nextInt(1000) >= infectionChance) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer) obj;
|
||||
|
||||
@@ -57,14 +59,15 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
|
||||
// armor.
|
||||
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3)
|
||||
if (count > 3) {
|
||||
continue;
|
||||
else if (count > 2)
|
||||
} else if (count > 2) {
|
||||
duration = 200;
|
||||
else if (count > 1)
|
||||
} else if (count > 1) {
|
||||
duration = 400;
|
||||
else if (count > 0)
|
||||
} else if (count > 0) {
|
||||
duration = 600;
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(Potion.poison.id, duration, 0));
|
||||
}
|
||||
@@ -77,12 +80,13 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
|
||||
|
||||
int[] area = getModifiedArea(genome, housing);
|
||||
|
||||
if (housing.getWorld().rand.nextBoolean())
|
||||
if (housing.getWorld().rand.nextBoolean()) {
|
||||
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
|
||||
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
|
||||
else
|
||||
} else {
|
||||
PluginApiculture.proxy.addBeeHiveFX("particles/poison", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
|
||||
housing.getZCoord(), 0xffffff, area[0], area[1], area[2]);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -24,7 +24,7 @@ import forestry.core.utils.DamageSourceForestry;
|
||||
|
||||
public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
|
||||
|
||||
public static DamageSource damageSourceBeeEnd = new DamageSourceForestry("bee.end");
|
||||
public static final DamageSource damageSourceBeeEnd = new DamageSourceForestry("bee.end");
|
||||
|
||||
public AlleleEffectMisanthrope(String uid) {
|
||||
super(uid, "misanthrope", true, 20, false, false);
|
||||
@@ -33,8 +33,9 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
|
||||
@Override
|
||||
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -49,14 +50,15 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
|
||||
// armor.
|
||||
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3)
|
||||
if (count > 3) {
|
||||
continue;
|
||||
else if (count > 2)
|
||||
} else if (count > 2) {
|
||||
damage = 1;
|
||||
else if (count > 1)
|
||||
} else if (count > 1) {
|
||||
damage = 2;
|
||||
else if (count > 0)
|
||||
} else if (count > 0) {
|
||||
damage = 3;
|
||||
}
|
||||
|
||||
player.attackEntityFrom(damageSourceBeeEnd, damage);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -57,12 +57,15 @@ public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
|
||||
area[1] *= housing.getTerritoryModifier(genome, 1f);
|
||||
area[2] *= housing.getTerritoryModifier(genome, 1f);
|
||||
|
||||
if (area[0] < 1)
|
||||
if (area[0] < 1) {
|
||||
area[0] = 1;
|
||||
if (area[1] < 1)
|
||||
}
|
||||
if (area[1] < 1) {
|
||||
area[1] = 1;
|
||||
if (area[2] < 1)
|
||||
}
|
||||
if (area[2] < 1) {
|
||||
area[2] = 1;
|
||||
}
|
||||
|
||||
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
|
||||
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -17,37 +17,73 @@ import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.apiculture.items.ItemArmorApiarist;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class AlleleEffectPotion extends AlleleEffectThrottled {
|
||||
|
||||
private int potionId = 0;
|
||||
private final Potion potion;
|
||||
private final boolean isBadEffect;
|
||||
private final int duration;
|
||||
|
||||
public AlleleEffectPotion(String uid, String name, boolean isDominant, Potion potion, int duration, boolean requiresWorking) {
|
||||
super(uid, name, isDominant, 200, requiresWorking, false);
|
||||
potionId = potion.getId();
|
||||
this.potion = potion;
|
||||
this.isBadEffect = isBadEffect(potion);
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, beatifyBox);
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityPlayer player = (EntityPlayer) obj;
|
||||
player.addPotionEffect(new PotionEffect(potionId, duration, 0));
|
||||
for (Object entity : list) {
|
||||
if (!(entity instanceof EntityPlayer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
|
||||
int dur = this.duration;
|
||||
if (isBadEffect) {
|
||||
// Players are not attacked if they wear a full set of apiarist's armor.
|
||||
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
|
||||
if (count >= 4) {
|
||||
continue; // Full set, no damage/effect
|
||||
} else if (count == 3) {
|
||||
dur = this.duration / 4;
|
||||
} else if (count == 2) {
|
||||
dur = this.duration / 2;
|
||||
} else if (count == 1) {
|
||||
dur = this.duration * 3 / 4;
|
||||
}
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(potion.getId(), dur, 0));
|
||||
}
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
//FIXME: remove when Potion.isBadEffect() is available server-side
|
||||
private static boolean isBadEffect(Potion potion) {
|
||||
try {
|
||||
return (Boolean) ReflectionHelper.getPrivateValue(Potion.class, potion, "field_76418_K", "isBadEffect");
|
||||
} catch (ReflectionHelper.UnableToFindFieldException e) {
|
||||
Proxies.log.severe("Could not access potion field isBadEffect.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -28,11 +28,11 @@ import forestry.apiculture.gadgets.BlockAlveary;
|
||||
import forestry.apiculture.gadgets.TileAlveary;
|
||||
import forestry.apiculture.items.ItemArmorApiarist;
|
||||
import forestry.core.utils.DamageSourceForestry;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
|
||||
public static DamageSource damageSourceBeeRadioactive = new DamageSourceForestry("bee.radioactive");
|
||||
public static final DamageSource damageSourceBeeRadioactive = new DamageSourceForestry("bee.radioactive");
|
||||
|
||||
public AlleleEffectRadioactive(String uid) {
|
||||
super(uid, "radioactive", true, 40, false, true);
|
||||
@@ -43,8 +43,9 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
|
||||
World world = housing.getWorld();
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr[0] * 2, areaAr[1] * 2, areaAr[2] * 2);
|
||||
@@ -69,14 +70,15 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3)
|
||||
if (count > 3) {
|
||||
continue;
|
||||
else if (count > 2)
|
||||
} else if (count > 2) {
|
||||
damage = 1;
|
||||
else if (count > 1)
|
||||
} else if (count > 1) {
|
||||
damage = 2;
|
||||
else if (count > 0)
|
||||
} else if (count > 0) {
|
||||
damage = 3;
|
||||
}
|
||||
}
|
||||
|
||||
entity.attackEntityFrom(damageSourceBeeRadioactive, damage);
|
||||
@@ -92,29 +94,36 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
|
||||
posBlock = posBlock.add(offset);
|
||||
|
||||
if(posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight())
|
||||
if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Don't destroy ourself and blocks below us.
|
||||
if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord())
|
||||
if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z))
|
||||
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
|
||||
|
||||
if (block instanceof BlockAlveary)
|
||||
if (block instanceof BlockAlveary) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z);
|
||||
if (tile instanceof IBeeHousing)
|
||||
if (tile instanceof IBeeHousing) {
|
||||
continue;
|
||||
if (tile instanceof TileAlveary)
|
||||
}
|
||||
if (tile instanceof TileAlveary) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0)
|
||||
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z);
|
||||
break;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -28,11 +28,13 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
if (housing.getOwnerName() == null)
|
||||
if (housing.getOwnerName() == null) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -43,8 +45,9 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled {
|
||||
|
||||
for (Object objT : mob.tasks.taskEntries) {
|
||||
EntityAITaskEntry task = (EntityAITaskEntry) objT;
|
||||
if (task.action instanceof AIAvoidPlayers)
|
||||
if (task.action instanceof AIAvoidPlayers) {
|
||||
return storedData;
|
||||
}
|
||||
}
|
||||
|
||||
mob.tasks.addTask(3, new AIAvoidPlayers(mob, 6.0f, 0.25f, 0.3f));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -79,30 +79,35 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB bounding = getBounding(genome, housing, 1.0f);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityItem.class, bounding);
|
||||
|
||||
if (list.size() > 0)
|
||||
if (list.size() > 0) {
|
||||
Collections.shuffle(resurrectables);
|
||||
}
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityItem item = (EntityItem) obj;
|
||||
if (item.isDead)
|
||||
if (item.isDead) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack contained = item.getEntityItem();
|
||||
for (Resurrectable entry : resurrectables)
|
||||
for (Resurrectable entry : resurrectables) {
|
||||
if (StackUtils.isIdenticalItem(entry.res, contained)) {
|
||||
Utils.spawnEntity(housing.getWorld(), entry.risen, item.posX, item.posY, item.posZ);
|
||||
contained.stackSize--;
|
||||
if (contained.stackSize <= 0)
|
||||
if (contained.stackSize <= 0) {
|
||||
item.setDead();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return storedData;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -21,7 +21,7 @@ import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
|
||||
public class AlleleEffectSnowing extends AlleleEffectThrottled {
|
||||
|
||||
@@ -34,17 +34,18 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
|
||||
|
||||
World world = housing.getWorld();
|
||||
|
||||
if (isHalted(storedData, housing))
|
||||
if (isHalted(storedData, housing)) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
|
||||
|
||||
switch (temp) {
|
||||
case HELLISH:
|
||||
case HOT:
|
||||
case WARM:
|
||||
return storedData;
|
||||
default:
|
||||
case HELLISH:
|
||||
case HOT:
|
||||
case WARM:
|
||||
return storedData;
|
||||
default:
|
||||
}
|
||||
|
||||
int[] areaAr = genome.getTerritory();
|
||||
@@ -59,11 +60,13 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
|
||||
posBlock = posBlock.add(offset);
|
||||
|
||||
// Put snow on the ground
|
||||
if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false))
|
||||
if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z))
|
||||
if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.snow_layer);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -19,7 +19,7 @@ import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.genetics.Allele;
|
||||
import forestry.core.genetics.EffectData;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public abstract class AlleleEffectThrottled extends Allele implements IAlleleBeeEffect {
|
||||
@@ -47,23 +47,26 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
|
||||
|
||||
@Override
|
||||
public IEffectData validateStorage(IEffectData storedData) {
|
||||
if (storedData instanceof EffectData)
|
||||
if (storedData instanceof EffectData) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
return new EffectData(1, 0);
|
||||
}
|
||||
|
||||
public boolean isHalted(IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
if (requiresWorkingQueen && housing.getErrorOrdinal() != EnumErrorCode.OK.ordinal())
|
||||
if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int throttle = storedData.getInteger(0);
|
||||
throttle++;
|
||||
storedData.setInteger(0, throttle);
|
||||
int throt = storedData.getInteger(0);
|
||||
throt++;
|
||||
storedData.setInteger(0, throt);
|
||||
|
||||
if (throttle < getThrottle())
|
||||
if (throt < getThrottle()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Reset since we are done throttling.
|
||||
storedData.setInteger(0, 0);
|
||||
@@ -86,12 +89,15 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
|
||||
area[1] *= housing.getTerritoryModifier(genome, 1f) * 3;
|
||||
area[2] *= housing.getTerritoryModifier(genome, 1f) * 3;
|
||||
|
||||
if (area[0] < 1)
|
||||
if (area[0] < 1) {
|
||||
area[0] = 1;
|
||||
if (area[1] < 1)
|
||||
}
|
||||
if (area[1] < 1) {
|
||||
area[1] = 1;
|
||||
if (area[2] < 1)
|
||||
}
|
||||
if (area[2] < 1) {
|
||||
area[2] = 1;
|
||||
}
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -16,7 +16,7 @@ import forestry.core.genetics.Allele;
|
||||
|
||||
public class AlleleFlowers extends Allele implements IAlleleFlowers {
|
||||
|
||||
IFlowerProvider provider;
|
||||
private final IFlowerProvider provider;
|
||||
|
||||
public AlleleFlowers(String uid, IFlowerProvider provider) {
|
||||
this(uid, provider, false);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IApiaristTracker;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
@@ -23,6 +24,7 @@ import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class ApiaristTracker extends BreedingTracker implements IApiaristTracker {
|
||||
|
||||
/** Required for creation from map storage */
|
||||
public ApiaristTracker(String s) {
|
||||
this(s, null);
|
||||
}
|
||||
@@ -59,12 +61,15 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
|
||||
|
||||
@Override
|
||||
public void registerPickup(IIndividual individual) {
|
||||
if(!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID))
|
||||
if (!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID)) {
|
||||
return;
|
||||
if(!individual.isPureBred(0))
|
||||
}
|
||||
if (!individual.isPureBred(EnumBeeChromosome.SPECIES)) {
|
||||
return;
|
||||
if(PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0)
|
||||
}
|
||||
if (PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
registerSpecies(individual.getGenome().getPrimary());
|
||||
}
|
||||
@@ -103,12 +108,12 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBreedingTracker getCommonTracker(EntityPlayer player) {
|
||||
return PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, null);
|
||||
protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
|
||||
return PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPacketTag() {
|
||||
protected String speciesRootUID() {
|
||||
return BeeHelper.UID;
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+311
-254
@@ -4,12 +4,26 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IAlleleBeeEffect;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
@@ -19,6 +33,7 @@ import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeMutation;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -30,31 +45,25 @@ import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.arboriculture.genetics.FakePollinatable;
|
||||
import forestry.arboriculture.genetics.ICheckPollinatable;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.genetics.Chromosome;
|
||||
import forestry.core.genetics.GenericRatings;
|
||||
import forestry.core.genetics.IndividualLiving;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.MutableVect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
protected int generation;
|
||||
protected boolean isNatural = true;
|
||||
|
||||
public IBeeGenome genome;
|
||||
public IBeeGenome mate;
|
||||
|
||||
@@ -63,34 +72,20 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
public Bee(World world, IBeeGenome genome, IBee mate) {
|
||||
this(world, genome);
|
||||
this.mate = mate.getGenome();
|
||||
this.isIrregularMating = mate.isNatural() != this.isNatural;
|
||||
}
|
||||
|
||||
public Bee(IBeeGenome genome, IBee mate) {
|
||||
this(genome);
|
||||
this.mate = mate.getGenome();
|
||||
this.isIrregularMating = mate.isNatural() != this.isNatural;
|
||||
}
|
||||
|
||||
public Bee(World world, IBeeGenome genome) {
|
||||
this(world, genome, true, 0);
|
||||
}
|
||||
|
||||
public Bee(IBeeGenome genome) {
|
||||
this(genome, true, 0);
|
||||
}
|
||||
|
||||
public Bee(World world, IBeeGenome genome, boolean isNatural, int generation) {
|
||||
super(genome.getLifespan(), isNatural, generation);
|
||||
this.genome = genome;
|
||||
}
|
||||
|
||||
public Bee(IBeeGenome genome, boolean isNatural, int generation) {
|
||||
super(genome.getLifespan(), isNatural, generation);
|
||||
super(genome.getLifespan());
|
||||
this.genome = genome;
|
||||
this.isNatural = isNatural;
|
||||
this.generation = generation;
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@@ -104,23 +99,65 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
if (nbttagcompound.hasKey("Genome"))
|
||||
if (nbttagcompound.hasKey("NA")) {
|
||||
isNatural = nbttagcompound.getBoolean("NA");
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasKey("GEN")) {
|
||||
generation = nbttagcompound.getInteger("GEN");
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasKey("Genome")) {
|
||||
genome = new BeeGenome(nbttagcompound.getCompoundTag("Genome"));
|
||||
else
|
||||
} else {
|
||||
genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate());
|
||||
if (nbttagcompound.hasKey("Mate"))
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasKey("Mate")) {
|
||||
mate = new BeeGenome(nbttagcompound.getCompoundTag("Mate"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mate(IIndividual individual) {
|
||||
if(!(individual instanceof IBee))
|
||||
return;
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
IBee drone = (IBee)individual;
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (!isNatural) {
|
||||
nbttagcompound.setBoolean("NA", false);
|
||||
}
|
||||
|
||||
if (generation > 0) {
|
||||
nbttagcompound.setInteger("GEN", generation);
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsNatural(boolean flag) {
|
||||
this.isNatural = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIrregularMating() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isNatural() {
|
||||
return this.isNatural;
|
||||
}
|
||||
|
||||
public int getGeneration() {
|
||||
return generation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mate(IIndividual individual) {
|
||||
if (!(individual instanceof IBee)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IBee drone = (IBee) individual;
|
||||
mate = drone.getGenome();
|
||||
this.isIrregularMating = drone.isNatural() != this.isNatural;
|
||||
}
|
||||
|
||||
/* EFFECTS */
|
||||
@@ -128,18 +165,21 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
public IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing) {
|
||||
IAlleleBeeEffect effect = genome.getEffect();
|
||||
|
||||
if (effect == null)
|
||||
if (effect == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
storedData[0] = doEffect(effect, storedData[0], housing);
|
||||
|
||||
// Return here if the primary can already not be combined
|
||||
if (!effect.isCombinable())
|
||||
if (!effect.isCombinable()) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal());
|
||||
if (!secondary.isCombinable())
|
||||
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
|
||||
if (!secondary.isCombinable()) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
storedData[1] = doEffect(secondary, storedData[1], housing);
|
||||
|
||||
@@ -155,18 +195,21 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
public IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing) {
|
||||
IAlleleBeeEffect effect = genome.getEffect();
|
||||
|
||||
if (effect == null)
|
||||
if (effect == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
storedData[0] = doFX(effect, storedData[0], housing);
|
||||
|
||||
// Return here if the primary can already not be combined
|
||||
if (!effect.isCombinable())
|
||||
if (!effect.isCombinable()) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal());
|
||||
if (!secondary.isCombinable())
|
||||
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
|
||||
if (!secondary.isCombinable()) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
storedData[1] = doFX(secondary, storedData[1], housing);
|
||||
|
||||
@@ -203,38 +246,51 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
@Override
|
||||
public int isWorking(IBeeHousing housing) {
|
||||
return canWork(housing).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumErrorCode canWork(IBeeHousing housing) {
|
||||
|
||||
World world = housing.getWorld();
|
||||
// / Rain needs tolerant flyers
|
||||
if (world.isRaining() && !genome.getTolerantFlyer() && housing.getHumidity() != EnumHumidity.ARID && !housing.isSealed())
|
||||
return EnumErrorCode.ISRAINING.ordinal();
|
||||
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(housing.getBiomeId()) && !housing.isSealed()) {
|
||||
return EnumErrorCode.ISRAINING;
|
||||
}
|
||||
|
||||
// / Night or darkness requires nocturnal species
|
||||
if(world.isDaytime()) {
|
||||
if(!canWorkDuringDay())
|
||||
return EnumErrorCode.NOTNIGHT.ordinal();
|
||||
} else if (!canWorkAtNight() && !housing.isSelfLighted())
|
||||
return EnumErrorCode.NOTDAY.ordinal();
|
||||
if (world.isDaytime()) {
|
||||
if (!canWorkDuringDay()) {
|
||||
return EnumErrorCode.NOTNIGHT;
|
||||
}
|
||||
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
|
||||
return EnumErrorCode.NOTDAY;
|
||||
}
|
||||
|
||||
if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) {
|
||||
if(!canWorkDuringDay())
|
||||
return EnumErrorCode.NOTGLOOMY.ordinal();
|
||||
} else if(!canWorkAtNight() && !housing.isSelfLighted())
|
||||
return EnumErrorCode.NOTLUCID.ordinal();
|
||||
if (!canWorkDuringDay()) {
|
||||
return EnumErrorCode.NOTGLOOMY;
|
||||
}
|
||||
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
|
||||
return EnumErrorCode.NOTLUCID;
|
||||
}
|
||||
|
||||
// / No sky, except if in hell
|
||||
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
|
||||
if(biome == null)
|
||||
return EnumErrorCode.NOSKY.ordinal();
|
||||
if (!BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.NETHER) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
|
||||
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated())
|
||||
return EnumErrorCode.NOSKY.ordinal();
|
||||
if (biome == null) {
|
||||
return EnumErrorCode.NOSKY;
|
||||
}
|
||||
if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
|
||||
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated()) {
|
||||
return EnumErrorCode.NOSKY;
|
||||
}
|
||||
|
||||
// / And finally climate check
|
||||
if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity()))
|
||||
return EnumErrorCode.INVALIDBIOME.ordinal();
|
||||
if (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
|
||||
return EnumErrorCode.INVALIDBIOME;
|
||||
}
|
||||
|
||||
return EnumErrorCode.OK.ordinal();
|
||||
return EnumErrorCode.OK;
|
||||
}
|
||||
|
||||
private boolean canWorkAtNight() {
|
||||
@@ -245,17 +301,17 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
return !genome.getPrimary().isNocturnal() || genome.getNocturnal();
|
||||
}
|
||||
|
||||
private boolean checkBiomeHazard(BiomeGenBase biome) {
|
||||
public boolean isSuitableBiome(BiomeGenBase biome) {
|
||||
if (biome == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EnumTemperature temperature = EnumTemperature.getFromValue(biome.temperature);
|
||||
EnumTemperature temperature = EnumTemperature.getFromBiome(biome);
|
||||
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
|
||||
return AlleleManager.climateHelper.isWithinLimits(temperature, humidity,
|
||||
genome.getPrimary().getTemperature(), genome.getToleranceTemp(),
|
||||
genome.getPrimary().getHumidity(), genome.getToleranceHumid());
|
||||
return isSuitableClimate(temperature, humidity);
|
||||
}
|
||||
|
||||
private boolean checkSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) {
|
||||
|
||||
private boolean isSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) {
|
||||
return AlleleManager.climateHelper.isWithinLimits(temperature, humidity,
|
||||
genome.getPrimary().getTemperature(), genome.getToleranceTemp(),
|
||||
genome.getPrimary().getHumidity(), genome.getToleranceHumid());
|
||||
@@ -266,26 +322,16 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
IFlowerProvider provider = genome.getFlowerProvider();
|
||||
|
||||
Vect coords = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
Vect posCurrent = new Vect(0, 0, 0);
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f));
|
||||
|
||||
if (area.x < 1)
|
||||
area.x = 1;
|
||||
if (area.y < 1)
|
||||
area.y = 1;
|
||||
if (area.z < 1)
|
||||
area.z = 1;
|
||||
|
||||
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
|
||||
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
Vect area = getArea(genome, housing);
|
||||
Vect offset = new Vect(-area.x / 2, -area.y / 2, -area.z / 2);
|
||||
|
||||
boolean hasFlower = false;
|
||||
|
||||
while (advancePosition(posCurrent, area)) {
|
||||
MutableVect posCurrent = new MutableVect(0, 0, 0);
|
||||
while (posCurrent.advancePositionInArea(area)) {
|
||||
|
||||
Vect posBlock = posCurrent.add(coords);
|
||||
posBlock = posBlock.add(offset);
|
||||
Vect posBlock = Vect.add(housingPos, posCurrent, offset);
|
||||
|
||||
if (provider.isAcceptedFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z)) {
|
||||
hasFlower = true;
|
||||
@@ -297,34 +343,26 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
return hasFlower;
|
||||
}
|
||||
|
||||
private boolean advancePosition(Vect posCurrent, Vect area) {
|
||||
// Increment z first until end reached
|
||||
if (posCurrent.z < area.z - 1)
|
||||
posCurrent.z++;
|
||||
else {
|
||||
posCurrent.z = 0;
|
||||
|
||||
if (posCurrent.x < area.x - 1)
|
||||
posCurrent.x++;
|
||||
else {
|
||||
posCurrent.x = 0;
|
||||
|
||||
if (posCurrent.y < area.y - 1)
|
||||
posCurrent.y++;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Integer> getSuitableBiomeIds() {
|
||||
ArrayList<Integer> suitableBiomes = new ArrayList<Integer>();
|
||||
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
|
||||
if (checkBiomeHazard(biome))
|
||||
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
|
||||
if (isSuitableBiome(biome)) {
|
||||
suitableBiomes.add(biome.biomeID);
|
||||
}
|
||||
}
|
||||
|
||||
return suitableBiomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<BiomeGenBase> getSuitableBiomes() {
|
||||
ArrayList<BiomeGenBase> suitableBiomes = new ArrayList<BiomeGenBase>();
|
||||
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
|
||||
if (isSuitableBiome(biome)) {
|
||||
suitableBiomes.add(biome);
|
||||
}
|
||||
}
|
||||
|
||||
return suitableBiomes;
|
||||
}
|
||||
@@ -341,27 +379,52 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
// You analyzed it? Juicy tooltip coming up!
|
||||
IAlleleBeeSpecies primary = genome.getPrimary();
|
||||
IAlleleBeeSpecies secondary = genome.getSecondary();
|
||||
if (!isPureBred(EnumBeeChromosome.SPECIES.ordinal()))
|
||||
list.add("\u00A79" + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName()));
|
||||
if (!isPureBred(EnumBeeChromosome.SPECIES)) {
|
||||
list.add(EnumChatFormatting.BLUE + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY", primary.getName()).replaceAll("%SECONDARY", secondary.getName()));
|
||||
}
|
||||
|
||||
IAllele speed = genome.getActiveAllele(EnumBeeChromosome.SPEED.ordinal());
|
||||
String customWorker = "tooltip.worker." + speed.getUnlocalizedName().replaceFirst("gui.", "");
|
||||
if (StringUtil.canTranslate(customWorker))
|
||||
list.add(StringUtil.localize(customWorker));
|
||||
else
|
||||
list.add(speed.getName() + " " + StringUtil.localize("gui.worker"));
|
||||
if (generation > 0) {
|
||||
EnumRarity rarity;
|
||||
if (generation >= 1000) {
|
||||
rarity = EnumRarity.epic;
|
||||
} else if (generation >= 100) {
|
||||
rarity = EnumRarity.rare;
|
||||
} else if (generation >= 10) {
|
||||
rarity = EnumRarity.uncommon;
|
||||
} else {
|
||||
rarity = EnumRarity.common;
|
||||
}
|
||||
|
||||
list.add(genome.getActiveAllele(EnumBeeChromosome.LIFESPAN.ordinal()).getName() + " " + StringUtil.localize("gui.life"));
|
||||
String generationString = rarity.rarityColor + StringUtil.localizeAndFormat("gui.beealyzer.generations", generation);
|
||||
list.add(generationString);
|
||||
}
|
||||
|
||||
IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
|
||||
list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName());
|
||||
IAllele speedAllele = genome.getActiveAllele(EnumBeeChromosome.SPEED);
|
||||
IAlleleTolerance tempToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
|
||||
IAlleleTolerance humidToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
|
||||
|
||||
IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
|
||||
list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName());
|
||||
String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceFirst("gui.", "");
|
||||
String speed;
|
||||
if (StringUtil.canTranslate(unlocalizedCustomSpeed)) {
|
||||
speed = StringUtil.localize(unlocalizedCustomSpeed);
|
||||
} else {
|
||||
speed = speedAllele.getName() + " " + StringUtil.localize("gui.worker");
|
||||
}
|
||||
|
||||
list.add(genome.getFlowerProvider().getDescription());
|
||||
if (genome.getNocturnal())
|
||||
list.add("\u00A7c" + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
|
||||
String lifespan = genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life");
|
||||
String tempTolerance = EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempToleranceAllele.getName();
|
||||
String humidTolerance = EnumChatFormatting.GREEN + "H: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidToleranceAllele.getName();
|
||||
String flowers = genome.getFlowerProvider().getDescription();
|
||||
|
||||
list.add(lifespan);
|
||||
list.add(speed);
|
||||
list.add(tempTolerance);
|
||||
list.add(humidTolerance);
|
||||
list.add(flowers);
|
||||
|
||||
if (genome.getNocturnal()) {
|
||||
list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -387,29 +450,33 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
for (ItemStack second : secondaryProducts) {
|
||||
boolean skip = false;
|
||||
|
||||
for (ItemStack compare : products)
|
||||
for (ItemStack compare : products) {
|
||||
if (second.isItemEqual(compare)) {
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!skip)
|
||||
if (!skip) {
|
||||
products.add(second);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return products.toArray(new ItemStack[0]);
|
||||
return products.toArray(new ItemStack[products.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getSpecialtyList() {
|
||||
return genome.getPrimary().getSpecialty().keySet().toArray(new ItemStack[0]);
|
||||
Set<ItemStack> specialties = genome.getPrimary().getSpecialty().keySet();
|
||||
return specialties.toArray(new ItemStack[specialties.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] produceStacks(IBeeHousing housing) {
|
||||
if (!hasFlower(housing))
|
||||
if (!hasFlower(housing)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (housing == null) {
|
||||
Proxies.log.warning("Failed to produce in an apiary because the beehousing was null.");
|
||||
@@ -427,32 +494,40 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
IAlleleBeeSpecies secondary = genome.getSecondary();
|
||||
|
||||
// All work and no play makes queen a dull girl.
|
||||
if(mode.isOverworked(this, housing))
|
||||
if (mode.isOverworked(this, housing)) {
|
||||
setIsNatural(false);
|
||||
}
|
||||
|
||||
// Bee genetic speed * beehousing * beekeeping mode
|
||||
float speed = genome.getSpeed() * housing.getProductionModifier(genome, 1f) * mode.getProductionModifier(genome, 1f);
|
||||
|
||||
// / Primary Products
|
||||
for (Map.Entry<ItemStack, Integer> entry : primary.getProducts().entrySet())
|
||||
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed)
|
||||
for (Map.Entry<ItemStack, Integer> entry : primary.getProducts().entrySet()) {
|
||||
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
|
||||
products.add(entry.getKey().copy());
|
||||
}
|
||||
}
|
||||
// / Secondary Products
|
||||
for (Map.Entry<ItemStack, Integer> entry : secondary.getProducts().entrySet())
|
||||
if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed)
|
||||
for (Map.Entry<ItemStack, Integer> entry : secondary.getProducts().entrySet()) {
|
||||
if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed) {
|
||||
products.add(entry.getKey().copy());
|
||||
}
|
||||
}
|
||||
|
||||
// We are done if the we are not jubilant.
|
||||
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing))
|
||||
return products.toArray(StackUtils.EMPTY_STACK_ARRAY);
|
||||
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing)) {
|
||||
return products.toArray(new ItemStack[products.size()]);
|
||||
}
|
||||
|
||||
// / Specialty products
|
||||
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet())
|
||||
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed)
|
||||
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet()) {
|
||||
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
|
||||
products.add(entry.getKey().copy());
|
||||
}
|
||||
}
|
||||
|
||||
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(),
|
||||
products.toArray(StackUtils.EMPTY_STACK_ARRAY));
|
||||
products.toArray(new ItemStack[products.size()]));
|
||||
}
|
||||
|
||||
/* REPRODUCTION */
|
||||
@@ -460,12 +535,14 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
public IBee spawnPrincess(IBeeHousing housing) {
|
||||
|
||||
// We need a mated queen to produce offspring.
|
||||
if (mate == null)
|
||||
if (mate == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fatigued queens do not produce princesses.
|
||||
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing))
|
||||
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return createOffspring(housing, getGeneration() + 1);
|
||||
}
|
||||
@@ -476,29 +553,32 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
World world = housing.getWorld();
|
||||
|
||||
// We need a mated queen to produce offspring.
|
||||
if (mate == null)
|
||||
if (mate == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ArrayList<IBee> bees = new ArrayList<IBee>();
|
||||
|
||||
int toCreate = PluginApiculture.beeInterface.getBeekeepingMode(world).getFinalFertility(this, world, housing.getXCoord(), housing.getYCoord(),
|
||||
housing.getZCoord());
|
||||
|
||||
if (toCreate <= 0)
|
||||
if (toCreate <= 0) {
|
||||
toCreate = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < toCreate; i++) {
|
||||
IBee offspring = createOffspring(housing, -1);
|
||||
IBee offspring = createOffspring(housing, 0);
|
||||
if (offspring != null) {
|
||||
offspring.setIsNatural(true);
|
||||
bees.add(offspring);
|
||||
}
|
||||
}
|
||||
|
||||
if (bees.size() > 0)
|
||||
return bees.toArray(new IBee[0]);
|
||||
else
|
||||
if (bees.size() > 0) {
|
||||
return bees.toArray(new IBee[bees.size()]);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IBee createOffspring(IBeeHousing housing, int generation) {
|
||||
@@ -512,25 +592,22 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
// Check for mutation. Replace one of the parents with the mutation
|
||||
// template if mutation occured.
|
||||
IChromosome[] mutated1 = mutateSpecies(housing, genome, mate);
|
||||
if (mutated1 != null)
|
||||
if (mutated1 != null) {
|
||||
parent1 = mutated1;
|
||||
}
|
||||
IChromosome[] mutated2 = mutateSpecies(housing, mate, genome);
|
||||
if (mutated2 != null)
|
||||
if (mutated2 != null) {
|
||||
parent2 = mutated2;
|
||||
}
|
||||
|
||||
for (int i = 0; i < parent1.length; i++)
|
||||
if (parent1[i] != null && parent2[i] != null)
|
||||
for (int i = 0; i < parent1.length; i++) {
|
||||
if (parent1[i] != null && parent2[i] != null) {
|
||||
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
|
||||
IBee offspring = new Bee(world, new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
|
||||
|
||||
/* Disabling the mutation rate nerf
|
||||
// All mutation and no play makes queen a dull girl.
|
||||
if(mode.isDegenerating(this, offspring, housing))
|
||||
offspring.setIsNatural(false);*/
|
||||
|
||||
return offspring;
|
||||
return new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
|
||||
}
|
||||
|
||||
private IChromosome[] mutateSpecies(IBeeHousing housing, IGenome genomeOne, IGenome genomeTwo) {
|
||||
@@ -560,14 +637,12 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
|
||||
for (IBeeMutation mutation : PluginApiculture.beeInterface.getMutations(true)) {
|
||||
float chance = 0;
|
||||
|
||||
if ((chance = mutation.getChance(housing, allele0, allele1, genome0, genome1)) > 0)
|
||||
if (world.rand.nextFloat()*100 < chance) {
|
||||
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName());
|
||||
breedingTracker.registerMutation(mutation);
|
||||
return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate());
|
||||
}
|
||||
float chance = mutation.getChance(housing, allele0, allele1, genome0, genome1);
|
||||
if (chance > world.rand.nextFloat() * 100) {
|
||||
IApiaristTracker breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(world, housing.getOwnerName());
|
||||
breedingTracker.registerMutation(mutation);
|
||||
return PluginApiculture.beeInterface.templateAsChromosomes(mutation.getTemplate());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -577,58 +652,39 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
@Override
|
||||
public IIndividual retrievePollen(IBeeHousing housing) {
|
||||
|
||||
int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
int chance = Math.round(genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
World world = housing.getWorld();
|
||||
Random random = world.rand;
|
||||
|
||||
// Correct speed
|
||||
if (housing.getWorld().rand.nextInt(100) >= chance)
|
||||
if (random.nextInt(100) >= chance) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
|
||||
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 2), -Math.round(area.z / 2));
|
||||
Vect area = getArea(genome, housing);
|
||||
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
|
||||
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
|
||||
if (area.x < 1)
|
||||
area.x = 1;
|
||||
if (area.y < 1)
|
||||
area.y = 1;
|
||||
if (area.z < 1)
|
||||
area.z = 1;
|
||||
IIndividual pollen = null;
|
||||
|
||||
// We have up to ten attempts
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect blockPos = Vect.add(housingPos, randomPos, offset);
|
||||
TileEntity tile = world.getTileEntity(blockPos.x, blockPos.y, blockPos.z);
|
||||
|
||||
Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z));
|
||||
|
||||
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
|
||||
posBlock = posBlock.add(offset);
|
||||
|
||||
TileEntity tile = housing.getWorld().getTileEntity(posBlock.x, posBlock.y, posBlock.z);
|
||||
if (!(tile instanceof IPollinatable)) {
|
||||
if (housing.getWorld().isAirBlock(posBlock.x, posBlock.y, posBlock.z))
|
||||
continue;
|
||||
|
||||
// Test for ersatz genomes
|
||||
for (Map.Entry<ItemStack, IIndividual> entry : AlleleManager.ersatzSpecimen.entrySet()) {
|
||||
if (!StackUtils.equals(housing.getWorld().getBlock(posBlock.x, posBlock.y, posBlock.z), entry.getKey()))
|
||||
continue;
|
||||
if (entry.getKey().getItemDamage() != housing.getWorld().getBlockMetadata(posBlock.x, posBlock.y, posBlock.z))
|
||||
continue;
|
||||
|
||||
// We matched, return ersatz genome
|
||||
return entry.getValue().copy();
|
||||
if (tile instanceof IPollinatable) {
|
||||
IPollinatable pitcher = (IPollinatable) tile;
|
||||
if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher)) {
|
||||
pollen = pitcher.getPollen();
|
||||
}
|
||||
|
||||
continue;
|
||||
} else {
|
||||
pollen = GeneticsUtil.getErsatzPollen(world, blockPos.x, blockPos.y, blockPos.z);
|
||||
}
|
||||
|
||||
IPollinatable pitcher = (IPollinatable) tile;
|
||||
if (!genome.getFlowerProvider().isAcceptedPollinatable(housing.getWorld(), pitcher))
|
||||
continue;
|
||||
|
||||
IIndividual pollen = pitcher.getPollen();
|
||||
|
||||
if (pollen != null)
|
||||
if (pollen != null) {
|
||||
return pollen;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -639,40 +695,41 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
World world = housing.getWorld();
|
||||
Random random = world.rand;
|
||||
|
||||
// Correct speed
|
||||
if (housing.getWorld().rand.nextInt(100) >= chance)
|
||||
if (random.nextInt(100) >= chance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
|
||||
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 4), -Math.round(area.z / 2));
|
||||
Vect area = getArea(genome, housing);
|
||||
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
|
||||
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
|
||||
if (area.x < 1)
|
||||
area.x = 1;
|
||||
if (area.y < 1)
|
||||
area.y = 1;
|
||||
if (area.z < 1)
|
||||
area.z = 1;
|
||||
|
||||
// We have up to ten attempts
|
||||
for (int i = 0; i < 30; i++) {
|
||||
|
||||
Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z));
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect posBlock = Vect.add(housingPos, randomPos, offset);
|
||||
|
||||
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
|
||||
posBlock = posBlock.add(offset);
|
||||
|
||||
IPollinatable receiver = Utils.getOrCreatePollinatable(housing.getOwnerName(), housing.getWorld(), posBlock.x, posBlock.y, posBlock.z);
|
||||
if(receiver == null)
|
||||
ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock.x, posBlock.y, posBlock.z);
|
||||
if (checkPollinatable == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!genome.getFlowerProvider().isAcceptedPollinatable(housing.getWorld(), receiver))
|
||||
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, new FakePollinatable(checkPollinatable))) {
|
||||
continue;
|
||||
if (!receiver.canMateWith(pollen))
|
||||
}
|
||||
if (!checkPollinatable.canMateWith(pollen)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
receiver.mateWith(pollen);
|
||||
return true;
|
||||
IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z);
|
||||
|
||||
if (realPollinatable != null) {
|
||||
realPollinatable.mateWith(pollen);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -681,35 +738,35 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
@Override
|
||||
public void plantFlowerRandom(IBeeHousing housing) {
|
||||
|
||||
int chance = (int) (genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
int chance = Math.round(genome.getFlowering() * housing.getFloweringModifier(getGenome(), 1f));
|
||||
|
||||
World world = housing.getWorld();
|
||||
Random random = world.rand;
|
||||
|
||||
// Correct speed
|
||||
if (housing.getWorld().rand.nextInt(100) >= chance)
|
||||
if (random.nextInt(100) >= chance) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Gather required info
|
||||
IFlowerProvider provider = genome.getFlowerProvider();
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr[0], areaAr[1], areaAr[2]).multiply(housing.getTerritoryModifier(genome, 1f)).multiply(3.0f);
|
||||
Vect offset = new Vect(-Math.round(area.x / 2), -Math.round(area.y / 4), -Math.round(area.z / 2));
|
||||
Vect area = getArea(genome, housing);
|
||||
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
|
||||
Vect housingPos = new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord());
|
||||
|
||||
if (area.x < 1)
|
||||
area.x = 1;
|
||||
if (area.y < 1)
|
||||
area.y = 1;
|
||||
if (area.z < 1)
|
||||
area.z = 1;
|
||||
|
||||
// We have up to ten attempts
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect posBlock = Vect.add(housingPos, randomPos, offset);
|
||||
|
||||
Vect randomPos = new Vect(housing.getWorld().rand.nextInt(area.x), housing.getWorld().rand.nextInt(area.y), housing.getWorld().rand.nextInt(area.z));
|
||||
|
||||
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
|
||||
posBlock = posBlock.add(offset);
|
||||
|
||||
if (provider.growFlower(housing.getWorld(), this, posBlock.x, posBlock.y, posBlock.z))
|
||||
if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Vect getArea(IBeeGenome genome, IBeeHousing housing) {
|
||||
int[] genomeTerritory = genome.getTerritory();
|
||||
float housingModifier = housing.getTerritoryModifier(genome, 1f);
|
||||
return new Vect(genomeTerritory).multiply(housingModifier * 3.0f);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,15 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IAlleleBeeEffect;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
@@ -26,39 +29,37 @@ import forestry.core.genetics.AlleleArea;
|
||||
import forestry.core.genetics.AlleleBoolean;
|
||||
import forestry.core.genetics.AlleleTolerance;
|
||||
import forestry.core.genetics.Genome;
|
||||
import forestry.core.utils.Vect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class BeeGenome extends Genome implements IBeeGenome {
|
||||
/**
|
||||
* 0 - Species (determines product)
|
||||
*
|
||||
*
|
||||
* 1 - Speed
|
||||
*
|
||||
*
|
||||
* 2 - Lifespan
|
||||
*
|
||||
*
|
||||
* 3 - Fertility (Maximum number of offspring)
|
||||
*
|
||||
*
|
||||
* 4 - Preferred temperature Icy: Snow biomes Cold: Tundra/Steppe, Extreme Mountains/Hills? Normal: Plains, Forests, Mountains Hot: Desert Hellish: Nether
|
||||
*
|
||||
*
|
||||
* 5 - Temperature tolerance (Range +/-)
|
||||
*
|
||||
*
|
||||
* 6 - Nocturnal
|
||||
*
|
||||
*
|
||||
* 7 - Preferred humidity (Arid - Normal - Damp)
|
||||
*
|
||||
*
|
||||
* 8 - Humidity tolerance (Range +/-)
|
||||
*
|
||||
*
|
||||
* 9 - Flight interference tolerance (stuff falling from the sky/other hindrances -> tolerates dampness + flight interference tolerance => rain resistance)
|
||||
*
|
||||
*
|
||||
* 10 - Cave dwelling
|
||||
*
|
||||
*
|
||||
* 11 - Required flowers
|
||||
*
|
||||
*
|
||||
* 12 - Flower plant chance
|
||||
*
|
||||
*
|
||||
* 13 - Territory
|
||||
*/
|
||||
/* CONSTRUCTOR */
|
||||
@@ -72,83 +73,84 @@ public class BeeGenome extends Genome implements IBeeGenome {
|
||||
|
||||
// NBT RETRIEVAL
|
||||
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
|
||||
IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumBeeChromosome.SPECIES);
|
||||
if (speciesAllele instanceof IAlleleBeeSpecies)
|
||||
return (IAlleleBeeSpecies)speciesAllele;
|
||||
else
|
||||
IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumBeeChromosome.SPECIES);
|
||||
if (speciesAllele instanceof IAlleleBeeSpecies) {
|
||||
return (IAlleleBeeSpecies) speciesAllele;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// / INFORMATION RETRIEVAL
|
||||
@Override
|
||||
public IAlleleBeeSpecies getPrimary() {
|
||||
return (IAlleleBeeSpecies) getActiveAllele(EnumBeeChromosome.SPECIES.ordinal());
|
||||
return (IAlleleBeeSpecies) getActiveAllele(EnumBeeChromosome.SPECIES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAlleleBeeSpecies getSecondary() {
|
||||
return (IAlleleBeeSpecies) getInactiveAllele(EnumBeeChromosome.SPECIES.ordinal());
|
||||
return (IAlleleBeeSpecies) getInactiveAllele(EnumBeeChromosome.SPECIES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSpeed() {
|
||||
return ((IAlleleFloat) getActiveAllele(EnumBeeChromosome.SPEED.ordinal())).getValue();
|
||||
return ((IAlleleFloat) getActiveAllele(EnumBeeChromosome.SPEED)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLifespan() {
|
||||
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.LIFESPAN.ordinal())).getValue();
|
||||
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.LIFESPAN)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFertility() {
|
||||
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FERTILITY.ordinal())).getValue();
|
||||
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FERTILITY)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTolerance getToleranceTemp() {
|
||||
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal())).getValue();
|
||||
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getNocturnal() {
|
||||
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.NOCTURNAL.ordinal())).getValue();
|
||||
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.NOCTURNAL)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTolerance getToleranceHumid() {
|
||||
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal())).getValue();
|
||||
return ((AlleleTolerance) getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTolerantFlyer() {
|
||||
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.TOLERANT_FLYER.ordinal())).getValue();
|
||||
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.TOLERANT_FLYER)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCaveDwelling() {
|
||||
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.CAVE_DWELLING.ordinal())).getValue();
|
||||
return ((AlleleBoolean) getActiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlowerProvider getFlowerProvider() {
|
||||
return ((IAlleleFlowers) getActiveAllele(EnumBeeChromosome.FLOWER_PROVIDER.ordinal())).getProvider();
|
||||
return ((IAlleleFlowers) getActiveAllele(EnumBeeChromosome.FLOWER_PROVIDER)).getProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlowering() {
|
||||
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FLOWERING.ordinal())).getValue();
|
||||
return ((IAlleleInteger) getActiveAllele(EnumBeeChromosome.FLOWERING)).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getTerritory() {
|
||||
Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY.ordinal())).getArea();
|
||||
return new int[] { area.x, area.y, area.z };
|
||||
Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea();
|
||||
return new int[]{area.x, area.y, area.z};
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAlleleBeeEffect getEffect() {
|
||||
return (IAlleleBeeEffect) getActiveAllele(EnumBeeChromosome.EFFECT.ordinal());
|
||||
return (IAlleleBeeEffect) getActiveAllele(EnumBeeChromosome.EFFECT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -13,7 +13,6 @@ package forestry.apiculture.genetics;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -22,10 +21,10 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
@@ -69,12 +68,12 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
public int getSpeciesCount() {
|
||||
if (beeSpeciesCount < 0) {
|
||||
beeSpeciesCount = 0;
|
||||
Iterator<Entry<String, IAllele> > it = AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<String, IAllele> entry = it.next();
|
||||
if (entry.getValue() instanceof IAlleleBeeSpecies)
|
||||
if (((IAlleleBeeSpecies) entry.getValue()).isCounted())
|
||||
for (Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
|
||||
if (entry.getValue() instanceof IAlleleBeeSpecies) {
|
||||
if (((IAlleleBeeSpecies) entry.getValue()).isCounted()) {
|
||||
beeSpeciesCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,26 +97,26 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public ItemStack getMemberStack(IIndividual bee, int type) {
|
||||
if (!isMember(bee))
|
||||
if (!isMember(bee)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Item beeItem = null;
|
||||
Item beeItem;
|
||||
switch (EnumBeeType.VALUES[type]) {
|
||||
case QUEEN:
|
||||
beeItem = ForestryItem.beeQueenGE.item();
|
||||
break;
|
||||
case PRINCESS:
|
||||
beeItem = ForestryItem.beePrincessGE.item();
|
||||
break;
|
||||
case DRONE:
|
||||
beeItem = ForestryItem.beeDroneGE.item();
|
||||
break;
|
||||
case LARVAE:
|
||||
beeItem = ForestryItem.beeLarvaeGE.item();
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Cannot instantiate a bee of type " + type);
|
||||
|
||||
case QUEEN:
|
||||
beeItem = ForestryItem.beeQueenGE.item();
|
||||
break;
|
||||
case PRINCESS:
|
||||
beeItem = ForestryItem.beePrincessGE.item();
|
||||
break;
|
||||
case DRONE:
|
||||
beeItem = ForestryItem.beeDroneGE.item();
|
||||
break;
|
||||
case LARVAE:
|
||||
beeItem = ForestryItem.beeLarvaeGE.item();
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Cannot instantiate a bee of type " + type);
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
@@ -129,17 +128,19 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public EnumBeeType getType(ItemStack stack) {
|
||||
if (stack == null)
|
||||
if (stack == null) {
|
||||
return EnumBeeType.NONE;
|
||||
}
|
||||
|
||||
if (ForestryItem.beeDroneGE.isItemEqual(stack))
|
||||
if (ForestryItem.beeDroneGE.isItemEqual(stack)) {
|
||||
return EnumBeeType.DRONE;
|
||||
else if (ForestryItem.beePrincessGE.isItemEqual(stack))
|
||||
} else if (ForestryItem.beePrincessGE.isItemEqual(stack)) {
|
||||
return EnumBeeType.PRINCESS;
|
||||
else if (ForestryItem.beeQueenGE.isItemEqual(stack))
|
||||
} else if (ForestryItem.beeQueenGE.isItemEqual(stack)) {
|
||||
return EnumBeeType.QUEEN;
|
||||
else if (ForestryItem.beeLarvaeGE.isItemEqual(stack))
|
||||
} else if (ForestryItem.beeLarvaeGE.isItemEqual(stack)) {
|
||||
return EnumBeeType.LARVAE;
|
||||
}
|
||||
|
||||
return EnumBeeType.NONE;
|
||||
}
|
||||
@@ -151,8 +152,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public boolean isMated(ItemStack stack) {
|
||||
if (getType(stack) != EnumBeeType.QUEEN)
|
||||
if (getType(stack) != EnumBeeType.QUEEN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IBee bee = getMember(stack);
|
||||
return bee.getMate() != null;
|
||||
@@ -160,9 +162,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public IBee getMember(ItemStack stack) {
|
||||
if (!ForestryItem.beeQueenGE.isItemEqual(stack) && !ForestryItem.beePrincessGE.isItemEqual(stack)
|
||||
&& !ForestryItem.beeDroneGE.isItemEqual(stack) && !ForestryItem.beeLarvaeGE.isItemEqual(stack))
|
||||
if (!isMember(stack)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Bee(stack.getTagCompound());
|
||||
}
|
||||
@@ -174,12 +176,12 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public IBee getBee(World world, IBeeGenome genome) {
|
||||
return new Bee(world, genome);
|
||||
return new Bee(genome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBee getBee(World world, IBeeGenome genome, IBee mate) {
|
||||
return new Bee(world, genome, mate);
|
||||
return new Bee(genome, mate);
|
||||
}
|
||||
|
||||
/* GENOME CONVERSIONS */
|
||||
@@ -204,7 +206,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
}
|
||||
|
||||
/* TEMPLATES */
|
||||
public static ArrayList<IBee> beeTemplates = new ArrayList<IBee>();
|
||||
public static final ArrayList<IBee> beeTemplates = new ArrayList<IBee>();
|
||||
|
||||
@Override
|
||||
public ArrayList<IBee> getIndividualTemplates() {
|
||||
@@ -226,29 +228,33 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
/**
|
||||
* List of possible mutations on species alleles.
|
||||
*/
|
||||
private static ArrayList<IBeeMutation> beeMutations = new ArrayList<IBeeMutation>();
|
||||
private static final ArrayList<IBeeMutation> beeMutations = new ArrayList<IBeeMutation>();
|
||||
|
||||
@Override
|
||||
public Collection<IBeeMutation> getMutations(boolean shuffle) {
|
||||
if (shuffle)
|
||||
if (shuffle) {
|
||||
Collections.shuffle(beeMutations);
|
||||
}
|
||||
return beeMutations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMutation(IMutation mutation) {
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID()))
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) {
|
||||
return;
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID()))
|
||||
}
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) {
|
||||
return;
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID()))
|
||||
}
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) {
|
||||
return;
|
||||
}
|
||||
|
||||
beeMutations.add((IBeeMutation) mutation);
|
||||
}
|
||||
|
||||
/* BREEDING MODES */
|
||||
ArrayList<IBeekeepingMode> beekeepingModes = new ArrayList<IBeekeepingMode>();
|
||||
final ArrayList<IBeekeepingMode> beekeepingModes = new ArrayList<IBeekeepingMode>();
|
||||
public static IBeekeepingMode activeBeekeepingMode;
|
||||
|
||||
@Override
|
||||
@@ -263,14 +269,16 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public IBeekeepingMode getBeekeepingMode(World world) {
|
||||
if (activeBeekeepingMode != null)
|
||||
if (activeBeekeepingMode != null) {
|
||||
return activeBeekeepingMode;
|
||||
}
|
||||
|
||||
// No beekeeping mode yet, get it.
|
||||
IApiaristTracker tracker = getBreedingTracker(world, null);
|
||||
String mode = tracker.getModeName();
|
||||
if (mode == null || mode.isEmpty())
|
||||
if (mode == null || mode.isEmpty()) {
|
||||
mode = PluginApiculture.beekeepingMode;
|
||||
}
|
||||
|
||||
setBeekeepingMode(world, mode);
|
||||
FMLCommonHandler.instance().getFMLLogger().debug("Set beekeeping mode for a world to " + mode);
|
||||
@@ -292,8 +300,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
@Override
|
||||
public IBeekeepingMode getBeekeepingMode(String name) {
|
||||
for (IBeekeepingMode mode : beekeepingModes) {
|
||||
if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH)))
|
||||
if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH))) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().getFMLLogger().debug("Failed to find a beekeeping mode called '%s', reverting to fallback.");
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -40,7 +40,7 @@ public class BeeMutation extends Mutation implements IBeeMutation {
|
||||
public BeeMutation(IAllele allele0, IAllele allele1, IAllele[] template, int chance) {
|
||||
super(allele0, allele1, template, chance);
|
||||
|
||||
root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
|
||||
root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
|
||||
PluginApiculture.beeInterface.registerMutation(this);
|
||||
}
|
||||
|
||||
@@ -78,49 +78,58 @@ public class BeeMutation extends Mutation implements IBeeMutation {
|
||||
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
|
||||
|
||||
World world = housing.getWorld();
|
||||
if (requiresDay && !world.isDaytime())
|
||||
if (requiresDay && !world.isDaytime()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (requiresNight && world.isDaytime())
|
||||
if (requiresNight && world.isDaytime()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Skip if we are restricted by biomes and this one does not match.
|
||||
if (restrictBiomeTypes.size() > 0) {
|
||||
boolean noneMatched = true;
|
||||
|
||||
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
|
||||
if(strictBiomeCheck) {
|
||||
if (strictBiomeCheck) {
|
||||
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
|
||||
if(types.length == 1 && restrictBiomeTypes.contains(types[0]))
|
||||
if (types.length == 1 && restrictBiomeTypes.contains(types[0])) {
|
||||
noneMatched = false;
|
||||
}
|
||||
} else {
|
||||
for(BiomeDictionary.Type type : restrictBiomeTypes) {
|
||||
if(BiomeDictionary.isBiomeOfType(biome, type)) {
|
||||
for (BiomeDictionary.Type type : restrictBiomeTypes) {
|
||||
if (BiomeDictionary.isBiomeOfType(biome, type)) {
|
||||
noneMatched = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (noneMatched)
|
||||
if (noneMatched) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(housing.getXCoord(), housing.getZCoord());
|
||||
if (biome.temperature < minTemperature || biome.temperature > maxTemperature)
|
||||
if (biome.temperature < minTemperature || biome.temperature > maxTemperature) {
|
||||
return 0;
|
||||
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall)
|
||||
}
|
||||
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float processedChance = chance * housing.getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f)
|
||||
* PluginApiculture.beeInterface.getBeekeepingMode(world).getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f);
|
||||
if(processedChance <= 0)
|
||||
if (processedChance <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID()))
|
||||
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) {
|
||||
return processedChance;
|
||||
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID()))
|
||||
}
|
||||
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) {
|
||||
return processedChance;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IMutation;
|
||||
@@ -98,24 +100,27 @@ public class BeeTemplates {
|
||||
public static IMutation vengefulB;
|
||||
public static IMutation avengingA;
|
||||
|
||||
public static IAllele[] defaultTemplate;
|
||||
|
||||
public static IAllele[] getDefaultTemplate() {
|
||||
IAllele[] alleles = new IAllele[EnumBeeChromosome.values().length];
|
||||
if (defaultTemplate == null) {
|
||||
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
|
||||
|
||||
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesForest;
|
||||
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
|
||||
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShorter;
|
||||
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityNormal;
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceNone;
|
||||
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolFalse;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceNone;
|
||||
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolFalse;
|
||||
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolFalse;
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersVanilla;
|
||||
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlowest;
|
||||
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryDefault;
|
||||
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectNone;
|
||||
|
||||
return alleles;
|
||||
defaultTemplate[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesForest;
|
||||
defaultTemplate[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
|
||||
defaultTemplate[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShorter;
|
||||
defaultTemplate[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityNormal;
|
||||
defaultTemplate[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceNone;
|
||||
defaultTemplate[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolFalse;
|
||||
defaultTemplate[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceNone;
|
||||
defaultTemplate[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolFalse;
|
||||
defaultTemplate[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolFalse;
|
||||
defaultTemplate[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersVanilla;
|
||||
defaultTemplate[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlowest;
|
||||
defaultTemplate[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryDefault;
|
||||
defaultTemplate[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectNone;
|
||||
}
|
||||
return Arrays.copyOf(defaultTemplate, defaultTemplate.length);
|
||||
}
|
||||
|
||||
// / COMMON BRANCH
|
||||
@@ -288,7 +293,7 @@ public class BeeTemplates {
|
||||
public static IAllele[] getAustereBranchTemplate() {
|
||||
IAllele[] alleles = getDefaultTemplate();
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1;
|
||||
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersCacti;
|
||||
return alleles;
|
||||
@@ -323,8 +328,8 @@ public class BeeTemplates {
|
||||
// / TROPICAL BRANCH
|
||||
public static IAllele[] getTropicalBranchTemplate() {
|
||||
IAllele[] alleles = getDefaultTemplate();
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1;
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1;
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersJungle;
|
||||
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMiasmic;
|
||||
return alleles;
|
||||
@@ -396,6 +401,7 @@ public class BeeTemplates {
|
||||
public static IAllele[] getFrozenBranchTemplate() {
|
||||
IAllele[] alleles = getDefaultTemplate();
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersSnow;
|
||||
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectGlacial;
|
||||
return alleles;
|
||||
@@ -543,13 +549,30 @@ public class BeeTemplates {
|
||||
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesRural;
|
||||
return alleles;
|
||||
}
|
||||
|
||||
public static IAllele[] getFarmerlyTemplate() {
|
||||
IAllele[] alleles = getAgrarianBranchTemplate();
|
||||
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesFarmerly;
|
||||
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
|
||||
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
|
||||
return alleles;
|
||||
}
|
||||
|
||||
public static IAllele[] getAgrarianTemplate() {
|
||||
IAllele[] alleles = getAgrarianBranchTemplate();
|
||||
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesArgrarian;
|
||||
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlow;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth2;
|
||||
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectFertile;
|
||||
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarge;
|
||||
return alleles;
|
||||
}
|
||||
|
||||
// / BOGGY BRANCH
|
||||
public static IAllele[] getBoggyBranchTemplate() {
|
||||
IAllele[] alleles = getDefaultTemplate();
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersMushrooms;
|
||||
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
return alleles;
|
||||
}
|
||||
@@ -559,6 +582,25 @@ public class BeeTemplates {
|
||||
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMarshy;
|
||||
return alleles;
|
||||
}
|
||||
|
||||
public static IAllele[] getMiryTemplate() {
|
||||
IAllele[] alleles = getBoggyBranchTemplate();
|
||||
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesMiry;
|
||||
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityMaximum;
|
||||
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
|
||||
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
|
||||
return alleles;
|
||||
}
|
||||
|
||||
public static IAllele[] getBoggyTemplate() {
|
||||
IAllele[] alleles = getBoggyBranchTemplate();
|
||||
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesBoggy;
|
||||
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolTrue;
|
||||
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
|
||||
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMycophilic;
|
||||
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarger;
|
||||
return alleles;
|
||||
}
|
||||
|
||||
/* MONASTIC BRANCH */
|
||||
public static IAllele[] getMonasticBranchTemplate() {
|
||||
|
||||
Loaded 100 of 974 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user