mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00c31a6158 | ||
|
|
5db5b712ce | ||
|
|
9cac9a14df | ||
|
|
43f98e9cca | ||
|
|
ff4c09324b | ||
|
|
d1c17a13b1 | ||
|
|
8a8ac56266 | ||
|
|
208de8ad3a | ||
|
|
d988fb849d | ||
|
|
ab83d90dd3 | ||
|
|
79c5cff926 | ||
|
|
5522c33924 | ||
|
|
93aa429cf2 | ||
|
|
fa5c4c0218 | ||
|
|
32691c6af4 | ||
|
|
5615ffc518 | ||
|
|
2af41cf68d | ||
|
|
0cdaf8cff8 | ||
|
|
7b5eafc42a | ||
|
|
59ca1d2082 | ||
|
|
0df88973c0 | ||
|
|
e54bb5d4ea | ||
|
|
824f155804 | ||
|
|
24e2cf668e | ||
|
|
f260099bfa | ||
|
|
855d359b02 | ||
|
|
abcb180689 | ||
|
|
507adb1b3f | ||
|
|
23c4e4ed91 | ||
|
|
e5057788a8 | ||
|
|
a5045bfc0f | ||
|
|
bfd678c63e | ||
|
|
320ea99090 | ||
|
|
08f16ba26d | ||
|
|
9419dc82de | ||
|
|
2d1f64c5f6 | ||
|
|
cd9f82001c | ||
|
|
f7b8435d28 | ||
|
|
013806f158 | ||
|
|
062b5ee75f | ||
|
|
56adc25fdf | ||
|
|
df375b1b30 | ||
|
|
789da29af0 | ||
|
|
e0df2f84a0 | ||
|
|
01656f13a6 | ||
|
|
b466e9ce4a | ||
|
|
60c9dad874 | ||
|
|
d734ca55e6 | ||
|
|
f16f349f10 | ||
|
|
66561ac66d | ||
|
|
ad96e21b37 | ||
|
|
3967d21b06 | ||
|
|
2a025254a0 | ||
|
|
97bfbe2213 | ||
|
|
98c56973db | ||
|
|
b83da5c628 | ||
|
|
4a2af4743f | ||
|
|
e90771e38a | ||
|
|
9c98a6a00b | ||
|
|
75a3a7b935 | ||
|
|
99020cde7f | ||
|
|
98e13299d6 | ||
|
|
010fe4662a | ||
|
|
92ee6dbc0d | ||
|
|
98c7b3b5ed | ||
|
|
507b03043e | ||
|
|
c1e00ff395 | ||
|
|
897123c883 | ||
|
|
0ed33cf9a3 | ||
|
|
8ba8c0fb17 | ||
|
|
9c40b03751 | ||
|
|
194c0a0e77 | ||
|
|
77157aa9cb | ||
|
|
f4681d251c | ||
|
|
96cc1b869c | ||
|
|
20ca044be0 | ||
|
|
6cd9f33c3f | ||
|
|
7585c6a265 | ||
|
|
91a5084bde | ||
|
|
0876a50be2 | ||
|
|
1941690330 | ||
|
|
bbd39ea5c7 | ||
|
|
53f4107ee3 | ||
|
|
6265c01f60 | ||
|
|
b9478e16b7 | ||
|
|
2cdee67624 | ||
|
|
58fe331fe3 | ||
|
|
a4d5117a97 | ||
|
|
32a9a6ff5c | ||
|
|
9f2f2ed85b | ||
|
|
22258c2dac | ||
|
|
e0c1c538aa | ||
|
|
825768e522 | ||
|
|
dd21d83ea3 | ||
|
|
d0ead16eaa | ||
|
|
1d924d5ed5 | ||
|
|
ff7adac9e1 | ||
|
|
45993f8213 | ||
|
|
33573fea20 | ||
|
|
178142bf7a | ||
|
|
5d2aaea757 | ||
|
|
fbb02e43f5 | ||
|
|
896767ae1b | ||
|
|
d11034e4aa | ||
|
|
cc64b09ad4 | ||
|
|
d5ebc02999 | ||
|
|
8415b657f2 | ||
|
|
f0099b728f | ||
|
|
1ceccddbd0 | ||
|
|
c875e8ed5d | ||
|
|
f3ee4f8694 | ||
|
|
c2437a8a13 | ||
|
|
e2f32ab767 | ||
|
|
d0c8c92863 | ||
|
|
a8c84cfcf9 | ||
|
|
8f8f6a05f7 | ||
|
|
721c8fd0ad | ||
|
|
962a17494c | ||
|
|
01e43d8a18 | ||
|
|
4228ef73d7 | ||
|
|
6b9614bccd | ||
|
|
179311a390 | ||
|
|
d8bcab07ba | ||
|
|
2368f05778 | ||
|
|
347e0a61e1 | ||
|
|
23792a84c1 | ||
|
|
b4c0777f1c | ||
|
|
db5daf9e3d | ||
|
|
a574eac903 | ||
|
|
b3799c22e6 | ||
|
|
97d10fdba3 | ||
|
|
e03400fc6a | ||
|
|
2a35c1072b | ||
|
|
a4dd450ff8 | ||
|
|
8df8404a84 | ||
|
|
54e73da1d5 | ||
|
|
7d83e28a03 | ||
|
|
db7736f7d2 | ||
|
|
eff9dfcca7 | ||
|
|
2b874fb42f | ||
|
|
27daa8e1ac | ||
|
|
a49eb1c5f9 | ||
|
|
7e3b7acdef | ||
|
|
9c532dd076 | ||
|
|
3de8bac1ad | ||
|
|
abca8b13f3 | ||
|
|
3c7856f264 | ||
|
|
408a66bb40 | ||
|
|
31231db459 | ||
|
|
67a7185261 | ||
|
|
aeaf113b11 | ||
|
|
084a84903f | ||
|
|
167e493160 | ||
|
|
ce2a2ec8ed | ||
|
|
10e5391f48 | ||
|
|
ffe19807db | ||
|
|
6cfae1462f | ||
|
|
18a0ae3643 | ||
|
|
358522b2af | ||
|
|
ade9bb6940 | ||
|
|
23fd664e34 | ||
|
|
60d5728ccb | ||
|
|
55118e399f | ||
|
|
7e50c57ba9 | ||
|
|
317dd0dbf9 | ||
|
|
e9af62e772 | ||
|
|
daa5e3bc75 | ||
|
|
e248f40f58 | ||
|
|
0e53fccfdb | ||
|
|
fc289c16d4 | ||
|
|
fe69452464 | ||
|
|
4c41d0bb6e | ||
|
|
0fe87253d1 | ||
|
|
4f19f95b71 | ||
|
|
a6ecc95f80 | ||
|
|
4b43ee9e8e | ||
|
|
f52059640e | ||
|
|
c96f260abd | ||
|
|
010c65b192 | ||
|
|
f2b95e1777 | ||
|
|
5f18a51827 | ||
|
|
eaad349b74 | ||
|
|
efd9cd06f6 | ||
|
|
2f16ca5828 | ||
|
|
d7c2f11ace | ||
|
|
d82db2f003 | ||
|
|
84b1fa8c07 | ||
|
|
723d07ab7c | ||
|
|
71b5f2f181 | ||
|
|
8d7dc86e9f | ||
|
|
5f2de3026e | ||
|
|
430115a7d4 | ||
|
|
a516886087 | ||
|
|
c6b1e65a4a | ||
|
|
e154d4e2c6 | ||
|
|
9247ed1509 | ||
|
|
0251691d66 | ||
|
|
d4cd0aaf7e | ||
|
|
90c9050e80 | ||
|
|
0713e0ea9c | ||
|
|
731d15fbd5 | ||
|
|
14bdab069e | ||
|
|
e73e18a3c7 | ||
|
|
fc69e25ea3 | ||
|
|
8465ff358a | ||
|
|
b7382f074a | ||
|
|
56a9e84800 | ||
|
|
01433d7741 | ||
|
|
fb595f7b26 | ||
|
|
53269c63ca | ||
|
|
63a48b2ea2 | ||
|
|
3770d34926 | ||
|
|
2ab553898f | ||
|
|
862feea792 | ||
|
|
bd8dbbeaf8 | ||
|
|
571bdd9b80 | ||
|
|
411b4959f2 | ||
|
|
f1afca664b | ||
|
|
d1fe7eee92 | ||
|
|
08812ae5ea | ||
|
|
c9b145817e | ||
|
|
407496a0ad | ||
|
|
eb0a55d91c | ||
|
|
5b53c3f153 |
No files matched your search
+1
-1
@@ -3,7 +3,7 @@
|
||||
url = https://github.com/ForestryMC/Forestry-Localization.git
|
||||
[submodule "api/redstoneflux"]
|
||||
path = api/redstoneflux
|
||||
url = https://github.com/CoFH/RedstoneFlux-API.git
|
||||
url = https://github.com/Texasjake95/RedstoneFlux-API.git
|
||||
[submodule "api/forestry"]
|
||||
path = api/forestry
|
||||
url = https://github.com/ForestryMC/ForestryAPI.git
|
||||
+1
-1
Submodule api/forestry updated: 7aafb5e521...5e44fe9c6a.
+1
-1
Submodule api/redstoneflux updated: 10e10af214...b5771e4ef8.
+21
-12
@@ -35,8 +35,10 @@ ext.apiForestry = "./api/forestry"
|
||||
ext.apiRedstoneFlux = "./api/redstoneflux"
|
||||
|
||||
// java version
|
||||
sourceCompatibility = 1.7
|
||||
targetCompatibility = 1.7
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = mcversion + "-" + forgeversion
|
||||
@@ -82,12 +84,12 @@ repositories {
|
||||
configurations {
|
||||
api
|
||||
compile.extendsFrom api
|
||||
shade
|
||||
compile.extendsFrom shade
|
||||
//shade
|
||||
//compile.extendsFrom shade
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api 'net.industrial-craft:industrialcraft-2:2.2.713-experimental:api'
|
||||
api 'net.industrial-craft:industrialcraft-2:2.2.790-experimental:api'
|
||||
api name: "buildcraft", version: "7.1.12", classifier: "api"
|
||||
|
||||
// http://files.minecraftforge.net/CodeChickenLib/
|
||||
@@ -99,7 +101,7 @@ dependencies {
|
||||
compile "codechicken:NotEnoughItems:1.7.10-1.0.5.111:src"
|
||||
|
||||
// http://maven.tterrag.com/
|
||||
shade "chylex.javacheck:JavaChecker:v1.2-b1"
|
||||
//shade "chylex.javacheck:JavaChecker:v1.2-b1"
|
||||
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
@@ -154,12 +156,15 @@ jar {
|
||||
into ('cofh/api') {
|
||||
from project.apiRedstoneFlux + "/LICENSE - LGPLv3.txt"
|
||||
}
|
||||
|
||||
configurations.shade.each{ dep ->
|
||||
from(project.zipTree(dep)){
|
||||
exclude 'META-INF', 'META-INF/**', 'mcmod.info'
|
||||
}
|
||||
into ('invtweaks/api') {
|
||||
from "./src/main/java/invtweaks/LICENSE.txt"
|
||||
}
|
||||
|
||||
//configurations.shade.each{ dep ->
|
||||
// from(project.zipTree(dep)){
|
||||
// exclude 'META-INF', 'META-INF/**', 'mcmod.info'
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
task mainJar(type: Jar, dependsOn: 'reobf') {
|
||||
@@ -174,7 +179,7 @@ task mainJar(type: Jar, dependsOn: 'reobf') {
|
||||
includeEmptyDirs = false
|
||||
|
||||
manifest{
|
||||
attributes 'TweakClass': 'forestry.shade.javacheck.Java7Checker'
|
||||
//attributes 'TweakClass': 'forestry.shade.javacheck.Java7Checker'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,3 +257,7 @@ def getBuildNumber() {
|
||||
return "$System.env.BUILD_NUMBER" != "null" ? "$System.env.BUILD_NUMBER" : "0"
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main { output.resourcesDir = output.classesDir }
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
mcversion=1.7.10
|
||||
forgeversion=10.13.4.1541-1.7.10
|
||||
forgeversion=10.13.4.1614-1.7.10
|
||||
version_major=4
|
||||
version_minor=1
|
||||
version_patch=1
|
||||
version_minor=2
|
||||
version_patch=26
|
||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,6 +1,6 @@
|
||||
#Wed Jul 02 15:54:47 CDT 2014
|
||||
#Sat Jan 04 01:52:14 CET 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip
|
||||
+1
-1
Submodule lang updated: 2843053395...4cfdcf1595.
@@ -11,35 +11,43 @@
|
||||
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 net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
|
||||
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.Type;
|
||||
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.core.ForestryCore;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.EventHandlerCore;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.config.GameMode;
|
||||
import forestry.core.config.Version;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.errors.ErrorStateRegistry;
|
||||
import forestry.core.gui.GuiHandler;
|
||||
import forestry.core.multiblock.MultiblockEventHandler;
|
||||
import forestry.core.network.PacketHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.datastructures.FluidMap;
|
||||
import forestry.core.utils.datastructures.ItemStackMap;
|
||||
import forestry.core.worldgen.WorldGenerator;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
/**
|
||||
* Forestry Minecraft Mod
|
||||
@@ -51,7 +59,7 @@ import forestry.core.utils.datastructures.ItemStackMap;
|
||||
name = "Forestry",
|
||||
version = Version.VERSION,
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
dependencies = "required-after:Forge@[10.13.0.1207,);"
|
||||
dependencies = "required-after:Forge@[10.13.4.1566,);"
|
||||
+ "after:Buildcraft|Core@[6.1.7,);"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
+ "after:BiomesOPlenty;"
|
||||
@@ -64,73 +72,70 @@ public class Forestry {
|
||||
public static Forestry instance;
|
||||
private File configFolder;
|
||||
|
||||
private static final Map<String, ForestryItem> mappedItems = new HashMap<>();
|
||||
|
||||
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<>();
|
||||
FuelManager.moistenerResource = new ItemStackMap<>();
|
||||
FuelManager.rainSubstrate = new ItemStackMap<>();
|
||||
FuelManager.bronzeEngineFuel = new FluidMap<>();
|
||||
FuelManager.copperEngineFuel = new ItemStackMap<>();
|
||||
FuelManager.generatorFuel = new FluidMap<>();
|
||||
ForestryAPI.instance = this;
|
||||
ForestryAPI.forestryConstants = new Constants();
|
||||
ForestryAPI.errorStateRegistry = new ErrorStateRegistry();
|
||||
EnumErrorCode.init();
|
||||
}
|
||||
|
||||
@SidedProxy(clientSide = "forestry.core.ForestryClient", serverSide = "forestry.core.ForestryCore")
|
||||
public static ForestryCore core = new ForestryCore();
|
||||
public static PacketHandler packetHandler;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
packetHandler = new PacketHandler();
|
||||
|
||||
configFolder = new File(event.getModConfigurationDirectory(), "forestry");
|
||||
|
||||
core.preInit(event.getSourceFile(), this);
|
||||
// Register event handler
|
||||
EventHandlerCore eventHandlerCore = new EventHandlerCore();
|
||||
MinecraftForge.EVENT_BUS.register(eventHandlerCore);
|
||||
FMLCommonHandler.instance().bus().register(eventHandlerCore);
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
|
||||
|
||||
configFolder = new File(event.getModConfigurationDirectory(), "forestry");
|
||||
Config.load();
|
||||
|
||||
PluginManager.runSetup();
|
||||
|
||||
ForestryAPI.activeMode = new GameMode(Config.gameMode);
|
||||
|
||||
PluginManager.runPreInit();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
core.init(this);
|
||||
// Register gui handler
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
|
||||
|
||||
PluginManager.runInit();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
core.postInit();
|
||||
PluginManager.runPostInit();
|
||||
|
||||
// Register world generator
|
||||
WorldGenerator worldGenerator = new WorldGenerator();
|
||||
GameRegistry.registerWorldGenerator(worldGenerator, 0);
|
||||
|
||||
// Register tick handlers
|
||||
Proxies.common.registerTickHandlers(worldGenerator);
|
||||
|
||||
// Handle IMC messages.
|
||||
PluginManager.processIMCMessages(FMLInterModComms.fetchRuntimeMessages(ForestryAPI.instance));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
core.serverStarting(event.getServer());
|
||||
PluginManager.serverStarting(event.getServer());
|
||||
}
|
||||
|
||||
public File getConfigFolder() {
|
||||
return configFolder;
|
||||
}
|
||||
/*@EventHandler
|
||||
public void fingerprintWarning(FMLFingerprintViolationEvent event) {
|
||||
Log.info("Fingerprint of the mod jar is invalid. The jar file was tampered with.");
|
||||
FMLInterModComms.sendMessage("Railcraft", "securityViolation", "Fingerprint of jar file did not match.");
|
||||
FMLInterModComms.sendMessage("Thaumcraft", "securityViolation", "Fingerprint of jar file did not match.");
|
||||
FMLInterModComms.sendMessage("IC2", "securityViolation", "Fingerprint of jar file did not match.");
|
||||
}*/
|
||||
|
||||
@EventHandler
|
||||
public void processIMCMessages(IMCEvent event) {
|
||||
core.processIMCMessages(event.getMessages());
|
||||
PluginManager.processIMCMessages(event.getMessages());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -143,16 +148,10 @@ public class Forestry {
|
||||
Log.warning("Remapping block " + mapping.name + " to " + StringUtil.cleanBlockName(block));
|
||||
}
|
||||
} else {
|
||||
Block block = GameRegistry.findBlock(Constants.MOD, StringUtil.cleanTags(mapping.name));
|
||||
if (block != null) {
|
||||
mapping.remap(Item.getItemFromBlock(block));
|
||||
Log.warning("Remapping item " + mapping.name + " to " + StringUtil.cleanBlockName(block));
|
||||
} else {
|
||||
ForestryItem mappedItem = mappedItems.get(mapping.name);
|
||||
if (mappedItem != null) {
|
||||
mapping.remap(mappedItem.item());
|
||||
Log.warning("Remapping item " + mapping.name + " to " + mappedItem.name());
|
||||
}
|
||||
Item item = GameRegistry.findItem(Constants.MOD, StringUtil.cleanTags(mapping.name));
|
||||
if (item != null) {
|
||||
mapping.remap(item);
|
||||
Log.warning("Remapping item " + mapping.name + " to " + StringUtil.cleanItemName(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* 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 forestry.api.apiculture.DefaultBeeModifier;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
|
||||
public class AlvearyBeeModifier extends DefaultBeeModifier {
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 2.0f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*******************************************************************************
|
||||
* 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 forestry.api.apiculture.DefaultBeeListener;
|
||||
import forestry.apiculture.inventory.IApiaryInventory;
|
||||
|
||||
public class ApiaryBeeListener extends DefaultBeeListener {
|
||||
private final IApiary apiary;
|
||||
|
||||
public ApiaryBeeListener(IApiary apiary) {
|
||||
this.apiary = apiary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) {
|
||||
IApiaryInventory apiaryInventory = apiary.getApiaryInventory();
|
||||
apiaryInventory.wearOutFrames(apiary, amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*******************************************************************************
|
||||
* 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 forestry.api.apiculture.DefaultBeeModifier;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
|
||||
public class ApiaryBeeModifier extends DefaultBeeModifier {
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0.1f;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -20,7 +21,7 @@ import forestry.api.apiculture.IArmorApiaristHelper;
|
||||
public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||
|
||||
@Override
|
||||
public boolean isArmorApiarist(ItemStack stack, EntityPlayer player, String cause, boolean doProtect) {
|
||||
public boolean isArmorApiarist(ItemStack stack, EntityLivingBase entity, String cause, boolean doProtect) {
|
||||
if (stack == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -31,19 +32,38 @@ public class ArmorApiaristHelper implements IArmorApiaristHelper {
|
||||
}
|
||||
|
||||
IArmorApiarist armorApiarist = (IArmorApiarist) item;
|
||||
return armorApiarist.protectPlayer(player, stack, cause, doProtect);
|
||||
try {
|
||||
return armorApiarist.protectEntity(entity, stack, cause, doProtect);
|
||||
} catch (Throwable ignored) { // protectEntity is new to the API and may not be implemented by the armor
|
||||
if (entity instanceof EntityPlayer) {
|
||||
return armorApiarist.protectPlayer((EntityPlayer) entity, stack, cause, doProtect);
|
||||
} else {
|
||||
return true; // fallback on assuming IArmorApiarist will protect the entity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int wearsItems(EntityPlayer player, String cause, boolean doProtect) {
|
||||
public int wearsItems(EntityLivingBase entity, String cause, boolean doProtect) {
|
||||
int count = 0;
|
||||
|
||||
for (ItemStack armorItem : player.inventory.armorInventory) {
|
||||
if (isArmorApiarist(armorItem, player, cause, doProtect)) {
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
ItemStack armorItem = entity.getEquipmentInSlot(i);
|
||||
if (isArmorApiarist(armorItem, entity, cause, doProtect)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isArmorApiarist(ItemStack stack, EntityPlayer player, String cause, boolean doProtect) {
|
||||
return isArmorApiarist(stack, (EntityLivingBase) player, cause, doProtect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int wearsItems(EntityPlayer player, String cause, boolean doProtect) {
|
||||
return wearsItems((EntityLivingBase) player, cause, doProtect);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*******************************************************************************
|
||||
* 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 forestry.api.apiculture.DefaultBeeModifier;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
|
||||
public class BeehouseBeeModifier extends DefaultBeeModifier {
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 0.25f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
||||
return 3.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 3.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,12 @@ import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
@@ -35,9 +38,9 @@ import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.network.PacketBeekeepingLogicActive;
|
||||
import forestry.apiculture.network.packets.PacketBeeLogicActive;
|
||||
import forestry.apiculture.network.packets.PacketBeeLogicActiveEntity;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
@@ -113,9 +116,13 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
hasFlowersCache.writeToNBT(nbttagcompound);
|
||||
|
||||
Stack<ItemStack> spawnCopy = new Stack<>();
|
||||
spawnCopy.addAll(spawn);
|
||||
if (spawn.size()<128)
|
||||
spawnCopy.addAll(spawn);
|
||||
else
|
||||
for (byte b=0;b<128;++b)
|
||||
spawnCopy.add(spawn.get(b));
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
while (!spawnCopy.isEmpty()) {
|
||||
while (!spawnCopy.isEmpty() && spawnCopy.size()<=128) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
spawnCopy.pop().writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
@@ -162,20 +169,20 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
IBeeHousingInventory beeInventory = housing.getBeeInventory();
|
||||
|
||||
boolean hasSpace = addPendingProducts(beeInventory, spawn);
|
||||
errorLogic.setCondition(!hasSpace, EnumErrorCode.NOSPACE);
|
||||
errorLogic.setCondition(!hasSpace, EnumErrorCode.NO_SPACE_INVENTORY);
|
||||
|
||||
ItemStack queenStack = beeInventory.getQueen();
|
||||
|
||||
EnumBeeType beeType = BeeManager.beeRoot.getType(queenStack);
|
||||
// check if we're breeding
|
||||
if (ForestryItem.beePrincessGE.isItemEqual(queenStack)) {
|
||||
if (beeType == EnumBeeType.PRINCESS) {
|
||||
boolean hasDrone = BeeManager.beeRoot.isDrone(beeInventory.getDrone());
|
||||
errorLogic.setCondition(!hasDrone, EnumErrorCode.NODRONE);
|
||||
errorLogic.setCondition(!hasDrone, EnumErrorCode.NO_DRONE);
|
||||
|
||||
setActive(false); // not active (no bee FX) when we are breeding
|
||||
return !errorLogic.hasErrors();
|
||||
}
|
||||
|
||||
if (ForestryItem.beeQueenGE.isItemEqual(queenStack)) {
|
||||
if (beeType == EnumBeeType.QUEEN) {
|
||||
if (!isQueenAlive(queenStack)) {
|
||||
IBee dyingQueen = BeeManager.beeRoot.getMember(queenStack);
|
||||
Collection<ItemStack> spawned = killQueen(dyingQueen, housing, beeListener);
|
||||
@@ -191,7 +198,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
this.queenStack = queenStack;
|
||||
}
|
||||
|
||||
if (errorLogic.setCondition(queen == null, EnumErrorCode.NOQUEEN)) {
|
||||
if (errorLogic.setCondition(queen == null, EnumErrorCode.NO_QUEEN)) {
|
||||
setActive(false);
|
||||
beeProgress = 0;
|
||||
return false;
|
||||
@@ -203,7 +210,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
}
|
||||
|
||||
boolean hasFlowers = hasFlowersCache.hasFlowers(queen, housing);
|
||||
errorLogic.setCondition(!hasFlowers, EnumErrorCode.NOFLOWER);
|
||||
errorLogic.setCondition(!hasFlowers, EnumErrorCode.NO_FLOWER);
|
||||
|
||||
boolean canWork = !errorLogic.hasErrors();
|
||||
setActive(canWork);
|
||||
@@ -214,7 +221,8 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
public void doWork() {
|
||||
IBeeHousingInventory beeInventory = housing.getBeeInventory();
|
||||
ItemStack queenStack = beeInventory.getQueen();
|
||||
if (ForestryItem.beePrincessGE.isItemEqual(queenStack)) {
|
||||
EnumBeeType beeType = BeeManager.beeRoot.getType(queenStack);
|
||||
if (beeType == EnumBeeType.PRINCESS) {
|
||||
tickBreed();
|
||||
} else {
|
||||
queenWorkTick(queen);
|
||||
@@ -285,7 +293,13 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
|
||||
/** Checks if a queen is alive. Much faster than reading the whole bee nbt */
|
||||
private static boolean isQueenAlive(ItemStack queenStack) {
|
||||
if (queenStack == null) {
|
||||
return false;
|
||||
}
|
||||
NBTTagCompound nbtTagCompound = queenStack.getTagCompound();
|
||||
if (nbtTagCompound == null) {
|
||||
return false;
|
||||
}
|
||||
int health = nbtTagCompound.getInteger("Health");
|
||||
return health > 0;
|
||||
}
|
||||
@@ -299,7 +313,9 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
ItemStack droneStack = beeInventory.getDrone();
|
||||
ItemStack princessStack = beeInventory.getQueen();
|
||||
|
||||
if (!ForestryItem.beeDroneGE.isItemEqual(droneStack) || !ForestryItem.beePrincessGE.isItemEqual(princessStack)) {
|
||||
EnumBeeType droneType = BeeManager.beeRoot.getType(droneStack);
|
||||
EnumBeeType princessType = BeeManager.beeRoot.getType(princessStack);
|
||||
if (droneType != EnumBeeType.DRONE || princessType != EnumBeeType.PRINCESS) {
|
||||
beeProgress = 0;
|
||||
return;
|
||||
}
|
||||
@@ -318,7 +334,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
princess.writeToNBT(nbttagcompound);
|
||||
queenStack = ForestryItem.beeQueenGE.getItemStack();
|
||||
queenStack = new ItemStack(PluginApiculture.items.beeQueenGE);
|
||||
queenStack.setTagCompound(nbttagcompound);
|
||||
|
||||
beeInventory.setQueen(queenStack);
|
||||
@@ -355,7 +371,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
} else {
|
||||
Log.warning("Tried to spawn offspring off an unmated queen. Devolving her to a princess.");
|
||||
|
||||
ItemStack convert = ForestryItem.beePrincessGE.getItemStack();
|
||||
ItemStack convert = new ItemStack(PluginApiculture.items.beePrincessGE);
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
queen.writeToNBT(nbttagcompound);
|
||||
convert.setTagCompound(nbttagcompound);
|
||||
@@ -418,7 +434,23 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
public void syncToClient() {
|
||||
World world = housing.getWorld();
|
||||
if (world != null && !world.isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketBeekeepingLogicActive(housing), world);
|
||||
if (housing instanceof Entity) {
|
||||
Proxies.net.sendNetworkPacket(new PacketBeeLogicActiveEntity(housing, (Entity) housing), world);
|
||||
} else {
|
||||
Proxies.net.sendNetworkPacket(new PacketBeeLogicActive(housing), world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToClient(EntityPlayerMP player) {
|
||||
World world = housing.getWorld();
|
||||
if (world != null && !world.isRemote) {
|
||||
if (housing instanceof TileEntity) {
|
||||
Proxies.net.sendToPlayer(new PacketBeeLogicActive(housing), player);
|
||||
} else if (housing instanceof Entity) {
|
||||
Proxies.net.sendToPlayer(new PacketBeeLogicActiveEntity(housing, (Entity) housing), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
@@ -36,6 +37,11 @@ public class FakeBeekeepingLogic implements IBeekeepingLogic {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToClient(EntityPlayerMP player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBeeProgressPercent() {
|
||||
return 0;
|
||||
|
||||
@@ -1,180 +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.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.apiculture.gui.ContainerAlveary;
|
||||
import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
|
||||
import forestry.apiculture.gui.ContainerAlvearySieve;
|
||||
import forestry.apiculture.gui.ContainerAlvearySwarmer;
|
||||
import forestry.apiculture.gui.ContainerBeeHousing;
|
||||
import forestry.apiculture.gui.ContainerHabitatLocator;
|
||||
import forestry.apiculture.gui.ContainerImprinter;
|
||||
import forestry.apiculture.gui.GuiAlveary;
|
||||
import forestry.apiculture.gui.GuiAlvearyHygroregulator;
|
||||
import forestry.apiculture.gui.GuiAlvearySieve;
|
||||
import forestry.apiculture.gui.GuiAlvearySwarmer;
|
||||
import forestry.apiculture.gui.GuiBeeHousing;
|
||||
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.ItemHabitatLocator.HabitatLocatorInventory;
|
||||
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
|
||||
import forestry.apiculture.multiblock.TileAlvearyHygroregulator;
|
||||
import forestry.apiculture.multiblock.TileAlvearyPlain;
|
||||
import forestry.apiculture.multiblock.TileAlvearySieve;
|
||||
import forestry.apiculture.multiblock.TileAlvearySwarmer;
|
||||
import forestry.apiculture.tiles.TileApiary;
|
||||
import forestry.apiculture.tiles.TileBeehouse;
|
||||
import forestry.core.GuiHandlerBase;
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
import forestry.core.network.GuiId;
|
||||
|
||||
public class GuiHandlerApiculture extends GuiHandlerBase {
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
int cleanId = decodeGuiID(id);
|
||||
int guiData = decodeGuiData(id);
|
||||
|
||||
if (cleanId >= GuiId.values().length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack equipped;
|
||||
switch (GuiId.values()[cleanId]) {
|
||||
|
||||
case AlvearyGUI:
|
||||
return new GuiAlveary(player.inventory, getTile(world, x, y, z, player, TileAlvearyPlain.class));
|
||||
|
||||
case AlvearySieveGUI:
|
||||
return new GuiAlvearySieve(player.inventory, getTile(world, x, y, z, player, TileAlvearySieve.class));
|
||||
|
||||
case AlvearySwarmerGUI:
|
||||
return new GuiAlvearySwarmer(player.inventory, getTile(world, x, y, z, player, TileAlvearySwarmer.class));
|
||||
|
||||
case ApiaristChestGUI:
|
||||
return getNaturalistChestGui(BeeManager.beeRoot, player, world, x, y, z, guiData);
|
||||
|
||||
case ApiaryGUI:
|
||||
return new GuiBeeHousing(player.inventory, getTile(world, x, y, z, player, TileApiary.class));
|
||||
|
||||
case BeealyzerGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
|
||||
|
||||
case BeehouseGUI:
|
||||
return new GuiBeeHousing(player.inventory, getTile(world, x, y, z, player, TileBeehouse.class));
|
||||
|
||||
case HabitatLocatorGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new GuiHabitatLocator(player, new HabitatLocatorInventory(player, equipped));
|
||||
|
||||
case HygroregulatorGUI:
|
||||
return new GuiAlvearyHygroregulator(player.inventory, getTile(world, x, y, z, player, TileAlvearyHygroregulator.class));
|
||||
|
||||
case ImprinterGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped));
|
||||
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
int cleanId = decodeGuiID(id);
|
||||
int guiData = decodeGuiData(id);
|
||||
|
||||
if (cleanId >= GuiId.values().length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack equipped;
|
||||
switch (GuiId.values()[cleanId]) {
|
||||
|
||||
case AlvearyGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerAlveary(player.inventory, getTile(world, x, y, z, player, TileAlvearyPlain.class));
|
||||
|
||||
case AlvearySieveGUI:
|
||||
return new ContainerAlvearySieve(player.inventory, getTile(world, x, y, z, player, TileAlvearySieve.class));
|
||||
|
||||
case AlvearySwarmerGUI:
|
||||
return new ContainerAlvearySwarmer(player.inventory, getTile(world, x, y, z, player, TileAlvearySwarmer.class));
|
||||
|
||||
case ApiaristChestGUI:
|
||||
return getNaturalistChestContainer(BeeManager.beeRoot, player, world, x, y, z, guiData);
|
||||
|
||||
case ApiaryGUI:
|
||||
synchApiaristTracker(world, player);
|
||||
return new ContainerBeeHousing(player.inventory, getTile(world, x, y, z, player, TileApiary.class), true);
|
||||
|
||||
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 ContainerBeeHousing(player.inventory, getTile(world, x, y, z, player, TileBeehouse.class), false);
|
||||
|
||||
case HabitatLocatorGUI:
|
||||
equipped = player.getCurrentEquippedItem();
|
||||
if (equipped == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ContainerHabitatLocator(player, new HabitatLocatorInventory(player, equipped));
|
||||
|
||||
case HygroregulatorGUI:
|
||||
return new ContainerAlvearyHygroregulator(player.inventory, getTile(world, x, y, z, player, TileAlvearyHygroregulator.class));
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static void synchApiaristTracker(World world, EntityPlayer player) {
|
||||
BeeManager.beeRoot.getBreedingTracker(world, player.getGameProfile()).synchToPlayer(player);
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,14 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.core.INBTTagable;
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class HasFlowersCache implements INBTTagable {
|
||||
@@ -42,7 +45,16 @@ public class HasFlowersCache implements INBTTagable {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (FlowerManager.flowerRegistry.isAcceptedFlower(flowerType, world, flowerCoords.posX, flowerCoords.posY, flowerCoords.posZ)) {
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(beeHousing);
|
||||
ChunkCoordinates housingCoords = beeHousing.getCoordinates();
|
||||
|
||||
int[] genomeTerritory = queen.getGenome().getTerritory();
|
||||
float housingModifier = beeModifier.getTerritoryModifier(queen.getGenome(), 1f);
|
||||
Vect area = new Vect(genomeTerritory).multiply(housingModifier * 3.0f);
|
||||
Vect min = new Vect(area).multiply(-0.5f).add(housingCoords);
|
||||
Vect max = new Vect(area).multiply(0.5f).add(housingCoords);
|
||||
|
||||
if (isFlowerValid(world, flowerType, min, max)) {
|
||||
return true;
|
||||
} else {
|
||||
flowerCoords = null;
|
||||
@@ -60,6 +72,17 @@ public class HasFlowersCache implements INBTTagable {
|
||||
return flowerCoords != null;
|
||||
}
|
||||
|
||||
private boolean isFlowerValid(World world, String flowerType, Vect min, Vect max) {
|
||||
if (!isFlowerCoordInRange(flowerCoords, min, max)) {
|
||||
return false;
|
||||
}
|
||||
return FlowerManager.flowerRegistry.isAcceptedFlower(flowerType, world, flowerCoords.posX, flowerCoords.posY, flowerCoords.posZ);
|
||||
}
|
||||
|
||||
private static boolean isFlowerCoordInRange(ChunkCoordinates flowerCoords, Vect min, Vect max) {
|
||||
return flowerCoords.posX >= min.x && flowerCoords.posX <= max.x && flowerCoords.posY >= min.y && flowerCoords.posY <= max.y && flowerCoords.posZ >= min.z && flowerCoords.posZ <= max.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
if (!nbttagcompound.hasKey(nbtKey)) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* 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 forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.apiculture.inventory.IApiaryInventory;
|
||||
|
||||
public interface IApiary extends IBeeHousing {
|
||||
IApiaryInventory getApiaryInventory();
|
||||
}
|
||||
+3
-3
@@ -20,14 +20,14 @@ import forestry.core.inventory.InventoryAdapterRestricted;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
|
||||
public class BeeHousingInventory extends InventoryAdapterRestricted implements IBeeHousingInventory {
|
||||
public class InventoryBeeHousing extends InventoryAdapterRestricted implements IBeeHousingInventory {
|
||||
public static final int SLOT_QUEEN = 0;
|
||||
public static final int SLOT_DRONE = 1;
|
||||
public static final int SLOT_PRODUCT_1 = 2;
|
||||
public static final int SLOT_PRODUCT_COUNT = 7;
|
||||
|
||||
public BeeHousingInventory(int size, String name, IAccessHandler accessHandler) {
|
||||
super(size, name, accessHandler);
|
||||
public InventoryBeeHousing(int size, IAccessHandler accessHandler) {
|
||||
super(size, "Items", accessHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,13 +29,11 @@ import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.apiculture.blocks.BlockApicultureType;
|
||||
import forestry.apiculture.genetics.BeeDefinition;
|
||||
import forestry.apiculture.items.ItemHoneycomb;
|
||||
import forestry.apiculture.worldgen.ComponentVillageBeeHouse;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler {
|
||||
|
||||
@@ -50,11 +48,38 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
|
||||
recipeList.add(new MerchantRecipe(ForestryItem.beePrincessGE.getItemStack(1, OreDictionary.WILDCARD_VALUE), new ItemStack(Items.emerald, 1)));
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.wheat, 2), ItemHoneycomb.getRandomComb(1, random, false)));
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Blocks.log, 24, OreDictionary.WILDCARD_VALUE), ForestryBlock.apiculture.getItemStack(1, Constants.DEFINITION_APIARY_META)));
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1), ForestryItem.frameProven.getItemStack(6)));
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 12), ForestryItem.beePrincessGE.getItemStack(1, OreDictionary.WILDCARD_VALUE), BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE)));
|
||||
ItemStack wildcardPrincess = new ItemStack(PluginApiculture.items.beePrincessGE, 1, OreDictionary.WILDCARD_VALUE);
|
||||
ItemStack wildcardDrone = new ItemStack(PluginApiculture.items.beeDroneGE, 4, OreDictionary.WILDCARD_VALUE);
|
||||
recipeList.add(new MerchantRecipe(wildcardPrincess, new ItemStack(Items.emerald, 1)));
|
||||
|
||||
ItemStack randomComb = PluginApiculture.items.beeComb.getRandomComb(1, random, false);
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.wheat, 2), randomComb));
|
||||
|
||||
ItemStack apiary = PluginApiculture.blocks.apiculture.get(BlockApicultureType.APIARY);
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Blocks.log, 24, OreDictionary.WILDCARD_VALUE), apiary));
|
||||
|
||||
ItemStack provenFrames = PluginApiculture.items.frameProven.getItemStack(6);
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1), provenFrames));
|
||||
|
||||
ItemStack monasticDrone = BeeDefinition.MONASTIC.getMemberStack(EnumBeeType.DRONE);
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 12), wildcardPrincess, monasticDrone));
|
||||
|
||||
ItemStack endDrone = BeeDefinition.ENDED.getMemberStack(EnumBeeType.DRONE);
|
||||
recipeList.add(new MerchantRecipe(new ItemStack(Items.ender_eye, 16), wildcardPrincess, endDrone));
|
||||
|
||||
ItemStack propolis = new ItemStack(PluginApiculture.items.propolis,1);
|
||||
ItemStack forestDrone = BeeDefinition.FOREST.getMemberStack(EnumBeeType.DRONE);
|
||||
ItemStack meadowsDrone = BeeDefinition.MEADOWS.getMemberStack(EnumBeeType.DRONE);
|
||||
ItemStack modestDrone = BeeDefinition.MODEST.getMemberStack(EnumBeeType.DRONE);
|
||||
ItemStack tropicalDrone = BeeDefinition.TROPICAL.getMemberStack(EnumBeeType.DRONE);
|
||||
ItemStack wintryDrone = BeeDefinition.WINTRY.getMemberStack(EnumBeeType.DRONE);
|
||||
ItemStack marshyDrone = BeeDefinition.MARSHY.getMemberStack(EnumBeeType.DRONE);
|
||||
recipeList.add(new MerchantRecipe(propolis, wildcardDrone, forestDrone));
|
||||
recipeList.add(new MerchantRecipe(propolis, wildcardDrone, meadowsDrone));
|
||||
recipeList.add(new MerchantRecipe(propolis, wildcardDrone, modestDrone));
|
||||
recipeList.add(new MerchantRecipe(propolis, wildcardDrone, tropicalDrone));
|
||||
recipeList.add(new MerchantRecipe(propolis, wildcardDrone, wintryDrone));
|
||||
recipeList.add(new MerchantRecipe(propolis, wildcardDrone, marshyDrone));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,15 +37,27 @@ import forestry.apiculture.multiblock.TileAlvearySieve;
|
||||
import forestry.apiculture.multiblock.TileAlvearyStabiliser;
|
||||
import forestry.apiculture.multiblock.TileAlvearySwarmer;
|
||||
import forestry.core.blocks.BlockStructure;
|
||||
import forestry.core.multiblock.MultiblockRegistry;
|
||||
import forestry.core.render.TextureManager;
|
||||
|
||||
public class BlockAlveary extends BlockStructure {
|
||||
public enum Type {
|
||||
PLAIN,
|
||||
ENTRANCE,
|
||||
SWARMER,
|
||||
FAN,
|
||||
HEATER,
|
||||
HYGRO,
|
||||
STABILIZER,
|
||||
SIEVE;
|
||||
|
||||
public static final Type[] VALUES = values();
|
||||
}
|
||||
|
||||
public BlockAlveary() {
|
||||
super(new MaterialBeehive(false));
|
||||
setHardness(1.0f);
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
setHarvestLevel("axe", 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@@ -86,19 +98,25 @@ public class BlockAlveary extends BlockStructure {
|
||||
/* TILE ENTITY CREATION */
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
switch (metadata) {
|
||||
case TileAlveary.SWARMER_META:
|
||||
if (metadata < 0 || metadata > Type.VALUES.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Type type = Type.VALUES[metadata];
|
||||
switch (type) {
|
||||
case SWARMER:
|
||||
return new TileAlvearySwarmer();
|
||||
case TileAlveary.FAN_META:
|
||||
case FAN:
|
||||
return new TileAlvearyFan();
|
||||
case TileAlveary.HEATER_META:
|
||||
case HEATER:
|
||||
return new TileAlvearyHeater();
|
||||
case TileAlveary.HYGRO_META:
|
||||
case HYGRO:
|
||||
return new TileAlvearyHygroregulator();
|
||||
case TileAlveary.STABILIZER_META:
|
||||
case STABILIZER:
|
||||
return new TileAlvearyStabiliser();
|
||||
case TileAlveary.SIEVE_META:
|
||||
case SIEVE:
|
||||
return new TileAlvearySieve();
|
||||
case PLAIN:
|
||||
default:
|
||||
return new TileAlvearyPlain();
|
||||
}
|
||||
@@ -152,27 +170,29 @@ public class BlockAlveary extends BlockStructure {
|
||||
@Override
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
if ((metadata <= 1
|
||||
|| metadata == TileAlveary.SIEVE_META || metadata == TileAlveary.SWARMER_META || metadata == TileAlveary.STABILIZER_META)
|
||||
|| metadata == Type.SIEVE.ordinal() || metadata == Type.SWARMER.ordinal() || metadata == Type.STABILIZER.ordinal())
|
||||
&& (side == 1 || side == 0)) {
|
||||
return icons[BOTTOM];
|
||||
}
|
||||
|
||||
switch (metadata) {
|
||||
case TileAlveary.PLAIN_META:
|
||||
Type type = Type.VALUES[metadata];
|
||||
|
||||
switch (type) {
|
||||
case PLAIN:
|
||||
return icons[PLAIN];
|
||||
case TileAlveary.ENTRANCE_META:
|
||||
case ENTRANCE:
|
||||
return icons[ENTRANCE];
|
||||
case TileAlveary.SWARMER_META:
|
||||
case SWARMER:
|
||||
return icons[ALVEARY_SWARMER_OFF];
|
||||
case TileAlveary.FAN_META:
|
||||
case FAN:
|
||||
return icons[ALVEARY_FAN_OFF];
|
||||
case TileAlveary.HEATER_META:
|
||||
case HEATER:
|
||||
return icons[ALVEARY_HEATER_OFF];
|
||||
case TileAlveary.HYGRO_META:
|
||||
case HYGRO:
|
||||
return icons[ALVEARY_HYGRO];
|
||||
case TileAlveary.STABILIZER_META:
|
||||
case STABILIZER:
|
||||
return icons[STABILISER];
|
||||
case TileAlveary.SIEVE_META:
|
||||
case SIEVE:
|
||||
return icons[SIEVE];
|
||||
default:
|
||||
return null;
|
||||
@@ -228,7 +248,7 @@ 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 instanceof TileAlveary)) {
|
||||
return getIcon(side, 0);
|
||||
}
|
||||
|
||||
@@ -261,7 +281,11 @@ public class BlockAlveary extends BlockStructure {
|
||||
TileAlveary tileAlveary = (TileAlveary) tileEntity;
|
||||
|
||||
// We must check that the slabs on top were not removed
|
||||
MultiblockRegistry.addDirtyController(world, tileAlveary.getMultiblockController());
|
||||
tileAlveary.getMultiblockLogic().getController().reassemble();
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack get(Type type) {
|
||||
return new ItemStack(this, 1, type.ordinal());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.blocks.BlockBase;
|
||||
|
||||
public class BlockApiculture extends BlockBase<BlockApicultureType> {
|
||||
public BlockApiculture() {
|
||||
super();
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
setHarvestLevel("axe", 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import forestry.apiculture.tiles.TileApiaristChest;
|
||||
import forestry.apiculture.tiles.TileApiary;
|
||||
import forestry.apiculture.tiles.TileBeehouse;
|
||||
import forestry.core.blocks.IMachineProperties;
|
||||
import forestry.core.tiles.TileForestry;
|
||||
|
||||
public enum BlockApicultureType implements IMachineProperties {
|
||||
APIARY(TileApiary.class),
|
||||
APIARIST_CHEST_LEGACY(TileApiaristChest.class, "ApiaristChest"),
|
||||
BEEHOUSE(TileBeehouse.class);
|
||||
|
||||
public static final BlockApicultureType[] VALUES = values();
|
||||
|
||||
private final String teIdent;
|
||||
private final Class<? extends TileForestry> teClass;
|
||||
|
||||
BlockApicultureType(Class<? extends TileForestry> teClass) {
|
||||
String name = toString().toLowerCase(Locale.ENGLISH);
|
||||
this.teIdent = "forestry." + WordUtils.capitalize(name);
|
||||
this.teClass = teClass;
|
||||
}
|
||||
|
||||
BlockApicultureType(Class<? extends TileForestry> teClass, String name) {
|
||||
this.teIdent = "forestry." + name;
|
||||
this.teClass = teClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMeta() {
|
||||
return ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTeIdent() {
|
||||
return teIdent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TileForestry> getTeClass() {
|
||||
return teClass;
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,11 @@ import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class BlockBeehives extends BlockContainer {
|
||||
public enum Type {
|
||||
LEGACY,
|
||||
FOREST,
|
||||
MEADOWS;
|
||||
}
|
||||
|
||||
public BlockBeehives() {
|
||||
super(new MaterialBeehive(true));
|
||||
|
||||
@@ -44,7 +44,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.tiles.TileCandle;
|
||||
import forestry.core.ForestryClient;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
@@ -110,7 +110,7 @@ public class BlockCandle extends BlockTorch {
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return ForestryClient.candleRenderId;
|
||||
return Proxies.render.getCandleRenderId();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -326,4 +326,11 @@ public class BlockCandle extends BlockTorch {
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getUnlitCandle(int amount) {
|
||||
return new ItemStack(this, amount, 0);
|
||||
}
|
||||
|
||||
public ItemStack getLitCandle(int amount) {
|
||||
return new ItemStack(this, amount, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*******************************************************************************
|
||||
* 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.blocks;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.items.ItemBlockCandle;
|
||||
import forestry.core.blocks.BlockBase;
|
||||
import forestry.core.blocks.BlockRegistry;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
|
||||
public class BlockRegistryApiculture extends BlockRegistry {
|
||||
public final BlockApiculture apiculture;
|
||||
public final BlockBase apicultureChest;
|
||||
public final BlockBeehives beehives;
|
||||
public final BlockCandle candle;
|
||||
public final BlockStump stump;
|
||||
public final BlockAlveary alveary;
|
||||
|
||||
public BlockRegistryApiculture() {
|
||||
apiculture = registerBlock(new BlockApiculture(), ItemBlockForestry.class, "apiculture");
|
||||
|
||||
apicultureChest = registerBlock(new BlockBase(true), ItemBlockForestry.class, "apicultureChest");
|
||||
apicultureChest.setCreativeTab(Tabs.tabApiculture);
|
||||
apicultureChest.setHarvestLevel("axe", 0);
|
||||
|
||||
beehives = registerBlock(new BlockBeehives(), ItemBlockForestry.class, "beehives");
|
||||
|
||||
candle = registerBlock(new BlockCandle(), ItemBlockCandle.class, "candle");
|
||||
stump = registerBlock(new BlockStump(), ItemBlockForestry.class, "stump");
|
||||
|
||||
alveary = registerBlock(new BlockAlveary(), ItemBlockForestry.class, "alveary");
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.tiles.TileCandle;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class BlockStump extends BlockTorch {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class BlockStump extends BlockTorch {
|
||||
(held.getItem() == Items.flint_and_steel ||
|
||||
held.getItem() == Items.flint ||
|
||||
ItemStackUtil.equals(Blocks.torch, held))) {
|
||||
world.setBlock(x, y, z, ForestryBlock.candle.block(), world.getBlockMetadata(x, y, z) | 0x08, Constants.FLAG_BLOCK_SYNCH);
|
||||
world.setBlock(x, y, z, PluginApiculture.blocks.candle, world.getBlockMetadata(x, y, z) | 0x08, Constants.FLAG_BLOCK_SYNCH);
|
||||
TileCandle tc = new TileCandle();
|
||||
tc.setColour(0); // default to white
|
||||
world.setTileEntity(x, y, z, tc);
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
/*******************************************************************************
|
||||
* 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.entities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.apiculture.ApiaryBeeListener;
|
||||
import forestry.apiculture.ApiaryBeeModifier;
|
||||
import forestry.apiculture.IApiary;
|
||||
import forestry.apiculture.blocks.BlockApicultureType;
|
||||
import forestry.apiculture.gui.ContainerMinecartBeehouse;
|
||||
import forestry.apiculture.gui.GuiBeeHousing;
|
||||
import forestry.apiculture.inventory.IApiaryInventory;
|
||||
import forestry.apiculture.inventory.InventoryApiary;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implements IApiary {
|
||||
private static final IBeeModifier beeModifier = new ApiaryBeeModifier();
|
||||
private final IBeeListener beeListener = new ApiaryBeeListener(this);
|
||||
private final InventoryApiary inventory = new InventoryApiary(getAccessHandler());
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public EntityMinecartApiary(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityMinecartApiary(World world, double posX, double posY, double posZ) {
|
||||
super(world, posX, posY, posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getHints() {
|
||||
return Config.hints.get("apiary");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IInventoryAdapter getInternalInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IApiaryInventory getApiaryInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block func_145820_n() {
|
||||
return PluginApiculture.blocks.apiculture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayTileData() {
|
||||
return BlockApicultureType.APIARY.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCartItem() {
|
||||
return PluginApiculture.items.minecartBeehouse.getApiaryMinecart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IBeeModifier> getBeeModifiers() {
|
||||
List<IBeeModifier> beeModifiers = new ArrayList<>();
|
||||
|
||||
beeModifiers.add(beeModifier);
|
||||
|
||||
for (IHiveFrame frame : inventory.getFrames()) {
|
||||
beeModifiers.add(frame.getBeeModifier());
|
||||
}
|
||||
|
||||
return beeModifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IBeeListener> getBeeListeners() {
|
||||
return Collections.singleton(beeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
ContainerMinecartBeehouse container = new ContainerMinecartBeehouse(player.inventory, this, true);
|
||||
return new GuiBeeHousing<>(this, container, GuiBeeHousing.Icon.APIARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerMinecartBeehouse(player.inventory, this, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdOfEntity() {
|
||||
return getEntityId();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*******************************************************************************
|
||||
* 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.entities;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.apiculture.gui.IGuiBeeHousingInventory;
|
||||
import forestry.apiculture.network.packets.PacketBeeLogicEntityRequest;
|
||||
import forestry.apiculture.tiles.TileBeeHousingBase;
|
||||
import forestry.core.entities.EntityMinecartContainerForestry;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IClimatised;
|
||||
|
||||
public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContainerForestry implements IBeeHousing, IGuiBeeHousingInventory, IClimatised, IStreamableGui {
|
||||
private static final Random random = new Random();
|
||||
private static final int beeFXInterval = 4;
|
||||
private static final int pollenFXInterval = 50;
|
||||
|
||||
private final int beeFXTime = random.nextInt(beeFXInterval);
|
||||
private final int pollenFXTime = random.nextInt(pollenFXInterval);
|
||||
|
||||
private final IBeekeepingLogic beeLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
||||
private final IErrorLogic errorLogic = ForestryAPI.errorStateRegistry.createErrorLogic();
|
||||
|
||||
// CLIENT
|
||||
private int breedingProgressPercent = 0;
|
||||
private boolean needsActiveUpdate = true;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public EntityMinecartBeeHousingBase(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityMinecartBeeHousingBase(World world, double posX, double posY, double posZ) {
|
||||
super(world, posX, posY, posZ);
|
||||
}
|
||||
|
||||
/* IBeeHousing */
|
||||
@Override
|
||||
public IBeekeepingLogic getBeekeepingLogic() {
|
||||
return beeLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromBiome(getBiome(), (int) posX, (int) posY, (int) posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(getBiome().rainfall);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return getBiome().temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return getBiome().rainfall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightValue() {
|
||||
return worldObj.getBlockLightValue((int) posX, (int) posY + 1, (int) posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockSeeTheSky() {
|
||||
return worldObj.canBlockSeeTheSky((int) posX, (int) posY + 1, (int) posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return worldObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return worldObj.getBiomeGenForCoords((int) posX, (int) posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return getAccessHandler().getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return errorLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return new ChunkCoordinates((int) posX, (int) posY, (int) posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getBeeFXCoordinates() {
|
||||
return Vec3.createVectorHelper(posX, posY + 0.25, posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeVarInt(beeLogic.getBeeProgressPercent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
breedingProgressPercent = data.readVarInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHealthScaled(int i) {
|
||||
return (breedingProgressPercent * i) / 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if (!worldObj.isRemote) {
|
||||
if (beeLogic.canWork()) {
|
||||
beeLogic.doWork();
|
||||
}
|
||||
} else {
|
||||
if (needsActiveUpdate) {
|
||||
IForestryPacketServer packet = new PacketBeeLogicEntityRequest(this);
|
||||
Proxies.net.sendToServer(packet);
|
||||
needsActiveUpdate = false;
|
||||
}
|
||||
|
||||
if (beeLogic.canDoBeeFX()) {
|
||||
if (worldObj.getTotalWorldTime() % beeFXInterval == beeFXTime) {
|
||||
beeLogic.doBeeFX();
|
||||
}
|
||||
|
||||
if (worldObj.getTotalWorldTime() % pollenFXInterval == pollenFXTime) {
|
||||
TileBeeHousingBase.doPollenFX(worldObj, posX - 0.5, posY - 0.1, posZ - 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
super.readEntityFromNBT(nbtTagCompound);
|
||||
beeLogic.readFromNBT(nbtTagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound nbtTagCompound) {
|
||||
super.writeEntityToNBT(nbtTagCompound);
|
||||
beeLogic.writeToNBT(nbtTagCompound);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*******************************************************************************
|
||||
* 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.entities;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.DefaultBeeListener;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.apiculture.BeehouseBeeModifier;
|
||||
import forestry.apiculture.InventoryBeeHousing;
|
||||
import forestry.apiculture.blocks.BlockApicultureType;
|
||||
import forestry.apiculture.gui.ContainerMinecartBeehouse;
|
||||
import forestry.apiculture.gui.GuiBeeHousing;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
|
||||
private static final IBeeModifier beeModifier = new BeehouseBeeModifier();
|
||||
private static final IBeeListener beeListener = new DefaultBeeListener();
|
||||
private final InventoryBeeHousing beeInventory = new InventoryBeeHousing(9, getAccessHandler());
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public EntityMinecartBeehouse(World world) {
|
||||
super(world);
|
||||
beeInventory.disableAutomation();
|
||||
}
|
||||
|
||||
public EntityMinecartBeehouse(World world, double posX, double posY, double posZ) {
|
||||
super(world, posX, posY, posZ);
|
||||
beeInventory.disableAutomation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getHints() {
|
||||
return Config.hints.get("bee.house");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block func_145820_n() {
|
||||
return PluginApiculture.blocks.apiculture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDisplayTileData() {
|
||||
return BlockApicultureType.BEEHOUSE.ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCartItem() {
|
||||
return PluginApiculture.items.minecartBeehouse.getBeeHouseMinecart();
|
||||
}
|
||||
|
||||
/* IBeeHousing */
|
||||
@Override
|
||||
public Iterable<IBeeModifier> getBeeModifiers() {
|
||||
return Collections.singleton(beeModifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IBeeListener> getBeeListeners() {
|
||||
return Collections.singleton(beeListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return beeInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IInventoryAdapter getInternalInventory() {
|
||||
return beeInventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, int data) {
|
||||
ContainerMinecartBeehouse container = new ContainerMinecartBeehouse(player.inventory, this, false);
|
||||
return new GuiBeeHousing<>(this, container, GuiBeeHousing.Icon.BEE_HOUSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, int data) {
|
||||
return new ContainerMinecartBeehouse(player.inventory, this, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIdOfEntity() {
|
||||
return getEntityId();
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public final class FlowerRegistry implements IFlowerRegistry, IFlowerGrowthHelpe
|
||||
if (PluginManager.Module.AGRICRAFT.isEnabled()) {
|
||||
Block cropBlock = GameRegistry.findBlock("AgriCraft", "crops");
|
||||
if (block == cropBlock) {
|
||||
if(block instanceof IPlantable) {
|
||||
if (block instanceof IPlantable) {
|
||||
//For agricraft versions which implement IPlantable in the BlockCrop class
|
||||
block = ((IPlantable) block).getPlant(world, x, y, z);
|
||||
} else {
|
||||
|
||||
@@ -13,8 +13,6 @@ package forestry.apiculture.genetics;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IApiaristTracker;
|
||||
@@ -27,11 +25,7 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
|
||||
|
||||
/** Required for creation from map storage */
|
||||
public ApiaristTracker(String s) {
|
||||
this(s, null);
|
||||
}
|
||||
|
||||
public ApiaristTracker(String s, GameProfile player) {
|
||||
super(s, player);
|
||||
super(s);
|
||||
}
|
||||
|
||||
private int queensTotal = 0;
|
||||
|
||||
@@ -45,6 +45,7 @@ import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
@@ -256,48 +257,87 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
|
||||
// / Rain needs tolerant flyers
|
||||
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(biome) && !beeModifier.isSealed()) {
|
||||
errorStates.add(EnumErrorCode.ISRAINING);
|
||||
if (world.isRaining() && BiomeHelper.canRainOrSnow(biome) && !canFlyInRain(beeModifier)) {
|
||||
errorStates.add(EnumErrorCode.IS_RAINING);
|
||||
}
|
||||
|
||||
// / Night or darkness requires nocturnal species
|
||||
if (world.isDaytime()) {
|
||||
if (!canWorkDuringDay()) {
|
||||
errorStates.add(EnumErrorCode.NOTNIGHT);
|
||||
errorStates.add(EnumErrorCode.NOT_NIGHT);
|
||||
}
|
||||
} else {
|
||||
if (!canWorkAtNight(beeModifier)) {
|
||||
errorStates.add(EnumErrorCode.NOT_DAY);
|
||||
}
|
||||
} else if (!canWorkAtNight() && !beeModifier.isSelfLighted()) {
|
||||
errorStates.add(EnumErrorCode.NOTDAY);
|
||||
}
|
||||
|
||||
if (housing.getBlockLightValue() > Constants.APIARY_MIN_LEVEL_LIGHT) {
|
||||
if (!canWorkDuringDay()) {
|
||||
errorStates.add(EnumErrorCode.NOTGLOOMY);
|
||||
errorStates.add(EnumErrorCode.NOT_GLOOMY);
|
||||
}
|
||||
} else {
|
||||
if (!canWorkAtNight(beeModifier)) {
|
||||
errorStates.add(EnumErrorCode.NOT_BRIGHT);
|
||||
}
|
||||
} else if (!canWorkAtNight() && !beeModifier.isSelfLighted()) {
|
||||
errorStates.add(EnumErrorCode.NOTLUCID);
|
||||
}
|
||||
|
||||
// / No sky, except if in hell
|
||||
if (biome != null && !BiomeHelper.isBiomeHellish(biome) && !housing.canBlockSeeTheSky() && !genome.getCaveDwelling() && !beeModifier.isSunlightSimulated()) {
|
||||
errorStates.add(EnumErrorCode.NOSKY);
|
||||
// / Check for the sky, except if in hell
|
||||
if (!world.provider.hasNoSky) {
|
||||
if (!housing.canBlockSeeTheSky() && !canWorkUnderground(beeModifier)) {
|
||||
errorStates.add(EnumErrorCode.NO_SKY);
|
||||
}
|
||||
}
|
||||
|
||||
// / And finally climate check
|
||||
if (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
|
||||
errorStates.add(EnumErrorCode.INVALIDBIOME);
|
||||
IAlleleBeeSpecies species = genome.getPrimary();
|
||||
{
|
||||
EnumTemperature actualTemperature = housing.getTemperature();
|
||||
EnumTemperature beeBaseTemperature = species.getTemperature();
|
||||
EnumTolerance beeToleranceTemperature = genome.getToleranceTemp();
|
||||
|
||||
if (!AlleleManager.climateHelper.isWithinLimits(actualTemperature, beeBaseTemperature, beeToleranceTemperature)) {
|
||||
if (beeBaseTemperature.ordinal() > actualTemperature.ordinal()) {
|
||||
errorStates.add(EnumErrorCode.TOO_COLD);
|
||||
} else {
|
||||
errorStates.add(EnumErrorCode.TOO_HOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
EnumHumidity actualHumidity = housing.getHumidity();
|
||||
EnumHumidity beeBaseHumidity = species.getHumidity();
|
||||
EnumTolerance beeToleranceHumidity = genome.getToleranceHumid();
|
||||
|
||||
if (!AlleleManager.climateHelper.isWithinLimits(actualHumidity, beeBaseHumidity, beeToleranceHumidity)) {
|
||||
if (beeBaseHumidity.ordinal() > actualHumidity.ordinal()) {
|
||||
errorStates.add(EnumErrorCode.TOO_ARID);
|
||||
} else {
|
||||
errorStates.add(EnumErrorCode.TOO_HUMID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errorStates;
|
||||
}
|
||||
|
||||
private boolean canWorkAtNight() {
|
||||
return genome.getPrimary().isNocturnal() || genome.getNocturnal();
|
||||
private boolean canWorkAtNight(IBeeModifier beeModifier) {
|
||||
return genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfLighted();
|
||||
}
|
||||
|
||||
private boolean canWorkDuringDay() {
|
||||
return !genome.getPrimary().isNocturnal() || genome.getNocturnal();
|
||||
}
|
||||
|
||||
private boolean canWorkUnderground(IBeeModifier beeModifier) {
|
||||
return genome.getCaveDwelling() || beeModifier.isSunlightSimulated();
|
||||
}
|
||||
|
||||
private boolean canFlyInRain(IBeeModifier beeModifier) {
|
||||
return genome.getTolerantFlyer() || beeModifier.isSealed();
|
||||
}
|
||||
|
||||
private boolean isSuitableBiome(BiomeGenBase biome) {
|
||||
if (biome == null) {
|
||||
return false;
|
||||
|
||||
@@ -33,16 +33,19 @@ import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.apiculture.genetics.alleles.AlleleEffect;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.apiculture.items.EnumHoneyComb;
|
||||
import forestry.apiculture.items.EnumPollenCluster;
|
||||
import forestry.core.genetics.alleles.AlleleHelper;
|
||||
import forestry.core.genetics.alleles.EnumAllele;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import forestry.plugins.PluginCore;
|
||||
|
||||
public enum BeeDefinition implements IBeeDefinition {
|
||||
/* HONEY BRANCH */
|
||||
FOREST(BeeBranchDefinition.HONEY, "nigrocincta", true, new Color(0x19d0ec), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 0), 0.30f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.HONEY, 1), 0.30f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +62,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
MEADOWS(BeeBranchDefinition.HONEY, "florea", true, new Color(0xef131e), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 0), 0.30f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.HONEY, 1), 0.30f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,7 +78,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
COMMON(BeeBranchDefinition.HONEY, "cerana", true, new Color(0xb2b2b2), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 0), 0.35f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.HONEY, 1), 0.35f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,7 +100,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
CULTIVATED(BeeBranchDefinition.HONEY, "mellifera", true, new Color(0x5734ec), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 0), 0.40f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.HONEY, 1), 0.40f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,7 +121,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
NOBLE(BeeBranchDefinition.NOBLE, "nobilis", false, new Color(0xec9a19), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 5), 0.20f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.DRIPPING, 1), 0.20f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,7 +139,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
MAJESTIC(BeeBranchDefinition.NOBLE, "regalis", true, new Color(0x7f0000), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 5), 0.30f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.DRIPPING, 1), 0.30f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,8 +157,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
IMPERIAL(BeeBranchDefinition.NOBLE, "imperatorius", false, new Color(0xa3e02f), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 5), 0.20f)
|
||||
.addProduct(ForestryItem.royalJelly.getItemStack(), 0.15f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.DRIPPING, 1), 0.20f)
|
||||
.addProduct(PluginApiculture.items.royalJelly.getItemStack(), 0.15f)
|
||||
.setHasEffect();
|
||||
}
|
||||
|
||||
@@ -176,7 +179,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
DILIGENT(BeeBranchDefinition.INDUSTRIOUS, "sedulus", false, new Color(0xc219ec), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 3), 0.20f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.STRINGY, 1), 0.20f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,7 +197,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
UNWEARY(BeeBranchDefinition.INDUSTRIOUS, "assiduus", true, new Color(0x19ec5a), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 3), 0.30f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.STRINGY, 1), 0.30f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -211,8 +214,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
INDUSTRIOUS(BeeBranchDefinition.INDUSTRIOUS, "industria", false, new Color(0xffffff), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 3), 0.20f)
|
||||
.addProduct(ForestryItem.pollenCluster.getItemStack(), 0.15f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.STRINGY, 1), 0.20f)
|
||||
.addProduct(PluginApiculture.items.pollenCluster.get(EnumPollenCluster.NORMAL, 1), 0.15f)
|
||||
.setHasEffect();
|
||||
}
|
||||
|
||||
@@ -233,7 +236,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
STEADFAST(BeeBranchDefinition.HEROIC, "legio", false, new Color(0x4d2b15), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 1), 0.20f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.COCOA, 1), 0.20f)
|
||||
.setHasEffect();
|
||||
}
|
||||
|
||||
@@ -253,7 +256,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
VALIANT(BeeBranchDefinition.HEROIC, "centurio", true, new Color(0x626bdd), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 1), 0.30f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.COCOA, 1), 0.30f)
|
||||
.addSpecialty(new ItemStack(Items.sugar), 0.15f);
|
||||
}
|
||||
|
||||
@@ -273,7 +276,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
HEROIC(BeeBranchDefinition.HEROIC, "kraphti", false, new Color(0xb3d5e4), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 1), 0.40f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.COCOA, 1), 0.40f)
|
||||
.setHasEffect();
|
||||
}
|
||||
|
||||
@@ -297,7 +300,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
SINISTER(BeeBranchDefinition.INFERNAL, "caecus", false, new Color(0xb3d5e4), new Color(0x9a2323)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 2), 0.45f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.SIMMERING, 1), 0.45f)
|
||||
.setTemperature(EnumTemperature.HELLISH)
|
||||
.setHumidity(EnumHumidity.ARID);
|
||||
}
|
||||
@@ -320,8 +323,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
FIENDISH(BeeBranchDefinition.INFERNAL, "diabolus", true, new Color(0xd7bee5), new Color(0x9a2323)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 2), 0.55f)
|
||||
.addProduct(ForestryItem.ash.getItemStack(), 0.15f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.SIMMERING, 1), 0.55f)
|
||||
.addProduct(PluginCore.items.ash.getItemStack(), 0.15f)
|
||||
.setTemperature(EnumTemperature.HELLISH)
|
||||
.setHumidity(EnumHumidity.ARID);
|
||||
}
|
||||
@@ -344,7 +347,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
DEMONIC(BeeBranchDefinition.INFERNAL, "draco", false, new Color(0xf4e400), new Color(0x9a2323)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 2), 0.45f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.SIMMERING, 1), 0.45f)
|
||||
.addProduct(new ItemStack(Items.glowstone_dust), 0.15f)
|
||||
.setHasEffect()
|
||||
.setTemperature(EnumTemperature.HELLISH)
|
||||
@@ -369,7 +372,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
MODEST(BeeBranchDefinition.AUSTERE, "modicus", false, new Color(0xc5be86), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 7), 0.20f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.PARCHED, 1), 0.20f)
|
||||
.setTemperature(EnumTemperature.HOT)
|
||||
.setHumidity(EnumHumidity.ARID);
|
||||
}
|
||||
@@ -388,7 +391,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
FRUGAL(BeeBranchDefinition.AUSTERE, "permodestus", true, new Color(0xe8dcb1), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 7), 0.30f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.PARCHED, 1), 0.30f)
|
||||
.setTemperature(EnumTemperature.HOT)
|
||||
.setHumidity(EnumHumidity.ARID);
|
||||
}
|
||||
@@ -412,8 +415,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
AUSTERE(BeeBranchDefinition.AUSTERE, "correpere", false, new Color(0xfffac2), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 7), 0.20f)
|
||||
.addSpecialty(ForestryItem.beeComb.getItemStack(1, 10), 0.50f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.PARCHED, 1), 0.20f)
|
||||
.addSpecialty(PluginApiculture.items.beeComb.get(EnumHoneyComb.POWDERY, 1), 0.50f)
|
||||
.setHasEffect()
|
||||
.setTemperature(EnumTemperature.HOT)
|
||||
.setHumidity(EnumHumidity.ARID);
|
||||
@@ -439,7 +442,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
TROPICAL(BeeBranchDefinition.TROPICAL, "mendelia", false, new Color(0x378020), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 6), 0.20f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.SILKY, 1), 0.20f)
|
||||
.setTemperature(EnumTemperature.WARM)
|
||||
.setHumidity(EnumHumidity.DAMP);
|
||||
}
|
||||
@@ -458,7 +461,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
EXOTIC(BeeBranchDefinition.TROPICAL, "darwini", true, new Color(0x304903), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 6), 0.30f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.SILKY, 1), 0.30f)
|
||||
.setTemperature(EnumTemperature.WARM)
|
||||
.setHumidity(EnumHumidity.DAMP);
|
||||
}
|
||||
@@ -477,7 +480,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
EDENIC(BeeBranchDefinition.TROPICAL, "humboldti", false, new Color(0x393d0d), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 6), 0.20f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.SILKY, 1), 0.20f)
|
||||
.setHasEffect()
|
||||
.setTemperature(EnumTemperature.WARM)
|
||||
.setHumidity(EnumHumidity.DAMP);
|
||||
@@ -501,7 +504,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
ENDED(BeeBranchDefinition.END, "notchi", false, new Color(0xe079fa), new Color(0xd9de9e)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 8), 0.30f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.MYSTERIOUS, 1), 0.30f)
|
||||
.setTemperature(EnumTemperature.COLD);
|
||||
}
|
||||
|
||||
@@ -518,7 +521,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
SPECTRAL(BeeBranchDefinition.END, "idolum", true, new Color(0xa98bed), new Color(0xd9de9e)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 8), 0.50f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.MYSTERIOUS, 1), 0.50f)
|
||||
.setTemperature(EnumTemperature.COLD);
|
||||
}
|
||||
|
||||
@@ -535,7 +538,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
PHANTASMAL(BeeBranchDefinition.END, "lemur", false, new Color(0xcc00fa), new Color(0xd9de9e)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 8), 0.40f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.MYSTERIOUS, 1), 0.40f)
|
||||
.setHasEffect()
|
||||
.setTemperature(EnumTemperature.COLD);
|
||||
}
|
||||
@@ -557,7 +560,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
WINTRY(BeeBranchDefinition.FROZEN, "brumalis", false, new Color(0xa0ffc8), new Color(0xdaf5f3)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 4), 0.30f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.FROZEN, 1), 0.30f)
|
||||
.setTemperature(EnumTemperature.ICY);
|
||||
}
|
||||
|
||||
@@ -576,8 +579,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
ICY(BeeBranchDefinition.FROZEN, "coagulis", true, new Color(0xa0ffff), new Color(0xdaf5f3)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 4), 0.20f)
|
||||
.addProduct(ForestryItem.craftingMaterial.getItemStack(1, 5), 0.20f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.FROZEN, 1), 0.20f)
|
||||
.addProduct(PluginCore.items.craftingMaterial.getIceShard(1), 0.20f)
|
||||
.setTemperature(EnumTemperature.ICY);
|
||||
}
|
||||
|
||||
@@ -596,8 +599,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
GLACIAL(BeeBranchDefinition.FROZEN, "glacialis", false, new Color(0xefffff), new Color(0xdaf5f3)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 4), 0.20f)
|
||||
.addProduct(ForestryItem.craftingMaterial.getItemStack(1, 5), 0.40f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.FROZEN, 1), 0.20f)
|
||||
.addProduct(PluginCore.items.craftingMaterial.getIceShard(1), 0.40f)
|
||||
.setTemperature(EnumTemperature.ICY)
|
||||
.setHasEffect();
|
||||
}
|
||||
@@ -619,7 +622,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
VINDICTIVE(BeeBranchDefinition.VENGEFUL, "ultio", false, new Color(0xeafff3), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 9), 0.25f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.IRRADIATED, 1), 0.25f)
|
||||
.setIsNotCounted();
|
||||
}
|
||||
|
||||
@@ -637,7 +640,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
VENGEFUL(BeeBranchDefinition.VENGEFUL, "punire", false, new Color(0xc2de00), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 9), 0.40f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.IRRADIATED, 1), 0.40f)
|
||||
.setIsNotCounted();
|
||||
}
|
||||
|
||||
@@ -656,7 +659,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
AVENGING(BeeBranchDefinition.VENGEFUL, "hostimentum", false, new Color(0xddff00), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 9), 0.40f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.IRRADIATED, 1), 0.40f)
|
||||
.setHasEffect()
|
||||
.setIsNotCounted();
|
||||
}
|
||||
@@ -678,7 +681,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
LEPORINE(BeeBranchDefinition.FESTIVE, "lepus", false, new Color(0xfeff8f), new Color(0x3cd757)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 6), 0.30f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.SILKY, 1), 0.30f)
|
||||
.addProduct(new ItemStack(Items.egg), 0.10f)
|
||||
.setHasEffect()
|
||||
.setIsNotCounted();
|
||||
@@ -700,8 +703,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
MERRY(BeeBranchDefinition.FESTIVE, "feliciter", false, new Color(0xffffff), new Color(0xd40000)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 4), 0.30f)
|
||||
.addProduct(ForestryItem.craftingMaterial.getItemStack(1, 5), 0.20f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.FROZEN, 1), 0.30f)
|
||||
.addProduct(PluginCore.items.craftingMaterial.getIceShard(1), 0.20f)
|
||||
.setTemperature(EnumTemperature.ICY)
|
||||
.setHasEffect()
|
||||
.setIsNotCounted();
|
||||
@@ -724,8 +727,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
TIPSY(BeeBranchDefinition.FESTIVE, "ebrius", false, new Color(0xffffff), new Color(0xc219ec)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 4), 0.30f)
|
||||
.addProduct(ForestryItem.craftingMaterial.getItemStack(1, 5), 0.20f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.FROZEN, 1), 0.30f)
|
||||
.addProduct(PluginCore.items.craftingMaterial.getIceShard(1), 0.20f)
|
||||
.setTemperature(EnumTemperature.ICY)
|
||||
.setHasEffect()
|
||||
.setIsNotCounted();
|
||||
@@ -749,7 +752,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
TRICKY(BeeBranchDefinition.FESTIVE, "libita", false, new Color(0x49413B), new Color(0xFF6A00)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 0), 0.40f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.HONEY, 1), 0.40f)
|
||||
.addProduct(new ItemStack(Items.cookie), 0.15f)
|
||||
.addSpecialty(new ItemStack(Items.skull, 1, 0), 0.02f)
|
||||
.addSpecialty(new ItemStack(Items.skull, 1, 2), 0.02f)
|
||||
@@ -779,7 +782,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
RURAL(BeeBranchDefinition.AGRARIAN, "rustico", false, new Color(0xfeff8f), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 14), 0.20f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.WHEATEN, 1), 0.20f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -796,7 +799,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
FARMERLY(BeeBranchDefinition.AGRARIAN, "arator", true, new Color(0xD39728), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 14), 0.27f);
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.WHEATEN, 1), 0.27f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -814,7 +817,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
AGRARIAN(BeeBranchDefinition.AGRARIAN, "arator", true, new Color(0xFFCA75), new Color(0xFFE047)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 14), 0.35f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.WHEATEN, 1), 0.35f)
|
||||
.setHasEffect();
|
||||
}
|
||||
|
||||
@@ -837,7 +840,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
MARSHY(BeeBranchDefinition.BOGGY, "adorasti", true, new Color(0x546626), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 15), 0.30f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.MOSSY, 1), 0.30f)
|
||||
.setHumidity(EnumHumidity.DAMP);
|
||||
}
|
||||
|
||||
@@ -854,7 +857,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
MIRY(BeeBranchDefinition.BOGGY, "humidium", true, new Color(0x92AF42), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 15), 0.36f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.MOSSY, 1), 0.36f)
|
||||
.setHumidity(EnumHumidity.DAMP);
|
||||
}
|
||||
|
||||
@@ -875,8 +878,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
BOGGY(BeeBranchDefinition.BOGGY, "paluster", true, new Color(0x698948), new Color(0xffdc16)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 15), 0.39f)
|
||||
.addSpecialty(ForestryItem.peat.getItemStack(), 0.08f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.MOSSY, 1), 0.39f)
|
||||
.addSpecialty(PluginCore.items.peat.getItemStack(), 0.08f)
|
||||
.setHumidity(EnumHumidity.DAMP);
|
||||
}
|
||||
|
||||
@@ -900,8 +903,8 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
MONASTIC(BeeBranchDefinition.MONASTIC, "monachus", false, new Color(0x42371c), new Color(0xfff7b6)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addProduct(ForestryItem.beeComb.getItemStack(1, 14), 0.30f)
|
||||
.addSpecialty(ForestryItem.beeComb.getItemStack(1, 16), 0.10f)
|
||||
beeSpecies.addProduct(PluginApiculture.items.beeComb.get(EnumHoneyComb.WHEATEN, 1), 0.30f)
|
||||
.addSpecialty(PluginApiculture.items.beeComb.get(EnumHoneyComb.MELLOW, 1), 0.10f)
|
||||
.setJubilanceProvider(new JubilanceProviderHermit());
|
||||
}
|
||||
|
||||
@@ -918,7 +921,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
SECLUDED(BeeBranchDefinition.MONASTIC, "contractus", true, new Color(0x7b6634), new Color(0xfff7b6)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addSpecialty(ForestryItem.beeComb.getItemStack(1, 16), 0.20f)
|
||||
beeSpecies.addSpecialty(PluginApiculture.items.beeComb.get(EnumHoneyComb.MELLOW, 1), 0.20f)
|
||||
.setJubilanceProvider(new JubilanceProviderHermit());
|
||||
}
|
||||
|
||||
@@ -935,7 +938,7 @@ public enum BeeDefinition implements IBeeDefinition {
|
||||
HERMITIC(BeeBranchDefinition.MONASTIC, "anachoreta", false, new Color(0xffd46c), new Color(0xfff7b6)) {
|
||||
@Override
|
||||
protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) {
|
||||
beeSpecies.addSpecialty(ForestryItem.beeComb.getItemStack(1, 16), 0.20f)
|
||||
beeSpecies.addSpecialty(PluginApiculture.items.beeComb.get(EnumHoneyComb.MELLOW, 1), 0.20f)
|
||||
.setJubilanceProvider(new JubilanceProviderHermit())
|
||||
.setHasEffect();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IAlleleBeeSpeciesCustom;
|
||||
import forestry.api.apiculture.IBeeFactory;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -20,7 +21,7 @@ public class BeeFactory implements IBeeFactory {
|
||||
@Override
|
||||
public IAlleleBeeSpeciesCustom createSpecies(String uid, boolean dominant, String authority, String unlocalizedName, String unlocalizedDescription, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
|
||||
IAlleleBeeSpeciesCustom species = new AlleleBeeSpecies(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial, primaryColor, secondaryColor);
|
||||
AlleleManager.alleleRegistry.registerAllele(species);
|
||||
AlleleManager.alleleRegistry.registerAllele(species, EnumBeeChromosome.SPECIES);
|
||||
return species;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,13 +41,13 @@ import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.apiculture.BeeHousingListener;
|
||||
import forestry.apiculture.BeeHousingModifier;
|
||||
import forestry.apiculture.BeekeepingLogic;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.genetics.SpeciesRoot;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
@@ -98,24 +98,29 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getMemberStack(IIndividual bee, int type) {
|
||||
if (!isMember(bee)) {
|
||||
public ItemStack getMemberStack(IIndividual individual, int type) {
|
||||
if (!isMember(individual)) {
|
||||
return null;
|
||||
}
|
||||
IBee bee = (IBee) individual;
|
||||
|
||||
Item beeItem;
|
||||
switch (EnumBeeType.VALUES[type]) {
|
||||
case QUEEN:
|
||||
beeItem = ForestryItem.beeQueenGE.item();
|
||||
beeItem = PluginApiculture.items.beeQueenGE;
|
||||
// ensure a queen is always mated
|
||||
if (bee.getMate() == null) {
|
||||
bee.mate(bee);
|
||||
}
|
||||
break;
|
||||
case PRINCESS:
|
||||
beeItem = ForestryItem.beePrincessGE.item();
|
||||
beeItem = PluginApiculture.items.beePrincessGE;
|
||||
break;
|
||||
case DRONE:
|
||||
beeItem = ForestryItem.beeDroneGE.item();
|
||||
beeItem = PluginApiculture.items.beeDroneGE;
|
||||
break;
|
||||
case LARVAE:
|
||||
beeItem = ForestryItem.beeLarvaeGE.item();
|
||||
beeItem = PluginApiculture.items.beeLarvaeGE;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Cannot instantiate a bee of type " + type);
|
||||
@@ -134,13 +139,15 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
return EnumBeeType.NONE;
|
||||
}
|
||||
|
||||
if (ForestryItem.beeDroneGE.isItemEqual(stack)) {
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (PluginApiculture.items.beeDroneGE == item) {
|
||||
return EnumBeeType.DRONE;
|
||||
} else if (ForestryItem.beePrincessGE.isItemEqual(stack)) {
|
||||
} else if (PluginApiculture.items.beePrincessGE == item) {
|
||||
return EnumBeeType.PRINCESS;
|
||||
} else if (ForestryItem.beeQueenGE.isItemEqual(stack)) {
|
||||
} else if (PluginApiculture.items.beeQueenGE == item) {
|
||||
return EnumBeeType.QUEEN;
|
||||
} else if (ForestryItem.beeLarvaeGE.isItemEqual(stack)) {
|
||||
} else if (PluginApiculture.items.beeLarvaeGE == item) {
|
||||
return EnumBeeType.LARVAE;
|
||||
}
|
||||
|
||||
@@ -189,7 +196,8 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
/* GENOME CONVERSIONS */
|
||||
@Override
|
||||
public IBeeGenome templateAsGenome(IAllele[] template) {
|
||||
return new BeeGenome(templateAsChromosomes(template));
|
||||
IChromosome[] chromosomes = templateAsChromosomes(template);
|
||||
return new BeeGenome(chromosomes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,7 +225,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
@Override
|
||||
public void registerTemplate(String identifier, IAllele[] template) {
|
||||
beeTemplates.add(new Bee(BeeManager.beeRoot.templateAsGenome(template)));
|
||||
IBeeGenome beeGenome = BeeManager.beeRoot.templateAsGenome(template);
|
||||
IBee bee = new Bee(beeGenome);
|
||||
beeTemplates.add(bee);
|
||||
speciesTemplates.put(identifier, template);
|
||||
}
|
||||
|
||||
@@ -318,10 +328,13 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
|
||||
// Create a tracker if there is none yet.
|
||||
if (tracker == null) {
|
||||
tracker = new ApiaristTracker(filename, player);
|
||||
tracker = new ApiaristTracker(filename);
|
||||
world.setItemData(filename, tracker);
|
||||
}
|
||||
|
||||
tracker.setUsername(player);
|
||||
tracker.setWorld(world);
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* 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.genetics;
|
||||
|
||||
import forestry.api.apiculture.IBeeIconColourProvider;
|
||||
|
||||
public class DefaultBeeIconColourProvider implements IBeeIconColourProvider {
|
||||
private final int primaryColour;
|
||||
private final int secondaryColour;
|
||||
|
||||
public DefaultBeeIconColourProvider(int primaryColour, int secondaryColour) {
|
||||
this.primaryColour = primaryColour;
|
||||
this.secondaryColour = secondaryColour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconColour(int renderPass) {
|
||||
if (renderPass == 0) {
|
||||
return primaryColour;
|
||||
}
|
||||
if (renderPass == 1) {
|
||||
return secondaryColour;
|
||||
}
|
||||
return 0xffffff;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*******************************************************************************
|
||||
* 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.genetics;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IBeeIconProvider;
|
||||
import forestry.core.render.TextureManager;
|
||||
|
||||
public class DefaultBeeIconProvider implements IBeeIconProvider {
|
||||
|
||||
public static final DefaultBeeIconProvider instance = new DefaultBeeIconProvider();
|
||||
|
||||
private DefaultBeeIconProvider() {
|
||||
|
||||
}
|
||||
|
||||
private static final IIcon[][] icons = new IIcon[EnumBeeType.values().length][3];
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister register) {
|
||||
String beeIconDir = "bees/default/";
|
||||
IIcon body1 = TextureManager.registerTex(register, beeIconDir + "body1");
|
||||
|
||||
for (int i = 0; i < EnumBeeType.values().length; i++) {
|
||||
EnumBeeType beeType = EnumBeeType.values()[i];
|
||||
if (beeType == EnumBeeType.NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String beeTypeNameBase = beeIconDir + beeType.toString().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
icons[i][0] = TextureManager.registerTex(register, beeTypeNameBase + ".outline");
|
||||
if (beeType == EnumBeeType.LARVAE) {
|
||||
icons[i][1] = TextureManager.registerTex(register, beeTypeNameBase + ".body");
|
||||
} else {
|
||||
icons[i][1] = body1;
|
||||
}
|
||||
icons[i][2] = TextureManager.registerTex(register, beeTypeNameBase + ".body2");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(EnumBeeType type, int renderPass) {
|
||||
return icons[type.ordinal()][renderPass];
|
||||
}
|
||||
}
|
||||
@@ -13,39 +13,19 @@ package forestry.apiculture.genetics;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.apiculture.genetics.alleles.AlleleEffect;
|
||||
|
||||
/**
|
||||
* Hermits will not produce if there are any other living creatures nearby.
|
||||
*/
|
||||
public class JubilanceProviderHermit extends JubilanceDefault {
|
||||
|
||||
@Override
|
||||
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
|
||||
AxisAlignedBB bounding = getBounding(genome, housing, 1.0f);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityLiving.class, bounding);
|
||||
List<EntityLiving> list = AlleleEffect.getEntitiesInRange(genome, housing, EntityLiving.class);
|
||||
return list.size() <= 0;
|
||||
}
|
||||
|
||||
private static AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing, float modifier) {
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr).multiply(modifier);
|
||||
Vect offset = area.multiply(-1 / 2.0f);
|
||||
|
||||
ChunkCoordinates housingCoordinates = housing.getCoordinates();
|
||||
|
||||
Vect min = new Vect(housingCoordinates).add(offset);
|
||||
Vect max = min.add(area);
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,16 +10,19 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IJubilanceProvider;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
//import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class JubilanceRequiresResource implements IJubilanceProvider {
|
||||
|
||||
@@ -33,10 +36,25 @@ public class JubilanceRequiresResource implements IJubilanceProvider {
|
||||
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
ChunkCoordinates housingCoords = housing.getCoordinates();
|
||||
/*
|
||||
Block block;
|
||||
TileEntity tile;
|
||||
int meta;
|
||||
int i = 1;
|
||||
do {
|
||||
block = world.getBlock(housingCoords.posX, housingCoords.posY - i, housingCoords.posZ);
|
||||
meta = world.getBlockMetadata(housingCoords.posX, housingCoords.posY - i, housingCoords.posZ);
|
||||
tile = world.getTileEntity(housingCoords.posX, housingCoords.posY - i, housingCoords.posZ);
|
||||
i++;
|
||||
} while (tile instanceof IBeeHousing);
|
||||
|
||||
Block block = world.getBlock(housingCoords.posX, housingCoords.posY - 1, housingCoords.posZ);
|
||||
int meta = world.getBlockMetadata(housingCoords.posX, housingCoords.posY - 1, housingCoords.posZ);
|
||||
return ItemStackUtil.equals(block, meta, blockRequired);
|
||||
*/
|
||||
ItemStack stk = BlockUtil.getItemStackFromBlockBelow(world, housingCoords.posX, housingCoords.posY, housingCoords.posZ,
|
||||
(TileEntity tile) -> (tile instanceof IBeeHousing)
|
||||
);
|
||||
|
||||
return InventoryUtil.isItemEqual(blockRequired, stk, true, true); //ffs dont compare itemsstacks with equal >_> and why tf didnt i got this until i debugged it? im getting old..
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,6 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -27,39 +26,38 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpeciesCustom;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeIconColourProvider;
|
||||
import forestry.api.apiculture.IBeeIconProvider;
|
||||
import forestry.api.apiculture.IBeeRoot;
|
||||
import forestry.api.apiculture.IJubilanceProvider;
|
||||
import forestry.api.core.IIconProvider;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.genetics.DefaultBeeIconColourProvider;
|
||||
import forestry.apiculture.genetics.DefaultBeeIconProvider;
|
||||
import forestry.apiculture.genetics.JubilanceDefault;
|
||||
import forestry.core.genetics.alleles.AlleleSpecies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpeciesCustom {
|
||||
private final Map<ItemStack, Float> productChances = new HashMap<>();
|
||||
private final Map<ItemStack, Float> specialtyChances = new HashMap<>();
|
||||
|
||||
private final int primaryColour;
|
||||
private final int secondaryColour;
|
||||
|
||||
private IBeeIconProvider beeIconProvider = DefaultBeeIconProvider.instance;
|
||||
private IJubilanceProvider jubilanceProvider = JubilanceDefault.instance;
|
||||
private IBeeIconProvider beeIconProvider;
|
||||
private IBeeIconColourProvider beeIconColourProvider;
|
||||
private IJubilanceProvider jubilanceProvider;
|
||||
private boolean nocturnal = false;
|
||||
|
||||
public AlleleBeeSpecies(String uid, String unlocalizedName, String authority, String unlocalizedDescription, boolean dominant, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
|
||||
super(uid, unlocalizedName, authority, unlocalizedDescription, dominant, branch, binomial);
|
||||
|
||||
this.primaryColour = primaryColor;
|
||||
this.secondaryColour = secondaryColor;
|
||||
beeIconProvider = DefaultBeeIconProvider.instance;
|
||||
beeIconColourProvider = new DefaultBeeIconColourProvider(primaryColor, secondaryColor);
|
||||
jubilanceProvider = JubilanceDefault.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,12 +107,13 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
return this;
|
||||
}
|
||||
|
||||
/* RESEARCH */
|
||||
@Override
|
||||
public int getComplexity() {
|
||||
return GeneticsUtil.getResearchComplexity(this, EnumBeeChromosome.SPECIES);
|
||||
public IAlleleBeeSpeciesCustom setCustomBeeIconColourProvider(IBeeIconColourProvider beeIconColourProvider) {
|
||||
this.beeIconColourProvider = beeIconColourProvider;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* RESEARCH */
|
||||
@Override
|
||||
public float getResearchSuitability(ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
@@ -185,13 +184,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
|
||||
@Override
|
||||
public int getIconColour(int renderPass) {
|
||||
if (renderPass == 0) {
|
||||
return primaryColour;
|
||||
}
|
||||
if (renderPass == 1) {
|
||||
return secondaryColour;
|
||||
}
|
||||
return 0xffffff;
|
||||
return beeIconColourProvider.getIconColour(renderPass);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,47 +192,6 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class DefaultBeeIconProvider implements IBeeIconProvider {
|
||||
|
||||
public static final DefaultBeeIconProvider instance = new DefaultBeeIconProvider();
|
||||
|
||||
private DefaultBeeIconProvider() {
|
||||
|
||||
}
|
||||
|
||||
private static final IIcon[][] icons = new IIcon[EnumBeeType.values().length][3];
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister register) {
|
||||
String beeIconDir = "bees/default/";
|
||||
IIcon body1 = TextureManager.registerTex(register, beeIconDir + "body1");
|
||||
|
||||
for (int i = 0; i < EnumBeeType.values().length; i++) {
|
||||
EnumBeeType beeType = EnumBeeType.values()[i];
|
||||
if (beeType == EnumBeeType.NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String beeTypeNameBase = beeIconDir + beeType.toString().toLowerCase(Locale.ENGLISH);
|
||||
|
||||
icons[i][0] = TextureManager.registerTex(register, beeTypeNameBase + ".outline");
|
||||
if (beeType == EnumBeeType.LARVAE) {
|
||||
icons[i][1] = TextureManager.registerTex(register, beeTypeNameBase + ".body");
|
||||
} else {
|
||||
icons[i][1] = body1;
|
||||
}
|
||||
icons[i][2] = TextureManager.registerTex(register, beeTypeNameBase + ".body2");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(EnumBeeType type, int renderPass) {
|
||||
return icons[type.ordinal()][renderPass];
|
||||
}
|
||||
}
|
||||
|
||||
private static class BeeIconProviderWrapper implements IIconProvider {
|
||||
|
||||
private final IBeeIconProvider beeIconProvider;
|
||||
|
||||
@@ -10,16 +10,26 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics.alleles;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.IAlleleBeeEffect;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.genetics.alleles.AlleleCategorized;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.EntityUtil;
|
||||
import forestry.core.utils.vect.MutableVect;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
@@ -45,6 +55,34 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
|
||||
public static IAlleleBeeEffect effectFertile;
|
||||
public static IAlleleBeeEffect effectMycophilic;
|
||||
|
||||
public static void createAlleles() {
|
||||
List<IAlleleBeeEffect> beeEffects = Arrays.asList(
|
||||
effectNone = new AlleleEffectNone("none", true),
|
||||
effectAggressive = new AlleleEffectAggressive(),
|
||||
effectHeroic = new AlleleEffectHeroic(),
|
||||
effectBeatific = new AlleleEffectPotion("beatific", false, Potion.regeneration, 100),
|
||||
effectMiasmic = new AlleleEffectPotion("miasmic", false, Potion.poison, 600, 100, 0.1f),
|
||||
effectMisanthrope = new AlleleEffectMisanthrope(),
|
||||
effectGlacial = new AlleleEffectGlacial(),
|
||||
effectRadioactive = new AlleleEffectRadioactive(),
|
||||
effectCreeper = new AlleleEffectCreeper(),
|
||||
effectIgnition = new AlleleEffectIgnition(),
|
||||
effectExploration = new AlleleEffectExploration(),
|
||||
effectFestiveEaster = new AlleleEffectNone("festiveEaster", true),
|
||||
effectSnowing = new AlleleEffectSnowing(),
|
||||
effectDrunkard = new AlleleEffectPotion("drunkard", false, Potion.confusion, 100),
|
||||
effectReanimation = new AlleleEffectResurrection("reanimation", AlleleEffectResurrection.getReanimationList()),
|
||||
effectResurrection = new AlleleEffectResurrection("resurrection", AlleleEffectResurrection.getResurrectionList()),
|
||||
effectRepulsion = new AlleleEffectRepulsion(),
|
||||
effectFertile = new AlleleEffectFertile(),
|
||||
effectMycophilic = new AlleleEffectFungification()
|
||||
);
|
||||
|
||||
for (IAlleleBeeEffect beeEffect : beeEffects) {
|
||||
AlleleManager.alleleRegistry.registerAllele(beeEffect, EnumBeeChromosome.EFFECT);
|
||||
}
|
||||
}
|
||||
|
||||
protected AlleleEffect(String valueName, boolean isDominant) {
|
||||
super("forestry", "effect", valueName, isDominant);
|
||||
}
|
||||
@@ -66,10 +104,21 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
|
||||
|
||||
@Override
|
||||
public IEffectData doFX(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
Proxies.render.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getCoordinates(), genome.getPrimary().getIconColour(0));
|
||||
Vec3 beeFXCoordinates = getFXCoordinates(housing);
|
||||
Proxies.render.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), beeFXCoordinates.xCoord, beeFXCoordinates.yCoord, beeFXCoordinates.zCoord, genome.getPrimary().getIconColour(0));
|
||||
return storedData;
|
||||
}
|
||||
|
||||
protected Vec3 getFXCoordinates(IBeeHousing housing) {
|
||||
try {
|
||||
return housing.getBeeFXCoordinates();
|
||||
} catch (Throwable error) {
|
||||
// getBeeFXCoordinates() is only newly added to the API, fall back on getCoordinates()
|
||||
ChunkCoordinates coordinates = housing.getCoordinates();
|
||||
return Vec3.createVectorHelper(coordinates.posX + 0.5D, coordinates.posY + 0.5D, coordinates.posZ + 0.5D);
|
||||
}
|
||||
}
|
||||
|
||||
protected Vect getModifiedArea(IBeeGenome genome, IBeeHousing housing) {
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
float territoryModifier = beeModifier.getTerritoryModifier(genome, 1f);
|
||||
@@ -90,7 +139,7 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
|
||||
return new Vect(area);
|
||||
}
|
||||
|
||||
protected AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing) {
|
||||
public static AxisAlignedBB getBounding(IBeeGenome genome, IBeeHousing housing) {
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
|
||||
float territoryModifier = beeModifier.getTerritoryModifier(genome, 1.0f);
|
||||
|
||||
@@ -104,4 +153,8 @@ public abstract class AlleleEffect extends AlleleCategorized implements IAlleleB
|
||||
return AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
|
||||
}
|
||||
|
||||
public static <T extends Entity> List<T> getEntitiesInRange(IBeeGenome genome, IBeeHousing housing, Class<T> entityClass) {
|
||||
AxisAlignedBB boundingBox = getBounding(genome, housing);
|
||||
return EntityUtil.getEntitiesWithinAABB(housing.getWorld(), entityClass, boundingBox);
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,6 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
@@ -24,7 +22,6 @@ import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.utils.DamageSourceForestry;
|
||||
|
||||
public class AlleleEffectAggressive extends AlleleEffectThrottled {
|
||||
|
||||
private static final DamageSource damageSourceBeeAggressive = new DamageSourceForestry("bee.aggressive");
|
||||
|
||||
public AlleleEffectAggressive() {
|
||||
@@ -33,29 +30,15 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
AxisAlignedBB hurtBox = getBounding(genome, housing);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, hurtBox);
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityLivingBase entity = (EntityLivingBase) obj;
|
||||
|
||||
List<EntityLivingBase> entities = getEntitiesInRange(genome, housing, EntityLivingBase.class);
|
||||
for (EntityLivingBase entity : entities) {
|
||||
int damage = 4;
|
||||
|
||||
// Players are not attacked if they wear a full set of apiarist's
|
||||
// armor.
|
||||
if (entity instanceof EntityPlayer) {
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems((EntityPlayer) entity, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3) {
|
||||
continue;
|
||||
} else if (count > 2) {
|
||||
damage = 1;
|
||||
} else if (count > 1) {
|
||||
damage = 2;
|
||||
} else if (count > 0) {
|
||||
damage = 3;
|
||||
}
|
||||
// Entities are not attacked if they wear a full set of apiarist's armor.
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems(entity, getUID(), true);
|
||||
damage -= count;
|
||||
if (damage <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entity.attackEntityFrom(damageSourceBeeAggressive, damage);
|
||||
|
||||
@@ -13,7 +13,6 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -59,24 +58,15 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB infectionBox = getBounding(genome, housing);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = world.getEntitiesWithinAABB(EntityPlayer.class, infectionBox);
|
||||
|
||||
for (Object obj : list) {
|
||||
|
||||
EntityPlayer player = (EntityPlayer) obj;
|
||||
|
||||
List<EntityPlayer> players = getEntitiesInRange(genome, housing, EntityPlayer.class);
|
||||
for (EntityPlayer player : players) {
|
||||
int chance = explosionChance;
|
||||
storedData.setInteger(indexExplosionForce, defaultForce);
|
||||
|
||||
// Players are not attacked if they wear a full set of apiarist's
|
||||
// armor.
|
||||
// Entities are not attacked if they wear a full set of apiarist's armor.
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems(player, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3) {
|
||||
continue;
|
||||
continue; // Full set, no damage/effect
|
||||
} else if (count > 2) {
|
||||
chance = 5;
|
||||
storedData.setInteger(indexExplosionForce, 6);
|
||||
@@ -94,8 +84,7 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
|
||||
world.playSoundEffect(housingCoords.posX, housingCoords.posY, housingCoords.posZ, "mob.creeper", 4F,
|
||||
(1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
|
||||
storedData.setInteger(indexExplosionTimer, 2); // Set explosion
|
||||
// timer
|
||||
storedData.setInteger(indexExplosionTimer, 2); // Set explosion timer
|
||||
}
|
||||
|
||||
return storedData;
|
||||
|
||||
@@ -13,7 +13,6 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
@@ -27,13 +26,8 @@ public class AlleleEffectExploration extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
AxisAlignedBB beatifyBox = getBounding(genome, housing);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, beatifyBox);
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityPlayer player = (EntityPlayer) obj;
|
||||
List<EntityPlayer> players = getEntitiesInRange(genome, housing, EntityPlayer.class);
|
||||
for (EntityPlayer player : players) {
|
||||
player.addExperience(2);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,12 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
@@ -58,8 +61,8 @@ public class AlleleEffectFertile extends AlleleEffectThrottled {
|
||||
|
||||
private static 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);
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (block.getTickRandomly() && (block instanceof IGrowable || block instanceof IPlantable)) {
|
||||
world.scheduleBlockUpdate(x, y, z, block, 5);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ 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.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
|
||||
@@ -78,16 +77,10 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
|
||||
|
||||
}
|
||||
|
||||
private void doEntityEffect(IBeeGenome genome, IBeeHousing housing) {
|
||||
AxisAlignedBB aabb = this.getBounding(genome, housing);
|
||||
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 static void doEntityEffect(IBeeGenome genome, IBeeHousing housing) {
|
||||
List<EntityCow> cows = getEntitiesInRange(genome, housing, EntityCow.class);
|
||||
for (EntityCow cow : cows) {
|
||||
convertCowToMooshroom(cow);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +97,9 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
|
||||
}
|
||||
|
||||
private static void convertCowToMooshroom(EntityCow cow) {
|
||||
if (cow instanceof EntityMooshroom) {
|
||||
return;
|
||||
}
|
||||
World worldObj = cow.worldObj;
|
||||
cow.setDead();
|
||||
EntityMooshroom mooshroom = new EntityMooshroom(worldObj);
|
||||
|
||||
@@ -13,14 +13,15 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.utils.DamageSourceForestry;
|
||||
|
||||
public class AlleleEffectHeroic extends AlleleEffectThrottled {
|
||||
private static final DamageSource damageSourceBeeHeroic = new DamageSourceForestry("bee.heroic");
|
||||
|
||||
public AlleleEffectHeroic() {
|
||||
super("heroic", false, 40, true, false);
|
||||
@@ -28,16 +29,11 @@ public class AlleleEffectHeroic extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
AxisAlignedBB hurtBox = getBounding(genome, housing);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityMob.class, hurtBox);
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityMob mob = (EntityMob) obj;
|
||||
mob.attackEntityFrom(DamageSource.generic, 2);
|
||||
List<EntityMob> mobs = getEntitiesInRange(genome, housing, EntityMob.class);
|
||||
for (EntityMob mob : mobs) {
|
||||
mob.attackEntityFrom(damageSourceBeeHeroic, 2);
|
||||
}
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,8 +13,7 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
@@ -24,7 +23,6 @@ import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class AlleleEffectIgnition extends AlleleEffectThrottled {
|
||||
|
||||
private static final int ignitionChance = 50;
|
||||
private static final int fireDuration = 500;
|
||||
|
||||
@@ -34,35 +32,25 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
World world = housing.getWorld();
|
||||
|
||||
AxisAlignedBB hurtBox = getBounding(genome, housing);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = world.getEntitiesWithinAABB(EntityLivingBase.class, hurtBox);
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityLivingBase entity = (EntityLivingBase) obj;
|
||||
|
||||
List<EntityLivingBase> entities = getEntitiesInRange(genome, housing, EntityLivingBase.class);
|
||||
for (EntityLivingBase entity : entities) {
|
||||
int chance = ignitionChance;
|
||||
int duration = fireDuration;
|
||||
|
||||
// Players are not attacked if they wear a full set of apiarist's armor.
|
||||
if (entity instanceof EntityPlayer) {
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems((EntityPlayer) entity, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3) {
|
||||
continue;
|
||||
} else if (count > 2) {
|
||||
chance = 5;
|
||||
duration = 50;
|
||||
} else if (count > 1) {
|
||||
chance = 20;
|
||||
duration = 200;
|
||||
} else if (count > 0) {
|
||||
chance = 35;
|
||||
duration = 350;
|
||||
}
|
||||
// Entities are not attacked if they wear a full set of apiarist's armor.
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems(entity, getUID(), true);
|
||||
if (count > 3) {
|
||||
continue; // Full set, no damage/effect
|
||||
} else if (count > 2) {
|
||||
chance = 5;
|
||||
duration = 50;
|
||||
} else if (count > 1) {
|
||||
chance = 20;
|
||||
duration = 200;
|
||||
} else if (count > 0) {
|
||||
chance = 35;
|
||||
duration = 350;
|
||||
}
|
||||
|
||||
if (world.rand.nextInt(1000) >= chance) {
|
||||
@@ -80,7 +68,8 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
|
||||
if (housing.getWorld().rand.nextInt(2) != 0) {
|
||||
super.doFX(genome, storedData, housing);
|
||||
} else {
|
||||
Proxies.render.addEntityIgnitionFX(housing.getWorld(), housing.getCoordinates().posX + 0.5, housing.getCoordinates().posY + 1, housing.getCoordinates().posZ + 0.5);
|
||||
Vec3 beeFXCoordinates = getFXCoordinates(housing);
|
||||
Proxies.render.addEntityIgnitionFX(housing.getWorld(), beeFXCoordinates.xCoord, beeFXCoordinates.yCoord + 0.5, beeFXCoordinates.zCoord);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ package forestry.apiculture.genetics.alleles;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
@@ -32,28 +31,15 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
AxisAlignedBB beatifyBox = getBounding(genome, housing);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, beatifyBox);
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityPlayer player = (EntityPlayer) obj;
|
||||
|
||||
List<EntityPlayer> players = getEntitiesInRange(genome, housing, EntityPlayer.class);
|
||||
for (EntityPlayer player : players) {
|
||||
int damage = 4;
|
||||
|
||||
// Players are not attacked if they wear a full set of apiarist's
|
||||
// armor.
|
||||
// Entities are not attacked if they wear a full set of apiarist's armor.
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems(player, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3) {
|
||||
damage -= count;
|
||||
if (damage <= 0) {
|
||||
continue;
|
||||
} else if (count > 2) {
|
||||
damage = 1;
|
||||
} else if (count > 1) {
|
||||
damage = 2;
|
||||
} else if (count > 0) {
|
||||
damage = 3;
|
||||
}
|
||||
|
||||
player.attackEntityFrom(damageSourceBeeEnd, damage);
|
||||
|
||||
@@ -14,12 +14,12 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.potion.PotionHelper;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
@@ -56,26 +56,17 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
World world = housing.getWorld();
|
||||
AxisAlignedBB effectArea = getBounding(genome, housing);
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, effectArea);
|
||||
|
||||
for (Object entity : list) {
|
||||
if (!(entity instanceof EntityPlayer)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<EntityLivingBase> entities = getEntitiesInRange(genome, housing, EntityLivingBase.class);
|
||||
for (EntityLivingBase entity : entities) {
|
||||
if (world.rand.nextFloat() >= chance) {
|
||||
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 = BeeManager.armorApiaristHelper.wearsItems((EntityPlayer) entity, getUID(), true);
|
||||
// Entities are not attacked if they wear a full set of apiarist's armor.
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems(entity, getUID(), true);
|
||||
if (count >= 4) {
|
||||
continue; // Full set, no damage/effect
|
||||
} else if (count == 3) {
|
||||
@@ -85,9 +76,14 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
|
||||
} else if (count == 1) {
|
||||
dur = this.duration * 3 / 4;
|
||||
}
|
||||
} else {
|
||||
// don't apply positive effects to mobs
|
||||
if (entity instanceof IMob) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(potion.getId(), dur, 0));
|
||||
entity.addPotionEffect(new PotionEffect(potion.getId(), dur, 0));
|
||||
}
|
||||
|
||||
return storedData;
|
||||
@@ -108,8 +104,8 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
|
||||
if (housing.getWorld().rand.nextBoolean()) {
|
||||
super.doFX(genome, storedData, housing);
|
||||
} else {
|
||||
ChunkCoordinates coords = housing.getCoordinates();
|
||||
Proxies.render.addEntityPotionFX(housing.getWorld(), coords.posX + 0.5, coords.posY + 1, coords.posZ + 0.5, potionFXColor);
|
||||
Vec3 beeFXCoordinates = getFXCoordinates(housing);
|
||||
Proxies.render.addEntityPotionFX(housing.getWorld(), beeFXCoordinates.xCoord, beeFXCoordinates.yCoord + 0.5, beeFXCoordinates.zCoord, potionFXColor);
|
||||
}
|
||||
return storedData;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,7 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -26,7 +24,6 @@ import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.apiculture.blocks.BlockAlveary;
|
||||
import forestry.apiculture.multiblock.TileAlveary;
|
||||
import forestry.core.utils.DamageSourceForestry;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
@@ -40,54 +37,38 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
harmEntities(genome, housing);
|
||||
|
||||
return destroyEnvironment(genome, storedData, housing);
|
||||
}
|
||||
|
||||
private void harmEntities(IBeeGenome genome, IBeeHousing housing) {
|
||||
List<EntityLivingBase> entities = getEntitiesInRange(genome, housing, EntityLivingBase.class);
|
||||
for (EntityLivingBase entity : entities) {
|
||||
int damage = 8;
|
||||
|
||||
// Entities are not attacked if they wear a full set of apiarist's armor.
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems(entity, getUID(), true);
|
||||
damage -= (count * 2);
|
||||
if (damage <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entity.attackEntityFrom(damageSourceBeeRadioactive, damage);
|
||||
}
|
||||
}
|
||||
|
||||
private static IEffectData destroyEnvironment(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
Random rand = world.rand;
|
||||
|
||||
int[] areaAr = genome.getTerritory();
|
||||
Vect area = new Vect(areaAr).multiply(2);
|
||||
Vect offset = area.multiply(-1 / 2.0f);
|
||||
Vect posHousing = new Vect(housing.getCoordinates());
|
||||
|
||||
// Radioactivity hurts players and mobs
|
||||
Vect min = new Vect(housing.getCoordinates()).add(offset);
|
||||
Vect max = min.add(area);
|
||||
|
||||
AxisAlignedBB hurtBox = AxisAlignedBB.getBoundingBox(min.x, min.y, min.z, max.x, max.y, max.z);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, hurtBox);
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityLivingBase entity = (EntityLivingBase) obj;
|
||||
|
||||
int damage = 8;
|
||||
|
||||
// Players are not attacked if they wear a full set of apiarist's
|
||||
// armor.
|
||||
if (entity instanceof EntityPlayer) {
|
||||
int count = BeeManager.armorApiaristHelper.wearsItems((EntityPlayer) entity, getUID(), true);
|
||||
// Full set, no damage/effect
|
||||
if (count > 3) {
|
||||
continue;
|
||||
} else if (count > 2) {
|
||||
damage = 1;
|
||||
} else if (count > 1) {
|
||||
damage = 2;
|
||||
} else if (count > 0) {
|
||||
damage = 3;
|
||||
}
|
||||
}
|
||||
|
||||
entity.attackEntityFrom(damageSourceBeeRadioactive, damage);
|
||||
|
||||
}
|
||||
|
||||
Random rand = housing.getWorld().rand;
|
||||
// Radioactivity destroys environment
|
||||
for (int i = 0; i < 20; i++) {
|
||||
|
||||
Vect randomPos = Vect.getRandomPositionInArea(rand, area);
|
||||
|
||||
Vect posHousing = new Vect(housing.getCoordinates());
|
||||
Vect posBlock = randomPos.add(posHousing);
|
||||
posBlock = posBlock.add(offset);
|
||||
|
||||
@@ -114,9 +95,6 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
if (tile instanceof IBeeHousing) {
|
||||
continue;
|
||||
}
|
||||
if (tile instanceof TileAlveary) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
|
||||
continue;
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
@@ -29,31 +28,24 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
if (housing.getOwner() == null) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
AxisAlignedBB hurtBox = getBounding(genome, housing);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityMob.class, hurtBox);
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityMob mob = (EntityMob) obj;
|
||||
|
||||
for (Object objT : mob.tasks.taskEntries) {
|
||||
EntityAITaskEntry task = (EntityAITaskEntry) objT;
|
||||
if (task.action instanceof AIAvoidPlayers) {
|
||||
return storedData;
|
||||
}
|
||||
List<EntityMob> mobs = getEntitiesInRange(genome, housing, EntityMob.class);
|
||||
for (EntityMob mob : mobs) {
|
||||
if (!isMobAvoidingPlayers(mob)) {
|
||||
mob.tasks.addTask(3, new AIAvoidPlayers(mob, 6.0f, 0.25f, 0.3f));
|
||||
mob.tasks.onUpdateTasks();
|
||||
}
|
||||
|
||||
mob.tasks.addTask(3, new AIAvoidPlayers(mob, 6.0f, 0.25f, 0.3f));
|
||||
mob.tasks.onUpdateTasks();
|
||||
|
||||
}
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
private boolean isMobAvoidingPlayers(EntityMob mob) {
|
||||
for (Object objT : mob.tasks.taskEntries) {
|
||||
EntityAITaskEntry task = (EntityAITaskEntry) objT;
|
||||
if (task.action instanceof AIAvoidPlayers) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
@@ -79,35 +78,37 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
|
||||
|
||||
@Override
|
||||
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
|
||||
|
||||
AxisAlignedBB bounding = getBounding(genome, housing);
|
||||
@SuppressWarnings("rawtypes")
|
||||
List list = housing.getWorld().getEntitiesWithinAABB(EntityItem.class, bounding);
|
||||
|
||||
if (list.size() > 0) {
|
||||
Collections.shuffle(resurrectables);
|
||||
List<EntityItem> entities = getEntitiesInRange(genome, housing, EntityItem.class);
|
||||
if (entities.size() == 0) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
for (Object obj : list) {
|
||||
EntityItem item = (EntityItem) obj;
|
||||
if (item.isDead) {
|
||||
continue;
|
||||
}
|
||||
Collections.shuffle(resurrectables);
|
||||
|
||||
ItemStack contained = item.getEntityItem();
|
||||
for (Resurrectable entry : resurrectables) {
|
||||
if (ItemStackUtil.isIdenticalItem(entry.res, contained)) {
|
||||
EntityUtil.spawnEntity(housing.getWorld(), entry.risen, item.posX, item.posY, item.posZ);
|
||||
contained.stackSize--;
|
||||
if (contained.stackSize <= 0) {
|
||||
item.setDead();
|
||||
}
|
||||
break;
|
||||
}
|
||||
for (EntityItem entity : entities) {
|
||||
if (resurrectEntity(entity)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return storedData;
|
||||
}
|
||||
|
||||
private boolean resurrectEntity(EntityItem entity) {
|
||||
if (entity.isDead) {
|
||||
return false;
|
||||
}
|
||||
ItemStack contained = entity.getEntityItem();
|
||||
for (Resurrectable entry : resurrectables) {
|
||||
if (ItemStackUtil.isIdenticalItem(entry.res, contained)) {
|
||||
EntityUtil.spawnEntity(entity.worldObj, entry.risen, entity.posX, entity.posY, entity.posZ);
|
||||
contained.stackSize--;
|
||||
if (contained.stackSize <= 0) {
|
||||
entity.setDead();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -12,32 +12,15 @@ package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.apiculture.BeeHousingInventory;
|
||||
import forestry.apiculture.multiblock.TileAlvearyPlain;
|
||||
import forestry.apiculture.multiblock.TileAlveary;
|
||||
import forestry.core.gui.ContainerTile;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.network.PacketGuiUpdate;
|
||||
import forestry.core.network.packets.PacketGuiUpdate;
|
||||
|
||||
public class ContainerAlveary extends ContainerTile<TileAlvearyPlain> {
|
||||
public class ContainerAlveary extends ContainerTile<TileAlveary> {
|
||||
|
||||
public ContainerAlveary(InventoryPlayer player, TileAlvearyPlain tile) {
|
||||
public ContainerAlveary(InventoryPlayer player, TileAlveary tile) {
|
||||
super(tile, player, 8, 108);
|
||||
|
||||
// Queen/Princess
|
||||
this.addSlotToContainer(new SlotFiltered(tile, BeeHousingInventory.SLOT_QUEEN, 29, 39));
|
||||
|
||||
// Drone
|
||||
this.addSlotToContainer(new SlotFiltered(tile, BeeHousingInventory.SLOT_DRONE, 29, 65));
|
||||
|
||||
// Product Inventory
|
||||
this.addSlotToContainer(new SlotOutput(tile, 2, 116, 52));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 3, 137, 39));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 4, 137, 65));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 5, 116, 78));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 6, 95, 65));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 7, 95, 39));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26));
|
||||
ContainerBeeHelper.addSlots(this, tile, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.apiculture.inventory.InventoryHygroregulator;
|
||||
import forestry.apiculture.multiblock.TileAlvearyHygroregulator;
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
@@ -21,7 +22,7 @@ public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks<TileAlv
|
||||
public ContainerAlvearyHygroregulator(InventoryPlayer playerInventory, TileAlvearyHygroregulator tile) {
|
||||
super(tile, playerInventory, 8, 84);
|
||||
|
||||
this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyHygroregulator.HygroInventory.SLOT_INPUT, 56, 38));
|
||||
this.addSlotToContainer(new SlotFiltered(tile, InventoryHygroregulator.SLOT_INPUT, 56, 38));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,21 +12,25 @@ package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.apiculture.inventory.InventoryAlvearySieve;
|
||||
import forestry.apiculture.multiblock.TileAlvearySieve;
|
||||
import forestry.core.gui.ContainerTile;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.inventory.watchers.ISlotPickupWatcher;
|
||||
|
||||
public class ContainerAlvearySieve extends ContainerTile<TileAlvearySieve> {
|
||||
|
||||
public ContainerAlvearySieve(InventoryPlayer player, TileAlvearySieve tile) {
|
||||
super(tile, player, 8, 87);
|
||||
|
||||
addSlotToContainer(new SlotOutput(tile, 0, 94, 52).setCrafter(tile));
|
||||
addSlotToContainer(new SlotOutput(tile, 1, 115, 39).setCrafter(tile));
|
||||
addSlotToContainer(new SlotOutput(tile, 2, 73, 39).setCrafter(tile));
|
||||
addSlotToContainer(new SlotOutput(tile, 3, 94, 26).setCrafter(tile));
|
||||
ISlotPickupWatcher crafter = tile.getCrafter();
|
||||
|
||||
addSlotToContainer(new SlotFiltered(tile, TileAlvearySieve.AlvearySieveInventory.SLOT_SIEVE, 43, 39).setCrafter(tile));
|
||||
addSlotToContainer(new SlotOutput(tile, 0, 94, 52).setPickupWatcher(crafter));
|
||||
addSlotToContainer(new SlotOutput(tile, 1, 115, 39).setPickupWatcher(crafter));
|
||||
addSlotToContainer(new SlotOutput(tile, 2, 73, 39).setPickupWatcher(crafter));
|
||||
addSlotToContainer(new SlotOutput(tile, 3, 94, 26).setPickupWatcher(crafter));
|
||||
|
||||
addSlotToContainer(new SlotFiltered(tile, InventoryAlvearySieve.SLOT_SIEVE, 43, 39).setPickupWatcher(crafter));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*******************************************************************************
|
||||
* 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.gui;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import forestry.apiculture.InventoryBeeHousing;
|
||||
import forestry.apiculture.inventory.InventoryApiary;
|
||||
import forestry.core.gui.ContainerForestry;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.tiles.IFilterSlotDelegate;
|
||||
|
||||
public abstract class ContainerBeeHelper {
|
||||
public static <T extends IInventory & IFilterSlotDelegate> void addSlots(ContainerForestry container, T inventory, boolean hasFrames) {
|
||||
// Queen/Princess
|
||||
container.addSlotToContainer(new SlotFiltered(inventory, InventoryBeeHousing.SLOT_QUEEN, 29, 39));
|
||||
|
||||
// Drone
|
||||
container.addSlotToContainer(new SlotFiltered(inventory, InventoryBeeHousing.SLOT_DRONE, 29, 65));
|
||||
|
||||
// Frames
|
||||
if (hasFrames) {
|
||||
int slotFrames = InventoryApiary.SLOT_FRAMES_1;
|
||||
container.addSlotToContainer(new SlotFiltered(inventory, slotFrames++, 66, 23));
|
||||
container.addSlotToContainer(new SlotFiltered(inventory, slotFrames++, 66, 52));
|
||||
container.addSlotToContainer(new SlotFiltered(inventory, slotFrames, 66, 81));
|
||||
}
|
||||
|
||||
// Product Inventory
|
||||
int slotProduct = InventoryBeeHousing.SLOT_PRODUCT_1;
|
||||
container.addSlotToContainer(new SlotOutput(inventory, slotProduct++, 116, 52));
|
||||
container.addSlotToContainer(new SlotOutput(inventory, slotProduct++, 137, 39));
|
||||
container.addSlotToContainer(new SlotOutput(inventory, slotProduct++, 137, 65));
|
||||
container.addSlotToContainer(new SlotOutput(inventory, slotProduct++, 116, 78));
|
||||
container.addSlotToContainer(new SlotOutput(inventory, slotProduct++, 95, 65));
|
||||
container.addSlotToContainer(new SlotOutput(inventory, slotProduct++, 95, 39));
|
||||
container.addSlotToContainer(new SlotOutput(inventory, slotProduct, 116, 26));
|
||||
}
|
||||
}
|
||||
@@ -11,54 +11,30 @@
|
||||
package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
|
||||
import forestry.apiculture.BeeHousingInventory;
|
||||
import forestry.apiculture.tiles.TileAbstractBeeHousing;
|
||||
import forestry.apiculture.tiles.TileApiary;
|
||||
import forestry.apiculture.tiles.TileBeeHousingBase;
|
||||
import forestry.core.gui.ContainerTile;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.packets.PacketGuiUpdate;
|
||||
|
||||
public class ContainerBeeHousing extends ContainerTile<TileAbstractBeeHousing> {
|
||||
public class ContainerBeeHousing extends ContainerTile<TileBeeHousingBase> implements IContainerBeeHousing {
|
||||
|
||||
public ContainerBeeHousing(InventoryPlayer player, TileAbstractBeeHousing tile, boolean hasFrames) {
|
||||
public ContainerBeeHousing(InventoryPlayer player, TileBeeHousingBase tile, boolean hasFrames) {
|
||||
super(tile, player, 8, 108);
|
||||
|
||||
// Queen/Princess
|
||||
this.addSlotToContainer(new SlotFiltered(tile, BeeHousingInventory.SLOT_QUEEN, 29, 39));
|
||||
|
||||
// Drone
|
||||
this.addSlotToContainer(new SlotFiltered(tile, BeeHousingInventory.SLOT_DRONE, 29, 65));
|
||||
|
||||
// Frames
|
||||
if (hasFrames) {
|
||||
final int slotFrames1 = TileApiary.ApiaryInventory.SLOT_FRAMES_1;
|
||||
this.addSlotToContainer(new SlotFiltered(tile, slotFrames1, 66, 23));
|
||||
this.addSlotToContainer(new SlotFiltered(tile, slotFrames1 + 1, 66, 52));
|
||||
this.addSlotToContainer(new SlotFiltered(tile, slotFrames1 + 2, 66, 81));
|
||||
}
|
||||
|
||||
// Product Inventory
|
||||
this.addSlotToContainer(new SlotOutput(tile, 2, 116, 52));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 3, 137, 39));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 4, 137, 65));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 5, 116, 78));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 6, 95, 65));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 7, 95, 39));
|
||||
this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26));
|
||||
ContainerBeeHelper.addSlots(this, tile, hasFrames);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
tile.getGUINetworkData(i, j);
|
||||
}
|
||||
private int beeProgress = 0;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (Object crafter : crafters) {
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafter);
|
||||
|
||||
int beeProgress = tile.getBeekeepingLogic().getBeeProgressPercent();
|
||||
if (this.beeProgress != beeProgress) {
|
||||
this.beeProgress = beeProgress;
|
||||
IForestryPacketClient packet = new PacketGuiUpdate(tile);
|
||||
sendPacketToCrafters(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory;
|
||||
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
|
||||
public class ContainerHabitatLocator extends ContainerItemInventory<HabitatLocatorInventory> {
|
||||
public class ContainerHabitatLocator extends ContainerItemInventory<ItemInventoryHabitatLocator> {
|
||||
|
||||
public ContainerHabitatLocator(EntityPlayer player, HabitatLocatorInventory inventory) {
|
||||
public ContainerHabitatLocator(EntityPlayer player, ItemInventoryHabitatLocator inventory) {
|
||||
super(inventory, player.inventory, 8, 102);
|
||||
|
||||
// Energy
|
||||
|
||||
@@ -10,23 +10,21 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
|
||||
import forestry.apiculture.network.PacketImprintSelectionResponse;
|
||||
import forestry.apiculture.inventory.ItemInventoryImprinter;
|
||||
import forestry.apiculture.network.packets.PacketImprintSelectionResponse;
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
|
||||
public class ContainerImprinter extends ContainerItemInventory<ImprinterInventory> implements IGuiSelectable {
|
||||
public class ContainerImprinter extends ContainerItemInventory<ItemInventoryImprinter> implements IGuiSelectable {
|
||||
|
||||
public ContainerImprinter(InventoryPlayer inventoryplayer, ImprinterInventory inventory) {
|
||||
public ContainerImprinter(InventoryPlayer inventoryplayer, ItemInventoryImprinter inventory) {
|
||||
super(inventory, inventoryplayer, 8, 103);
|
||||
|
||||
// Input
|
||||
@@ -35,15 +33,6 @@ public class ContainerImprinter extends ContainerItemInventory<ImprinterInventor
|
||||
this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 72));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer) {
|
||||
if (entityplayer.worldObj.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryUtil.dropInventory(inventory, entityplayer.worldObj, entityplayer.posX, entityplayer.posY, entityplayer.posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSelectionRequest(EntityPlayerMP player, PacketGuiSelectRequest packetRequest) {
|
||||
if (packetRequest.getPrimaryIndex() == 0) {
|
||||
|
||||
@@ -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.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.apiculture.entities.EntityMinecartBeeHousingBase;
|
||||
import forestry.core.gui.ContainerEntity;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
import forestry.core.network.packets.PacketGuiUpdateEntity;
|
||||
|
||||
public class ContainerMinecartBeehouse extends ContainerEntity<EntityMinecartBeeHousingBase> implements IContainerBeeHousing {
|
||||
public ContainerMinecartBeehouse(InventoryPlayer player, EntityMinecartBeeHousingBase entity, boolean hasFrames) {
|
||||
super(entity, player, 8, 108);
|
||||
ContainerBeeHelper.addSlots(this, entity, hasFrames);
|
||||
}
|
||||
|
||||
private int beeProgress = 0;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
int beeProgress = entity.getBeekeepingLogic().getBeeProgressPercent();
|
||||
if (this.beeProgress != beeProgress) {
|
||||
this.beeProgress = beeProgress;
|
||||
IForestryPacketClient packet = new PacketGuiUpdateEntity(entity, entity);
|
||||
sendPacketToCrafters(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,16 +12,15 @@ package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.apiculture.multiblock.IAlvearyController;
|
||||
import forestry.apiculture.multiblock.TileAlvearyPlain;
|
||||
import forestry.apiculture.multiblock.IAlvearyControllerInternal;
|
||||
import forestry.apiculture.multiblock.TileAlveary;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.ledgers.OwnerLedger;
|
||||
import forestry.core.render.EnumTankLevel;
|
||||
|
||||
public class GuiAlveary extends GuiForestryTitled<ContainerAlveary, TileAlvearyPlain> {
|
||||
public class GuiAlveary extends GuiForestryTitled<ContainerAlveary, TileAlveary> {
|
||||
|
||||
public GuiAlveary(InventoryPlayer inventory, TileAlvearyPlain tile) {
|
||||
public GuiAlveary(InventoryPlayer inventory, TileAlveary tile) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/alveary.png", new ContainerAlveary(inventory, tile), tile);
|
||||
|
||||
ySize = 190;
|
||||
@@ -31,7 +30,7 @@ public class GuiAlveary extends GuiForestryTitled<ContainerAlveary, TileAlvearyP
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
IAlvearyController alvearyController = inventory.getAlvearyController();
|
||||
IAlvearyControllerInternal alvearyController = inventory.getMultiblockLogic().getController();
|
||||
drawHealthMeter(guiLeft + 20, guiTop + 37, alvearyController.getHealthScaled(46), EnumTankLevel.rateTankLevel(alvearyController.getHealthScaled(100)));
|
||||
}
|
||||
|
||||
@@ -41,13 +40,4 @@ public class GuiAlveary extends GuiForestryTitled<ContainerAlveary, TileAlvearyP
|
||||
|
||||
this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
|
||||
}
|
||||
|
||||
/* LEDGERS */
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
IAlvearyController alvearyController = inventory.getAlvearyController();
|
||||
ledgerManager.add(new OwnerLedger(ledgerManager, alvearyController));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,26 +10,27 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import forestry.apiculture.tiles.TileAbstractBeeHousing;
|
||||
import forestry.apiculture.tiles.TileApiary;
|
||||
import forestry.apiculture.tiles.TileBeehouse;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.render.EnumTankLevel;
|
||||
|
||||
public class GuiBeeHousing extends GuiForestryTitled<ContainerBeeHousing, TileAbstractBeeHousing> {
|
||||
public class GuiBeeHousing<C extends Container & IContainerBeeHousing> extends GuiForestryTitled<C, IGuiBeeHousingInventory> {
|
||||
|
||||
public GuiBeeHousing(InventoryPlayer inventory, TileApiary tile) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/apiary.png", new ContainerBeeHousing(inventory, tile, true), tile);
|
||||
public enum Icon {
|
||||
APIARY("/apiary.png"),
|
||||
BEE_HOUSE("/alveary.png");
|
||||
|
||||
ySize = 190;
|
||||
private final String path;
|
||||
|
||||
Icon(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
}
|
||||
|
||||
public GuiBeeHousing(InventoryPlayer inventory, TileBeehouse tile) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/alveary.png", new ContainerBeeHousing(inventory, tile, false), tile);
|
||||
|
||||
public GuiBeeHousing(IGuiBeeHousingInventory tile, C container, Icon icon) {
|
||||
super(Constants.TEXTURE_PATH_GUI + icon.path, container, tile);
|
||||
ySize = 190;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,26 +21,24 @@ import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAlleleArea;
|
||||
import forestry.api.genetics.IAlleleInteger;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
import forestry.apiculture.genetics.BeeGenome;
|
||||
import forestry.apiculture.items.ItemBeeGE;
|
||||
import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.apiculture.inventory.ItemInventoryBeealyzer;
|
||||
import forestry.core.genetics.alleles.AlleleBoolean;
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
import forestry.core.gui.GuiAlyzer;
|
||||
import forestry.core.gui.widgets.ItemStackWidget;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class GuiBeealyzer extends GuiAlyzer {
|
||||
|
||||
public GuiBeealyzer(EntityPlayer player, BeealyzerInventory inventory) {
|
||||
super("rootBees", player, new ContainerAlyzer(inventory, player), inventory, "gui.beealyzer");
|
||||
public GuiBeealyzer(EntityPlayer player, ItemInventoryBeealyzer inventory) {
|
||||
super(BeeManager.beeRoot, player, new ContainerAlyzer(inventory, player), inventory, "gui.beealyzer");
|
||||
|
||||
ArrayList<ItemStack> beeList = new ArrayList<>();
|
||||
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
|
||||
PluginApiculture.items.beeDroneGE.addCreativeItems(beeList, false);
|
||||
for (ItemStack beeStack : beeList) {
|
||||
IAlleleBeeSpecies species = BeeGenome.getSpecies(beeStack);
|
||||
if (species != null) {
|
||||
@@ -57,8 +55,8 @@ public class GuiBeealyzer extends GuiAlyzer {
|
||||
IBee bee = null;
|
||||
EnumBeeType beeType = EnumBeeType.DRONE;
|
||||
|
||||
for (int k = BeealyzerInventory.SLOT_SPECIMEN; k <= BeealyzerInventory.SLOT_ANALYZE_5; k++) {
|
||||
if (k == BeealyzerInventory.SLOT_ENERGY) {
|
||||
for (int k = ItemInventoryBeealyzer.SLOT_SPECIMEN; k <= ItemInventoryBeealyzer.SLOT_ANALYZE_5; k++) {
|
||||
if (k == ItemInventoryBeealyzer.SLOT_ENERGY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -99,81 +97,81 @@ public class GuiBeealyzer extends GuiAlyzer {
|
||||
|
||||
private void drawAnalyticsPage1(IBee bee, EnumBeeType type) {
|
||||
|
||||
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
|
||||
textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2);
|
||||
|
||||
drawLine(StringUtil.localize("gui.active"), COLUMN_1);
|
||||
drawLine(StringUtil.localize("gui.inactive"), COLUMN_2);
|
||||
textLayout.drawLine(StringUtil.localize("gui.active"), COLUMN_1);
|
||||
textLayout.drawLine(StringUtil.localize("gui.inactive"), COLUMN_2);
|
||||
|
||||
newLine();
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
{
|
||||
String customPrimaryBeeKey = "bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.", "");
|
||||
String customSecondaryBeeKey = "bees.custom.beealyzer." + type.getName() + "." + bee.getGenome().getSecondary().getUnlocalizedName().replace("bees.species.", "");
|
||||
|
||||
drawSpeciesRow(StringUtil.localize("gui.species"), bee, EnumBeeChromosome.SPECIES, checkCustomName(customPrimaryBeeKey), checkCustomName(customSecondaryBeeKey));
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
}
|
||||
|
||||
drawChromosomeRow(StringUtil.localize("gui.lifespan"), bee, EnumBeeChromosome.LIFESPAN);
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
drawChromosomeRow(StringUtil.localize("gui.speed"), bee, EnumBeeChromosome.SPEED);
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
drawChromosomeRow(StringUtil.localize("gui.pollination"), bee, EnumBeeChromosome.FLOWERING);
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
drawChromosomeRow(StringUtil.localize("gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER);
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
drawLine(StringUtil.localize("gui.fertility"), COLUMN_0);
|
||||
textLayout.drawLine(StringUtil.localize("gui.fertility"), COLUMN_0);
|
||||
IAlleleInteger primaryFertility = (IAlleleInteger) bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY);
|
||||
IAlleleInteger secondaryFertility = (IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY);
|
||||
drawFertilityInfo(primaryFertility.getValue(), COLUMN_1, getColorCoding(primaryFertility.isDominant()), 0);
|
||||
drawFertilityInfo(secondaryFertility.getValue(), COLUMN_2, getColorCoding(secondaryFertility.isDominant()), 0);
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
drawChromosomeRow(StringUtil.localize("gui.area"), bee, EnumBeeChromosome.TERRITORY);
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
drawChromosomeRow(StringUtil.localize("gui.effect"), bee, EnumBeeChromosome.EFFECT);
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
endPage();
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
private void drawAnalyticsPage2(IBee bee, EnumBeeType type) {
|
||||
|
||||
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
|
||||
textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2);
|
||||
|
||||
drawLine(StringUtil.localize("gui.active"), COLUMN_1);
|
||||
drawLine(StringUtil.localize("gui.inactive"), COLUMN_2);
|
||||
textLayout.drawLine(StringUtil.localize("gui.active"), COLUMN_1);
|
||||
textLayout.drawLine(StringUtil.localize("gui.inactive"), COLUMN_2);
|
||||
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
drawRow(StringUtil.localize("gui.climate"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getTemperature()),
|
||||
AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getTemperature()), bee, EnumBeeChromosome.SPECIES);
|
||||
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
IAlleleTolerance tempToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
|
||||
IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
|
||||
drawLine(" " + StringUtil.localize("gui.tolerance"), COLUMN_0);
|
||||
textLayout.drawLine(" " + StringUtil.localize("gui.tolerance"), COLUMN_0);
|
||||
drawToleranceInfo(tempToleranceActive, COLUMN_1);
|
||||
drawToleranceInfo(tempToleranceInactive, COLUMN_2);
|
||||
|
||||
newLine(16);
|
||||
textLayout.newLine(16);
|
||||
|
||||
drawRow(StringUtil.localize("gui.humidity"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getHumidity()),
|
||||
AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getHumidity()), bee, EnumBeeChromosome.SPECIES);
|
||||
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
IAlleleTolerance humidToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
|
||||
IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
|
||||
drawLine(" " + StringUtil.localize("gui.tolerance"), COLUMN_0);
|
||||
textLayout.drawLine(" " + StringUtil.localize("gui.tolerance"), COLUMN_0);
|
||||
drawToleranceInfo(humidToleranceActive, COLUMN_1);
|
||||
drawToleranceInfo(humidToleranceInactive, COLUMN_2);
|
||||
|
||||
newLine(16);
|
||||
textLayout.newLine(16);
|
||||
|
||||
String yes = StringUtil.localize("yes");
|
||||
String no = StringUtil.localize("no");
|
||||
@@ -192,29 +190,29 @@ public class GuiBeealyzer extends GuiAlyzer {
|
||||
diurnal1 = !bee.getGenome().getSecondary().isNocturnal() ? yes : no;
|
||||
}
|
||||
|
||||
drawLine(StringUtil.localize("gui.diurnal"), COLUMN_0);
|
||||
drawLine(diurnal0, COLUMN_1, getColorCoding(false));
|
||||
drawLine(diurnal1, COLUMN_2, getColorCoding(false));
|
||||
newLineCompressed();
|
||||
textLayout.drawLine(StringUtil.localize("gui.diurnal"), COLUMN_0);
|
||||
textLayout.drawLine(diurnal0, COLUMN_1, getColorCoding(false));
|
||||
textLayout.drawLine(diurnal1, COLUMN_2, getColorCoding(false));
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
drawLine(StringUtil.localize("gui.nocturnal"), COLUMN_0);
|
||||
drawLine(nocturnal0, COLUMN_1, getColorCoding(false));
|
||||
drawLine(nocturnal1, COLUMN_2, getColorCoding(false));
|
||||
newLineCompressed();
|
||||
textLayout.drawLine(StringUtil.localize("gui.nocturnal"), COLUMN_0);
|
||||
textLayout.drawLine(nocturnal0, COLUMN_1, getColorCoding(false));
|
||||
textLayout.drawLine(nocturnal1, COLUMN_2, getColorCoding(false));
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
String primary = StringUtil.readableBoolean(bee.getGenome().getTolerantFlyer(), yes, no);
|
||||
String secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TOLERANT_FLYER)).getValue(), yes, no);
|
||||
|
||||
drawRow(StringUtil.localize("gui.flyer"), primary, secondary, bee, EnumBeeChromosome.TOLERANT_FLYER);
|
||||
|
||||
newLineCompressed();
|
||||
textLayout.newLineCompressed();
|
||||
|
||||
primary = StringUtil.readableBoolean(bee.getGenome().getCaveDwelling(), yes, no);
|
||||
secondary = StringUtil.readableBoolean(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.CAVE_DWELLING)).getValue(), yes, no);
|
||||
|
||||
drawRow(StringUtil.localize("gui.cave"), primary, secondary, bee, EnumBeeChromosome.CAVE_DWELLING);
|
||||
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
String displayText;
|
||||
if (type == EnumBeeType.PRINCESS || type == EnumBeeType.QUEEN) {
|
||||
@@ -223,57 +221,57 @@ public class GuiBeealyzer extends GuiAlyzer {
|
||||
displayText = "bees.stock.ignoble";
|
||||
}
|
||||
displayText = StringUtil.localize(displayText);
|
||||
drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial"));
|
||||
textLayout.drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial"));
|
||||
}
|
||||
|
||||
if (bee.getGeneration() >= 0) {
|
||||
newLineCompressed();
|
||||
textLayout.newLineCompressed();
|
||||
displayText = StringUtil.localizeAndFormat("gui.beealyzer.generations", bee.getGeneration());
|
||||
drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial"));
|
||||
textLayout.drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial"));
|
||||
}
|
||||
|
||||
endPage();
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
private void drawAnalyticsPage3(IBee bee) {
|
||||
|
||||
startPage(COLUMN_0, COLUMN_1, COLUMN_2);
|
||||
textLayout.startPage(COLUMN_0, COLUMN_1, COLUMN_2);
|
||||
|
||||
drawLine(StringUtil.localize("gui.beealyzer.produce") + ":", COLUMN_0);
|
||||
textLayout.drawLine(StringUtil.localize("gui.beealyzer.produce") + ":", COLUMN_0);
|
||||
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
int x = COLUMN_0;
|
||||
for (ItemStack stack : bee.getProduceList()) {
|
||||
widgetManager.add(new ItemStackWidget(x, getLineY(), stack));
|
||||
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack));
|
||||
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = COLUMN_0;
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
textLayout.newLine();
|
||||
|
||||
drawLine(StringUtil.localize("gui.beealyzer.specialty") + ":", COLUMN_0);
|
||||
newLine();
|
||||
textLayout.drawLine(StringUtil.localize("gui.beealyzer.specialty") + ":", COLUMN_0);
|
||||
textLayout.newLine();
|
||||
|
||||
x = COLUMN_0;
|
||||
for (ItemStack stack : bee.getSpecialtyList()) {
|
||||
widgetManager.add(new ItemStackWidget(x, getLineY(), stack));
|
||||
widgetManager.add(new ItemStackWidget(widgetManager, x, textLayout.getLineY(), stack));
|
||||
|
||||
x += 18;
|
||||
if (x > 148) {
|
||||
x = COLUMN_0;
|
||||
newLine();
|
||||
textLayout.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
endPage();
|
||||
textLayout.endPage();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,15 +10,17 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gui;
|
||||
|
||||
import com.google.common.collect.LinkedListMultimap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@@ -26,70 +28,57 @@ import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory;
|
||||
import forestry.apiculture.gui.widgets.HabitatSlot;
|
||||
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.render.TextureManager;
|
||||
|
||||
public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, HabitatLocatorInventory> {
|
||||
public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, ItemInventoryHabitatLocator> {
|
||||
private static final LinkedListMultimap<String, BiomeDictionary.Type> habitats = LinkedListMultimap.create();
|
||||
|
||||
private final HabitatSlot[] habitatSlots = new HabitatSlot[]{
|
||||
new HabitatSlot(0, "Ocean"), // ocean, beach
|
||||
new HabitatSlot(1, "Plains"),
|
||||
new HabitatSlot(2, "Desert"), // desert, desert hills
|
||||
new HabitatSlot(3, "Forest"), // forest, forestHills, river
|
||||
new HabitatSlot(4, "Jungle"), // jungle, jungleHills
|
||||
new HabitatSlot(5, "Taiga"), // taiga, taigaHills
|
||||
new HabitatSlot(6, "Hills"), // extremeHills, extremeHillsEdge
|
||||
new HabitatSlot(7, "Swamp"),
|
||||
new HabitatSlot(8, "Snow"), // Ice plains, mountains, frozen rivers, frozen oceans
|
||||
new HabitatSlot(9, "Mushroom"),
|
||||
new HabitatSlot(10, "Nether"),
|
||||
new HabitatSlot(11, "End")};
|
||||
private final Map<BiomeDictionary.Type, HabitatSlot> biomeToHabitat = new EnumMap<>(BiomeDictionary.Type.class);
|
||||
static {
|
||||
habitats.putAll("Ocean", Arrays.asList(BiomeDictionary.Type.OCEAN, BiomeDictionary.Type.BEACH));
|
||||
habitats.put("Plains", BiomeDictionary.Type.PLAINS);
|
||||
habitats.put("Desert", BiomeDictionary.Type.SANDY);
|
||||
habitats.putAll("Forest", Arrays.asList(BiomeDictionary.Type.FOREST, BiomeDictionary.Type.RIVER));
|
||||
habitats.put("Jungle", BiomeDictionary.Type.JUNGLE);
|
||||
habitats.put("Taiga", BiomeDictionary.Type.CONIFEROUS);
|
||||
habitats.put("Hills", BiomeDictionary.Type.MOUNTAIN);
|
||||
habitats.put("Swamp", BiomeDictionary.Type.SWAMP);
|
||||
habitats.put("Snow", BiomeDictionary.Type.SNOWY);
|
||||
habitats.put("Mushroom", BiomeDictionary.Type.MUSHROOM);
|
||||
habitats.put("Nether", BiomeDictionary.Type.NETHER);
|
||||
habitats.put("End", BiomeDictionary.Type.END);
|
||||
}
|
||||
|
||||
private final List<HabitatSlot> habitatSlots = new ArrayList<>(habitats.size());
|
||||
|
||||
private int startX;
|
||||
private int startY;
|
||||
|
||||
public GuiHabitatLocator(EntityPlayer player, HabitatLocatorInventory item) {
|
||||
public GuiHabitatLocator(EntityPlayer player, ItemInventoryHabitatLocator item) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/biomefinder.png", new ContainerHabitatLocator(player, item), item);
|
||||
|
||||
xSize = 176;
|
||||
ySize = 184;
|
||||
|
||||
int x;
|
||||
int y;
|
||||
for (HabitatSlot slot : habitatSlots) {
|
||||
|
||||
if (slot.slot > 5) {
|
||||
x = 18 + (slot.slot - 6) * 20;
|
||||
int slot = 0;
|
||||
for (String habitatName : habitats.keySet()) {
|
||||
int x;
|
||||
int y;
|
||||
if (slot > 5) {
|
||||
x = 18 + (slot - 6) * 20;
|
||||
y = 50;
|
||||
} else {
|
||||
x = 18 + slot.slot * 20;
|
||||
x = 18 + slot * 20;
|
||||
y = 32;
|
||||
}
|
||||
|
||||
slot.setPosition(x, y);
|
||||
this.widgetManager.add(slot);
|
||||
Collection<BiomeDictionary.Type> biomes = habitats.get(habitatName);
|
||||
HabitatSlot habitatSlot = new HabitatSlot(widgetManager, x, y, habitatName, biomes);
|
||||
habitatSlots.add(habitatSlot);
|
||||
widgetManager.add(habitatSlot);
|
||||
slot++;
|
||||
}
|
||||
|
||||
biomeToHabitat.put(BiomeDictionary.Type.OCEAN, habitatSlots[0]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.BEACH, habitatSlots[0]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.PLAINS, habitatSlots[1]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.SANDY, habitatSlots[2]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.FOREST, habitatSlots[3]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.RIVER, habitatSlots[3]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.JUNGLE, habitatSlots[4]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.CONIFEROUS, habitatSlots[5]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.MOUNTAIN, habitatSlots[6]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.SWAMP, habitatSlots[7]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.SNOWY, habitatSlots[8]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.MUSHROOM, habitatSlots[9]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.NETHER, habitatSlots[10]);
|
||||
biomeToHabitat.put(BiomeDictionary.Type.END, habitatSlots[11]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,31 +86,22 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Habi
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
String str = StatCollector.translateToLocal("item.for.habitatLocator.name").toUpperCase();
|
||||
fontRendererObj.drawString(str, startX + 8 + getCenteredOffset(str, 138), startY + 16, fontColor.get("gui.screen"));
|
||||
fontRendererObj.drawString(str, startX + 8 + textLayout.getCenteredOffset(str, 138), startY + 16, fontColor.get("gui.screen"));
|
||||
|
||||
// Set active according to valid biomes.
|
||||
Set<BiomeDictionary.Type> activeBiomeTypes = EnumSet.noneOf(BiomeDictionary.Type.class);
|
||||
|
||||
for (HabitatSlot habitatSlot : habitatSlots) {
|
||||
habitatSlot.isActive = false;
|
||||
}
|
||||
|
||||
for (BiomeGenBase biome : inventory.getBiomesToSearch()) {
|
||||
Collections.addAll(activeBiomeTypes, BiomeDictionary.getTypesForBiome(biome));
|
||||
}
|
||||
|
||||
for (BiomeDictionary.Type biomeType : activeBiomeTypes) {
|
||||
HabitatSlot habitatSlot = biomeToHabitat.get(biomeType);
|
||||
if (habitatSlot != null) {
|
||||
habitatSlot.isActive = true;
|
||||
}
|
||||
for (HabitatSlot habitatSlot : habitatSlots) {
|
||||
habitatSlot.setActive(activeBiomeTypes);
|
||||
}
|
||||
|
||||
for (HabitatSlot slot : habitatSlots) {
|
||||
slot.draw(startX, startY);
|
||||
}
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Reset afterwards.
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,53 +111,4 @@ public class GuiHabitatLocator extends GuiForestry<ContainerHabitatLocator, Habi
|
||||
startX = (this.width - this.xSize) / 2;
|
||||
startY = (this.height - this.ySize) / 2;
|
||||
}
|
||||
|
||||
public class HabitatSlot extends Widget {
|
||||
|
||||
private final int slot;
|
||||
private final String name;
|
||||
private final String iconIndex;
|
||||
public boolean isActive = false;
|
||||
|
||||
public HabitatSlot(int slot, String name) {
|
||||
super(widgetManager, 0, 0);
|
||||
this.slot = slot;
|
||||
this.name = name;
|
||||
this.iconIndex = "habitats/" + name.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTooltip(EntityPlayer player) {
|
||||
return name;
|
||||
}
|
||||
|
||||
public IIcon getIcon() {
|
||||
return TextureManager.getInstance().getDefault(iconIndex);
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y) {
|
||||
this.xPos = x;
|
||||
this.yPos = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int startX, int startY) {
|
||||
|
||||
if (getIcon() != null) {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
if (!isActive) {
|
||||
GL11.glColor4f(0.2f, 0.2f, 0.2f, 0.2f);
|
||||
} else {
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
Proxies.render.bindTexture(SpriteSheet.ITEMS);
|
||||
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIcon(), 16, 16);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,36 +15,35 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.apiculture.genetics.BeeGenome;
|
||||
import forestry.apiculture.items.ItemBeeGE;
|
||||
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
|
||||
import forestry.apiculture.inventory.ItemInventoryImprinter;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.network.PacketGuiSelectRequest;
|
||||
import forestry.core.gui.GuiUtil;
|
||||
import forestry.core.network.packets.PacketGuiSelectRequest;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class GuiImprinter extends GuiForestry<ContainerImprinter, ImprinterInventory> {
|
||||
public class GuiImprinter extends GuiForestry<ContainerImprinter, ItemInventoryImprinter> {
|
||||
|
||||
private int startX;
|
||||
private int startY;
|
||||
|
||||
private final Map<String, ItemStack> iconStacks = new HashMap<>();
|
||||
|
||||
public GuiImprinter(InventoryPlayer inventoryplayer, ImprinterInventory inventory) {
|
||||
public GuiImprinter(InventoryPlayer inventoryplayer, ItemInventoryImprinter inventory) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/imprinter.png", new ContainerImprinter(inventoryplayer, inventory), inventory);
|
||||
|
||||
xSize = 176;
|
||||
ySize = 185;
|
||||
|
||||
List<ItemStack> beeList = new ArrayList<>();
|
||||
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
|
||||
PluginApiculture.items.beeDroneGE.addCreativeItems(beeList, false);
|
||||
for (ItemStack beeStack : beeList) {
|
||||
IAlleleBeeSpecies species = BeeGenome.getSpecies(beeStack);
|
||||
if (species != null) {
|
||||
@@ -75,9 +74,7 @@ public class GuiImprinter extends GuiForestry<ContainerImprinter, ImprinterInven
|
||||
}
|
||||
|
||||
private void drawBeeSpeciesIcon(IAlleleBeeSpecies bee, int x, int y) {
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
drawItemStack(iconStacks.get(bee.getUID()), x, y);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GuiUtil.drawItemStack(this, iconStacks.get(bee.getUID()), x, y);
|
||||
}
|
||||
|
||||
private static int getHabitatSlotAtPosition(int i, int j) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/*******************************************************************************
|
||||
* 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.gui;
|
||||
|
||||
public interface IContainerBeeHousing {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* 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.gui;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import forestry.core.tiles.ITitled;
|
||||
|
||||
public interface IGuiBeeHousingInventory extends ITitled, IInventory {
|
||||
/** Returns scaled queen health or breeding progress */
|
||||
int getHealthScaled(int i);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*******************************************************************************
|
||||
* 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.gui.widgets;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.render.TextureManager;
|
||||
|
||||
public class HabitatSlot extends Widget {
|
||||
private final Collection<BiomeDictionary.Type> biomes;
|
||||
private final String name;
|
||||
private final String iconIndex;
|
||||
public boolean isActive = false;
|
||||
|
||||
public HabitatSlot(WidgetManager widgetManager, int xPos, int yPos, String name, Collection<BiomeDictionary.Type> biomes) {
|
||||
super(widgetManager, xPos, yPos);
|
||||
this.biomes = biomes;
|
||||
this.name = name;
|
||||
this.iconIndex = "habitats/" + name.toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTooltip(EntityPlayer player) {
|
||||
return name;
|
||||
}
|
||||
|
||||
public IIcon getIcon() {
|
||||
return TextureManager.getInstance().getDefault(iconIndex);
|
||||
}
|
||||
|
||||
public void setActive(Collection<BiomeDictionary.Type> biomes) {
|
||||
isActive = !Collections.disjoint(this.biomes, biomes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int startX, int startY) {
|
||||
if (getIcon() != null) {
|
||||
if (!isActive) {
|
||||
GL11.glColor4f(0.2f, 0.2f, 0.2f, 0.2f);
|
||||
} else {
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
Proxies.render.bindTexture(SpriteSheet.ITEMS);
|
||||
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIcon(), 16, 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* 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.inventory;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
|
||||
public interface IApiaryInventory extends IBeeHousingInventory {
|
||||
void wearOutFrames(IBeeHousing beeHousing, int amount);
|
||||
}
|
||||
@@ -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.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.apiculture.multiblock.TileAlvearySieve;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.core.inventory.watchers.ISlotPickupWatcher;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.plugins.PluginCore;
|
||||
|
||||
public class InventoryAlvearySieve extends InventoryAdapterTile<TileAlvearySieve> implements ISlotPickupWatcher {
|
||||
public static final int SLOT_POLLEN_1 = 0;
|
||||
public static final int SLOTS_POLLEN_COUNT = 4;
|
||||
public static final int SLOT_SIEVE = 4;
|
||||
|
||||
public InventoryAlvearySieve(TileAlvearySieve alvearySieve) {
|
||||
super(alvearySieve, 5, "Items", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return ItemStackUtil.isIdenticalItem(PluginCore.items.craftingMaterial.getWovenSilk(), itemStack);
|
||||
}
|
||||
|
||||
public boolean canStorePollen() {
|
||||
if (getStackInSlot(SLOT_SIEVE) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
|
||||
if (getStackInSlot(i) == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void storePollenStack(ItemStack itemstack) {
|
||||
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
|
||||
if (getStackInSlot(i) == null) {
|
||||
setInventorySlotContents(i, itemstack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ISlotPickupWatcher */
|
||||
@Override
|
||||
public void onPickupFromSlot(int slotIndex, EntityPlayer player) {
|
||||
if (slotIndex == SLOT_SIEVE) {
|
||||
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
|
||||
setInventorySlotContents(i, null);
|
||||
}
|
||||
} else {
|
||||
setInventorySlotContents(SLOT_SIEVE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*******************************************************************************
|
||||
* 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.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.apiculture.InventoryBeeHousing;
|
||||
import forestry.core.access.IAccessHandler;
|
||||
import forestry.core.utils.SlotUtil;
|
||||
|
||||
public class InventoryApiary extends InventoryBeeHousing implements IApiaryInventory {
|
||||
public static final int SLOT_FRAMES_1 = 9;
|
||||
public static final int SLOT_FRAMES_COUNT = 3;
|
||||
|
||||
public InventoryApiary(IAccessHandler accessHandler) {
|
||||
super(12, accessHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (SlotUtil.isSlotInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) {
|
||||
return (itemStack.getItem() instanceof IHiveFrame) && (getStackInSlot(slotIndex) == null);
|
||||
}
|
||||
|
||||
return super.canSlotAccept(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
// override for pipe automation
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
if (SlotUtil.isSlotInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) {
|
||||
return false;
|
||||
}
|
||||
return super.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
public Collection<IHiveFrame> getFrames() {
|
||||
Collection<IHiveFrame> hiveFrames = new ArrayList<>(SLOT_FRAMES_COUNT);
|
||||
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
ItemStack stackInSlot = getStackInSlot(i);
|
||||
if (stackInSlot == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Item itemInSlot = stackInSlot.getItem();
|
||||
if (itemInSlot instanceof IHiveFrame) {
|
||||
hiveFrames.add((IHiveFrame) itemInSlot);
|
||||
}
|
||||
}
|
||||
|
||||
return hiveFrames;
|
||||
}
|
||||
|
||||
public void wearOutFrames(IBeeHousing beeHousing, int amount) {
|
||||
IBeekeepingMode beekeepingMode = BeeManager.beeRoot.getBeekeepingMode(beeHousing.getWorld());
|
||||
int wear = Math.round(amount * beekeepingMode.getWearModifier());
|
||||
|
||||
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
|
||||
ItemStack hiveFrameStack = getStackInSlot(i);
|
||||
if (hiveFrameStack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Item hiveFrameItem = hiveFrameStack.getItem();
|
||||
if (!(hiveFrameItem instanceof IHiveFrame)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IHiveFrame hiveFrame = (IHiveFrame) hiveFrameItem;
|
||||
|
||||
ItemStack queenStack = getQueen();
|
||||
IBee queen = BeeManager.beeRoot.getMember(queenStack);
|
||||
ItemStack usedFrame = hiveFrame.frameUsed(beeHousing, hiveFrameStack, queen, wear);
|
||||
|
||||
setInventorySlotContents(i, usedFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*******************************************************************************
|
||||
* 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.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import forestry.apiculture.multiblock.TileAlvearyHygroregulator;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
|
||||
public class InventoryHygroregulator extends InventoryAdapterTile<TileAlvearyHygroregulator> {
|
||||
public static final short SLOT_INPUT = 0;
|
||||
|
||||
public InventoryHygroregulator(TileAlvearyHygroregulator alvearyHygroregulator) {
|
||||
super(alvearyHygroregulator, 1, "CanInv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.getTankManager().accepts(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*******************************************************************************
|
||||
* 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.inventory;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.apiculture.multiblock.TileAlvearySwarmer;
|
||||
import forestry.core.inventory.InventoryAdapterTile;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class InventorySwarmer extends InventoryAdapterTile<TileAlvearySwarmer> {
|
||||
public InventorySwarmer(TileAlvearySwarmer alvearySwarmer) {
|
||||
super(alvearySwarmer, 4, "SwarmInv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return ItemStackUtil.containsItemStack(BeeManager.inducers.keySet(), itemStack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* 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.inventory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.inventory.ItemInventoryAlyzer;
|
||||
|
||||
public class ItemInventoryBeealyzer extends ItemInventoryAlyzer implements IHintSource {
|
||||
|
||||
public ItemInventoryBeealyzer(EntityPlayer player, ItemStack itemStack) {
|
||||
super(BeeManager.beeRoot, player, itemStack);
|
||||
}
|
||||
|
||||
/* IHintSource */
|
||||
@Override
|
||||
public List<String> getHints() {
|
||||
return Config.hints.get("beealyzer");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*******************************************************************************
|
||||
* 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.inventory;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.core.IErrorSource;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.apiculture.items.HabitatLocatorLogic;
|
||||
import forestry.apiculture.items.ItemHabitatLocator;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.inventory.ItemInventory;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class ItemInventoryHabitatLocator extends ItemInventory implements IErrorSource, IHintSource {
|
||||
|
||||
private static final short SLOT_ENERGY = 2;
|
||||
private static final short SLOT_SPECIMEN = 0;
|
||||
private static final short SLOT_ANALYZED = 1;
|
||||
|
||||
private final HabitatLocatorLogic locatorLogic;
|
||||
|
||||
public ItemInventoryHabitatLocator(EntityPlayer player, ItemStack itemstack) {
|
||||
super(player, 3, itemstack);
|
||||
ItemHabitatLocator habitatLocator = (ItemHabitatLocator) itemstack.getItem();
|
||||
this.locatorLogic = habitatLocator.getLocatorLogic();
|
||||
}
|
||||
|
||||
private static boolean isEnergy(ItemStack itemstack) {
|
||||
if (itemstack == null || itemstack.stackSize <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Item item = itemstack.getItem();
|
||||
return PluginApiculture.items.honeyDrop == item || PluginApiculture.items.honeydew == item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotClick(EntityPlayer player) {
|
||||
|
||||
if (getStackInSlot(SLOT_ANALYZED) != null) {
|
||||
if (locatorLogic.isBiomeFound()) {
|
||||
return;
|
||||
}
|
||||
} else if (getStackInSlot(SLOT_SPECIMEN) != null) {
|
||||
// Requires energy
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Decrease energy
|
||||
decrStackSize(SLOT_ENERGY, 1);
|
||||
|
||||
setInventorySlotContents(SLOT_ANALYZED, getStackInSlot(SLOT_SPECIMEN));
|
||||
setInventorySlotContents(SLOT_SPECIMEN, null);
|
||||
}
|
||||
|
||||
IBee bee = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_ANALYZED));
|
||||
|
||||
// No bee, abort
|
||||
if (bee == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
locatorLogic.startBiomeSearch(bee, player);
|
||||
}
|
||||
|
||||
public Set<BiomeGenBase> getBiomesToSearch() {
|
||||
return locatorLogic.getTargetBiomes();
|
||||
}
|
||||
|
||||
/* IHintSource */
|
||||
@Override
|
||||
public List<String> getHints() {
|
||||
return Config.hints.get("habitat.locator");
|
||||
}
|
||||
|
||||
/* IErrorSource */
|
||||
@Override
|
||||
public ImmutableSet<IErrorState> getErrorStates() {
|
||||
if (getStackInSlot(SLOT_ANALYZED) != null) {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
|
||||
|
||||
ItemStack specimen = getStackInSlot(SLOT_SPECIMEN);
|
||||
if (!BeeManager.beeRoot.isMember(specimen)) {
|
||||
errorStates.add(EnumErrorCode.NO_SPECIMEN);
|
||||
}
|
||||
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
errorStates.add(EnumErrorCode.NO_HONEY);
|
||||
}
|
||||
|
||||
return errorStates.build();
|
||||
}
|
||||
|
||||
/* IFilterSlotDelegate */
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_ENERGY) {
|
||||
return isEnergy(itemStack);
|
||||
} else if (slotIndex == SLOT_SPECIMEN) {
|
||||
return BeeManager.beeRoot.isMember(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/*******************************************************************************
|
||||
* 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.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.apiculture.genetics.Bee;
|
||||
import forestry.core.inventory.ItemInventory;
|
||||
|
||||
public class ItemInventoryImprinter extends ItemInventory {
|
||||
private static final short specimenSlot = 0;
|
||||
private static final short imprintedSlot = 1;
|
||||
|
||||
private int primaryIndex = 0;
|
||||
private int secondaryIndex = 0;
|
||||
|
||||
public ItemInventoryImprinter(EntityPlayer player, ItemStack itemStack) {
|
||||
super(player, 2, itemStack);
|
||||
}
|
||||
|
||||
public void advancePrimary() {
|
||||
if (primaryIndex < BeeManager.beeRoot.getIndividualTemplates().size() - 1) {
|
||||
primaryIndex++;
|
||||
} else {
|
||||
primaryIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void advanceSecondary() {
|
||||
if (secondaryIndex < BeeManager.beeRoot.getIndividualTemplates().size() - 1) {
|
||||
secondaryIndex++;
|
||||
} else {
|
||||
secondaryIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void regressPrimary() {
|
||||
if (primaryIndex > 0) {
|
||||
primaryIndex--;
|
||||
} else {
|
||||
primaryIndex = BeeManager.beeRoot.getIndividualTemplates().size() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void regressSecondary() {
|
||||
if (secondaryIndex > 0) {
|
||||
secondaryIndex--;
|
||||
} else {
|
||||
secondaryIndex = BeeManager.beeRoot.getIndividualTemplates().size() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public IAlleleBeeSpecies getPrimary() {
|
||||
return BeeManager.beeRoot.getIndividualTemplates().get(primaryIndex).getGenome().getPrimary();
|
||||
}
|
||||
|
||||
public IAlleleBeeSpecies getSecondary() {
|
||||
return BeeManager.beeRoot.getIndividualTemplates().get(secondaryIndex).getGenome().getPrimary();
|
||||
}
|
||||
|
||||
public IBee getSelectedBee() {
|
||||
return new Bee(BeeManager.beeRoot.templateAsGenome(
|
||||
BeeManager.beeRoot.getGenomeTemplates().get(BeeManager.beeRoot.getIndividualTemplates().get(primaryIndex).getIdent()),
|
||||
BeeManager.beeRoot.getGenomeTemplates().get(BeeManager.beeRoot.getIndividualTemplates().get(secondaryIndex).getIdent())));
|
||||
}
|
||||
|
||||
public int getPrimaryIndex() {
|
||||
return primaryIndex;
|
||||
}
|
||||
|
||||
public int getSecondaryIndex() {
|
||||
return secondaryIndex;
|
||||
}
|
||||
|
||||
public void setPrimaryIndex(int index) {
|
||||
primaryIndex = index;
|
||||
}
|
||||
|
||||
public void setSecondaryIndex(int index) {
|
||||
secondaryIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotClick(EntityPlayer player) {
|
||||
ItemStack specimen = getStackInSlot(specimenSlot);
|
||||
if (specimen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only imprint bees
|
||||
if (!BeeManager.beeRoot.isMember(specimen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Needs space
|
||||
if (getStackInSlot(imprintedSlot) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IBee imprint = getSelectedBee();
|
||||
if (imprint == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
imprint.writeToNBT(nbttagcompound);
|
||||
specimen.setTagCompound(nbttagcompound);
|
||||
|
||||
setInventorySlotContents(imprintedSlot, specimen);
|
||||
setInventorySlotContents(specimenSlot, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Imprinter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return BeeManager.beeRoot.isMember(itemStack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumHoneyComb {
|
||||
HONEY(new Color(0xe8d56a), new Color(0xffa12b)),
|
||||
COCOA(new Color(0x674016), new Color(0xffb62b), true),
|
||||
SIMMERING(new Color(0x981919), new Color(0xffb62b)),
|
||||
STRINGY(new Color(0xc8be67), new Color(0xbda93e)),
|
||||
FROZEN(new Color(0xf9ffff), new Color(0xa0ffff)),
|
||||
DRIPPING(new Color(0xdc7613), new Color(0xffff00)),
|
||||
SILKY(new Color(0x508907), new Color(0xddff00)),
|
||||
PARCHED(new Color(0xdcbe13), new Color(0xffff00)),
|
||||
MYSTERIOUS(new Color(0x161616), new Color(0xe099ff), true),
|
||||
IRRADIATED(new Color(0xeafff3), new Color(0xeeff00), true),
|
||||
POWDERY(new Color(0xe4e4e4), new Color(0xffffff), true),
|
||||
REDDENED(new Color(0x4b0000), new Color(0x6200e7), true),
|
||||
DARKENED(new Color(0x353535), new Color(0x33ebcb), true),
|
||||
OMEGA(new Color(0x191919), new Color(0x6dcff6), true),
|
||||
WHEATEN(new Color(0xfeff8f), new Color(0xffffff), true),
|
||||
MOSSY(new Color(0x2a3313), new Color(0x7e9939)),
|
||||
MELLOW(new Color(0x886000), new Color(0xfff960));
|
||||
//""(new Color(0xd7bee5), new Color(0xfd58ab)); // kindof pinkish
|
||||
|
||||
public static final EnumHoneyComb[] VALUES = values();
|
||||
|
||||
public final String name;
|
||||
public final int primaryColor;
|
||||
public final int secondaryColor;
|
||||
private final boolean secret;
|
||||
|
||||
EnumHoneyComb(Color primary, Color secondary) {
|
||||
this(primary, secondary, false);
|
||||
}
|
||||
|
||||
EnumHoneyComb(Color primary, Color secondary, boolean secret) {
|
||||
this.name = toString().toLowerCase(Locale.ENGLISH);
|
||||
this.primaryColor = primary.getRGB();
|
||||
this.secondaryColor = secondary.getRGB();
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public boolean isSecret() {
|
||||
return secret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Locale;
|
||||
|
||||
import forestry.core.items.ItemOverlay;
|
||||
|
||||
public enum EnumHoneyDrop implements ItemOverlay.IOverlayInfo {
|
||||
HONEY(new Color(0xecb42d), new Color(0xe8c814)),
|
||||
CHARGED(new Color(0x800505), new Color(0x9c0707), true),
|
||||
OMEGA(new Color(0x191919), new Color(0x4a8ca7), true);
|
||||
|
||||
public static final EnumHoneyDrop[] VALUES = values();
|
||||
|
||||
private final String name;
|
||||
private final int primaryColor;
|
||||
private final int secondaryColor;
|
||||
private final boolean secret;
|
||||
|
||||
EnumHoneyDrop(Color primary, Color secondary) {
|
||||
this(primary, secondary, false);
|
||||
}
|
||||
|
||||
EnumHoneyDrop(Color primary, Color secondary, boolean secret) {
|
||||
this.name = toString().toLowerCase(Locale.ENGLISH);
|
||||
this.primaryColor = primary.getRGB();
|
||||
this.secondaryColor = secondary.getRGB();
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrimaryColor() {
|
||||
return primaryColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondaryColor() {
|
||||
return secondaryColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecret() {
|
||||
return secret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Locale;
|
||||
|
||||
import forestry.core.items.ItemOverlay;
|
||||
|
||||
public enum EnumPollenCluster implements ItemOverlay.IOverlayInfo {
|
||||
NORMAL(new Color(0xa28a25), new Color(0xa28a25)),
|
||||
CRYSTALLINE(new Color(0xffffff), new Color(0xc5feff));
|
||||
|
||||
public static final EnumPollenCluster[] VALUES = values();
|
||||
|
||||
private final String name;
|
||||
private final int primaryColor;
|
||||
private final int secondaryColor;
|
||||
|
||||
EnumPollenCluster(Color primary, Color secondary) {
|
||||
this.name = toString().toLowerCase(Locale.ENGLISH);
|
||||
this.primaryColor = primary.getRGB();
|
||||
this.secondaryColor = secondary.getRGB();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrimaryColor() {
|
||||
return primaryColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondaryColor() {
|
||||
return secondaryColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecret() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Locale;
|
||||
|
||||
import forestry.core.items.ItemOverlay;
|
||||
|
||||
public enum EnumPropolis implements ItemOverlay.IOverlayInfo {
|
||||
NORMAL(new Color(0xc5b24e)),
|
||||
STICKY(new Color(0xc68e57)),
|
||||
PULSATING(new Color(0x2ccdb1), true),
|
||||
SILKY(new Color(0xddff00));
|
||||
|
||||
public static final EnumPropolis[] VALUES = values();
|
||||
|
||||
private final String name;
|
||||
private final int primaryColor;
|
||||
private final boolean secret;
|
||||
|
||||
EnumPropolis(Color color) {
|
||||
this(color, false);
|
||||
}
|
||||
|
||||
EnumPropolis(Color color, boolean secret) {
|
||||
this.name = toString().toLowerCase(Locale.ENGLISH);
|
||||
this.primaryColor = color.getRGB();
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrimaryColor() {
|
||||
return primaryColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSecondaryColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecret() {
|
||||
return secret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.apiculture.network.packets.PacketHabitatBiomePointer;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public class HabitatLocatorLogic {
|
||||
private static final int maxChecksPerTick = 100;
|
||||
private static final int maxSearchRadiusIterations = 500;
|
||||
private static final int spacing = 20;
|
||||
private static final int minBiomeRadius = 8;
|
||||
|
||||
private static final Set<BiomeGenBase> waterBiomes = new HashSet<>();
|
||||
private static final Set<BiomeGenBase> netherBiomes = new HashSet<>();
|
||||
private static final Set<BiomeGenBase> endBiomes = new HashSet<>();
|
||||
|
||||
static {
|
||||
Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.BEACH));
|
||||
Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.OCEAN));
|
||||
Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.RIVER));
|
||||
|
||||
Collections.addAll(netherBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.NETHER));
|
||||
|
||||
Collections.addAll(endBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.END));
|
||||
}
|
||||
|
||||
private Set<BiomeGenBase> targetBiomes = new HashSet<>();
|
||||
private boolean biomeFound = false;
|
||||
private int searchRadiusIteration = 0;
|
||||
private int searchAngleIteration = 0;
|
||||
private Vect searchCenter;
|
||||
|
||||
public boolean isBiomeFound() {
|
||||
return biomeFound;
|
||||
}
|
||||
|
||||
public Set<BiomeGenBase> getTargetBiomes() {
|
||||
return targetBiomes;
|
||||
}
|
||||
|
||||
public void startBiomeSearch(IBee bee, EntityPlayer player) {
|
||||
this.targetBiomes = new HashSet<>(bee.getSuitableBiomes());
|
||||
this.searchAngleIteration = 0;
|
||||
this.searchRadiusIteration = 0;
|
||||
this.biomeFound = false;
|
||||
this.searchCenter = new Vect(player);
|
||||
|
||||
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords(searchCenter.x, searchCenter.z);
|
||||
removeInvalidBiomes(currentBiome, targetBiomes);
|
||||
|
||||
// reset the locator coordinates
|
||||
Proxies.render.setHabitatLocatorTexture(null, null);
|
||||
}
|
||||
|
||||
public void onUpdate(World world, Entity player) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetBiomes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// once we've found the biome, slow down to conserve cpu and network data
|
||||
if (biomeFound && world.getTotalWorldTime() % 20 != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChunkCoordinates target = findNearestBiome(player, targetBiomes);
|
||||
|
||||
// send an update if we find the biome
|
||||
if (target != null && player instanceof EntityPlayerMP) {
|
||||
Proxies.net.sendToPlayer(new PacketHabitatBiomePointer(target), (EntityPlayerMP) player);
|
||||
biomeFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
private ChunkCoordinates findNearestBiome(Entity player, Collection<BiomeGenBase> biomesToSearch) {
|
||||
Vect playerPos = new Vect(player);
|
||||
|
||||
// If we are in a valid spot, we point to ourselves.
|
||||
ChunkCoordinates coordinates = getChunkCoordinates(playerPos, player.worldObj, biomesToSearch);
|
||||
if (coordinates != null) {
|
||||
searchAngleIteration = 0;
|
||||
searchRadiusIteration = 0;
|
||||
return new ChunkCoordinates(playerPos.x, playerPos.y, playerPos.z);
|
||||
}
|
||||
|
||||
// check in a circular pattern, starting at the center and increasing radius each step
|
||||
final int radius = spacing * (searchRadiusIteration + 1);
|
||||
|
||||
double angleSpacing = 2.0f * Math.asin(spacing / (2.0 * radius));
|
||||
|
||||
// round to nearest divisible angle, for an even distribution
|
||||
angleSpacing = 2.0 * Math.PI / Math.round(2.0 * Math.PI / angleSpacing);
|
||||
|
||||
// do a limited number of checks per tick
|
||||
for (int i = 0; i < maxChecksPerTick; i++) {
|
||||
|
||||
double angle = angleSpacing * searchAngleIteration;
|
||||
if (angle > 2.0 * Math.PI) {
|
||||
searchAngleIteration = 0;
|
||||
searchRadiusIteration++;
|
||||
if (searchRadiusIteration > maxSearchRadiusIterations) {
|
||||
searchAngleIteration = 0;
|
||||
searchRadiusIteration = 0;
|
||||
searchCenter = playerPos;
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
searchAngleIteration++;
|
||||
}
|
||||
|
||||
int xOffset = Math.round((float) (radius * Math.cos(angle)));
|
||||
int zOffset = Math.round((float) (radius * Math.sin(angle)));
|
||||
Vect pos = searchCenter.add(xOffset, 0, zOffset);
|
||||
|
||||
coordinates = getChunkCoordinates(pos, player.worldObj, biomesToSearch);
|
||||
if (coordinates != null) {
|
||||
searchAngleIteration = 0;
|
||||
searchRadiusIteration = 0;
|
||||
return coordinates;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ChunkCoordinates getChunkCoordinates(Vect pos, World world, Collection<BiomeGenBase> biomesToSearch) {
|
||||
BiomeGenBase biome;
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x, pos.z);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x - minBiomeRadius, pos.z);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x + minBiomeRadius, pos.z);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x, pos.z - minBiomeRadius);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x, pos.z + minBiomeRadius);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ChunkCoordinates(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
private static void removeInvalidBiomes(BiomeGenBase currentBiome, Set<BiomeGenBase> biomesToSearch) {
|
||||
|
||||
biomesToSearch.removeAll(waterBiomes);
|
||||
|
||||
if (BiomeDictionary.isBiomeOfType(currentBiome, BiomeDictionary.Type.NETHER)) {
|
||||
biomesToSearch.retainAll(netherBiomes);
|
||||
} else {
|
||||
biomesToSearch.removeAll(netherBiomes);
|
||||
}
|
||||
|
||||
if (BiomeDictionary.isBiomeOfType(currentBiome, BiomeDictionary.Type.END)) {
|
||||
biomesToSearch.retainAll(endBiomes);
|
||||
} else {
|
||||
biomesToSearch.removeAll(endBiomes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package forestry.apiculture.items;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -24,9 +25,9 @@ import forestry.api.apiculture.IArmorApiarist;
|
||||
import forestry.api.core.IArmorNaturalist;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArmorNaturalist {
|
||||
|
||||
@@ -38,7 +39,7 @@ public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArm
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
if (ForestryItem.apiaristLegs.isItemEqual(stack)) {
|
||||
if (stack != null && stack.getItem() == PluginApiculture.items.apiaristLegs) {
|
||||
return Constants.ID + ":" + Constants.TEXTURE_APIARIST_ARMOR_SECONDARY;
|
||||
} else {
|
||||
return Constants.ID + ":" + Constants.TEXTURE_APIARIST_ARMOR_PRIMARY;
|
||||
@@ -72,6 +73,11 @@ public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArm
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean protectEntity(EntityLivingBase entity, ItemStack armor, String cause, boolean doProtect) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean protectPlayer(EntityPlayer player, ItemStack armor, String cause, boolean doProtect) {
|
||||
return true;
|
||||
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
@@ -33,7 +32,6 @@ import forestry.api.core.Tabs;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.genetics.BeeGenome;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.genetics.ItemGE;
|
||||
@@ -44,9 +42,8 @@ public class ItemBeeGE extends ItemGE {
|
||||
private final EnumBeeType type;
|
||||
|
||||
public ItemBeeGE(EnumBeeType type) {
|
||||
super();
|
||||
super(Tabs.tabApiculture);
|
||||
this.type = type;
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
if (type != EnumBeeType.DRONE) {
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
@@ -112,27 +109,21 @@ public class ItemBeeGE extends ItemGE {
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
if (type == EnumBeeType.QUEEN) {
|
||||
return;
|
||||
}
|
||||
|
||||
addCreativeItems(itemList, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public void addCreativeItems(List itemList, boolean hideSecrets) {
|
||||
|
||||
for (IIndividual individual : BeeManager.beeRoot.getIndividualTemplates()) {
|
||||
for (IBee bee : BeeManager.beeRoot.getIndividualTemplates()) {
|
||||
// Don't show secret bees unless ordered to.
|
||||
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
|
||||
if (hideSecrets && bee.isSecret() && !Config.isDebug) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
ItemStack someStack = new ItemStack(this);
|
||||
individual.writeToNBT(nbttagcompound);
|
||||
someStack.setTagCompound(nbttagcompound);
|
||||
itemList.add(someStack);
|
||||
ItemStack beeStack = BeeManager.beeRoot.getMemberStack(bee, type.ordinal());
|
||||
if (beeStack != null) {
|
||||
itemList.add(beeStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+38
-68
@@ -1,68 +1,38 @@
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.items.ItemAlyzer;
|
||||
import forestry.core.network.GuiId;
|
||||
|
||||
public class ItemBeealyzer extends ItemAlyzer {
|
||||
|
||||
public ItemBeealyzer() {
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(ForestryAPI.instance, GuiId.BeealyzerGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
public static class BeealyzerInventory extends AlyzerInventory implements IHintSource {
|
||||
|
||||
public BeealyzerInventory(EntityPlayer player, ItemStack itemStack) {
|
||||
super(player, 7, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ISpeciesRoot getSpeciesRoot() {
|
||||
return BeeManager.beeRoot;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// / IHINTSOURCE
|
||||
@Override
|
||||
public boolean hasHints() {
|
||||
return Config.hints.get("beealyzer") != null && Config.hints.get("beealyzer").length > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHints() {
|
||||
return Config.hints.get("beealyzer");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.gui.GuiBeealyzer;
|
||||
import forestry.apiculture.inventory.ItemInventoryBeealyzer;
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
|
||||
public class ItemBeealyzer extends ItemWithGui {
|
||||
public ItemBeealyzer() {
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
|
||||
return new GuiBeealyzer(player, inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
ItemInventoryBeealyzer inventory = new ItemInventoryBeealyzer(player, heldItem);
|
||||
return new ContainerAlyzer(inventory, player);
|
||||
}
|
||||
}
|
||||
@@ -10,77 +10,51 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.items;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorSource;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.apiculture.network.PacketHabitatBiomePointer;
|
||||
import forestry.apiculture.gui.ContainerHabitatLocator;
|
||||
import forestry.apiculture.gui.GuiHabitatLocator;
|
||||
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
|
||||
import forestry.apiculture.render.TextureHabitatLocator;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.errors.EnumErrorCode;
|
||||
import forestry.core.gui.IHintSource;
|
||||
import forestry.core.inventory.ItemInventory;
|
||||
import forestry.core.items.ItemInventoried;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.core.utils.vect.Vect;
|
||||
|
||||
public class ItemHabitatLocator extends ItemInventoried {
|
||||
|
||||
public class ItemHabitatLocator extends ItemWithGui {
|
||||
private static final String iconName = "forestry:biomefinder";
|
||||
|
||||
private Set<BiomeGenBase> targetBiomes = new HashSet<>();
|
||||
private boolean biomeFound = false;
|
||||
private int searchRadiusIteration = 0;
|
||||
private int searchAngleIteration = 0;
|
||||
private Vect searchCenter;
|
||||
private final HabitatLocatorLogic locatorLogic;
|
||||
|
||||
public ItemHabitatLocator() {
|
||||
super();
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
setMaxStackSize(1);
|
||||
locatorLogic = new HabitatLocatorLogic();
|
||||
}
|
||||
|
||||
public HabitatLocatorLogic getLocatorLogic() {
|
||||
return locatorLogic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
|
||||
|
||||
public void onUpdate(ItemStack p_77663_1_, World world, Entity player, int p_77663_4_, boolean p_77663_5_) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(ForestryAPI.instance, GuiId.HabitatLocatorGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ);
|
||||
locatorLogic.onUpdate(world, player);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
/* TEXTURES */
|
||||
@@ -108,266 +82,13 @@ public class ItemHabitatLocator extends ItemInventoried {
|
||||
list.add(StringUtil.localize("gui.humidity") + ": " + AlleleManager.climateHelper.toDisplay(humidity));
|
||||
}
|
||||
|
||||
private void startBiomeSearch(IBee bee, EntityPlayer player) {
|
||||
|
||||
this.targetBiomes = new HashSet<>(bee.getSuitableBiomes());
|
||||
this.searchAngleIteration = 0;
|
||||
this.searchRadiusIteration = 0;
|
||||
this.biomeFound = false;
|
||||
this.searchCenter = new Vect(player);
|
||||
|
||||
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords(searchCenter.x, searchCenter.z);
|
||||
removeInvalidBiomes(currentBiome, targetBiomes);
|
||||
|
||||
// reset the locator coordinates
|
||||
Proxies.render.setHabitatLocatorTexture(null, null);
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
return new GuiHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack p_77663_1_, World world, Entity player, int p_77663_4_, boolean p_77663_5_) {
|
||||
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetBiomes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// once we've found the biome, slow down to conserve cpu and network data
|
||||
if (biomeFound && world.getTotalWorldTime() % 20 != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ChunkCoordinates target = findNearestBiome(player, targetBiomes);
|
||||
|
||||
// send an update if we find the biome
|
||||
if (target != null && player instanceof EntityPlayerMP) {
|
||||
Proxies.net.sendToPlayer(new PacketHabitatBiomePointer(target), (EntityPlayerMP) player);
|
||||
biomeFound = true;
|
||||
}
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
return new ContainerHabitatLocator(player, new ItemInventoryHabitatLocator(player, heldItem));
|
||||
}
|
||||
|
||||
private ChunkCoordinates findNearestBiome(Entity player, Collection<BiomeGenBase> biomesToSearch) {
|
||||
|
||||
final int maxChecksPerTick = 100;
|
||||
final int maxSearchRadiusIterations = 500;
|
||||
final int spacing = 20;
|
||||
|
||||
Vect playerPos = new Vect(player);
|
||||
|
||||
// If we are in a valid spot, we point to ourselves.
|
||||
ChunkCoordinates coordinates = getChunkCoordinates(playerPos, player.worldObj, biomesToSearch);
|
||||
if (coordinates != null) {
|
||||
searchAngleIteration = 0;
|
||||
searchRadiusIteration = 0;
|
||||
return new ChunkCoordinates(playerPos.x, playerPos.y, playerPos.z);
|
||||
}
|
||||
|
||||
// check in a circular pattern, starting at the center and increasing radius each step
|
||||
final int radius = spacing * (searchRadiusIteration + 1);
|
||||
|
||||
double angleSpacing = 2.0f * Math.asin(spacing / (2.0 * radius));
|
||||
|
||||
// round to nearest divisible angle, for an even distribution
|
||||
angleSpacing = 2.0 * Math.PI / Math.round(2.0 * Math.PI / angleSpacing);
|
||||
|
||||
// do a limited number of checks per tick
|
||||
for (int i = 0; i < maxChecksPerTick; i++) {
|
||||
|
||||
double angle = angleSpacing * searchAngleIteration;
|
||||
if (angle > 2.0 * Math.PI) {
|
||||
searchAngleIteration = 0;
|
||||
searchRadiusIteration++;
|
||||
if (searchRadiusIteration > maxSearchRadiusIterations) {
|
||||
searchAngleIteration = 0;
|
||||
searchRadiusIteration = 0;
|
||||
searchCenter = playerPos;
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
searchAngleIteration++;
|
||||
}
|
||||
|
||||
int xOffset = Math.round((float) (radius * Math.cos(angle)));
|
||||
int zOffset = Math.round((float) (radius * Math.sin(angle)));
|
||||
Vect pos = searchCenter.add(xOffset, 0, zOffset);
|
||||
|
||||
coordinates = getChunkCoordinates(pos, player.worldObj, biomesToSearch);
|
||||
if (coordinates != null) {
|
||||
searchAngleIteration = 0;
|
||||
searchRadiusIteration = 0;
|
||||
return coordinates;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ChunkCoordinates getChunkCoordinates(Vect pos, World world, Collection<BiomeGenBase> biomesToSearch) {
|
||||
|
||||
// to avoid reporting very tiny patches, check around the point want
|
||||
final int minBiomeRadius = 8;
|
||||
|
||||
BiomeGenBase biome;
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x, pos.z);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x - minBiomeRadius, pos.z);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x + minBiomeRadius, pos.z);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x, pos.z - minBiomeRadius);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
biome = world.getBiomeGenForCoords(pos.x, pos.z + minBiomeRadius);
|
||||
if (!biomesToSearch.contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ChunkCoordinates(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
private static final Set<BiomeGenBase> waterBiomes = new HashSet<>();
|
||||
private static final Set<BiomeGenBase> netherBiomes = new HashSet<>();
|
||||
private static final Set<BiomeGenBase> endBiomes = new HashSet<>();
|
||||
|
||||
static {
|
||||
Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.BEACH));
|
||||
Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.OCEAN));
|
||||
Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.RIVER));
|
||||
|
||||
Collections.addAll(netherBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.NETHER));
|
||||
|
||||
Collections.addAll(endBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.END));
|
||||
}
|
||||
|
||||
private static void removeInvalidBiomes(BiomeGenBase currentBiome, Set<BiomeGenBase> biomesToSearch) {
|
||||
|
||||
biomesToSearch.removeAll(waterBiomes);
|
||||
|
||||
if (BiomeDictionary.isBiomeOfType(currentBiome, BiomeDictionary.Type.NETHER)) {
|
||||
biomesToSearch.retainAll(netherBiomes);
|
||||
} else {
|
||||
biomesToSearch.removeAll(netherBiomes);
|
||||
}
|
||||
|
||||
if (BiomeDictionary.isBiomeOfType(currentBiome, BiomeDictionary.Type.END)) {
|
||||
biomesToSearch.retainAll(endBiomes);
|
||||
} else {
|
||||
biomesToSearch.removeAll(endBiomes);
|
||||
}
|
||||
}
|
||||
|
||||
public static class HabitatLocatorInventory extends ItemInventory implements IErrorSource, IHintSource {
|
||||
|
||||
private static final short SLOT_ENERGY = 2;
|
||||
private static final short SLOT_SPECIMEN = 0;
|
||||
private static final short SLOT_ANALYZED = 1;
|
||||
|
||||
private final ItemHabitatLocator habitatLocator;
|
||||
|
||||
public HabitatLocatorInventory(EntityPlayer player, ItemStack itemstack) {
|
||||
super(player, 3, itemstack);
|
||||
this.habitatLocator = (ItemHabitatLocator) itemstack.getItem();
|
||||
}
|
||||
|
||||
private static boolean isEnergy(ItemStack itemstack) {
|
||||
if (itemstack == null || itemstack.stackSize <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotClick(EntityPlayer player) {
|
||||
|
||||
if (getStackInSlot(SLOT_ANALYZED) != null) {
|
||||
if (habitatLocator.biomeFound) {
|
||||
return;
|
||||
}
|
||||
} else if (getStackInSlot(SLOT_SPECIMEN) != null) {
|
||||
// Requires energy
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Decrease energy
|
||||
decrStackSize(SLOT_ENERGY, 1);
|
||||
|
||||
setInventorySlotContents(SLOT_ANALYZED, getStackInSlot(SLOT_SPECIMEN));
|
||||
setInventorySlotContents(SLOT_SPECIMEN, null);
|
||||
}
|
||||
|
||||
IBee bee = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_ANALYZED));
|
||||
|
||||
// No bee, abort
|
||||
if (bee == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
habitatLocator.startBiomeSearch(bee, player);
|
||||
}
|
||||
|
||||
public Set<BiomeGenBase> getBiomesToSearch() {
|
||||
return habitatLocator.targetBiomes;
|
||||
}
|
||||
|
||||
// / IHINTSOURCE
|
||||
@Override
|
||||
public boolean hasHints() {
|
||||
return Config.hints.get("habitatlocator") != null && Config.hints.get("habitatlocator").length > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHints() {
|
||||
return Config.hints.get("habitatlocator");
|
||||
}
|
||||
|
||||
// / IERRORSOURCE
|
||||
@Override
|
||||
public ImmutableSet<IErrorState> getErrorStates() {
|
||||
if (getStackInSlot(SLOT_ANALYZED) != null) {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
|
||||
|
||||
ItemStack specimen = getStackInSlot(SLOT_SPECIMEN);
|
||||
if (!BeeManager.beeRoot.isMember(specimen)) {
|
||||
errorStates.add(EnumErrorCode.NOTHINGANALYZE);
|
||||
}
|
||||
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
errorStates.add(EnumErrorCode.NOHONEY);
|
||||
}
|
||||
|
||||
return errorStates.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_ENERGY) {
|
||||
Item item = itemStack.getItem();
|
||||
return item == ForestryItem.honeydew.item() || item == ForestryItem.honeyDrop.item();
|
||||
} else if (slotIndex == SLOT_SPECIMEN) {
|
||||
return BeeManager.beeRoot.isMember(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,51 +20,9 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.items.ItemForestryMultiPass;
|
||||
|
||||
public class ItemHoneycomb extends ItemForestryMultiPass {
|
||||
|
||||
private static class CombInfo {
|
||||
|
||||
public final String name;
|
||||
public final int primaryColor;
|
||||
public final int secondaryColor;
|
||||
public boolean isSecret = false;
|
||||
|
||||
public CombInfo(String name, int primaryColor, int secondaryColor) {
|
||||
this.name = name;
|
||||
this.primaryColor = primaryColor;
|
||||
this.secondaryColor = secondaryColor;
|
||||
}
|
||||
|
||||
public CombInfo setIsSecret() {
|
||||
this.isSecret = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final CombInfo[] combs = new CombInfo[]{
|
||||
new CombInfo("honey", 0xe8d56a, 0xffa12b), // 0
|
||||
new CombInfo("cocoa", 0x674016, 0xffb62b).setIsSecret(), // 1
|
||||
new CombInfo("simmering", 0x981919, 0xffb62b), // 2
|
||||
new CombInfo("stringy", 0xc8be67, 0xbda93e), // 3
|
||||
new CombInfo("frozen", 0xf9ffff, 0xa0ffff), // 4
|
||||
new CombInfo("dripping", 0xdc7613, 0xffff00), // 5
|
||||
new CombInfo("silky", 0x508907, 0xddff00), // 6
|
||||
new CombInfo("parched", 0xdcbe13, 0xffff00), // 7
|
||||
new CombInfo("mysterious", 0x161616, 0xe099ff).setIsSecret(), // 8
|
||||
new CombInfo("irradiated", 0xeafff3, 0xeeff00).setIsSecret(), // 9
|
||||
new CombInfo("powdery", 0xe4e4e4, 0xffffff).setIsSecret(), // 10
|
||||
new CombInfo("reddened", 0x4b0000, 0x6200e7).setIsSecret(), // 11
|
||||
new CombInfo("darkened", 0x353535, 0x33ebcb).setIsSecret(), // 12
|
||||
new CombInfo("omega", 0x191919, 0x6dcff6).setIsSecret(), // 13
|
||||
new CombInfo("wheaten", 0xfeff8f, 0xffffff).setIsSecret(), // 14
|
||||
new CombInfo("mossy", 0x2a3313, 0x7e9939), // 15
|
||||
new CombInfo("mellow", 0x886000, 0xfff960) // 16
|
||||
// new CombInfo("", 0xd7bee5, 0xfd58ab), // kindof pinkish
|
||||
};
|
||||
|
||||
public ItemHoneycomb() {
|
||||
super();
|
||||
setMaxDamage(0);
|
||||
@@ -84,44 +42,53 @@ public class ItemHoneycomb extends ItemForestryMultiPass {
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + "." + combs[stack.getItemDamage()].name;
|
||||
EnumHoneyComb honeyComb = EnumHoneyComb.VALUES[stack.getItemDamage()];
|
||||
return super.getUnlocalizedName(stack) + "." + honeyComb.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack itemstack, int j) {
|
||||
EnumHoneyComb honeyComb = EnumHoneyComb.VALUES[itemstack.getItemDamage()];
|
||||
if (j == 0) {
|
||||
return combs[itemstack.getItemDamage()].primaryColor;
|
||||
return honeyComb.primaryColor;
|
||||
} else {
|
||||
return combs[itemstack.getItemDamage()].secondaryColor;
|
||||
return honeyComb.secondaryColor;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
for (int i = 0; i < combs.length; i++) {
|
||||
if (!combs[i].isSecret || Config.isDebug) {
|
||||
for (int i = 0; i < EnumHoneyComb.VALUES.length; i++) {
|
||||
EnumHoneyComb honeyComb = EnumHoneyComb.VALUES[i];
|
||||
if (!honeyComb.isSecret() || Config.isDebug) {
|
||||
itemList.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getRandomCombType(Random random, boolean includeSecret) {
|
||||
List<Integer> validCombs = new ArrayList<>(combs.length);
|
||||
for (int i = 0; i < combs.length; i++) {
|
||||
if (!combs[i].isSecret || includeSecret) {
|
||||
validCombs.add(i);
|
||||
private static EnumHoneyComb getRandomCombType(Random random, boolean includeSecret) {
|
||||
List<EnumHoneyComb> validCombs = new ArrayList<>(EnumHoneyComb.VALUES.length);
|
||||
for (int i = 0; i < EnumHoneyComb.VALUES.length; i++) {
|
||||
EnumHoneyComb honeyComb = EnumHoneyComb.VALUES[i];
|
||||
if (!honeyComb.isSecret() || includeSecret) {
|
||||
validCombs.add(honeyComb);
|
||||
}
|
||||
}
|
||||
|
||||
if (validCombs.isEmpty()) {
|
||||
return 0;
|
||||
return null;
|
||||
} else {
|
||||
return validCombs.get(random.nextInt(validCombs.size()));
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getRandomComb(int qty, Random random, boolean includeSecret) {
|
||||
return ForestryItem.beeComb.getItemStack(qty, ((ItemHoneycomb) ForestryItem.beeComb.item()).getRandomCombType(random, includeSecret));
|
||||
public ItemStack getRandomComb(int amount, Random random, boolean includeSecret) {
|
||||
EnumHoneyComb honeyComb = getRandomCombType(random, includeSecret);
|
||||
return get(honeyComb, amount);
|
||||
}
|
||||
|
||||
public ItemStack get(EnumHoneyComb honeyComb, int amount) {
|
||||
return new ItemStack(this, amount, honeyComb.ordinal());
|
||||
}
|
||||
}
|
||||
Executable → Regular
+36
-162
@@ -1,162 +1,36 @@
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.genetics.Bee;
|
||||
import forestry.core.inventory.ItemInventory;
|
||||
import forestry.core.items.ItemForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
|
||||
public class ItemImprinter extends ItemForestry {
|
||||
|
||||
public static class ImprinterInventory extends ItemInventory {
|
||||
|
||||
private static final short specimenSlot = 0;
|
||||
private static final short imprintedSlot = 1;
|
||||
|
||||
private int primaryIndex = 0;
|
||||
private int secondaryIndex = 0;
|
||||
|
||||
public ImprinterInventory(EntityPlayer player, ItemStack itemStack) {
|
||||
super(player, 2, itemStack);
|
||||
}
|
||||
|
||||
public void advancePrimary() {
|
||||
if (primaryIndex < BeeManager.beeRoot.getIndividualTemplates().size() - 1) {
|
||||
primaryIndex++;
|
||||
} else {
|
||||
primaryIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void advanceSecondary() {
|
||||
if (secondaryIndex < BeeManager.beeRoot.getIndividualTemplates().size() - 1) {
|
||||
secondaryIndex++;
|
||||
} else {
|
||||
secondaryIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void regressPrimary() {
|
||||
if (primaryIndex > 0) {
|
||||
primaryIndex--;
|
||||
} else {
|
||||
primaryIndex = BeeManager.beeRoot.getIndividualTemplates().size() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void regressSecondary() {
|
||||
if (secondaryIndex > 0) {
|
||||
secondaryIndex--;
|
||||
} else {
|
||||
secondaryIndex = BeeManager.beeRoot.getIndividualTemplates().size() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public IAlleleBeeSpecies getPrimary() {
|
||||
return BeeManager.beeRoot.getIndividualTemplates().get(primaryIndex).getGenome().getPrimary();
|
||||
}
|
||||
|
||||
public IAlleleBeeSpecies getSecondary() {
|
||||
return BeeManager.beeRoot.getIndividualTemplates().get(secondaryIndex).getGenome().getPrimary();
|
||||
}
|
||||
|
||||
public IBee getSelectedBee() {
|
||||
return new Bee(BeeManager.beeRoot.templateAsGenome(
|
||||
BeeManager.beeRoot.getGenomeTemplates().get(BeeManager.beeRoot.getIndividualTemplates().get(primaryIndex).getIdent()),
|
||||
BeeManager.beeRoot.getGenomeTemplates().get(BeeManager.beeRoot.getIndividualTemplates().get(secondaryIndex).getIdent())));
|
||||
}
|
||||
|
||||
public int getPrimaryIndex() {
|
||||
return primaryIndex;
|
||||
}
|
||||
|
||||
public int getSecondaryIndex() {
|
||||
return secondaryIndex;
|
||||
}
|
||||
|
||||
public void setPrimaryIndex(int index) {
|
||||
primaryIndex = index;
|
||||
}
|
||||
|
||||
public void setSecondaryIndex(int index) {
|
||||
secondaryIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotClick(EntityPlayer player) {
|
||||
ItemStack specimen = getStackInSlot(specimenSlot);
|
||||
if (specimen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only imprint bees
|
||||
if (!BeeManager.beeRoot.isMember(specimen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Needs space
|
||||
if (getStackInSlot(imprintedSlot) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IBee imprint = getSelectedBee();
|
||||
if (imprint == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
imprint.writeToNBT(nbttagcompound);
|
||||
specimen.setTagCompound(nbttagcompound);
|
||||
|
||||
setInventorySlotContents(imprintedSlot, specimen);
|
||||
setInventorySlotContents(specimenSlot, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Imprinter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return BeeManager.beeRoot.isMember(itemStack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ItemImprinter() {
|
||||
super();
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(ForestryAPI.instance, GuiId.ImprinterGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY,
|
||||
(int) entityplayer.posZ);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.gui.ContainerImprinter;
|
||||
import forestry.apiculture.gui.GuiImprinter;
|
||||
import forestry.apiculture.inventory.ItemInventoryImprinter;
|
||||
import forestry.core.items.ItemWithGui;
|
||||
|
||||
public class ItemImprinter extends ItemWithGui {
|
||||
public ItemImprinter() {
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGui(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
return new GuiImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) {
|
||||
return new ContainerImprinter(player.inventory, new ItemInventoryImprinter(player, heldItem));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.block.BlockRailBase;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemMinecart;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.apiculture.entities.EntityMinecartApiary;
|
||||
import forestry.apiculture.entities.EntityMinecartBeeHousingBase;
|
||||
import forestry.apiculture.entities.EntityMinecartBeehouse;
|
||||
import forestry.core.render.TextureManager;
|
||||
|
||||
public class ItemMinecartBeehouse extends ItemMinecart {
|
||||
private final String[] definition = new String[]{"cart.beehouse", "cart.apiary"};
|
||||
|
||||
public ItemMinecartBeehouse() {
|
||||
super(0);
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
BlockDispenser.dispenseBehaviorRegistry.putObject(this, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float facingX, float facingY, float facingZ) {
|
||||
if (!BlockRailBase.func_150051_a(world.getBlock(x, y, z))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
EntityMinecartBeeHousingBase entityMinecart;
|
||||
if (itemStack.getItemDamage() == 0) {
|
||||
entityMinecart = new EntityMinecartBeehouse(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F));
|
||||
} else {
|
||||
entityMinecart = new EntityMinecartApiary(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F));
|
||||
}
|
||||
entityMinecart.setOwner(player.getGameProfile());
|
||||
|
||||
if (itemStack.hasDisplayName()) {
|
||||
entityMinecart.setMinecartName(itemStack.getDisplayName());
|
||||
}
|
||||
|
||||
world.spawnEntityInWorld(entityMinecart);
|
||||
}
|
||||
|
||||
--itemStack.stackSize;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
if (stack.getItemDamage() >= definition.length || stack.getItemDamage() < 0) {
|
||||
return "item.forestry.unknown";
|
||||
} else {
|
||||
return "item.for." + definition[stack.getItemDamage()];
|
||||
}
|
||||
}
|
||||
|
||||
/* ICONS */
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register) {
|
||||
icons = new IIcon[definition.length];
|
||||
for (int i = 0; i < definition.length; i++) {
|
||||
icons[i] = TextureManager.registerTex(register, definition[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
if (damage >= definition.length || damage < 0) {
|
||||
return icons[0];
|
||||
} else {
|
||||
return icons[damage];
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
for (int i = 0; i < definition.length; i++) {
|
||||
itemList.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getBeeHouseMinecart() {
|
||||
return new ItemStack(this, 1, 0);
|
||||
}
|
||||
|
||||
public ItemStack getApiaryMinecart() {
|
||||
return new ItemStack(this, 1, 1);
|
||||
}
|
||||
}
|
||||
@@ -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.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.items.ItemOverlay;
|
||||
|
||||
public class ItemPollenCluster extends ItemOverlay {
|
||||
public ItemPollenCluster() {
|
||||
super(Tabs.tabApiculture, EnumPollenCluster.VALUES);
|
||||
}
|
||||
|
||||
public ItemStack get(EnumPollenCluster pollenCluster, int amount) {
|
||||
return new ItemStack(this, amount, pollenCluster.ordinal());
|
||||
}
|
||||
}
|
||||
@@ -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.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.items.ItemOverlay;
|
||||
|
||||
public class ItemPropolis extends ItemOverlay {
|
||||
public ItemPropolis() {
|
||||
super(Tabs.tabApiculture, EnumPropolis.VALUES);
|
||||
}
|
||||
|
||||
public ItemStack get(EnumPropolis propolis, int amount) {
|
||||
return new ItemStack(this, amount, propolis.ordinal());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*******************************************************************************
|
||||
* 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.items;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.items.ItemForestry;
|
||||
import forestry.core.items.ItemOverlay;
|
||||
import forestry.core.items.ItemRegistry;
|
||||
import forestry.core.items.ItemScoop;
|
||||
|
||||
public class ItemRegistryApiculture extends ItemRegistry {
|
||||
public final ItemBeeGE beeQueenGE;
|
||||
public final ItemBeeGE beeDroneGE;
|
||||
public final ItemBeeGE beePrincessGE;
|
||||
public final ItemBeeGE beeLarvaeGE;
|
||||
|
||||
public final ItemHabitatLocator habitatLocator;
|
||||
public final ItemBeealyzer beealyzer;
|
||||
public final ItemImprinter imprinter;
|
||||
|
||||
public final ItemMinecartBeehouse minecartBeehouse;
|
||||
|
||||
public final ItemHiveFrame frameUntreated;
|
||||
public final ItemHiveFrame frameImpregnated;
|
||||
public final ItemHiveFrame frameProven;
|
||||
|
||||
public final ItemOverlay honeyDrop;
|
||||
public final ItemPollenCluster pollenCluster;
|
||||
public final ItemPropolis propolis;
|
||||
public final ItemForestry honeydew;
|
||||
public final ItemForestry royalJelly;
|
||||
public final ItemForestry waxCast;
|
||||
public final ItemHoneycomb beeComb;
|
||||
|
||||
public final ItemArmorApiarist apiaristHat;
|
||||
public final ItemArmorApiarist apiaristChest;
|
||||
public final ItemArmorApiarist apiaristLegs;
|
||||
public final ItemArmorApiarist apiaristBoots;
|
||||
|
||||
public final ItemScoop scoop;
|
||||
|
||||
public ItemRegistryApiculture() {
|
||||
// / BEES
|
||||
beeQueenGE = registerItem(new ItemBeeGE(EnumBeeType.QUEEN), "beeQueenGE");
|
||||
beeDroneGE = registerItem(new ItemBeeGE(EnumBeeType.DRONE), "beeDroneGE");
|
||||
beePrincessGE = registerItem(new ItemBeeGE(EnumBeeType.PRINCESS), "beePrincessGE");
|
||||
beeLarvaeGE = registerItem(new ItemBeeGE(EnumBeeType.LARVAE), "beeLarvaeGE");
|
||||
|
||||
beealyzer = registerItem(new ItemBeealyzer(), "beealyzer");
|
||||
habitatLocator = registerItem(new ItemHabitatLocator(), "habitatLocator");
|
||||
imprinter = registerItem(new ItemImprinter(), "imprinter");
|
||||
|
||||
minecartBeehouse = registerItem(new ItemMinecartBeehouse(), "cart.beehouse");
|
||||
|
||||
// / COMB FRAMES
|
||||
frameUntreated = registerItem(new ItemHiveFrame(80, 0.9f), "frameUntreated");
|
||||
frameImpregnated = registerItem(new ItemHiveFrame(240, 0.4f), "frameImpregnated");
|
||||
frameProven = registerItem(new ItemHiveFrame(720, 0.3f), "frameProven");
|
||||
|
||||
// / BEE RESOURCES
|
||||
honeyDrop = registerItem(new ItemOverlay(Tabs.tabApiculture, EnumHoneyDrop.VALUES), "honeyDrop");
|
||||
OreDictionary.registerOre("dropHoney", honeyDrop);
|
||||
|
||||
pollenCluster = registerItem(new ItemPollenCluster(), "pollen");
|
||||
OreDictionary.registerOre("itemPollen", pollenCluster);
|
||||
|
||||
propolis = registerItem(new ItemPropolis(), "propolis");
|
||||
|
||||
honeydew = registerItem(new ItemForestry(Tabs.tabApiculture), "honeydew");
|
||||
OreDictionary.registerOre("dropHoneydew", honeydew);
|
||||
|
||||
royalJelly = registerItem(new ItemForestry(Tabs.tabApiculture), "royalJelly");
|
||||
OreDictionary.registerOre("dropRoyalJelly", royalJelly);
|
||||
|
||||
waxCast = registerItem(new ItemWaxCast(), "waxCast");
|
||||
|
||||
// / BEE COMBS
|
||||
beeComb = registerItem(new ItemHoneycomb(), "beeCombs");
|
||||
OreDictionary.registerOre("beeComb", beeComb.getWildcard());
|
||||
|
||||
// / APIARIST'S CLOTHES
|
||||
apiaristHat = registerItem(new ItemArmorApiarist(0), "apiaristHelmet");
|
||||
apiaristChest = registerItem(new ItemArmorApiarist(1), "apiaristChest");
|
||||
apiaristLegs = registerItem(new ItemArmorApiarist(2), "apiaristLegs");
|
||||
apiaristBoots = registerItem(new ItemArmorApiarist(3), "apiaristBoots");
|
||||
|
||||
// TOOLS
|
||||
scoop = registerItem(new ItemScoop(), "scoop");
|
||||
scoop.setHarvestLevel("scoop", 3);
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,16 @@ package forestry.apiculture.items;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.items.ICraftingPlan;
|
||||
import forestry.core.items.ItemForestry;
|
||||
|
||||
public class ItemWaxCast extends ItemForestry implements ICraftingPlan {
|
||||
|
||||
public ItemWaxCast() {
|
||||
super();
|
||||
super(Tabs.tabApiculture);
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(10);
|
||||
setMaxDamage(16);
|
||||
setNoRepair();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,19 +14,19 @@ import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.DefaultBeeModifier;
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
@@ -34,28 +34,26 @@ import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.apiculture.BeeHousingInventory;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.apiculture.AlvearyBeeModifier;
|
||||
import forestry.apiculture.InventoryBeeHousing;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.multiblock.CoordTriplet;
|
||||
import forestry.core.multiblock.IMultiblockPart;
|
||||
import forestry.core.multiblock.MultiblockControllerBase;
|
||||
import forestry.core.multiblock.MultiblockTileEntityBase;
|
||||
import forestry.core.multiblock.IMultiblockControllerInternal;
|
||||
import forestry.core.multiblock.MultiblockValidationException;
|
||||
import forestry.core.multiblock.rectangular.RectangularMultiblockControllerBase;
|
||||
import forestry.core.multiblock.RectangularMultiblockControllerBase;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.PacketGuiUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
public class AlvearyController extends RectangularMultiblockControllerBase implements IAlvearyController, IClimateControlled {
|
||||
public class AlvearyController extends RectangularMultiblockControllerBase implements IAlvearyControllerInternal, IClimateControlled {
|
||||
|
||||
private final BeeHousingInventory inventory;
|
||||
private final InventoryBeeHousing inventory;
|
||||
private final IBeekeepingLogic beekeepingLogic;
|
||||
|
||||
private BiomeGenBase cachedBiome;
|
||||
private float tempChange = 0.0f;
|
||||
private float humidChange = 0.0f;
|
||||
|
||||
@@ -64,14 +62,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
private final Set<IBeeListener> beeListeners = new HashSet<>();
|
||||
private final Set<IAlvearyComponent.Climatiser> climatisers = new HashSet<>();
|
||||
private final Set<IAlvearyComponent.Active> activeComponents = new HashSet<>();
|
||||
private final Set<IAlvearyComponent> allComponents = new HashSet<>();
|
||||
|
||||
// CLIENT
|
||||
private int breedingProgressPercent = 0;
|
||||
|
||||
public AlvearyController(World world) {
|
||||
super(world);
|
||||
this.inventory = new BeeHousingInventory(9, "Items", getAccessHandler());
|
||||
super(world, AlvearyMultiblockSizeLimits.instance);
|
||||
this.inventory = new InventoryBeeHousing(9, getAccessHandler());
|
||||
this.beekeepingLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
||||
|
||||
this.beeModifiers.add(new AlvearyBeeModifier());
|
||||
@@ -107,20 +104,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IAlvearyComponent> getComponents() {
|
||||
return allComponents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedPartWithMultiblockData(IMultiblockPart part, NBTTagCompound data) {
|
||||
public void onAttachedPartWithMultiblockData(IMultiblockComponent part, NBTTagCompound data) {
|
||||
this.readFromNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBlockAdded(IMultiblockPart newPart) {
|
||||
protected void onBlockAdded(IMultiblockComponent newPart) {
|
||||
if (newPart instanceof IAlvearyComponent) {
|
||||
allComponents.add((IAlvearyComponent) newPart);
|
||||
|
||||
if (newPart instanceof IAlvearyComponent.BeeModifier) {
|
||||
IAlvearyComponent.BeeModifier alvearyBeeModifier = (IAlvearyComponent.BeeModifier) newPart;
|
||||
IBeeModifier beeModifier = alvearyBeeModifier.getBeeModifier();
|
||||
@@ -144,10 +134,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBlockRemoved(IMultiblockPart oldPart) {
|
||||
protected void onBlockRemoved(IMultiblockComponent oldPart) {
|
||||
if (oldPart instanceof IAlvearyComponent) {
|
||||
allComponents.remove(oldPart);
|
||||
|
||||
if (oldPart instanceof IAlvearyComponent.BeeModifier) {
|
||||
IAlvearyComponent.BeeModifier alvearyBeeModifier = (IAlvearyComponent.BeeModifier) oldPart;
|
||||
IBeeModifier beeModifier = alvearyBeeModifier.getBeeModifier();
|
||||
@@ -174,14 +162,14 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
protected void isMachineWhole() throws MultiblockValidationException {
|
||||
super.isMachineWhole();
|
||||
|
||||
final CoordTriplet maximumCoord = getMaximumCoord();
|
||||
final CoordTriplet minimumCoord = getMinimumCoord();
|
||||
final ChunkCoordinates maximumCoord = getMaximumCoord();
|
||||
final ChunkCoordinates minimumCoord = getMinimumCoord();
|
||||
|
||||
// check that the top is covered in wood slabs
|
||||
|
||||
final int slabY = maximumCoord.y + 1;
|
||||
for (int slabX = minimumCoord.x; slabX <= maximumCoord.x; slabX++) {
|
||||
for (int slabZ = minimumCoord.z; slabZ <= maximumCoord.z; slabZ++) {
|
||||
final int slabY = maximumCoord.posY + 1;
|
||||
for (int slabX = minimumCoord.posX; slabX <= maximumCoord.posX; slabX++) {
|
||||
for (int slabZ = minimumCoord.posZ; slabZ <= maximumCoord.posZ; slabZ++) {
|
||||
Block block = worldObj.getBlock(slabX, slabY, slabZ);
|
||||
if (!BlockUtil.isWoodSlabBlock(block)) {
|
||||
throw new MultiblockValidationException(StatCollector.translateToLocal("for.multiblock.alveary.error.needSlabs"));
|
||||
@@ -196,9 +184,9 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
// check that there is space all around the alveary entrances
|
||||
|
||||
int airY = maximumCoord.y;
|
||||
for (int airX = minimumCoord.x - 1; airX <= maximumCoord.x + 1; airX++) {
|
||||
for (int airZ = minimumCoord.z - 1; airZ <= maximumCoord.z + 1; airZ++) {
|
||||
int airY = maximumCoord.posY;
|
||||
for (int airX = minimumCoord.posX - 1; airX <= maximumCoord.posX + 1; airX++) {
|
||||
for (int airZ = minimumCoord.posZ - 1; airZ <= maximumCoord.posZ + 1; airZ++) {
|
||||
if (isCoordInMultiblock(airX, airY, airZ)) {
|
||||
continue;
|
||||
}
|
||||
@@ -211,47 +199,26 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMinimumNumberOfBlocksForAssembledMachine() {
|
||||
return 27;
|
||||
protected void isGoodForExteriorLevel(IMultiblockComponent part, int level) throws MultiblockValidationException {
|
||||
if (level == 2 && !(part instanceof TileAlvearyPlain)) {
|
||||
throw new MultiblockValidationException(StatCollector.translateToLocal("for.multiblock.alveary.error.needPlainOnTop"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaximumXSize() {
|
||||
return 3;
|
||||
protected void isGoodForInterior(IMultiblockComponent part) throws MultiblockValidationException {
|
||||
if (!(part instanceof TileAlvearyPlain)) {
|
||||
throw new MultiblockValidationException(StatCollector.translateToLocal("for.multiblock.alveary.error.needPlainInterior"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaximumZSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMaximumYSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMinimumXSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMinimumYSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getMinimumZSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAssimilate(MultiblockControllerBase assimilated) {
|
||||
protected void onAssimilate(IMultiblockControllerInternal assimilated) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAssimilated(MultiblockControllerBase assimilator) {
|
||||
public void onAssimilated(IMultiblockControllerInternal assimilator) {
|
||||
|
||||
}
|
||||
|
||||
@@ -298,10 +265,10 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
beekeepingLogic.doBeeFX();
|
||||
|
||||
if (updateOnInterval(50)) {
|
||||
CoordTriplet center = getCenterCoord();
|
||||
float fxX = center.x + 0.5F;
|
||||
float fxY = center.y + 1.0F;
|
||||
float fxZ = center.z + 0.5F;
|
||||
ChunkCoordinates center = getCenterCoord();
|
||||
float fxX = center.posX + 0.5F;
|
||||
float fxY = center.posY + 1.0F;
|
||||
float fxZ = center.posZ + 0.5F;
|
||||
float distanceFromCenter = 1.6F;
|
||||
|
||||
float leftRightSpreadFromCenter = distanceFromCenter * (worldObj.rand.nextFloat() - 0.5F);
|
||||
@@ -323,7 +290,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
data.setFloat("TempChange", tempChange);
|
||||
data.setFloat("HumidChange", humidChange);
|
||||
|
||||
beekeepingLogic.writeToNBT(data);
|
||||
inventory.writeToNBT(data);
|
||||
}
|
||||
@@ -354,21 +320,24 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
CoordTriplet coord = getCenterCoord();
|
||||
return new ChunkCoordinates(coord.x, coord.y + 1, coord.z);
|
||||
ChunkCoordinates coord = getCenterCoord();
|
||||
return new ChunkCoordinates(coord.posX, coord.posY + 1, coord.posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getBeeFXCoordinates() {
|
||||
ChunkCoordinates coord = getCenterCoord();
|
||||
return Vec3.createVectorHelper(coord.posX + 0.5, coord.posY + 1.5, coord.posZ + 0.5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(this);
|
||||
Proxies.net.sendNetworkPacket(packet, worldObj);
|
||||
|
||||
if (oldAccess == EnumAccess.SHARED || newAccess == EnumAccess.SHARED) {
|
||||
// pipes connected to this need to update
|
||||
for (IMultiblockPart part : connectedParts) {
|
||||
if (part instanceof MultiblockTileEntityBase) {
|
||||
MultiblockTileEntityBase tile = (MultiblockTileEntityBase) part;
|
||||
tile.notifyNeighborsOfBlockChange();
|
||||
for (IMultiblockComponent part : connectedParts) {
|
||||
if (part instanceof TileEntity) {
|
||||
TileEntity tile = (TileEntity) part;
|
||||
worldObj.notifyBlocksOfNeighborChange(tile.xCoord, tile.yCoord, tile.zCoord, tile.getBlockType());
|
||||
}
|
||||
}
|
||||
markDirty();
|
||||
@@ -377,8 +346,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
CoordTriplet coords = getReferenceCoord();
|
||||
return getBiome().getFloatTemperature(coords.x, coords.y, coords.z) + tempChange;
|
||||
ChunkCoordinates coords = getReferenceCoord();
|
||||
return getBiome().getFloatTemperature(coords.posX, coords.posY, coords.posZ) + tempChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -389,8 +358,11 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(this);
|
||||
if (beeModifier.isHellish() && tempChange >= 0) {
|
||||
return EnumTemperature.HELLISH;
|
||||
BiomeGenBase biome = getBiome();
|
||||
if (beeModifier.isHellish() || BiomeHelper.isBiomeHellish(biome)) {
|
||||
if (tempChange >= 0) {
|
||||
return EnumTemperature.HELLISH;
|
||||
}
|
||||
}
|
||||
|
||||
return EnumTemperature.getFromValue(getExactTemperature());
|
||||
@@ -413,23 +385,20 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
if (cachedBiome == null) {
|
||||
CoordTriplet coords = getReferenceCoord();
|
||||
cachedBiome = worldObj.getBiomeGenForCoords(coords.x, coords.z);
|
||||
}
|
||||
return cachedBiome;
|
||||
ChunkCoordinates coords = getReferenceCoord();
|
||||
return worldObj.getBiomeGenForCoords(coords.posX, coords.posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightValue() {
|
||||
CoordTriplet topCenter = getTopCenterCoord();
|
||||
return worldObj.getBlockLightValue(topCenter.x, topCenter.y + 1, topCenter.z);
|
||||
ChunkCoordinates topCenter = getTopCenterCoord();
|
||||
return worldObj.getBlockLightValue(topCenter.posX, topCenter.posY + 1, topCenter.posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockSeeTheSky() {
|
||||
CoordTriplet topCenter = getTopCenterCoord();
|
||||
return worldObj.canBlockSeeTheSky(topCenter.x, topCenter.y + 2, topCenter.z);
|
||||
ChunkCoordinates topCenter = getTopCenterCoord();
|
||||
return worldObj.canBlockSeeTheSky(topCenter.posX, topCenter.posY + 2, topCenter.posZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -460,7 +429,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeGuiData(data);
|
||||
data.writeVarInt(beekeepingLogic.getBeeProgressPercent());
|
||||
data.writeVarInt(Math.round(tempChange * 100));
|
||||
data.writeVarInt(Math.round(humidChange * 100));
|
||||
@@ -468,17 +436,8 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
super.readGuiData(data);
|
||||
breedingProgressPercent = data.readVarInt();
|
||||
tempChange = data.readVarInt() / 100.0F;
|
||||
humidChange = data.readVarInt() / 100.0F;
|
||||
}
|
||||
|
||||
private static class AlvearyBeeModifier extends DefaultBeeModifier {
|
||||
@Override
|
||||
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
||||
return 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*******************************************************************************
|
||||
* 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.multiblock;
|
||||
|
||||
import forestry.core.multiblock.IMultiblockSizeLimits;
|
||||
|
||||
class AlvearyMultiblockSizeLimits implements IMultiblockSizeLimits {
|
||||
|
||||
public static final AlvearyMultiblockSizeLimits instance = new AlvearyMultiblockSizeLimits();
|
||||
|
||||
private AlvearyMultiblockSizeLimits() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumNumberOfBlocksForAssembledMachine() {
|
||||
return 27;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumXSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumZSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumYSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumXSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumYSize() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumZSize() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -10,35 +10,25 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.apiculture.FakeBeekeepingLogic;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.access.FakeAccessHandler;
|
||||
import forestry.core.access.IAccessHandler;
|
||||
import forestry.core.errors.FakeErrorLogic;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.multiblock.FakeMultiblockController;
|
||||
|
||||
public class FakeAlvearyController implements IAlvearyController {
|
||||
public class FakeAlvearyController extends FakeMultiblockController implements IAlvearyControllerInternal {
|
||||
public static final FakeAlvearyController instance = new FakeAlvearyController();
|
||||
|
||||
private FakeAlvearyController() {
|
||||
@@ -55,11 +45,6 @@ public class FakeAlvearyController implements IAlvearyController {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<IAlvearyComponent> getComponents() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return FakeBeeHousingInventory.instance;
|
||||
@@ -70,16 +55,6 @@ public class FakeAlvearyController implements IAlvearyController {
|
||||
return FakeBeekeepingLogic.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockLightValue() {
|
||||
return 0;
|
||||
@@ -90,49 +65,19 @@ public class FakeAlvearyController implements IAlvearyController {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getOwner() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorLogic getErrorLogic() {
|
||||
return FakeErrorLogic.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getCoordinates() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
|
||||
public Vec3 getBeeFXCoordinates() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,11 +85,6 @@ public class FakeAlvearyController implements IAlvearyController {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAccessHandler getAccessHandler() {
|
||||
return FakeAccessHandler.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventoryAdapter getInternalInventory() {
|
||||
return FakeInventoryAdapter.instance();
|
||||
|
||||
+5
-6
@@ -10,16 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.multiblock.IAlvearyController;
|
||||
import forestry.core.access.IRestrictedAccess;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.multiblock.IMultiblockControllerInternal;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.tiles.IClimatised;
|
||||
import forestry.core.tiles.IRestrictedAccessTile;
|
||||
|
||||
public interface IAlvearyController extends IBeeHousing, IClimatised, IRestrictedAccessTile {
|
||||
public interface IAlvearyControllerInternal extends IAlvearyController, IMultiblockControllerInternal, IClimatised, IRestrictedAccess, IStreamableGui {
|
||||
IInventoryAdapter getInternalInventory();
|
||||
|
||||
Iterable<IAlvearyComponent> getComponents();
|
||||
|
||||
int getHealthScaled(int i);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*******************************************************************************
|
||||
* 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.multiblock;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.multiblock.IMultiblockLogicAlveary;
|
||||
import forestry.core.multiblock.MultiblockLogic;
|
||||
|
||||
public class MultiblockLogicAlveary extends MultiblockLogic<IAlvearyControllerInternal> implements IMultiblockLogicAlveary {
|
||||
public MultiblockLogicAlveary() {
|
||||
super(IAlvearyControllerInternal.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAlvearyControllerInternal getController() {
|
||||
if (super.isConnected()) {
|
||||
return controller;
|
||||
} else {
|
||||
return FakeAlvearyController.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public IAlvearyControllerInternal createNewController(World world) {
|
||||
return new AlvearyController(world);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 739 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user