Compare commits

..
98 Commits
Author SHA1 Message Date
mezz ac653d46c1 Fix #326 decorative leaves should not pollinate 2014-11-15 04:15:20 -08:00
mezz 63d9935d01 Minor code cleanup 2014-11-15 04:15:14 -08:00
mezz ba695b977d Fix #325 Centrifuge dupe bug 2014-11-15 04:13:46 -08:00
CovertJaguar 6b1dfb1596 Set submodules 2014-11-15 04:12:44 -08:00
CovertJaguar fff02be71d Bump version to 3.2 2014-11-08 21:40:45 -08:00
CovertJaguar 0e5b9e4957 Merge branch 'dev' into release_3.2
Conflicts:
	src/main/resources/assets/forestry/textures/blocks/storage/apatite.png
	src/main/resources/assets/forestry/textures/blocks/storage/bronze.png
	src/main/resources/assets/forestry/textures/blocks/storage/copper.png
	src/main/resources/assets/forestry/textures/blocks/storage/tin.png
2014-11-08 21:39:26 -08:00
mezz d385a25efa Fix Fermenter error state and hasWork 2014-11-06 19:18:33 -08:00
mezz 5f52cf54cb Add icon for "no power" error state 2014-11-06 19:04:07 -08:00
mezz acb85e75ef Add "No Power" error state to multifarm 2014-11-05 23:03:13 -08:00
mezz 220ce0b6a2 Add "No Power" error state to multifarm 2014-11-05 23:00:44 -08:00
mezz 63ec46d830 Close #312, use BuildCraft's IHasWork instead of TriggerHasWork 2014-11-05 22:51:10 -08:00
mezz 06907ae3d4 Fix engineTin constantly switching error states 2014-11-05 22:51:10 -08:00
mezz cb805e3a22 Fix TileAnalyzer's error state checking and display 2014-11-05 22:51:10 -08:00
mezz 393bd691d8 Fix crash from TriggerLowLiquid 2014-11-05 22:51:09 -08:00
mezz 3a5275396b Add "No Power" error state 2014-11-05 22:51:04 -08:00
mezz 7d72a60f9b Make unpowered machines not inherit from TilePowered 2014-11-05 21:50:14 -08:00
mezz 32313cfe6a #309 Convert MJ to RF for BuildCraft plugin 2014-11-04 21:08:13 -08:00
mezz 9f0084c1b7 Optimize NBT species retrieval from ItemStacks 2014-11-03 23:02:08 -08:00
mezz 13d89fc347 Give fireproof genes a name 2014-11-03 21:33:16 -08:00
mezz 8bf9184ba4 Fix #313: Genome NBT errors 2014-11-03 21:32:49 -08:00
mezz 5487aba3a2 Close #287. Add fireproof logs and planks, and recipes 2014-11-03 00:30:19 -08:00
mezz 66a74703f8 #287 Add fireproof gene to trees 2014-11-03 00:28:14 -08:00
mezz c9bd15a20d Close #84. Fix #302. Fix #309. Update BuildCraft API to 6.1.x 2014-11-02 15:00:28 -08:00
mezz 486b7a8f80 Fix low paper trigger message 2014-11-02 15:00:28 -08:00
mezz bc2e27e495 Bump to trigger a build on jenkins (it was down) 2014-11-02 11:26:15 -08:00
mezz e028428a67 Fix Tropical Hive generation 2014-11-01 21:37:11 -07:00
mezz a9b72c85bd Fix #306: Raintank fills in Desert biome 2014-10-29 22:04:21 -07:00
mezz 247cb0b336 #300: Fix leaf tick frequency to match BlockTreeContainer 2014-10-26 23:09:21 -07:00
mezz 50a155aa2a Fix #300: Fruits on leaves do not ripen 2014-10-26 22:20:51 -07:00
mezz f47d349056 Fix #303: Default Farm Logic disappears with smaller circuits 2014-10-26 21:03:08 -07:00
mezz 4c52620f0f use foreach 2014-10-26 21:02:39 -07:00
mezz f4121b0849 Fix Lang submodule 2014-10-26 20:58:55 -07:00
MysteriousAges 3415030fbf Revert "Storage block textures - Apatite, Bronze, Copper, Tin."
This reverts commit c8fd93873a.
2014-10-24 20:18:30 -07:00
MysteriousAges f0dedf56a5 Adding storage blocks for Apatite, Copper, Tin and Bronze. 2014-10-24 20:01:43 -07:00
MysteriousAges 71b0a7bc1d Adding storage block textures. 2014-10-24 18:52:38 -07:00
MysteriousAges c8fd93873a Storage block textures - Apatite, Bronze, Copper, Tin. 2014-10-23 17:42:20 -07:00
mezz d1baa7d69c Fix crash from addon circuits 2014-10-20 22:22:09 -07:00
mezz 8c19ba73cb Change warning about MCPC+ to Cauldron 2014-10-20 20:34:17 -07:00
mezz 7d373ad75b Formatting cleanup in MailAddress 2014-10-17 00:10:36 -07:00
mezz 5960f800e7 Fix #288 The MultiFarm won't place dirt 2014-10-16 22:46:37 -07:00
mezz eb4fcf3267 Exclude old language files from jars 2014-10-12 23:50:15 -07:00
mezz 1f9d4badc3 Losslessly compress all png assets with PNGGauntlet 2014-10-12 23:40:07 -07:00
mezz b60b5c1251 Fix #283 Crash from Disabling Arboriculture 2014-10-11 16:52:10 -07:00
mezz d7dc7a8c69 Re-add deprecated backpack method to stop outdated mods from crashing 2014-10-11 16:37:18 -07:00
mezz 5e9cc9e2b1 Fix #280, crash on viewing the name of research notes from 1.6.4 2014-10-10 00:25:20 -07:00
CovertJaguar 4fcb9cb221 Update README.md 2014-10-08 18:22:09 -07:00
CovertJaguar 1e4db46584 Update README.md 2014-10-08 18:21:42 -07:00
CovertJaguar eb102ac7d7 Bump version 2014-10-08 15:46:13 -07:00
mezz 01388ca02e Remove root api package-info that duplicates ForestryAPI|core 2014-10-08 14:12:51 -07:00
mezz 2792eda133 Fix #277. Remove minimum input energy requirement for machines 2014-10-08 13:56:03 -07:00
CovertJaguar 7fbdb8b670 Update lang 2014-10-08 08:31:23 -07:00
CovertJaguar ef3a62a9e7 Add some sanity checks to the Sapling1 pickBlock() function.
Closes #276
2014-10-08 08:18:46 -07:00
mezz cbf8822d1e Add sand to farm breakable-ground whitelist 2014-10-08 03:22:52 -07:00
mezz ec088976cb Update CONTRIBUTING.md to include bug reports 2014-10-08 02:39:41 -07:00
mezz 704acf008c Have farms do a block update when setting new ground 2014-10-07 01:17:54 -07:00
mezz 3bb0acc04c Prevent farms from accidentally destroying anything but farmland. 2014-10-07 01:10:45 -07:00
CovertJaguar 7ae094ab72 There is a function for that. 2014-10-06 15:14:14 -07:00
mezz 911aa8ca5c Fix #272. Allow every kind of log to be smelted into charcoal 2014-10-06 14:18:46 -07:00
CovertJaguar 9a1888e85c Update application.properties 2014-10-06 08:47:42 -07:00
mezz 955ae9640a Make ItemScoop an ItemForestryTool and work in Adventure Mode 2014-10-05 21:12:06 -07:00
mezz d510e121eb Fix #268 saplings not being picked up by large farms 2014-10-05 05:46:55 -07:00
mezz 46c4c65488 Put harvested farm resources back in the resources slot 2014-10-05 04:29:15 -07:00
mezz 087780fbf8 Farms treat any ground block that isn't their ground as waste 2014-10-05 04:29:14 -07:00
mezz 46f5b2fb46 First steps to being able to disable the Lepidopterology module 2014-10-04 21:56:26 -07:00
mezz 056dc75fab #252 Add debug.conf with option to generate hives everywhere 2014-10-04 03:27:57 -07:00
mezz 814e48ba5a Better temperature control for spawning beehives 2014-10-04 03:03:26 -07:00
mezz ebcdf7fbf5 Use strings to register hives in HiveManager 2014-10-04 00:44:03 -07:00
mezz 625b5038a5 Fix #262 crash from squeezer 2014-10-03 20:55:42 -07:00
mezz 9ec59e9dcd Stop hives being placed sunken into grass 2014-10-03 20:43:11 -07:00
mezz 4600180cb7 fix some build.gradle warnings 2014-10-03 16:02:10 -07:00
mezz 1f2c32669e Fix #265, Fix #264. Stop modest hive spawning in nether, stop high cpu 2014-10-03 16:01:46 -07:00
mezz 4b2336bae2 #260 Expose basic hive gen in the API 2014-10-03 02:08:41 -07:00
mezz 8816a5fea8 #252 Improve hive worldgen. Works with more biome variations 2014-10-02 03:38:26 -07:00
mezz f8ff6f9ea4 Fix crashes when disabling apiculture module 2014-10-01 22:28:21 -07:00
mezz c0ba391f4f Rename plain pollen to pollenCluster internally 2014-10-01 20:40:15 -07:00
mezz bbcfa7bf2b Fix #258 crash when disabling storage module 2014-10-01 19:44:10 -07:00
CovertJaguar 270147ce36 Add a build qualifer to the version string 2014-09-30 18:42:33 -07:00
mezz dd4529aa75 #255 Add custom localization for worker speed tooltip 2014-09-29 21:32:56 -07:00
mezz a50198dd3d #255 fix temperature and humidity tolerance localization 2014-09-29 17:09:57 -07:00
mezz 6bcd77ceff #255 fix missing translations for bee effects 2014-09-29 16:30:15 -07:00
mezz 83d545e3c7 automatic spaces to tabs 2014-09-29 16:23:47 -07:00
mezz 974ce7ea65 Close #247 Custom names for adjectives 2014-09-29 01:36:19 -07:00
mezz fe5d14643b move "for." prefix into StringUtil.canTranslate 2014-09-29 01:14:11 -07:00
mezz 548823813f Added StringUtil.canTranslate 2014-09-28 23:48:34 -07:00
mezz cfd60a9610 Fix #250. Make getPlayer return fake player when missing profile 2014-09-28 21:56:13 -07:00
mezz a8583bfbfd removed isClientPlayer from MailAddress 2014-09-28 21:54:30 -07:00
mezz f02426b219 Make peat farm replace farmland 2014-09-28 18:57:33 -07:00
mezz d7aae80bdd Made codechicken fully optional, not included in jars. 2014-09-28 18:35:49 -07:00
mezz e75afa927f Fix CircuitFarmLogic 2014-09-28 17:28:44 -07:00
CovertJaguar 6c0dc4a5d9 Merge pull request #249 from MineMaarten/patch-1
Update CircuitFarmLogic.java
2014-09-28 08:50:51 -07:00
MineMaarten 9acb76a676 Update CircuitFarmLogic.java
I've created a custom farm logic for my seeds, but it just implements IFarmLogic, and doesn't extend FarmLogic (as that isn't available from the API), causing a ClassCastException. This would resolve that issue.
2014-09-28 16:27:27 +02:00
mezz 5fb04e4467 #246 Exclude codechicken from build jars 2014-09-27 16:52:58 -07:00
mezz c43d057339 #245 Add localized plugin description comments to modules.cfg too 2014-09-27 12:50:24 -07:00
mezz ccd91f91d5 Fix #245: Localize plugin descriptions 2014-09-27 12:46:54 -07:00
mezz cea331470e Moved all electric engine circuits and generator fuel to PluginIC2 2014-09-27 11:44:00 -07:00
mezz d2960b19be Fix #243. Add smelting recipe for apatite 2014-09-27 10:14:52 -07:00
mezz bb708797ba Fix xp for smelting 2014-09-27 10:06:20 -07:00
CovertJaguar c1b29f5c20 Make Analyzer Machine require power and accept Honey Drops 2014-09-26 23:17:07 -07:00
982 changed files with 3443 additions and 2977 deletions

No files matched your search

+13
View File
@@ -1,3 +1,16 @@
How to submit a bug report to Forestry
====================================
Please make sure the bug has not already been reported by [searching the issues](https://github.com/ForestryMC/ForestryMC/issues?q=is%3Aissue).
If you can, see if the bug still happens with the latest unstable build.
[The latest unstable builds are available here](http://jenkins.ic2.player.to/job/Forestry_Dev/)
For crashes, you must post a link to the full crash report.
[gist.github.com](gist.github.com) or [pastebin.com](www.pastebin.com) are good places to upload them.
Full crash reports are located in [the minecraft data folder](http://hopper.minecraft.net/help/finding-minecraft-data-folder/), in "crash-reports".
Thank you for reporting bugs!
How to contribute to Forestry
====================================
+4 -2
View File
@@ -1,6 +1,6 @@
Forestry
====================================
### What is it?
Forestry is a modification for the game Minecraft and known primarily for its farms and bees.
@@ -9,10 +9,12 @@ Forestry is a modification for the game Minecraft and known primarily for its fa
[Wiki](http://forestry.sengir.net/)
[Latest Builds for 1.7.10](http://jenkins.ic2.player.to/job/Forestry/)
[Latest Builds for 1.7.10](http://jenkins.ic2.player.to/job/Forestry_Dev/)
[IRC #forestry on esper.net](http://webchat.esper.net/?nick=ForestryGithub...&channels=forestry&prompt=1)
For those interested in developement, you can also visit #forestry-dev.
### Building
The API and localization files reside in their own repository. It is pulled in automatically.
+1 -1
Submodule api updated: b3c8d281a3...4f7ca82190.
+2 -2
View File
@@ -1,6 +1,6 @@
mcversion=1.7.10
forgeversion=10.13.0.1207
version_major=3
version_minor=1
version_patch=1
version_minor=2
version_patch=0
+21 -14
View File
@@ -76,14 +76,14 @@ configurations {
dependencies {
compile 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api'
apis 'com.mod-buildcraft:buildcraft:6.0.18:dev'
apis 'com.mod-buildcraft:buildcraft:6.1.5:dev'
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
@@ -102,19 +102,19 @@ processResources {
runClient {
if (project.hasProperty('mcUsername')) {
args "--username=${project.mcUsername}"
args "--username=" + project.mcUsername
}
if (project.hasProperty('mcPassword')) {
args "--password=${project.mcPassword}"
args "--password=" + project.mcPassword
}
}
debugClient {
if (project.hasProperty('mcUsername')) {
args "--username=${project.mcUsername}"
args "--username=" + project.mcUsername
}
if (project.hasProperty('mcPassword')) {
args "--password=${project.mcPassword}"
args "--password=" + project.mcPassword
}
}
@@ -157,17 +157,19 @@ task bumpPatch << {
saveVersion()
}
import org.ajoberstar.grgit.Grgit
task initCraftGuide << {
def localRepo = file(CraftGuideTmp)
if (localRepo.exists()) {
println 'Updating CraftGuide repo'
def grgit = org.ajoberstar.grgit.Grgit.open(localRepo)
def grgit = Grgit.open(localRepo)
grgit.pull()
grgit.close()
} else {
println 'Cloning CraftGuide repo'
def grgit = org.ajoberstar.grgit.Grgit.clone(dir: localRepo, uri: CraftGuideRepo)
def grgit = Grgit.clone(dir: localRepo, uri: CraftGuideRepo)
grgit.close()
}
}
@@ -176,7 +178,7 @@ jar {
destinationDir = file("build/tmp")
archiveName = "main.jar"
from {
from {
configurations.apis.collect {
it.isDirectory() ? it : zipTree(it).matching {
include '**/api/**'
@@ -189,6 +191,7 @@ task mainJarSigned ( type: Jar, dependsOn: 'reobf' ) {
from (zipTree(jar.getArchivePath())) {
exclude '**/api/**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
@@ -214,7 +217,8 @@ task mainJar ( type: Zip, dependsOn: mainJarSigned ) {
from (zipTree(jar.getArchivePath())) {
include '**'
exclude '**/codechicken/**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
@@ -227,6 +231,7 @@ task devJarSigned ( type: Jar, dependsOn: 'classes' ) {
from(sourceSets.main.output) {
exclude '**/api/**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
destinationDir = file("build/tmp")
@@ -251,12 +256,14 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) {
from(sourceSets.main.allSource) {
include '**'
exclude '**/codechicken/**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
from(sourceSets.main.output) {
include '**'
exclude '**/codechicken/**'
exclude '**/codechicken/**'
exclude '**/old/lang/**'
}
from {
+1 -1
Submodule lang updated: c37b50751a...8ca6c91070.
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -28,13 +28,13 @@ import forestry.plugins.PluginApiculture;
public class EntityBee extends EntityCreature implements IAnimals {
private static final String DEFAULT_TEXTURE = Defaults.TEXTURE_PATH_ENTITIES + "/bees/honeyBee.png";
IBee contained;
IAlleleBeeSpecies species;
EnumBeeType type = EnumBeeType.DRONE;
private String beeTexture = DEFAULT_TEXTURE;
private long lastUpdate;
private String beeTexture = DEFAULT_TEXTURE;
private long lastUpdate;
public EntityBee(World world) {
super(world);
@@ -43,49 +43,50 @@ public class EntityBee extends EntityCreature implements IAnimals {
private void resetAppearance() {
beeTexture = species.getEntityTexture();
}
public EntityBee setIndividual(IBee bee) {
if(bee != null)
if (bee != null)
contained = bee;
else
contained = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate());
//isImmuneToFire = contained.getGenome().getFireResist();
setSpecies(contained.getGenome().getPrimary());
//dataWatcher.updateObject(DATAWATCHER_ID_SPECIES, species.getUID());
//dataWatcher.updateObject(DATAWATCHER_ID_SCALE, (int)(contained.getSize() * 100));
return this;
}
public IBee getBee() {
return contained;
}
public EntityBee setType(EnumBeeType type) {
this.type = type;
return this;
}
public EnumBeeType getType() {
return type;
}
public EntityBee setSpecies(IAlleleBeeSpecies species) {
this.species = species;
resetAppearance();
lastUpdate = worldObj.getTotalWorldTime();
return this;
}
@SideOnly(Side.CLIENT)
private ResourceLocation textureResource;
private long lastTextureUpdate;
@SideOnly(Side.CLIENT)
public ResourceLocation getTexture() {
if(textureResource == null || lastTextureUpdate != lastUpdate)
if (textureResource == null || lastTextureUpdate != lastUpdate)
textureResource = new ForestryResource(beeTexture);
return textureResource;
}
}
@@ -10,15 +10,7 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.statements.ITriggerExternal;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.apiculture.IBeeListener;
import forestry.api.apiculture.IBeeModifier;
@@ -32,6 +24,12 @@ import forestry.core.proxy.Proxies;
import forestry.core.triggers.ForestryTrigger;
import forestry.core.utils.TileInventoryAdapter;
import forestry.core.utils.Utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import java.util.LinkedList;
public abstract class TileAlveary extends TileForestry implements IAlvearyComponent {
@@ -249,8 +247,8 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
// / ITRIGGERPROVIDER
@Override
public LinkedList<ITrigger> getCustomTriggers() {
LinkedList<ITrigger> res = new LinkedList<ITrigger>();
public LinkedList<ITriggerExternal> getCustomTriggers() {
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
res.add(ForestryTrigger.missingQueen);
res.add(ForestryTrigger.missingDrone);
return res;
@@ -10,14 +10,7 @@
******************************************************************************/
package forestry.apiculture.gadgets;
import java.util.LinkedList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.statements.ITriggerExternal;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.ForestryAPI;
@@ -25,6 +18,11 @@ import forestry.core.gadgets.TileBase;
import forestry.core.network.GuiId;
import forestry.core.triggers.ForestryTrigger;
import forestry.plugins.PluginApiculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import java.util.LinkedList;
public class TileApiary extends TileBeehouse implements ISidedInventory {
@@ -345,8 +343,8 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
/* ITRIGGERPROVIDER */
@Override
public LinkedList<ITrigger> getCustomTriggers() {
LinkedList<ITrigger> res = new LinkedList<ITrigger>();
public LinkedList<ITriggerExternal> getCustomTriggers() {
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
res.add(ForestryTrigger.missingQueen);
res.add(ForestryTrigger.missingDrone);
res.add(PluginApiculture.triggerNoFrames);
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.core.utils.StringUtil;
import net.minecraft.world.World;
import forestry.api.apiculture.IAlleleBeeEffect;
@@ -46,8 +45,8 @@ public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
}
@Override
public String getName() {
return StringUtil.localize("apiculture.effect.none");
public String getUnlocalizedName() {
return "apiculture.effect.none";
}
@Override
@@ -19,13 +19,11 @@ import forestry.api.genetics.IEffectData;
import forestry.core.EnumErrorCode;
import forestry.core.genetics.Allele;
import forestry.core.genetics.EffectData;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Vect;
import forestry.plugins.PluginApiculture;
public abstract class AlleleEffectThrottled extends Allele implements IAlleleBeeEffect {
private final String name;
private boolean isCombinable = false;
private final int throttle;
private boolean requiresWorkingQueen = false;
@@ -38,11 +36,6 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
this.requiresWorkingQueen = requiresWorking;
}
@Override
public String getName() {
return StringUtil.localize(name);
}
public int getThrottle() {
return throttle;
}
@@ -10,19 +10,6 @@
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -36,6 +23,7 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IFlowerProvider;
@@ -53,6 +41,17 @@ import forestry.core.utils.StringUtil;
import forestry.core.utils.Utils;
import forestry.core.utils.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class Bee extends IndividualLiving implements IBee {
@@ -344,12 +343,22 @@ public class Bee extends IndividualLiving implements IBee {
IAlleleBeeSpecies secondary = genome.getSecondary();
if (!isPureBred(EnumBeeChromosome.SPECIES.ordinal()))
list.add("\u00A79" + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName()));
list.add(genome.getActiveAllele(EnumBeeChromosome.SPEED.ordinal()).getName() + " " + StringUtil.localize("gui.worker"));
IAllele speed = genome.getActiveAllele(EnumBeeChromosome.SPEED.ordinal());
String customWorker = "tooltip.worker." + speed.getUnlocalizedName().replaceFirst("gui.", "");
if (StringUtil.canTranslate(customWorker))
list.add(StringUtil.localize(customWorker));
else
list.add(speed.getName() + " " + StringUtil.localize("gui.worker"));
list.add(genome.getActiveAllele(EnumBeeChromosome.LIFESPAN.ordinal()).getName() + " " + StringUtil.localize("gui.life"));
list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / "
+ StringUtil.capitalize(genome.getToleranceTemp().name()));
list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / "
+ StringUtil.capitalize(genome.getToleranceHumid().name()));
IAlleleTolerance tempTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
list.add("\u00A7aT: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempTolerance.getName());
IAlleleTolerance humidTolerance = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
list.add("\u00A7aH: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getHumidity()) + " / " + humidTolerance.getName());
list.add(genome.getFlowerProvider().getDescription());
if (genome.getNocturnal())
list.add("\u00A7c" + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
@@ -10,13 +10,12 @@
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleFloat;
import forestry.api.genetics.IAlleleFlowers;
import forestry.api.genetics.IAlleleInteger;
@@ -29,6 +28,8 @@ import forestry.core.genetics.AlleleTolerance;
import forestry.core.genetics.Genome;
import forestry.core.utils.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class BeeGenome extends Genome implements IBeeGenome {
/**
@@ -69,6 +70,15 @@ public class BeeGenome extends Genome implements IBeeGenome {
super(chromosomes);
}
// NBT RETRIEVAL
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumBeeChromosome.SPECIES);
if (speciesAllele instanceof IAlleleBeeSpecies)
return (IAlleleBeeSpecies)speciesAllele;
else
return null;
}
// / INFORMATION RETRIEVAL
@Override
public IAlleleBeeSpecies getPrimary() {
@@ -20,7 +20,7 @@ import net.minecraft.entity.player.InventoryPlayer;
public class ContainerBeealyzer extends ContainerAlyzer {
public ContainerBeealyzer(InventoryPlayer inventoryplayer, BeealyzerInventory inventory) {
super(inventoryplayer, inventory, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }, new Object[] { ItemBeeGE.class });
super(inventoryplayer, inventory, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }, ItemBeeGE.class);
}
}
@@ -10,11 +10,6 @@
******************************************************************************/
package forestry.apiculture.gui;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeEffect;
@@ -22,16 +17,21 @@ import forestry.api.apiculture.IBee;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAlleleFlowers;
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.core.genetics.AlleleArea;
import forestry.core.genetics.AlleleBoolean;
import forestry.core.genetics.AlleleTolerance;
import forestry.core.gui.GuiAlyzer;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
public class GuiBeealyzer extends GuiAlyzer {
@@ -46,7 +46,7 @@ public class GuiBeealyzer extends GuiAlyzer {
ArrayList<ItemStack> beeList = new ArrayList<ItemStack>();
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList)
iconStacks.put(PluginApiculture.beeInterface.getMember(beeStack).getIdent(), beeStack);
iconStacks.put(BeeGenome.getSpecies(beeStack).getUID(), beeStack);
breedingTracker = PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile());
}
@@ -161,22 +161,22 @@ public class GuiBeealyzer extends GuiAlyzer {
drawRow(StringUtil.localize("gui.climate"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getTemperature()),
AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getTemperature()), bee, EnumBeeChromosome.SPECIES);
IAlleleTolerance tempToleranceActive = (IAlleleTolerance)bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
IAlleleTolerance tempToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal());
drawLine(StringUtil.localize("gui.temptol"), COLUMN_0);
drawToleranceInfo(bee.getGenome().getToleranceTemp(), COLUMN_1,
getColorCoding(bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()).isDominant()));
drawToleranceInfo(((AlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal())).getValue(), COLUMN_2,
getColorCoding(bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()).isDominant()));
drawToleranceInfo(tempToleranceActive, COLUMN_1);
drawToleranceInfo(tempToleranceInactive, COLUMN_2);
newLine();
drawRow(StringUtil.localize("gui.humidity"), AlleleManager.climateHelper.toDisplay(bee.getGenome().getPrimary().getHumidity()),
AlleleManager.climateHelper.toDisplay(bee.getGenome().getSecondary().getHumidity()), bee, EnumBeeChromosome.SPECIES);
IAlleleTolerance humidToleranceActive = (IAlleleTolerance)bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal());
IAlleleTolerance humidToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal());
drawLine(StringUtil.localize("gui.humidtol"), COLUMN_0);
drawToleranceInfo(bee.getGenome().getToleranceHumid(), COLUMN_1,
getColorCoding(bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()).isDominant()));
drawToleranceInfo(((AlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal())).getValue(), COLUMN_2,
getColorCoding(bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()).isDominant()));
drawToleranceInfo(humidToleranceActive, COLUMN_1);
drawToleranceInfo(humidToleranceInactive, COLUMN_2);
newLine();
newLine();
@@ -10,14 +10,8 @@
******************************************************************************/
package forestry.apiculture.gui;
import java.util.ArrayList;
import java.util.HashMap;
import forestry.core.utils.StringUtil;
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.core.config.Defaults;
@@ -25,7 +19,12 @@ import forestry.core.config.ForestryItem;
import forestry.core.gadgets.TileForestry;
import forestry.core.gui.GuiForestry;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
import forestry.core.utils.StringUtil;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
public class GuiImprinter extends GuiForestry<TileForestry> {
@@ -49,7 +48,7 @@ public class GuiImprinter extends GuiForestry<TileForestry> {
ArrayList<ItemStack> beeList = new ArrayList<ItemStack>();
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList)
iconStacks.put(PluginApiculture.beeInterface.getMember(beeStack).getIdent(), beeStack);
iconStacks.put(BeeGenome.getSpecies(beeStack).getUID(), beeStack);
}
@@ -10,19 +10,8 @@
******************************************************************************/
package forestry.apiculture.items;
import java.util.List;
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.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -33,11 +22,20 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.genetics.Bee;
import forestry.apiculture.genetics.BeeGenome;
import forestry.core.config.Config;
import forestry.core.genetics.ItemGE;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
import net.minecraft.util.StatCollector;
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.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import java.util.List;
public class ItemBeeGE extends ItemGE {
@@ -56,6 +54,11 @@ public class ItemBeeGE extends ItemGE {
return new Bee(itemstack.getTagCompound());
}
@Override
protected IAlleleSpecies getSpecies(ItemStack itemStack) {
return BeeGenome.getSpecies(itemStack);
}
@Override
protected int getDefaultPrimaryColour() {
return 0xffffff;
@@ -74,7 +77,7 @@ public class ItemBeeGE extends ItemGE {
IBee individual = new Bee(itemstack.getTagCompound());
String customBeeKey = "bees.custom." + type.getName() + "." + individual.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.","");
if(StatCollector.canTranslate("for." + customBeeKey)){
if(StringUtil.canTranslate(customBeeKey)){
return StringUtil.localize(customBeeKey);
}
String beeGrammar = StringUtil.localize("bees.grammar." + type.getName());
@@ -131,7 +134,7 @@ public class ItemBeeGE extends ItemGE {
if (!itemstack.hasTagCompound())
return super.getColorFromItemStack(itemstack, renderPass);
return getColourFromSpecies(PluginApiculture.beeInterface.getMember(itemstack).getGenome().getPrimary(), renderPass);
return getColourFromSpecies(BeeGenome.getSpecies(itemstack), renderPass);
}
@Override
@@ -166,7 +169,7 @@ public class ItemBeeGE extends ItemGE {
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(ItemStack itemstack, int renderPass) {
return getIconFromSpecies(PluginApiculture.beeInterface.getMember(itemstack).getGenome().getPrimary(), renderPass);
return getIconFromSpecies(BeeGenome.getSpecies(itemstack), renderPass);
}
@SideOnly(Side.CLIENT)
@@ -10,14 +10,12 @@
******************************************************************************/
package forestry.apiculture.trigger;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.IStatementParameter;
import forestry.apiculture.gadgets.TileApiary;
import forestry.core.triggers.Trigger;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TriggerNoFrames extends Trigger {
@@ -29,7 +27,7 @@ public class TriggerNoFrames extends Trigger {
* Return true if the tile given in parameter activates the trigger, given the parameters.
*/
@Override
public boolean isTriggerActive(ForgeDirection direction, TileEntity tile, ITriggerParameter parameter) {
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
if (!(tile instanceof TileApiary))
return false;
@@ -10,17 +10,23 @@
******************************************************************************/
package forestry.apiculture.worldgen;
import java.util.Random;
import net.minecraft.world.World;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import forestry.api.apiculture.hives.HiveManager;
import forestry.api.apiculture.hives.IHive;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType;
import net.minecraftforge.event.terraingen.TerrainGen;
import java.util.Random;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
@@ -30,13 +36,6 @@ public class HiveDecorator {
@SuppressWarnings("rawtypes")
public static final EventType EVENT_TYPE = EnumHelper.addEnum(EventType.class, "FORESTRY_HIVES", new Class[0], new Object[0]);
private static HiveDecorator instance;
private final WorldGenHiveForest forest = new WorldGenHiveForest();
private final WorldGenHiveJungle jungle = new WorldGenHiveJungle();
private final WorldGenHiveMeadows meadows = new WorldGenHiveMeadows();
private final WorldGenHiveParched parched = new WorldGenHiveParched();
private final WorldGenHiveEnd end = new WorldGenHiveEnd();
private final WorldGenHiveSnow snow = new WorldGenHiveSnow();
private final WorldGenHiveSwamp swamp = new WorldGenHiveSwamp();
public static HiveDecorator instance() {
if (instance == null) {
@@ -57,22 +56,79 @@ public class HiveDecorator {
}
private void decorateHives(World world, Random rand, int worldX, int worldZ) {
genHive(world, rand, worldX, worldZ, 42, 3, forest);
genHive(world, rand, worldX, worldZ, 62, 4, jungle);
genHive(world, rand, worldX, worldZ, 42, 1, meadows);
genHive(world, rand, worldX, worldZ, 42, 1, parched);
genHive(world, rand, worldX, worldZ, 42, 4, end);
genHive(world, rand, worldX, worldZ, 42, 2, snow);
genHive(world, rand, worldX, worldZ, 42, 2, swamp);
for (IHive hive : HiveManager.getHives())
if (Config.generateBeehivesDebug)
genHiveDebug(world, worldX, worldZ, hive);
else
genHive(world, rand, worldX, worldZ, hive);
}
private void genHive(World world, Random rand, int worldX, int worldZ, int height, int attempts, WorldGenHive gen) {
for (int i = 0; i < attempts; i++) {
int randPosX = worldX + rand.nextInt(16);
int randPosY = height + rand.nextInt(50);
int randPosZ = worldZ + rand.nextInt(16);
if (gen.generate(world, rand, randPosX, randPosY, randPosZ))
private void genHive(World world, Random rand, int worldX, int worldZ, IHive hive) {
if (hive.genChance() < rand.nextFloat() * 128.0f)
return;
BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity))
return;
for (int tries = 0; tries < 4; tries ++) {
int x = worldX + rand.nextInt(16);
int z = worldZ + rand.nextInt(16);
if (tryGenHive(world, x, z, hive))
return;
}
}
private void genHiveDebug(World world, int worldX, int worldZ, IHive hive) {
BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity))
return;
for (int x = 0; x < 16; x++)
for (int z = 0; z < 16; z++)
tryGenHive(world, worldX + x, worldZ + z, hive);
}
private boolean tryGenHive(World world, int x, int z, IHive hive) {
int y = hive.getYForHive(world, x, z);
if (y < 0)
return false;
if (!hive.canReplace(world, x, y, z))
return false;
BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
EnumTemperature temperature = EnumTemperature.getFromValue(biome.getFloatTemperature(x, y, z));
if (!hive.isGoodTemperature(temperature))
return false;
if (!hive.isGoodLocation(world, x, y, z))
return false;
return setHive(world, x, y, z, hive);
}
protected boolean setHive(World world, int x, int y, int z, IHive hive) {
Block hiveBlock = hive.getHiveBlock();
boolean placed = world.setBlock(x, y, z, hiveBlock, hive.getHiveMeta(), Defaults.FLAG_BLOCK_SYNCH);
if (!placed)
return false;
Block placedBlock = world.getBlock(x, y, z);
if (!Block.isEqualTo(hiveBlock, placedBlock))
return false;
hiveBlock.onBlockAdded(world, x, y, z);
world.markBlockForUpdate(x, y, z);
hive.postGen(world, x, y, z);
return true;
}
}
@@ -4,27 +4,27 @@
* 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.worldgen;
import java.util.Random;
import forestry.api.apiculture.hives.HiveGround;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
public class WorldGenHiveEnd extends WorldGenHive {
public class HiveEnd extends HiveGround {
public HiveEnd(float genChance) {
super(ForestryBlock.beehives.block(), 5, genChance, Blocks.end_stone);
}
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (biome.biomeID != BiomeGenBase.sky.biomeID)
return false;
return tryPlaceGroundHive(world, x, y, z, 5, Blocks.end_stone);
public boolean isGoodBiome(BiomeGenBase biome) {
return biome.biomeID == BiomeGenBase.sky.biomeID;
}
}
@@ -4,30 +4,31 @@
* 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.worldgen;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.hives.HiveTree;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.world.biome.BiomeGenBase;
public class WorldGenHiveJungle extends WorldGenHive {
public class HiveForest extends HiveTree {
public HiveForest(float genChance) {
super(ForestryBlock.beehives.block(), 1, genChance);
}
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
public boolean isGoodHumidity(EnumHumidity humidity) {
return humidity == EnumHumidity.NORMAL;
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (EnumTemperature.getFromValue(biome.temperature) != EnumTemperature.WARM
|| EnumHumidity.getFromValue(biome.rainfall) != EnumHumidity.DAMP)
return false;
return tryPlaceTreeHive(world, x, y, z, 4);
@Override
public boolean isGoodTemperature(EnumTemperature temperature) {
return temperature == EnumTemperature.NORMAL;
}
}
@@ -4,31 +4,31 @@
* 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.worldgen;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.hives.HiveTree;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.world.biome.BiomeGenBase;
public class WorldGenHiveForest extends WorldGenHive {
public class HiveJungle extends HiveTree {
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (EnumTemperature.getFromValue(biome.temperature) != EnumTemperature.NORMAL ||
EnumHumidity.getFromValue(biome.rainfall) != EnumHumidity.NORMAL)
return false;
return tryPlaceTreeHive(world, x, y, z, 1);
public HiveJungle(float genChance) {
super(ForestryBlock.beehives.block(), 4, genChance);
}
@Override
public boolean isGoodHumidity(EnumHumidity humidity) {
return humidity == EnumHumidity.DAMP;
}
@Override
public boolean isGoodTemperature(EnumTemperature temperature) {
return temperature == EnumTemperature.WARM;
}
}
@@ -4,31 +4,32 @@
* 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.worldgen;
import java.util.Random;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.hives.HiveGround;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
public class WorldGenHiveSwamp extends WorldGenHive {
public class HiveMeadows extends HiveGround {
public HiveMeadows(float genChance) {
super(ForestryBlock.beehives.block(), 2, genChance, Blocks.dirt, Blocks.grass);
}
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
public boolean isGoodHumidity(EnumHumidity humidity) {
return humidity == EnumHumidity.NORMAL;
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (EnumTemperature.getFromValue(biome.temperature) != EnumTemperature.NORMAL
|| EnumHumidity.getFromValue(biome.rainfall) != EnumHumidity.DAMP)
return false;
return tryPlaceGroundHive(world, x, y, z, 7, Blocks.dirt, Blocks.grass);
@Override
public boolean isGoodTemperature(EnumTemperature temperature) {
return temperature == EnumTemperature.NORMAL;
}
}
@@ -4,31 +4,32 @@
* 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.worldgen;
import java.util.Random;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.hives.HiveGround;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
public class WorldGenHiveParched extends WorldGenHive {
public class HiveParched extends HiveGround {
public HiveParched(float genChance) {
super(ForestryBlock.beehives.block(), 3, genChance, Blocks.sand, Blocks.sandstone);
}
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
public boolean isGoodHumidity(EnumHumidity humidity) {
return humidity == EnumHumidity.ARID;
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (EnumTemperature.getFromValue(biome.temperature) != EnumTemperature.HOT
|| EnumHumidity.getFromValue(biome.rainfall) != EnumHumidity.ARID)
return false;
return tryPlaceGroundHive(world, x, y, z, 3, Blocks.sand, Blocks.sandstone);
@Override
public boolean isGoodTemperature(EnumTemperature temperature) {
return temperature == EnumTemperature.HOT;
}
}
@@ -4,35 +4,34 @@
* 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.worldgen;
import java.util.Random;
import forestry.api.apiculture.hives.HiveGround;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.core.EnumTemperature;
public class HiveSnow extends HiveGround {
public class WorldGenHiveSnow extends WorldGenHive {
public HiveSnow(float genChance) {
super(ForestryBlock.beehives.block(), 6, genChance, Blocks.dirt, Blocks.grass, Blocks.snow);
}
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
public boolean isGoodTemperature(EnumTemperature temperature) {
return temperature == EnumTemperature.COLD || temperature == EnumTemperature.ICY;
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (EnumTemperature.getFromValue(biome.temperature) != EnumTemperature.ICY
&& EnumTemperature.getFromValue(biome.temperature) != EnumTemperature.COLD)
return false;
if (tryPlaceGroundHive(world, x, y, z, 6, Blocks.dirt, Blocks.grass)) {
@Override
public void postGen(World world, int x, int y, int z) {
if (world.isAirBlock(x, y + 1, z))
world.setBlock(x, y + 1, z, Blocks.snow_layer, 0, 0);
return true;
}
return false;
}
}
@@ -4,31 +4,32 @@
* 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.worldgen;
import java.util.Random;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.hives.HiveGround;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.config.ForestryBlock;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
public class WorldGenHiveMeadows extends WorldGenHive {
public class HiveSwamp extends HiveGround {
public HiveSwamp(float genChance) {
super(ForestryBlock.beehives.block(), 7, genChance, Blocks.dirt, Blocks.grass);
}
@Override
public boolean generate(World world, Random random, int x, int y, int z) {
public boolean isGoodHumidity(EnumHumidity humidity) {
return humidity == EnumHumidity.DAMP;
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (EnumTemperature.getFromValue(biome.temperature) != EnumTemperature.NORMAL
|| EnumHumidity.getFromValue(biome.rainfall) != EnumHumidity.NORMAL)
return false;
return tryPlaceGroundHive(world, x, y, z, 2, Blocks.dirt, Blocks.grass);
@Override
public boolean isGoodTemperature(EnumTemperature temperature) {
return temperature == EnumTemperature.NORMAL;
}
}
@@ -12,13 +12,9 @@ package forestry.apiculture.worldgen;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.IPlantable;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
@@ -27,49 +23,6 @@ public abstract class WorldGenHive extends WorldGenerator {
@Override
public abstract boolean generate(World world, Random random, int x, int y, int z);
protected boolean tryPlaceTreeHive(World world, int x, int y, int z, int meta) {
if (!world.isAirBlock(x, y, z))
return false;
Block b = world.getBlock(x, y + 1, z);
if (b == null || !b.isLeaves(world, x, y + 1, z))
return false;
if (world.isAirBlock(x, y - 1, z)) {
setHive(world, x, y, z, meta);
return true;
}
return false;
}
protected boolean tryPlaceGroundHive(World world, int x, int y, int z, int meta, Block... groundBlocks) {
if (!world.isAirBlock(x, y, z)) {
Block block = world.getBlock(x, y, z);
if (block != Blocks.snow_layer && !(block instanceof IPlantable))
return false;
}
if (!world.isAirBlock(x, y + 1, z))
return false;
if (isAcceptableBlock(world, x, y - 1, z, groundBlocks)) {
setHive(world, x, y, z, meta);
return true;
}
return false;
}
private boolean isAcceptableBlock(World world, int x, int y, int z, Block... blocks) {
Block block = world.getBlock(x, y, z);
if (block == null)
return false;
for (Block testBlock : blocks)
if (block.isReplaceableOreGen(world, x, y, z, testBlock))
return true;
return false;
}
protected void setHive(World world, int x, int y, int z, int meta) {
boolean placed = world.setBlock(x, y, z, ForestryBlock.beehives.block(), meta, Defaults.FLAG_BLOCK_SYNCH);
if (!placed)
@@ -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.arboriculture;
public interface IWoodFireproof {
}
@@ -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.arboriculture.gadgets;
import forestry.arboriculture.IWoodFireproof;
import forestry.core.config.ForestryBlock;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockFireproofLog extends BlockLog implements IWoodFireproof {
public static Material fireproofWood = new Material(MapColor.woodColor);
public BlockFireproofLog(LogCat cat) {
super(cat, fireproofWood);
}
public static ForestryBlock getFireproofLog(BlockLog log) {
return getFireproofLog(log.cat);
}
private static ForestryBlock getFireproofLog(BlockLog.LogCat logCat) {
switch (logCat) {
case CAT0: return ForestryBlock.fireproofLog1;
case CAT1: return ForestryBlock.fireproofLog2;
case CAT2: return ForestryBlock.fireproofLog3;
case CAT3: return ForestryBlock.fireproofLog4;
case CAT4: return ForestryBlock.fireproofLog5;
case CAT5: return ForestryBlock.fireproofLog6;
case CAT6: return ForestryBlock.fireproofLog7;
case CAT7: return ForestryBlock.fireproofLog8;
}
throw new IllegalArgumentException("No fireproof log for this category: " + logCat);
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 0;
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return false;
}
@Override
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 0;
}
}
@@ -0,0 +1,55 @@
/*******************************************************************************
* 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.arboriculture.gadgets;
import forestry.arboriculture.IWoodFireproof;
import forestry.core.config.ForestryBlock;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockFireproofPlanks extends BlockPlanks implements IWoodFireproof {
public static Material fireproofWood = new Material(MapColor.woodColor);
public BlockFireproofPlanks(PlankCat cat) {
super(cat, fireproofWood);
}
public static ForestryBlock getFireproofPlanks(BlockPlanks planks) {
return getFireproofPlanks(planks.cat);
}
private static ForestryBlock getFireproofPlanks(PlankCat plankCat) {
switch (plankCat) {
case CAT0: return ForestryBlock.fireproofPlanks1;
case CAT1: return ForestryBlock.fireproofPlanks2;
}
throw new IllegalArgumentException("No fireproof log for this category: " + plankCat);
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 0;
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return false;
}
@Override
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return 0;
}
}
@@ -38,18 +38,20 @@ public class BlockLog extends Block implements IWoodTyped {
CAT0, CAT1, CAT2, CAT3, CAT4, CAT5, CAT6, CAT7
}
private final LogCat cat;
protected final LogCat cat;
public BlockLog(LogCat cat) {
this(cat, Material.wood);
}
super(Material.wood);
protected BlockLog(LogCat cat, Material material) {
super(material);
this.cat = cat;
setHardness(2.0F);
setResistance(5.0F);
setStepSound(soundTypeWood);
setCreativeTab(Tabs.tabArboriculture);
}
public static int getTypeFromMeta(int damage) {
@@ -37,10 +37,14 @@ public class BlockPlanks extends Block implements IWoodTyped {
CAT0, CAT1
}
private final PlankCat cat;
protected final PlankCat cat;
public BlockPlanks(PlankCat cat) {
super(Material.wood);
this(cat, Material.wood);
}
protected BlockPlanks(PlankCat cat, Material material) {
super(material);
this.cat = cat;
setResistance(5.0F);
setStepSound(soundTypeWood);
@@ -189,9 +189,15 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
if (getLeafTile(world, x, y, z).isDecorative())
TileLeaves tileLeaves = getLeafTile(world, x, y, z);
if (tileLeaves == null || tileLeaves.isDecorative())
return;
super.updateTick(world, x, y, z, random);
if (world.rand.nextFloat() > 0.1)
return;
tileLeaves.onBlockTick();
}
/* RENDERING */
@@ -96,7 +96,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
maturationTime = nbttagcompound.getInteger("CATMAT");
caterpillar = (IButterfly)AlleleManager.alleleRegistry.getSpeciesRoot("rootButterflies").getMember(nbttagcompound.getCompoundTag("CATER"));
}
isDecorative = nbttagcompound.getBoolean("Decorative");
}
@Override
@@ -114,7 +114,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
caterpillar.writeToNBT(subcompound);
nbttagcompound.setTag("CATER", subcompound);
}
nbttagcompound.setBoolean("Decorative", isDecorative);
}
@Override
@@ -10,7 +10,6 @@
******************************************************************************/
package forestry.arboriculture.genetics;
import forestry.core.utils.StringUtil;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
@@ -39,8 +38,8 @@ public class AlleleLeafEffectNone extends Allele implements IAlleleLeafEffect {
}
@Override
public String getName() {
return StringUtil.localize("arboriculture.effect.none");
public String getUnlocalizedName() {
return "arboriculture.effect.none";
}
@Override
@@ -12,7 +12,6 @@ package forestry.arboriculture.genetics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
@@ -254,7 +253,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
@SideOnly(Side.CLIENT)
public IIcon getGermlingIcon(EnumGermlingType type, int renderPass) {
if(type == EnumGermlingType.POLLEN)
return ForestryItem.pollen.item().getIconFromDamageForRenderPass(0, renderPass);
return ForestryItem.pollenCluster.item().getIconFromDamageForRenderPass(0, renderPass);
return icon;
}
@@ -10,24 +10,7 @@
******************************************************************************/
package forestry.arboriculture.genetics;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.EnumGrowthConditions;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleLeafEffect;
@@ -37,6 +20,7 @@ import forestry.api.arboriculture.ITree;
import forestry.api.arboriculture.ITreeGenome;
import forestry.api.arboriculture.ITreeMutation;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleBoolean;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IFruitFamily;
@@ -47,6 +31,21 @@ import forestry.core.genetics.Chromosome;
import forestry.core.genetics.Individual;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginArboriculture;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
public class Tree extends Individual implements ITree, ITreeGenData, IPlantable {
@@ -285,6 +284,10 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable
list.add(String.format("\u00A7eS: %s, \u00A7fY: %s", genome.getActiveAllele(EnumTreeChromosome.FERTILITY.ordinal()).getName(), genome.getActiveAllele(EnumTreeChromosome.YIELD.ordinal()).getName()));
IAlleleBoolean primaryFireproof = (IAlleleBoolean)genome.getActiveAllele(EnumTreeChromosome.FIREPROOF.ordinal());
if (primaryFireproof.getValue())
list.add(String.format("\u00A7c%s", StatCollector.translateToLocal("for.gui.fireresist")));
IAllele fruit = getGenome().getActiveAllele(EnumTreeChromosome.FRUITS.ordinal());
if(fruit != Allele.fruitNone) {
String strike = "";
@@ -12,6 +12,7 @@ package forestry.arboriculture.genetics;
import java.util.EnumSet;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.EnumPlantType;
@@ -45,6 +46,15 @@ public class TreeGenome extends Genome implements ITreeGenome {
super(nbttagcompound);
}
// NBT RETRIEVAL
public static IAlleleTreeSpecies getSpecies(ItemStack itemStack) {
IAllele speciesAllele = Genome.getPrimaryAllele(itemStack, EnumTreeChromosome.SPECIES);
if (speciesAllele instanceof IAlleleTreeSpecies)
return (IAlleleTreeSpecies)speciesAllele;
else
return null;
}
@Override
public IAlleleTreeSpecies getPrimary() {
return (IAlleleTreeSpecies) getActiveAllele(EnumTreeChromosome.SPECIES.ordinal());
@@ -80,6 +80,7 @@ public class TreeTemplates {
alleles[EnumTreeChromosome.EFFECT.ordinal()] = Allele.leavesNone;
alleles[EnumTreeChromosome.MATURATION.ordinal()] = Allele.maturationAverage;
alleles[EnumTreeChromosome.GIRTH.ordinal()] = Allele.int1;
alleles[EnumTreeChromosome.FIREPROOF.ordinal()] = Allele.fireproofFalse;
return alleles;
}
@@ -149,6 +150,7 @@ public class TreeTemplates {
alleles[EnumTreeChromosome.SAPPINESS.ordinal()] = Allele.sappinessLower;
alleles[EnumTreeChromosome.MATURATION.ordinal()] = Allele.maturationSlower;
alleles[EnumTreeChromosome.GIRTH.ordinal()] = Allele.int3;
alleles[EnumTreeChromosome.FIREPROOF.ordinal()] = Allele.fireproofTrue;
return alleles;
}
@@ -159,6 +161,7 @@ public class TreeTemplates {
alleles[EnumTreeChromosome.SAPPINESS.ordinal()] = Allele.sappinessLowest;
alleles[EnumTreeChromosome.MATURATION.ordinal()] = Allele.maturationSlowest;
alleles[EnumTreeChromosome.GIRTH.ordinal()] = Allele.int4;
alleles[EnumTreeChromosome.FIREPROOF.ordinal()] = Allele.fireproofTrue;
return alleles;
}
@@ -10,14 +10,6 @@
******************************************************************************/
package forestry.arboriculture.gui;
import java.util.ArrayList;
import java.util.Locale;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleFruit;
@@ -29,14 +21,22 @@ import forestry.api.genetics.IAlleleEffect;
import forestry.api.genetics.IAlleleFloat;
import forestry.api.genetics.IAlleleInteger;
import forestry.api.genetics.IFruitFamily;
import forestry.arboriculture.genetics.TreeGenome;
import forestry.arboriculture.items.ItemGermlingGE;
import forestry.arboriculture.items.ItemTreealyzer.TreealyzerInventory;
import forestry.core.config.ForestryItem;
import forestry.core.genetics.Allele;
import forestry.core.genetics.AlleleBoolean;
import forestry.core.genetics.AllelePlantType;
import forestry.core.gui.GuiAlyzer;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginArboriculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.EnumPlantType;
import java.util.ArrayList;
import java.util.Locale;
public class GuiTreealyzer extends GuiAlyzer {
@@ -50,8 +50,8 @@ public class GuiTreealyzer extends GuiAlyzer {
ArrayList<ItemStack> treeList = new ArrayList<ItemStack>();
((ItemGermlingGE) ForestryItem.sapling.item()).addCreativeItems(treeList, false);
for (ItemStack beeStack : treeList)
iconStacks.put(PluginArboriculture.treeInterface.getMember(beeStack).getIdent(), beeStack);
for (ItemStack treeStack : treeList)
iconStacks.put(TreeGenome.getSpecies(treeStack).getUID(), treeStack);
}
@Override
@@ -174,6 +174,18 @@ public class GuiTreealyzer extends GuiAlyzer {
newLine();
String yes = StringUtil.localize("yes");
String no = StringUtil.localize("no");
AlleleBoolean primaryFireproof = (AlleleBoolean)tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF.ordinal());
AlleleBoolean secondaryFireproof = (AlleleBoolean)tree.getGenome().getInactiveAllele(EnumTreeChromosome.FIREPROOF.ordinal());
drawLine(StringUtil.localize("gui.fireproof"), COLUMN_0);
drawLine(StringUtil.readableBoolean(primaryFireproof.getValue(), yes, no), COLUMN_1, tree, EnumTreeChromosome.FIREPROOF, false);
drawLine(StringUtil.readableBoolean(secondaryFireproof.getValue(), yes, no), COLUMN_2, tree, EnumTreeChromosome.FIREPROOF, false);
newLine();
drawRow(StringUtil.localize("gui.effect"), tree.getGenome().getEffect().getName(),
((IAlleleEffect) tree.getGenome().getInactiveAllele(EnumTreeChromosome.EFFECT.ordinal())).getName(), tree,
EnumTreeChromosome.EFFECT);
@@ -10,37 +10,36 @@
******************************************************************************/
package forestry.arboriculture.items;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
import forestry.api.core.Tabs;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.api.recipes.IVariableFermentable;
import forestry.arboriculture.genetics.Tree;
import forestry.arboriculture.genetics.TreeGenome;
import forestry.core.config.Config;
import forestry.core.genetics.ItemGE;
import forestry.core.network.PacketFXSignal;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Utils;
import forestry.plugins.PluginArboriculture;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.arboriculture.EnumGermlingType;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.arboriculture.ITree;
import forestry.api.core.Tabs;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.api.recipes.IVariableFermentable;
import forestry.arboriculture.genetics.Tree;
import forestry.core.config.Config;
import forestry.core.genetics.ItemGE;
import forestry.core.network.PacketFXSignal;
import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.utils.Utils;
import forestry.plugins.PluginArboriculture;
import java.util.List;
public class ItemGermlingGE extends ItemGE implements IVariableFermentable {
@@ -57,12 +56,17 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable {
return new Tree(itemstack.getTagCompound());
}
private IAlleleTreeSpecies getPrimarySpecies(ItemStack itemstack) {
ITree tree = PluginArboriculture.treeInterface.getMember(itemstack);
if (tree == null)
return (IAlleleTreeSpecies) PluginArboriculture.treeInterface.getDefaultTemplate()[EnumTreeChromosome.SPECIES.ordinal()];
else
return tree.getGenome().getPrimary();
@Override
protected IAlleleTreeSpecies getSpecies(ItemStack itemStack) {
return TreeGenome.getSpecies(itemStack);
}
private IAlleleTreeSpecies getSpeciesOrDefault(ItemStack itemstack) {
IAlleleTreeSpecies treeSpecies = TreeGenome.getSpecies(itemstack);
if (treeSpecies == null)
treeSpecies = (IAlleleTreeSpecies) PluginArboriculture.treeInterface.getDefaultTemplate()[EnumTreeChromosome.SPECIES.ordinal()];
return treeSpecies;
}
@Override
@@ -79,12 +83,13 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable {
public String getItemStackDisplayName(ItemStack itemstack) {
if (!itemstack.hasTagCompound())
return "Unknown";
IIndividual individual = getIndividual(itemstack);
String customTreeKey = "trees.custom." + type.getName() + "." + individual.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.","");
if(StatCollector.canTranslate("for." + customTreeKey)){
IAlleleSpecies species = getSpecies(itemstack);
String customTreeKey = "trees.custom." + type.getName() + "." + species.getUnlocalizedName().replace("trees.species.","");
if(StringUtil.canTranslate(customTreeKey)){
return StringUtil.localize(customTreeKey);
}
return StringUtil.localize("trees.grammar." + type.getName()).replaceAll("%SPECIES", individual.getDisplayName()).replaceAll("%TYPE", StringUtil.localize("trees.grammar." + type.getName() + ".type"));
return StringUtil.localize("trees.grammar." + type.getName()).replaceAll("%SPECIES", species.getName()).replaceAll("%TYPE", StringUtil.localize("trees.grammar." + type.getName() + ".type"));
}
@SuppressWarnings("rawtypes")
@@ -106,7 +111,7 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable {
@Override
public int getColorFromItemStack(ItemStack itemstack, int renderPass) {
return getPrimarySpecies(itemstack).getGermlingColour(type, renderPass);
return getSpeciesOrDefault(itemstack).getGermlingColour(type, renderPass);
}
/* ICONS */
@@ -128,7 +133,7 @@ public class ItemGermlingGE extends ItemGE implements IVariableFermentable {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack itemstack, int renderPass) {
IAlleleTreeSpecies species = getPrimarySpecies(itemstack);
IAlleleTreeSpecies species = getSpeciesOrDefault(itemstack);
return species.getGermlingIcon(type, renderPass);
}
@@ -25,7 +25,7 @@ public class ItemLeavesBlock extends ItemForestryBlock {
return type;
ITree tree = getTree(itemstack);
String customTreeKey = "trees.custom.leaves." + tree.getGenome().getPrimary().getUnlocalizedName().replace("trees.species.","");
if(StatCollector.canTranslate("for." + customTreeKey)){
if(StringUtil.canTranslate(customTreeKey)){
return StringUtil.localize(customTreeKey);
}
String grammar = StringUtil.localize("trees.grammar.leaves");
@@ -10,6 +10,8 @@
******************************************************************************/
package forestry.arboriculture.items;
import forestry.arboriculture.IWoodFireproof;
import forestry.core.utils.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
@@ -23,22 +25,23 @@ public class ItemWoodBlock extends ItemForestryBlock {
super(block);
}
public static int getTypeFromMeta(int damage) {
return damage & 3;
}
@Override
public String getUnlocalizedName(ItemStack itemstack) {
public String getItemStackDisplayName(ItemStack itemstack) {
if (this.getBlock() instanceof IWoodTyped) {
IWoodTyped block = (IWoodTyped) getBlock();
int meta = itemstack.getItemDamage();
WoodType woodType = block.getWoodType(meta);
if (woodType == null)
return null;
return "tile.for." + block.getBlockKind() + "." + woodType.ordinal();
}
return super.getUnlocalizedName(itemstack);
}
String unlocalizedName = block.getBlockKind() + "." + woodType.ordinal() + ".name";
String displayName = StringUtil.localizeTile(unlocalizedName);
if (this.getBlock() instanceof IWoodFireproof)
displayName = StringUtil.localizeAndFormatRaw("tile.for.fireproof", displayName);
return displayName;
}
return super.getItemStackDisplayName(itemstack);
}
}
@@ -52,10 +52,10 @@ public class FruitPodRenderingHandler implements ISimpleBlockRenderingHandler {
double d1 = 15.0D;
double d2 = 4.0D;
double d3 = 4.0D + l1;
double d4 = (double)podIcon.getInterpolatedU(d0);
double d5 = (double)podIcon.getInterpolatedU(d1);
double d6 = (double)podIcon.getInterpolatedV(d2);
double d7 = (double)podIcon.getInterpolatedV(d3);
double d4 = (double) podIcon.getInterpolatedU(d0);
double d5 = (double) podIcon.getInterpolatedU(d1);
double d6 = (double) podIcon.getInterpolatedV(d2);
double d7 = (double) podIcon.getInterpolatedV(d3);
double d8 = 0.0D;
double d9 = 0.0D;
@@ -104,10 +104,10 @@ public class FruitPodRenderingHandler implements ISimpleBlockRenderingHandler {
if (maturity >= 2)
i2 = k1 - 1;
d4 = (double)podIcon.getMinU();
d5 = (double)podIcon.getInterpolatedU((double)i2);
d6 = (double)podIcon.getMinV();
d7 = (double)podIcon.getInterpolatedV((double)i2);
d4 = (double) podIcon.getMinU();
d5 = (double) podIcon.getInterpolatedU((double) i2);
d6 = (double) podIcon.getMinV();
d7 = (double) podIcon.getInterpolatedV((double) i2);
tessellator.addVertexWithUV(d10, d13, d15, d4, d7);
tessellator.addVertexWithUV(d11, d13, d15, d5, d7);
@@ -117,10 +117,10 @@ public class FruitPodRenderingHandler implements ISimpleBlockRenderingHandler {
tessellator.addVertexWithUV(d11, d12, d14, d5, d6);
tessellator.addVertexWithUV(d11, d12, d15, d5, d7);
tessellator.addVertexWithUV(d10, d12, d15, d4, d7);
d4 = (double)podIcon.getInterpolatedU(12.0D);
d5 = (double)podIcon.getMaxU();
d6 = (double)podIcon.getMinV();
d7 = (double)podIcon.getInterpolatedV(4.0D);
d4 = (double) podIcon.getInterpolatedU(12.0D);
d5 = (double) podIcon.getMaxU();
d6 = (double) podIcon.getMinV();
d7 = (double) podIcon.getInterpolatedV(4.0D);
d8 = 8.0D;
d9 = 0.0D;
double d16;
@@ -90,10 +90,10 @@ public class SaplingRenderHandler implements ISimpleBlockRenderingHandler {
Tessellator tess = Tessellator.instance;
IIcon icon = species.getGermlingIcon(EnumGermlingType.SAPLING, renderLayer);
double d3 = (double)icon.getMinU();
double d4 = (double)icon.getMinV();
double d5 = (double)icon.getMaxU();
double d6 = (double)icon.getMaxV();
double d3 = (double) icon.getMinU();
double d4 = (double) icon.getMinV();
double d5 = (double) icon.getMaxU();
double d6 = (double) icon.getMaxV();
double d7 = 0.45D * mod;
double d8 = par3 + 0.5D - d7;
double d9 = par3 + 0.5D + d7;
@@ -48,10 +48,4 @@ public class WorldGenAcacia extends WorldGenTree {
height = determineHeight(5, 2);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log1, 2);
}
}
@@ -46,10 +46,4 @@ public class WorldGenBalsa extends WorldGenTree {
height = determineHeight(6, 6);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log3, 3);
}
}
@@ -64,10 +64,4 @@ public class WorldGenBaobab extends WorldGenTree {
height = determineHeight(6, 6);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log2, 2);
}
}
@@ -40,10 +40,4 @@ public class WorldGenCherry extends WorldGenTree {
height = determineHeight(4, 4);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log4, 3);
}
}
@@ -44,10 +44,4 @@ public class WorldGenChestnut extends WorldGenTree {
height = determineHeight(7, 3);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log2, 0);
}
}
@@ -32,11 +32,6 @@ public class WorldGenDate extends WorldGenTree {
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log5, 2);
}
@Override
public void preGenerate() {
height = determineHeight(6, 2);
@@ -61,10 +61,4 @@ public class WorldGenEbony extends WorldGenTree {
height = determineHeight(10, 4);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log3, 1);
}
}
@@ -31,10 +31,4 @@ public class WorldGenGiganteum extends WorldGenSequoia {
height = determineHeight(35, 15);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log7, 0);
}
}
@@ -55,10 +55,4 @@ public class WorldGenGreenheart extends WorldGenTree {
height = determineHeight(10, 8);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log4, 2);
}
}
@@ -54,10 +54,4 @@ public class WorldGenKapok extends WorldGenTree {
height = determineHeight(10, 8);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log3, 0);
}
}
@@ -41,10 +41,4 @@ public class WorldGenLarch extends WorldGenTree {
height = determineHeight(6, 5);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log1, 0);
}
}
@@ -30,11 +30,6 @@ public class WorldGenLemon extends WorldGenTree {
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log6, 3);
}
@Override
public void preGenerate() {
height = determineHeight(6, 3);
@@ -38,10 +38,4 @@ public class WorldGenLime extends WorldGenTree {
height = determineHeight(6, 4);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log1, 3);
}
}
@@ -30,11 +30,6 @@ public class WorldGenMahoe extends WorldGenTree {
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log5, 0);
}
@Override
public void preGenerate() {
height = determineHeight(6, 3);
@@ -43,10 +43,4 @@ public class WorldGenMahogany extends WorldGenTree {
height = determineHeight(12, 6);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log3, 2);
}
}
@@ -44,10 +44,4 @@ public class WorldGenMaple extends WorldGenTree {
height = determineHeight(7, 5);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log6, 2);
}
}
@@ -29,11 +29,6 @@ public class WorldGenPapaya extends WorldGenTree {
generateSphere(getCenteredAt(yCenter, 0), 2 + rand.nextInt(girth), leaf, EnumReplaceMode.NONE);
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log5, 3);
}
@Override
public void preGenerate() {
@@ -44,10 +44,4 @@ public class WorldGenPine extends WorldGenTree {
height = determineHeight(6, 4);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log6, 0);
}
}
@@ -30,11 +30,6 @@ public class WorldGenPlum extends WorldGenTree {
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log6, 1);
}
@Override
public void preGenerate() {
height = determineHeight(6, 3);
@@ -31,11 +31,6 @@ public class WorldGenPoplar extends WorldGenTree {
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log5, 1);
}
@Override
public void preGenerate() {
height = determineHeight(8, 3);
@@ -55,10 +55,4 @@ public class WorldGenSequoia extends WorldGenTree {
height = determineHeight(20, 5);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log2, 3);
}
}
@@ -42,10 +42,4 @@ public class WorldGenSpruce extends WorldGenTree {
height = determineHeight(5, 3);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(Blocks.log, 1);
}
}
@@ -43,10 +43,4 @@ public class WorldGenTeak extends WorldGenTree {
height = determineHeight(6, 3);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log1, 1);
}
}
@@ -12,9 +12,17 @@ package forestry.arboriculture.worldgen;
import com.mojang.authlib.GameProfile;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.genetics.IAlleleBoolean;
import forestry.api.world.ITreeGenData;
import forestry.arboriculture.gadgets.BlockFireproofLog;
import forestry.arboriculture.gadgets.BlockLog;
import forestry.core.config.ForestryBlock;
import forestry.core.utils.StackUtils;
import forestry.core.worldgen.BlockType;
import forestry.plugins.PluginArboriculture;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
public abstract class WorldGenTree extends WorldGenArboriculture {
@@ -93,6 +101,22 @@ public abstract class WorldGenTree extends WorldGenArboriculture {
}
@Override
public abstract BlockType getWood();
public BlockType getWood() {
ItemStack woodStack = tree.getGenome().getPrimary().getLogStacks()[0];
Block block = StackUtils.getBlock(woodStack);
int meta = woodStack.getItemDamage();
// if we have a fireproof tree, return the fireproof log
if (block instanceof BlockLog) {
IAlleleBoolean fireproof = (IAlleleBoolean) tree.getGenome().getActiveAllele(EnumTreeChromosome.FIREPROOF.ordinal());
if (fireproof.getValue()) {
BlockLog blockLog = (BlockLog) block;
ForestryBlock fireproofLogBlock = BlockFireproofLog.getFireproofLog(blockLog);
return new BlockType(fireproofLogBlock.block(), meta);
}
}
return new BlockType(block, meta);
}
}
@@ -46,10 +46,4 @@ public class WorldGenWalnut extends WorldGenTree {
height = determineHeight(7, 3);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log4, 1);
}
}
@@ -43,10 +43,4 @@ public class WorldGenWenge extends WorldGenTree {
height = determineHeight(6, 2);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log2, 1);
}
}
@@ -47,10 +47,4 @@ public class WorldGenWillow extends WorldGenTree {
height = determineHeight(5, 2);
girth = determineGirth(tree.getGirth(world, startX, startY, startZ));
}
@Override
public BlockType getWood() {
return new BlockType(ForestryBlock.log4, 0);
}
}
@@ -25,6 +25,7 @@ import forestry.core.proxy.Proxies;
import forestry.core.utils.CommandMC;
import forestry.plugins.ForestryPlugin;
import forestry.plugins.PluginManager;
import net.minecraft.util.StatCollector;
public class CommandForestry extends CommandMC {
@@ -137,8 +138,8 @@ public class CommandForestry extends CommandMC {
sendChatMessage(sender, "\u00A79Author(s): " + info.author());
if (!info.url().isEmpty())
sendChatMessage(sender, "\u00A79URL: " + info.url());
if (!info.description().isEmpty())
sendChatMessage(sender, info.description());
if (!info.unlocalizedDescription().isEmpty())
sendChatMessage(sender, StatCollector.translateToLocal(info.unlocalizedDescription()));
}
}
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.core;
import forestry.plugins.PluginManager;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -23,9 +24,14 @@ import forestry.core.config.ForestryItem;
public class CreativeTabForestry extends CreativeTabs {
static {
Tabs.tabApiculture = new CreativeTabForestry(1, "apiculture");
Tabs.tabArboriculture = new CreativeTabForestry(2, "arboriculture");
Tabs.tabLepidopterology = new CreativeTabForestry(3, "lepidopterology");
if (PluginManager.Module.APICULTURE.isEnabled())
Tabs.tabApiculture = new CreativeTabForestry(1, "apiculture");
if (PluginManager.Module.ARBORICULTURE.isEnabled())
Tabs.tabArboriculture = new CreativeTabForestry(2, "arboriculture");
if (PluginManager.Module.LEPIDOPTEROLOGY.isEnabled())
Tabs.tabLepidopterology = new CreativeTabForestry(3, "lepidopterology");
}
public static final CreativeTabs tabForestry = new CreativeTabForestry(0, "forestry");
@@ -94,7 +94,9 @@ public enum EnumErrorCode {
NOSUPPLIES("noSupplies", "noResource", 32),
NOTRADE("noTrade", "noResource", 33);
NOTRADE("noTrade", "noResource", 33),
NOPOWER("noPower", 34);
private String name;
private String iconName;
@@ -69,8 +69,9 @@ public class CircuitBoard implements ICircuitBoard {
if (layout == null)
ChipsetManager.circuitRegistry.getDefaultLayout();
// FIXME: Legacy I
ArrayList<ICircuit> readcircuits = new ArrayList<ICircuit>();
// FIXME: Legacy I
if (nbttagcompound.hasKey("CS")) {
NBTTagList nbttaglist = nbttagcompound.getTagList("CS", 10);
@@ -100,12 +101,14 @@ public class CircuitBoard implements ICircuitBoard {
if (circuits != null)
return;
circuits = new ICircuit[4];
for (int i = 0; i < 4; i++) {
if (!nbttagcompound.hasKey("CA.I" + i))
continue;
circuits[i] = ChipsetManager.circuitRegistry.getCircuit(nbttagcompound.getString("CA.I" + i));
ICircuit circuit = ChipsetManager.circuitRegistry.getCircuit(nbttagcompound.getString("CA.I" + i));
if (circuit != null)
readcircuits.add(circuit);
}
circuits = readcircuits.toArray(new ICircuit[readcircuits.size()]);
}
@Override
@@ -99,7 +99,6 @@ public class CircuitRegistry implements ICircuitRegistry {
}
public void initialize() {
registerLayout(new CircuitLayout("engine.tin"));
}
@@ -27,6 +27,7 @@ import forestry.core.triggers.ForestryTrigger;
public class Config {
public static final String CATEGORY_COMMON = "common";
public static final String CATEGORY_DEBUG = "debug";
public static Configuration config;
@@ -57,6 +58,7 @@ public class Config {
public static boolean generateTinOre = true;
public static boolean generateBeehives = true;
public static boolean generateBogEarth = false;
public static boolean generateBeehivesDebug = false;
// Performance
public static boolean enableBackpackResupply = true;
@@ -148,6 +150,10 @@ public class Config {
genBeehives.Comment = "set to false to force forestry to skip generating beehives in the world";
generateBeehives = Boolean.parseBoolean(genBeehives.Value);
Property genDebugBeehives = config.get("world.generate.beehives.debug", CATEGORY_DEBUG, false);
genDebugBeehives.Comment = "Set to true to force Forestry to try to generate a beehive at every possible location.";
generateBeehivesDebug = Boolean.parseBoolean(genDebugBeehives.Value);
Property genCopperOre = config.get("world.generate.copper", CATEGORY_COMMON, true);
genCopperOre.Comment = "set to false to force forestry to skip generating own copper ore blocks in the world";
generateCopperOre = Boolean.parseBoolean(genCopperOre.Value);
@@ -31,6 +31,7 @@ public class Defaults {
public static final String DEFAULT_POWER_FRAMEWORK = "forestry.energy.BioPowerFramework";
public static final int BUCKET_VOLUME = 1000;
public static final int FLUID_PER_HONEY_DROP = 100;
public static final int[] FACINGS = { 0, 1, 2, 3, 4, 5 };
public static final int FACING_UP = 1;
@@ -41,6 +41,7 @@ public enum ForestryBlock {
* 0 - Apatite Ore 1 - Copper Ore 2 - Tin Ore
*/
resources,
resourceStorage,
/**
* 0 - Legacy 1 - Forest Hive 2 - Meadows Hive
*/
@@ -51,6 +52,8 @@ public enum ForestryBlock {
glass,
planks1,
planks2,
fireproofPlanks1,
fireproofPlanks2,
slabs1,
slabs2,
slabs3,
@@ -63,6 +66,14 @@ public enum ForestryBlock {
log6,
log7,
log8,
fireproofLog1,
fireproofLog2,
fireproofLog3,
fireproofLog4,
fireproofLog5,
fireproofLog6,
fireproofLog7,
fireproofLog8,
fences1,
fences2,
stairs,
@@ -100,7 +100,7 @@ public enum ForestryItem {
honeyDrop,
scoop,
beeswax,
pollen,
pollenCluster,
propolis,
honeydew,
royalJelly,
@@ -33,254 +33,262 @@ import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
*/
public final class FluidHelper {
public static final int BUCKET_FILL_TIME = 8;
public static final int NETWORK_UPDATE_INTERVAL = 128;
public static final int BUCKET_VOLUME = 1000;
public static final int BUCKET_FILL_TIME = 8;
public static final int NETWORK_UPDATE_INTERVAL = 128;
public static final int BUCKET_VOLUME = 1000;
private FluidHelper() {
}
private FluidHelper() {
}
public static boolean handleRightClick(IFluidHandler tank, ForgeDirection side, EntityPlayer player, boolean fill, boolean drain) {
if (player == null)
return false;
ItemStack current = player.inventory.getCurrentItem();
if (current != null) {
public static boolean handleRightClick(IFluidHandler tank, ForgeDirection side, EntityPlayer player, boolean fill, boolean drain) {
if (player == null)
return false;
ItemStack current = player.inventory.getCurrentItem();
if (current != null) {
FluidStack liquid = getFluidStackInContainer(current);
FluidStack liquid = getFluidStackInContainer(current);
if (fill && liquid != null) {
int used = tank.fill(side, liquid, true);
if (fill && liquid != null) {
int used = tank.fill(side, liquid, true);
if (used > 0) {
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current));
player.inventory.markDirty();
}
return true;
}
if (used > 0) {
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current));
player.inventory.markDirty();
}
return true;
}
} else if (drain) {
} else if (drain) {
FluidStack available = tank.drain(side, Integer.MAX_VALUE, false);
if (available != null) {
ItemStack filled = fillContainer(available, current);
FluidStack available = tank.drain(side, Integer.MAX_VALUE, false);
if (available != null) {
ItemStack filled = fillContainer(available, current);
liquid = getFluidStackInContainer(filled);
if (liquid != null) {
liquid = getFluidStackInContainer(filled);
if (liquid != null) {
if (current.stackSize > 1) {
if (!player.inventory.addItemStackToInventory(filled))
return false;
player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current));
player.inventory.markDirty();
} else {
player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current));
player.inventory.setInventorySlotContents(player.inventory.currentItem, filled);
player.inventory.markDirty();
}
if (current.stackSize > 1) {
if (!player.inventory.addItemStackToInventory(filled))
return false;
player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current));
player.inventory.markDirty();
} else {
player.inventory.setInventorySlotContents(player.inventory.currentItem, InvTools.depleteItem(current));
player.inventory.setInventorySlotContents(player.inventory.currentItem, filled);
player.inventory.markDirty();
}
tank.drain(side, liquid.amount, true);
return true;
}
}
}
}
return false;
}
tank.drain(side, liquid.amount, true);
return true;
}
}
}
}
return false;
}
public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot) {
processContainers(tank, inv, inputSlot, outputSlot, tank.getFluidType(), true, true);
}
public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot) {
processContainers(tank, inv, inputSlot, outputSlot, tank.getFluidType(), true, true);
}
public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) {
TankManager tankManger = new TankManager();
tankManger.add(tank);
processContainers(tankManger, inv, inputSlot, outputSlot, fluidToFill, processFilled, processEmpty);
}
public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) {
TankManager tankManger = new TankManager();
tankManger.add(tank);
processContainers(tankManger, inv, inputSlot, outputSlot, fluidToFill, processFilled, processEmpty);
}
public static void processContainers(TankManager tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
processContainers(tank, inv, inputSlot, outputSlot, fluidToFill, true, true);
}
public static void processContainers(TankManager tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
processContainers(tank, inv, inputSlot, outputSlot, fluidToFill, true, true);
}
public static void processContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) {
ItemStack input = inv.getStackInSlot(inputSlot);
public static void processContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) {
ItemStack input = inv.getStackInSlot(inputSlot);
if (input == null)
return;
if (input == null)
return;
if (processFilled && drainContainers(fluidHandler, inv, inputSlot, outputSlot))
return;
if (processFilled && drainContainers(fluidHandler, inv, inputSlot, outputSlot))
return;
if (processEmpty && fluidToFill != null)
fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill);
}
if (processEmpty && fluidToFill != null)
fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill);
}
public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
ItemStack filled = getFilledContainer(fluidToFill, input);
if (filled != null && (output == null || (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(filled, output)))) {
FluidStack fluidInContainer = getFluidStackInContainer(filled);
FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (drain != null && drain.amount == fluidInContainer.amount) {
fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (output == null)
inv.setInventorySlotContents(outputSlot, filled);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
return true;
}
}
return false;
}
public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
ItemStack filled = getFilledContainer(fluidToFill, input);
if (filled != null && (output == null || (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(filled, output)))) {
FluidStack fluidInContainer = getFluidStackInContainer(filled);
FluidStack drain = fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (drain != null && drain.amount == fluidInContainer.amount) {
fluidHandler.drain(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (output == null)
inv.setInventorySlotContents(outputSlot, filled);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
return true;
}
}
return false;
}
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int slot) {
return drainContainers(fluidHandler, inv, slot, slot);
}
if (input != null) {
FluidStack fluidInContainer = getFluidStackInContainer(input);
ItemStack emptyItem = input.getItem().getContainerItem(input);
if (fluidInContainer != null && (emptyItem == null || output == null || (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(output, emptyItem)))) {
int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (used >= fluidInContainer.amount) {
fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (emptyItem != null)
if (output == null)
inv.setInventorySlotContents(outputSlot, emptyItem);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
return true;
}
}
}
return false;
}
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
public static boolean isBucket(ItemStack stack) {
return FluidContainerRegistry.isBucket(stack);
}
if (input != null) {
FluidStack fluidInContainer = getFluidStackInContainer(input);
ItemStack emptyItem = input.getItem().getContainerItem(input);
if (fluidInContainer != null && (emptyItem == null || output == null
|| (inputSlot == outputSlot && input.stackSize == 1)
|| (output.stackSize < output.getMaxStackSize() && InvTools.isItemEqual(output, emptyItem)))) {
int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (used >= fluidInContainer.amount) {
fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (emptyItem != null)
if (output == null)
inv.setInventorySlotContents(outputSlot, emptyItem);
else
output.stackSize++;
inv.decrStackSize(inputSlot, 1);
return true;
}
}
}
return false;
}
public static boolean isContainer(ItemStack stack) {
if (stack != null && stack.getItem() instanceof IFluidContainerItem)
return true;
return FluidContainerRegistry.isContainer(stack);
}
public static boolean isBucket(ItemStack stack) {
return FluidContainerRegistry.isBucket(stack);
}
public static boolean isFilledContainer(ItemStack stack) {
return FluidContainerRegistry.isFilledContainer(stack);
}
public static boolean isContainer(ItemStack stack) {
if (stack != null && stack.getItem() instanceof IFluidContainerItem)
return true;
return FluidContainerRegistry.isContainer(stack);
}
public static boolean isEmptyContainer(ItemStack stack) {
return FluidContainerRegistry.isEmptyContainer(stack);
}
public static boolean isFilledContainer(ItemStack stack) {
return FluidContainerRegistry.isFilledContainer(stack);
}
public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) {
if (fluid == null || empty == null) return null;
return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, Integer.MAX_VALUE), empty);
}
public static boolean isEmptyContainer(ItemStack stack) {
return FluidContainerRegistry.isEmptyContainer(stack);
}
public static ItemStack getFilledContainer(FluidStack fluid, ItemStack empty) {
if (fluid == null || empty == null) return null;
fluid = fluid.copy();
fluid.amount = Integer.MAX_VALUE;
return FluidContainerRegistry.fillFluidContainer(fluid, empty);
}
public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) {
if (fluid == null || empty == null)
return null;
return FluidContainerRegistry.fillFluidContainer(new FluidStack(fluid, Integer.MAX_VALUE), empty);
}
public static ItemStack fillContainer(FluidStack liquid, ItemStack empty) {
if (liquid == null || empty == null) return null;
return FluidContainerRegistry.fillFluidContainer(liquid, empty);
}
public static ItemStack getFilledContainer(FluidStack fluid, ItemStack empty) {
if (fluid == null || empty == null)
return null;
fluid = fluid.copy();
fluid.amount = Integer.MAX_VALUE;
return FluidContainerRegistry.fillFluidContainer(fluid, empty);
}
public static FluidStack getFluidStackInContainer(ItemStack stack) {
return FluidContainerRegistry.getFluidForFilledItem(stack);
}
public static ItemStack fillContainer(FluidStack liquid, ItemStack empty) {
if (liquid == null || empty == null)
return null;
return FluidContainerRegistry.fillFluidContainer(liquid, empty);
}
public static Fluid getFluidInContianer(ItemStack stack) {
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
return fluidStack != null ? fluidStack.getFluid() : null;
}
public static FluidStack getFluidStackInContainer(ItemStack stack) {
return FluidContainerRegistry.getFluidForFilledItem(stack);
}
public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) {
return FluidContainerRegistry.containsFluid(stack, fluidStack);
}
public static Fluid getFluidInContianer(ItemStack stack) {
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(stack);
return fluidStack != null ? fluidStack.getFluid() : null;
}
public static boolean containsFluid(ItemStack stack, Fluid fluid) {
return FluidContainerRegistry.containsFluid(stack, new FluidStack(fluid, 1));
}
public static boolean containsFluidStack(ItemStack stack, FluidStack fluidStack) {
return FluidContainerRegistry.containsFluid(stack, fluidStack);
}
public static boolean isFluidEqual(FluidStack L1, FluidStack L2) {
if (L1 == null || L2 == null)
return false;
return L1.isFluidEqual(L2);
}
public static boolean containsFluid(ItemStack stack, Fluid fluid) {
return FluidContainerRegistry.containsFluid(stack, new FluidStack(fluid, 1));
}
public static Collection<ItemStack> getContainersFilledWith(FluidStack fluidStack) {
List<ItemStack> containers = new ArrayList<ItemStack>();
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
FluidStack inContainer = getFluidStackInContainer(data.filledContainer);
if (inContainer != null && inContainer.containsFluid(fluidStack))
containers.add(data.filledContainer.copy());
}
return containers;
}
public static boolean isFluidEqual(FluidStack L1, FluidStack L2) {
if (L1 == null || L2 == null)
return false;
return L1.isFluidEqual(L2);
}
public static void nerfWaterBottle() {
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
if (data.filledContainer.getItem() == Items.potionitem && data.emptyContainer.getItem() == Items.glass_bottle && Fluids.WATER.is(data.fluid)) {
data.fluid.amount = 333;
return;
}
}
}
public static Collection<ItemStack> getContainersFilledWith(FluidStack fluidStack) {
List<ItemStack> containers = new ArrayList<ItemStack>();
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) {
FluidStack inContainer = getFluidStackInContainer(data.filledContainer);
if (inContainer != null && inContainer.containsFluid(fluidStack))
containers.add(data.filledContainer.copy());
}
return containers;
}
public static FluidStack drainBlock(World world, int x, int y, int z, boolean doDrain) {
return drainBlock(world.getBlock(x, y, z), world, x, y, z, doDrain);
}
public static void nerfWaterBottle() {
for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData())
if (data.filledContainer.getItem() == Items.potionitem && data.emptyContainer.getItem() == Items.glass_bottle && Fluids.WATER.is(data.fluid)) {
data.fluid.amount = 333;
return;
}
}
public static FluidStack drainBlock(Block block, World world, int x, int y, int z, boolean doDrain) {
if (block instanceof IFluidBlock) {
IFluidBlock fluidBlock = (IFluidBlock)block;
if (fluidBlock.canDrain(world, x, y, z))
return fluidBlock.drain(world, x, y, z, doDrain);
} else if (block == Blocks.water || block == Blocks.flowing_water) {
int meta = world.getBlockMetadata(x, y, z);
if (meta != 0)
return null;
if (doDrain)
world.setBlockToAir(x, y, z);
return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME);
} else if (block == Blocks.lava || block == Blocks.flowing_lava) {
int meta = world.getBlockMetadata(x, y, z);
if (meta != 0)
return null;
if (doDrain)
world.setBlockToAir(x, y, z);
return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME);
}
return null;
}
public static FluidStack drainBlock(World world, int x, int y, int z, boolean doDrain) {
return drainBlock(world.getBlock(x, y, z), world, x, y, z, doDrain);
}
public static boolean isFullFluidBlock(World world, int x, int y, int z) {
return isFullFluidBlock(world.getBlock(x, y, z), world, x, y, z);
}
public static FluidStack drainBlock(Block block, World world, int x, int y, int z, boolean doDrain) {
if (block instanceof IFluidBlock) {
IFluidBlock fluidBlock = (IFluidBlock) block;
if (fluidBlock.canDrain(world, x, y, z))
return fluidBlock.drain(world, x, y, z, doDrain);
} else if (block == Blocks.water || block == Blocks.flowing_water) {
int meta = world.getBlockMetadata(x, y, z);
if (meta != 0)
return null;
if (doDrain)
world.setBlockToAir(x, y, z);
return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME);
} else if (block == Blocks.lava || block == Blocks.flowing_lava) {
int meta = world.getBlockMetadata(x, y, z);
if (meta != 0)
return null;
if (doDrain)
world.setBlockToAir(x, y, z);
return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME);
}
return null;
}
public static boolean isFullFluidBlock(Block block, World world, int x, int y, int z) {
if (block instanceof BlockLiquid || block instanceof IFluidBlock)
return world.getBlockMetadata(x, y, z) == 0;
return false;
}
public static boolean isFullFluidBlock(World world, int x, int y, int z) {
return isFullFluidBlock(world.getBlock(x, y, z), world, x, y, z);
}
public static Fluid getFluid(Block block) {
if (block instanceof IFluidBlock)
return ((IFluidBlock) block).getFluid();
else if (block == Blocks.water || block == Blocks.flowing_water)
return FluidRegistry.WATER;
else if (block == Blocks.lava || block == Blocks.flowing_lava)
return FluidRegistry.LAVA;
return null;
}
public static boolean isFullFluidBlock(Block block, World world, int x, int y, int z) {
if (block instanceof BlockLiquid || block instanceof IFluidBlock)
return world.getBlockMetadata(x, y, z) == 0;
return false;
}
public static Fluid getFluid(Block block) {
if (block instanceof IFluidBlock)
return ((IFluidBlock) block).getFluid();
else if (block == Blocks.water || block == Blocks.flowing_water)
return FluidRegistry.WATER;
else if (block == Blocks.lava || block == Blocks.flowing_lava)
return FluidRegistry.LAVA;
return null;
}
}
+49 -43
View File
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.core.fluids;
import forestry.core.config.Defaults;
import java.util.Locale;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
@@ -23,57 +24,62 @@ import net.minecraftforge.fluids.FluidStack;
*/
public enum Fluids {
WATER, LAVA, FUEL, BIOFUEL, CREOSOTE, STEAM, BIOETHANOL, COAL, PYROTHEUM;
private final String tag;
WATER, LAVA, FUEL, BIOMASS, BIOFUEL, CREOSOTE, STEAM, BIOETHANOL,
COAL, PYROTHEUM, HONEY, MILK, JUICE, ICE, GLASS, OIL, SEEDOIL, SHORT_MEAD(Defaults.LIQUID_MEAD);
private final String tag;
private Fluids() {
tag = name().toLowerCase(Locale.ENGLISH);
}
private Fluids() {
tag = name().toLowerCase(Locale.ENGLISH);
}
public String getTag() {
return tag;
}
private Fluids(String tag) {
this.tag = tag;
}
public Fluid get() {
return FluidRegistry.getFluid(tag);
}
public String getTag() {
return tag;
}
/**
* Gets a FluidStack filled with qty milliBuckets worth of Fluid.
*
* @param qty
* @return
*/
public FluidStack get(int qty) {
return FluidRegistry.getFluidStack(tag, qty);
}
public Fluid get() {
return FluidRegistry.getFluid(tag);
}
/**
* Gets a FluidStack filled with n buckets worth of Fluid.
*
* @param n
* @return
*/
public FluidStack getB(int n) {
return FluidRegistry.getFluidStack(tag, n * FluidContainerRegistry.BUCKET_VOLUME);
}
/**
* Gets a FluidStack filled with qty milliBuckets worth of Fluid.
*
* @param qty
* @return
*/
public FluidStack get(int qty) {
return FluidRegistry.getFluidStack(tag, qty);
}
public boolean is(Fluid fluid) {
return get() == fluid;
}
/**
* Gets a FluidStack filled with n buckets worth of Fluid.
*
* @param n
* @return
*/
public FluidStack getB(int n) {
return FluidRegistry.getFluidStack(tag, n * FluidContainerRegistry.BUCKET_VOLUME);
}
public boolean is(FluidStack fluidStack) {
return fluidStack != null && get() == fluidStack.getFluid();
}
public boolean is(Fluid fluid) {
return get() == fluid;
}
public boolean isContained(ItemStack containerStack) {
return containerStack != null && FluidHelper.containsFluid(containerStack, get());
}
public boolean is(FluidStack fluidStack) {
return fluidStack != null && get() == fluidStack.getFluid();
}
public static boolean areEqual(Fluid fluid, FluidStack fluidStack) {
if (fluidStack != null && fluid == fluidStack.getFluid())
return true;
return fluid == null && fluidStack == null;
}
public boolean isContained(ItemStack containerStack) {
return containerStack != null && FluidHelper.containsFluid(containerStack, get());
}
public static boolean areEqual(Fluid fluid, FluidStack fluidStack) {
if (fluidStack != null && fluid == fluidStack.getFluid())
return true;
return fluid == null && fluidStack == null;
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -14,27 +14,26 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
/**
*
* @author CovertJaguar <http://www.railcraft.info>
*/
public final class FakeTank extends StandardTank {
public static final FakeTank INSTANCE = new FakeTank();
public static final FakeTank[] ARRAY = new FakeTank[]{INSTANCE};
public static final FluidTankInfo[] INFO = new FluidTankInfo[]{INSTANCE.getInfo()};
public static final FakeTank INSTANCE = new FakeTank();
public static final FakeTank[] ARRAY = new FakeTank[]{INSTANCE};
public static final FluidTankInfo[] INFO = new FluidTankInfo[]{INSTANCE.getInfo()};
private FakeTank() {
super(1);
}
private FakeTank() {
super(1);
}
@Override
public int fill(FluidStack resource, boolean doFill) {
return 0;
}
@Override
public int fill(FluidStack resource, boolean doFill) {
return 0;
}
@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
return null;
}
@Override
public FluidStack drain(int maxDrain, boolean doDrain) {
return null;
}
}
@@ -0,0 +1,70 @@
package forestry.core.gadgets;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.core.CreativeTabForestry;
import forestry.core.render.TextureManager;
public class BlockResourceStorageBlock extends Block {
public BlockResourceStorageBlock() {
super(Material.iron);
setHardness(3F);
setResistance(5F);
setCreativeTab(CreativeTabForestry.tabForestry);
}
@SideOnly(Side.CLIENT)
private IIcon iconApatite;
@SideOnly(Side.CLIENT)
private IIcon iconCopper;
@SideOnly(Side.CLIENT)
private IIcon iconTin;
@SideOnly(Side.CLIENT)
private IIcon iconBronze;
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubBlocks(Item item, CreativeTabs creativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 0));
itemList.add(new ItemStack(this, 1, 1));
itemList.add(new ItemStack(this, 1, 2));
itemList.add(new ItemStack(this, 1, 3));
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister register) {
iconApatite = TextureManager.getInstance().registerTex(register, "storage/apatite");
iconCopper = TextureManager.getInstance().registerTex(register, "storage/copper");
iconTin = TextureManager.getInstance().registerTex(register, "storage/tin");
iconBronze = TextureManager.getInstance().registerTex(register, "storage/bronze");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int meta) {
IIcon icon = null;
if (meta == 0) {
icon = iconApatite;
} else if (meta == 1) {
icon = iconCopper;
} else if (meta == 2) {
icon = iconTin;
} else {
icon = iconBronze;
}
return icon;
}
}
@@ -72,8 +72,8 @@ public class BlockStainedGlass extends BlockBreakable {
@Override
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int meta) {
Block block = world.getBlock(x, y, z);
return block == this ? false : super.shouldSideBeRendered(world, x, y, z, meta);
Block block = world.getBlock(x, y, z);
return block == this ? false : super.shouldSideBeRendered(world, x, y, z, meta);
}
@Override
@@ -12,7 +12,7 @@ package forestry.core.gadgets;
import forestry.core.network.EntityNetData;
public abstract class Mill extends TilePowered {
public abstract class Mill extends TileBase {
@EntityNetData
public int charge = 0;
@@ -23,7 +23,6 @@ public abstract class Mill extends TilePowered {
public float progress;
public Mill() {
super(0, 0, 0);
speed = 0.01F;
}
@@ -76,10 +75,4 @@ public abstract class Mill extends TilePowered {
}
protected abstract void activate();
@Override
public boolean isWorking() {
return charge != 0;
}
}
@@ -23,18 +23,18 @@ import net.minecraft.network.Packet;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpecialInventory;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IIndividual;
import forestry.core.EnumErrorCode;
import forestry.core.fluids.TankManager;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.Fluids;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.network.EntityNetData;
import forestry.core.network.GuiId;
@@ -42,14 +42,17 @@ import forestry.core.network.PacketIds;
import forestry.core.network.PacketInventoryStack;
import forestry.core.proxy.Proxies;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.wrappers.IInvSlot;
import forestry.core.inventory.wrappers.InventoryIterator;
import forestry.core.inventory.wrappers.InventoryMapper;
import forestry.core.utils.InventoryAdapter;
import forestry.core.utils.LiquidHelper;
import forestry.core.utils.StackUtils;
import net.minecraft.inventory.IInventory;
public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedInventory, ILiquidTankContainer {
public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankContainer {
/* CONSTANTS */
public static final int TIME_TO_ANALYZE = 500;
public static final int TIME_TO_ANALYZE = 125;
public static final int HONEY_REQUIRED = 100;
public static final short SLOT_ANALYZE = 0;
@@ -62,11 +65,6 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
private int analyzeTime;
private final short analyzeSlot = 0;
private final short canSlot = 1;
private final short inputSlot1 = 2;
private final short outputSlot1 = 8;
@EntityNetData
public FilteredTank resourceTank;
@@ -74,9 +72,12 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
private final Stack<ItemStack> pendingProducts = new Stack<ItemStack>();
private final IInventory invInput = new InventoryMapper(inventory, SLOT_INPUT_1, 6);
/* CONSTRUCTOR */
public TileAnalyzer() {
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.getFluid(Defaults.LIQUID_HONEY));
super(800, 40, Defaults.MACHINE_MAX_ENERGY);
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, Fluids.HONEY.get());
tankManager = new TankManager(resourceTank);
}
@@ -135,92 +136,116 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
inventory.readFromNBT(nbttagcompound);
}
/* WORKING */
@Override
public void updateServerSide() {
// If we add pending products, we skip to the next work cycle.
if (tryAddPending())
return;
protected void updateServerSide() {
// Check if we have suitable items waiting in the can slot
FluidHelper.drainContainers(tankManager, this, SLOT_CAN);
ItemStack can = getStackInSlot(SLOT_CAN);
if (ForestryItem.honeyDrop.isItemEqual(can) && resourceTank.fill(Fluids.HONEY.get(Defaults.FLUID_PER_HONEY_DROP), false) == Defaults.FLUID_PER_HONEY_DROP) {
setInventorySlotContents(SLOT_CAN, InvTools.depleteItem(can));
resourceTank.fill(Fluids.HONEY.get(Defaults.FLUID_PER_HONEY_DROP), true);
}
for (int i = 0; i < invInput.getSizeInventory(); i++) {
ItemStack inputStack = invInput.getStackInSlot(i);
if (inputStack == null || !AlleleManager.alleleRegistry.isIndividual(inputStack))
continue;
// Analyzed bees in the input buffer are added to the output queue.
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(inputStack);
if (individual.isAnalyzed()) {
pendingProducts.push(inputStack);
invInput.decrStackSize(i, inputStack.stackSize);
}
}
tryAddPending();
if (!pendingProducts.isEmpty()) {
setErrorState(EnumErrorCode.NOSPACE);
return;
}
// Check if we have suitable items waiting in the can slot
if (getStackInSlot(canSlot) != null) {
FluidContainerData container = LiquidHelper.getLiquidContainer(getStackInSlot(canSlot));
if (container != null && resourceTank.accepts(container.fluid.getFluid())) {
setInventorySlotContents(canSlot, StackUtils.replenishByContainer(this, getStackInSlot(canSlot), container, resourceTank));
if (getStackInSlot(canSlot).stackSize <= 0)
setInventorySlotContents(canSlot, null);
if (analyzeTime == 0) {
// Look for bees in input slots.
IInvSlot slot = getInputSlot();
if (slot == null) {
// Nothing to analyze
setErrorState(EnumErrorCode.NOTHINGANALYZE);
return;
}
}
if (analyzeTime > 0 && getStackInSlot(analyzeSlot) != null && AlleleManager.alleleRegistry.isIndividual(getStackInSlot(analyzeSlot))) {
// We need our liquid honey
if (resourceTank.getFluidAmount() < HONEY_REQUIRED) {
setErrorState(EnumErrorCode.NORESOURCE);
return;
}
if (energyManager.getTotalEnergyStored() == 0) {
setErrorState(EnumErrorCode.NOPOWER);
return;
}
setErrorState(EnumErrorCode.OK);
}
/* WORKING */
@Override
public boolean workCycle() {
ItemStack stackToAnalyze = getStackInSlot(SLOT_ANALYZE);
if (analyzeTime > 0 && stackToAnalyze != null && AlleleManager.alleleRegistry.isIndividual(stackToAnalyze)) {
analyzeTime--;
// Still not done
if (analyzeTime > 0) {
setErrorState(EnumErrorCode.OK);
return;
return true;
}
// Analyzation is done.
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(getStackInSlot(analyzeSlot));
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(stackToAnalyze);
// No bee, abort
if (individual == null)
return;
return false;
individual.analyze();
NBTTagCompound nbttagcompound = new NBTTagCompound();
individual.writeToNBT(nbttagcompound);
getStackInSlot(analyzeSlot).setTagCompound(nbttagcompound);
stackToAnalyze.setTagCompound(nbttagcompound);
pendingProducts.push(getStackInSlot(analyzeSlot));
setInventorySlotContents(analyzeSlot, null);
pendingProducts.push(stackToAnalyze);
setInventorySlotContents(SLOT_ANALYZE, null);
sendNetworkUpdate();
} else {
analyzeTime = 0;
// Don't start if analyze slot already occupied
if (getStackInSlot(analyzeSlot) != null)
return;
// We need our liquid honey
if (resourceTank.getFluidAmount() < HONEY_REQUIRED) {
setErrorState(EnumErrorCode.NORESOURCE);
return;
}
// Look for bees in input slots.
for (int i = inputSlot1; i < outputSlot1; i++) {
if (getStackInSlot(i) == null || !AlleleManager.alleleRegistry.isIndividual(getStackInSlot(i)))
continue;
// Analyzed bees in the input buffer are added to the output
// queue at once.
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(getStackInSlot(i));
if (individual.isAnalyzed()) {
pendingProducts.push(getStackInSlot(i));
setInventorySlotContents(i, null);
continue;
}
setInventorySlotContents(analyzeSlot, getStackInSlot(i));
setInventorySlotContents(i, null);
resourceTank.drain(HONEY_REQUIRED, true);
analyzeTime = TIME_TO_ANALYZE;
sendNetworkUpdate();
return;
}
// Nothing to analyze
setErrorState(EnumErrorCode.NOTHINGANALYZE);
return true;
}
analyzeTime = 0;
// Don't start if analyze slot already occupied
if (stackToAnalyze != null)
return false;
if (getErrorState() != EnumErrorCode.OK)
return false;
// Look for bees in input slots.
IInvSlot slot = getInputSlot();
ItemStack inputStack = slot.getStackInSlot();
setInventorySlotContents(SLOT_ANALYZE, inputStack);
slot.setStackInSlot(null);
resourceTank.drain(HONEY_REQUIRED, true);
analyzeTime = TIME_TO_ANALYZE;
sendNetworkUpdate();
return true;
}
private IInvSlot getInputSlot() {
for (IInvSlot slot : InventoryIterator.getIterable(invInput)) {
ItemStack inputStack = slot.getStackInSlot();
if (inputStack != null && AlleleManager.alleleRegistry.isIndividual(inputStack))
return slot;
}
return null;
}
private boolean tryAddPending() {
@@ -228,7 +253,7 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
return false;
ItemStack next = pendingProducts.peek();
if (inventory.tryAddStack(next, outputSlot1, inventory.getSizeInventory() - outputSlot1, true)) {
if (inventory.tryAddStack(next, SLOT_OUTPUT_1, inventory.getSizeInventory() - SLOT_OUTPUT_1, true)) {
pendingProducts.pop();
return true;
}
@@ -237,10 +262,21 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
/* STATE INFORMATION */
// @Override
@Override
public boolean isWorking() {
return analyzeTime > 0;
}
@Override
public boolean hasWork() {
if (!pendingProducts.isEmpty())
return true;
if (analyzeTime > 0)
return true;
return getErrorState() == EnumErrorCode.OK ||getErrorState() == EnumErrorCode.NOPOWER;
}
public int getProgressScaled(int i) {
return (analyzeTime * i) / TIME_TO_ANALYZE;
}
@@ -250,10 +286,11 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
}
public ItemStack getIndividualOnDisplay() {
return getStackInSlot(analyzeSlot);
return getStackInSlot(SLOT_ANALYZE);
}
/* SMP */
@Override
public void getGUINetworkData(int i, int j) {
i -= tankManager.maxMessageId() + 1;
switch (i) {
@@ -263,23 +300,13 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
}
}
@Override
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
int i = tankManager.maxMessageId() + 1;
iCrafting.sendProgressBarUpdate(container, i, analyzeTime);
}
@Override
public void sendNetworkUpdate() {
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_ANALYZE, inventory.getStackInSlot(SLOT_ANALYZE)),
xCoord, yCoord, zCoord);
}
@Override
public Packet getDescriptionPacket() {
return new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_ANALYZE, inventory.getStackInSlot(SLOT_ANALYZE)).getPacket();
}
/* ISIDEDINVENTORY */
@Override
public InventoryAdapter getInternalInventory() {
@@ -288,37 +315,64 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
@Override
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
if(!super.canTakeStackFromSide(slotIndex, itemstack, side))
if (!super.canTakeStackFromSide(slotIndex, itemstack, side))
return false;
return slotIndex >= SLOT_OUTPUT_1 && slotIndex < SLOT_OUTPUT_1 + 4;
}
@Override
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
protected boolean canPutStackFromSide(int slotIndex, ItemStack stack, int side) {
if(!super.canPutStackFromSide(slotIndex, itemstack, side))
if (!super.canPutStackFromSide(slotIndex, stack, side))
return false;
if(slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + 6)
return AlleleManager.alleleRegistry.isIndividual(itemstack);
if (slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + 6)
return AlleleManager.alleleRegistry.isIndividual(stack);
if(slotIndex == SLOT_CAN) {
FluidContainerData container = LiquidHelper.getLiquidContainer(itemstack);
return container != null && LiquidHelper.isLiquid(Defaults.LIQUID_HONEY, container.fluid);
}
if (slotIndex == SLOT_CAN)
return Fluids.HONEY.isContained(stack);
return false;
}
@Override public int getSizeInventory() { return inventory.getSizeInventory(); }
@Override public ItemStack getStackInSlot(int i) { return inventory.getStackInSlot(i); }
@Override public ItemStack decrStackSize(int i, int j) { return inventory.decrStackSize(i, j); }
@Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory.setInventorySlotContents(i, itemstack); }
@Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); }
@Override public ItemStack getStackInSlotOnClosing(int slot) { return inventory.getStackInSlotOnClosing(slot); }
@Override public void openInventory() {}
@Override public void closeInventory() {}
@Override
public int getSizeInventory() {
return inventory.getSizeInventory();
}
@Override
public ItemStack getStackInSlot(int i) {
return inventory.getStackInSlot(i);
}
@Override
public ItemStack decrStackSize(int i, int j) {
return inventory.decrStackSize(i, j);
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
inventory.setInventorySlotContents(i, itemstack);
}
@Override
public int getInventoryStackLimit() {
return inventory.getInventoryStackLimit();
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
return inventory.getStackInSlotOnClosing(slot);
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
/**
* TODO: just a specialsource workaround
@@ -368,66 +422,6 @@ public class TileAnalyzer extends TileBase implements ISpecialInventory, ISidedI
return super.getAccessibleSlotsFromSide(side);
}
/* ISPECIALINVENTORY */
@Override
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
ItemStack product = null;
for (int i = outputSlot1; i < inventory.getSizeInventory(); i++) {
if (inventory.getStackInSlot(i) == null)
continue;
product = getStackInSlot(i).copy();
if (doRemove) {
getStackInSlot(i).stackSize = 0;
setInventorySlotContents(i, null);
}
break;
}
return new ItemStack[] { product };
}
@Override
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
if (!AlleleManager.alleleRegistry.isIndividual(stack)) {
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
if (container == null || !resourceTank.accepts(container.fluid.getFluid()))
return 0;
if (getStackInSlot(canSlot) == null) {
if (doAdd)
setInventorySlotContents(canSlot, stack.copy());
return stack.stackSize;
}
int space = getStackInSlot(canSlot).getMaxStackSize() - getStackInSlot(canSlot).stackSize;
if (space <= 0)
return 0;
if (doAdd) {
getStackInSlot(canSlot).stackSize += stack.stackSize;
if (getStackInSlot(canSlot).stackSize > getStackInSlot(canSlot).getMaxStackSize())
getStackInSlot(canSlot).stackSize = getStackInSlot(canSlot).getMaxStackSize();
}
return space;
}
for (int i = inputSlot1; i < outputSlot1; i++)
if (getStackInSlot(i) == null) {
if (doAdd)
setInventorySlotContents(i, stack.copy());
return stack.stackSize;
}
return 0;
}
/* ILIQUIDCONTAINER */
@Override
public TankManager getTankManager() {
@@ -24,7 +24,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.ITrigger;
import buildcraft.api.statements.ITriggerExternal;
import com.mojang.authlib.GameProfile;
import forestry.core.EnumErrorCode;
@@ -147,7 +147,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
fromPacketPayload(packet.payload);
}
public LinkedList<ITrigger> getCustomTriggers() {
public LinkedList<ITriggerExternal> getCustomTriggers() {
return null;
}
@@ -10,20 +10,6 @@
******************************************************************************/
package forestry.core.gadgets;
import java.util.HashMap;
import java.util.LinkedList;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.gates.ITrigger;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ISpecialInventory;
@@ -37,11 +23,19 @@ import forestry.core.utils.EnumAccess;
import forestry.core.utils.EnumTankLevel;
import forestry.core.utils.Utils;
import forestry.plugins.PluginApiculture;
import forestry.plugins.PluginCore;
import forestry.plugins.PluginEnergy;
import forestry.plugins.PluginFactory;
import forestry.plugins.PluginMail;
import forestry.plugins.PluginIC2;
import forestry.plugins.PluginMail;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import java.util.HashMap;
public abstract class TileMachine extends TileForestry implements ISpecialInventory, IClimatised, IHintSource {
@@ -163,7 +157,7 @@ public abstract class TileMachine extends TileForestry implements ISpecialInvent
millMap.put(Defaults.ID_PACKAGE_MILL_TRADER, PluginMail.definitionTradestation);
millMap.put(Defaults.ID_PACKAGE_MILL_PHILATELIST, PluginMail.definitionPhilatelist);
millMap.put(Defaults.ID_PACKAGE_MILL_APIARIST_CHEST, PluginApiculture.definitionChest);
millMap.put(Defaults.ID_PACKAGE_MILL_ANALYZER, PluginCore.definitionAnalyzer);
millMap.put(Defaults.ID_PACKAGE_MILL_ANALYZER, PluginApiculture.definitionAnalyzer);
millMap.put(Defaults.ID_PACKAGE_MILL_RAINMAKER, PluginFactory.definitionRainmaker);
definitionMap.put(ForestryBlock.factoryPlain.block(), millMap);
@@ -379,11 +373,4 @@ public abstract class TileMachine extends TileForestry implements ISpecialInvent
// NEIGHBOUR CHANGE
public void onNeighborBlockChange() {
}
// ITRIGGERPROVIDER
@Override
public LinkedList<ITrigger> getCustomTriggers() {
return null;
}
}
@@ -10,11 +10,12 @@
******************************************************************************/
package forestry.core.gadgets;
import buildcraft.api.tiles.IHasWork;
import cpw.mods.fml.common.Optional;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.interfaces.IPowerHandler;
import forestry.core.interfaces.IRenderableMachine;
import forestry.core.network.ClassMap;
import forestry.core.network.EntityNetData;
import forestry.core.network.IndexInPayload;
import forestry.core.network.PacketPayload;
import forestry.core.proxy.Proxies;
@@ -25,7 +26,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
public abstract class TilePowered extends TileBase implements IRenderableMachine, IPowerHandler {
@Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraft|Core")
public abstract class TilePowered extends TileBase implements IRenderableMachine, IPowerHandler, IHasWork {
public static int WORK_CYCLES = 4;
@@ -82,9 +84,7 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine
return false;
}
public boolean hasWork() {
return false;
}
public abstract boolean hasWork();
private int workCounter;
@@ -119,6 +119,10 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine
}
/* LIQUID CONTAINER HANDLING */
/**
@deprecated Use FluidHelper
*/
@Deprecated
protected ItemStack bottleIntoContainer(ItemStack canStack, ItemStack outputStack, FluidContainerData container, StandardTank tank) {
if (tank.getFluidAmount() < container.fluid.amount)
return outputStack;
@@ -408,6 +408,10 @@ public class Allele implements IAllele {
public static Allele plantTypeNether;
public static Allele plantTypeCrop;
// / TREES // FIREPROOF
public static Allele fireproofFalse;
public static Allele fireproofTrue;
public static void initialize() {
// ALL // GENERIC
boolFalse = new AlleleBoolean("boolFalse", false);
@@ -425,13 +429,13 @@ public class Allele implements IAllele {
int10 = new AlleleInteger("i10d", 10, true);
// BEES // SPEED
speedSlowest = new AlleleFloat("speedSlowest", 0.3f, true).setName("gui.slowest");
speedSlower = new AlleleFloat("speedSlower", 0.6f, true).setName("gui.slower");
speedSlow = new AlleleFloat("speedSlow", 0.8f, true).setName("gui.slow");
speedNorm = new AlleleFloat("speedNorm", 1.0f).setName("gui.normal");
speedFast = new AlleleFloat("speedFast", 1.2f, true).setName("gui.fast");
speedFaster = new AlleleFloat("speedFaster", 1.4f).setName("gui.faster");
speedFastest = new AlleleFloat("speedFastest", 1.7f).setName("gui.fastest");
speedSlowest = new AlleleFloat("speedSlowest", 0.3f, true).setName("speed", "slowest");
speedSlower = new AlleleFloat("speedSlower", 0.6f, true).setName("speed", "slower");
speedSlow = new AlleleFloat("speedSlow", 0.8f, true).setName("speed", "slow");
speedNorm = new AlleleFloat("speedNorm", 1.0f).setName("speed", "normal");
speedFast = new AlleleFloat("speedFast", 1.2f, true).setName("speed", "fast");
speedFaster = new AlleleFloat("speedFaster", 1.4f).setName("speed", "faster");
speedFastest = new AlleleFloat("speedFastest", 1.7f).setName("speed", "fastest");
// BEES // LIFESPAN
lifespanShortest = new AlleleInteger("lifespanShortest", 10, false).setName("gui.shortestlife");
@@ -451,23 +455,23 @@ public class Allele implements IAllele {
fertilityMaximum = new AlleleInteger("fertilityMaximum", 4);
// TREES // HEIGHT
heightSmallest = new AlleleFloat("heightSmallest", 0.25f).setName("gui.smallest");
heightSmaller = new AlleleFloat("heightSmaller", 0.5f).setName("gui.smaller");
heightSmall = new AlleleFloat("heightSmall", 0.75f).setName("gui.small");
heightAverage = new AlleleFloat("heightMax10", 1.0f).setName("gui.average");
heightLarge = new AlleleFloat("heightLarge", 1.25f).setName("gui.large");
heightLarger = new AlleleFloat("heightLarger", 1.5f).setName("gui.larger");
heightLargest = new AlleleFloat("heightLargest", 1.75f).setName("gui.largest");
heightGigantic = new AlleleFloat("heightGigantic", 2.0f).setName("gui.gigantic");
heightSmallest = new AlleleFloat("heightSmallest", 0.25f).setName("height", "smallest");
heightSmaller = new AlleleFloat("heightSmaller", 0.5f).setName("height", "smaller");
heightSmall = new AlleleFloat("heightSmall", 0.75f).setName("height", "small");
heightAverage = new AlleleFloat("heightMax10", 1.0f).setName("height", "average");
heightLarge = new AlleleFloat("heightLarge", 1.25f).setName("height", "large");
heightLarger = new AlleleFloat("heightLarger", 1.5f).setName("height", "larger");
heightLargest = new AlleleFloat("heightLargest", 1.75f).setName("height", "largest");
heightGigantic = new AlleleFloat("heightGigantic", 2.0f).setName("height", "gigantic");
// BUTTERFLIES // SIZE
sizeSmallest = new AlleleFloat("sizeSmallest", 0.3f).setName("gui.smallest");
sizeSmaller = new AlleleFloat("sizeSmaller", 0.4f).setName("gui.smaller");
sizeSmall = new AlleleFloat("sizeSmall", 0.5f).setName("gui.small");
sizeAverage = new AlleleFloat("sizeAverage", 0.6f).setName("gui.average");
sizeLarge = new AlleleFloat("sizeLarge", 0.75f).setName("gui.large");
sizeLarger = new AlleleFloat("sizeLarger", 0.9f).setName("gui.larger");
sizeLargest = new AlleleFloat("sizeLargest", 1.0f).setName("gui.largest");
sizeSmallest = new AlleleFloat("sizeSmallest", 0.3f).setName("size", "smallest");
sizeSmaller = new AlleleFloat("sizeSmaller", 0.4f).setName("size", "smaller");
sizeSmall = new AlleleFloat("sizeSmall", 0.5f).setName("size", "small");
sizeAverage = new AlleleFloat("sizeAverage", 0.6f).setName("size", "average");
sizeLarge = new AlleleFloat("sizeLarge", 0.75f).setName("size", "large");
sizeLarger = new AlleleFloat("sizeLarger", 0.9f).setName("size", "larger");
sizeLargest = new AlleleFloat("sizeLargest", 1.0f).setName("size", "largest");
// BEES // TOLERANCE
toleranceNone = new AlleleTolerance("toleranceNone", EnumTolerance.NONE);
@@ -488,61 +492,61 @@ public class Allele implements IAllele {
toleranceDown5 = new AlleleTolerance("toleranceDown5", EnumTolerance.DOWN_5);
// TREES // FERTILITY
saplingsLowest = new AlleleFloat("saplingsLowest", 0.01f, true).setName("gui.lowest");
saplingsLower = new AlleleFloat("saplingsLower", 0.025f, true).setName("gui.lower");
saplingsLow = new AlleleFloat("saplingsLow", 0.035f, true).setName("gui.low");
saplingsAverage = new AlleleFloat("saplingsDefault", 0.05f, true).setName("gui.average");
saplingsHigh = new AlleleFloat("saplingsDouble", 0.1f, true).setName("gui.high");
saplingsHigher = new AlleleFloat("saplingsTriple", 0.2f, true).setName("gui.higher");
saplingsHighest = new AlleleFloat("saplingsHighest", 0.3f, true).setName("gui.highest");
saplingsLowest = new AlleleFloat("saplingsLowest", 0.01f, true).setName("saplings", "lowest");
saplingsLower = new AlleleFloat("saplingsLower", 0.025f, true).setName("saplings", "lower");
saplingsLow = new AlleleFloat("saplingsLow", 0.035f, true).setName("saplings", "low");
saplingsAverage = new AlleleFloat("saplingsDefault", 0.05f, true).setName("saplings", "average");
saplingsHigh = new AlleleFloat("saplingsDouble", 0.1f, true).setName("saplings", "high");
saplingsHigher = new AlleleFloat("saplingsTriple", 0.2f, true).setName("saplings", "higher");
saplingsHighest = new AlleleFloat("saplingsHighest", 0.3f, true).setName("saplings", "highest");
// TREES // YIELD
yieldLowest = new AlleleFloat("yieldLowest", 0.025f, true).setName("gui.lowest");
yieldLower = new AlleleFloat("yieldLower", 0.05f, true).setName("gui.lower");
yieldLow = new AlleleFloat("yieldLow", 0.1f, true).setName("gui.low");
yieldAverage = new AlleleFloat("yieldDefault", 0.2f, true).setName("gui.average");
yieldHigh = new AlleleFloat("yieldHigh", 0.3f, false).setName("gui.high");
yieldHigher = new AlleleFloat("yieldHigher", 0.35f, false).setName("gui.higher");
yieldHighest = new AlleleFloat("yieldHighest", 0.4f, false).setName("gui.highest");
yieldLowest = new AlleleFloat("yieldLowest", 0.025f, true).setName("yield", "lowest");
yieldLower = new AlleleFloat("yieldLower", 0.05f, true).setName("yield", "lower");
yieldLow = new AlleleFloat("yieldLow", 0.1f, true).setName("yield", "low");
yieldAverage = new AlleleFloat("yieldDefault", 0.2f, true).setName("yield", "average");
yieldHigh = new AlleleFloat("yieldHigh", 0.3f, false).setName("yield", "high");
yieldHigher = new AlleleFloat("yieldHigher", 0.35f, false).setName("yield", "higher");
yieldHighest = new AlleleFloat("yieldHighest", 0.4f, false).setName("yield", "highest");
// TREES // SAPPINESS
sappinessLowest = new AlleleFloat("sappinessLowest", 0.1f, true).setName("gui.lowest");
sappinessLower = new AlleleFloat("sappinessLower", 0.2f, true).setName("gui.lower");
sappinessLow = new AlleleFloat("sappinessLow", 0.3f, true).setName("gui.low");
sappinessAverage = new AlleleFloat("sappinessAverage", 0.4f, true).setName("gui.average");
sappinessHigh = new AlleleFloat("sappinessHigh", 0.6f, true).setName("gui.high");
sappinessHigher = new AlleleFloat("sappinessHigher", 0.8f, false).setName("gui.higher");
sappinessHighest = new AlleleFloat("sappinessHighest", 1.0f, false).setName("gui.highest");
sappinessLowest = new AlleleFloat("sappinessLowest", 0.1f, true).setName("sappiness", "lowest");
sappinessLower = new AlleleFloat("sappinessLower", 0.2f, true).setName("sappiness", "lower");
sappinessLow = new AlleleFloat("sappinessLow", 0.3f, true).setName("sappiness", "low");
sappinessAverage = new AlleleFloat("sappinessAverage", 0.4f, true).setName("sappiness", "average");
sappinessHigh = new AlleleFloat("sappinessHigh", 0.6f, true).setName("sappiness", "high");
sappinessHigher = new AlleleFloat("sappinessHigher", 0.8f, false).setName("sappiness", "higher");
sappinessHighest = new AlleleFloat("sappinessHighest", 1.0f, false).setName("sappiness", "highest");
// TREES // MATURATION TIME
maturationSlowest = new AlleleInteger("maturationSlowest", 10, true).setName("gui.slowest");
maturationSlower = new AlleleInteger("maturationSlower", 7).setName("gui.slower");
maturationSlow = new AlleleInteger("maturationSlow", 5, true).setName("gui.slow");
maturationAverage = new AlleleInteger("maturationAverage", 4).setName("gui.average");
maturationFast = new AlleleInteger("maturationFast", 3).setName("gui.fast");
maturationFaster = new AlleleInteger("maturationFaster", 2).setName("gui.faster");
maturationFastest = new AlleleInteger("maturationFastest", 1).setName("gui.fastest");
maturationSlowest = new AlleleInteger("maturationSlowest", 10, true).setName("maturity", "slowest");
maturationSlower = new AlleleInteger("maturationSlower", 7).setName("maturity", "slower");
maturationSlow = new AlleleInteger("maturationSlow", 5, true).setName("maturity", "slow");
maturationAverage = new AlleleInteger("maturationAverage", 4).setName("maturity", "average");
maturationFast = new AlleleInteger("maturationFast", 3).setName("maturity", "fast");
maturationFaster = new AlleleInteger("maturationFaster", 2).setName("maturity", "faster");
maturationFastest = new AlleleInteger("maturationFastest", 1).setName("maturity", "fastest");
// BEES // FLOWER GROWTH
floweringSlowest = new AlleleInteger("floweringSlowest", 5, true).setName("gui.slowest");
floweringSlower = new AlleleInteger("floweringSlower", 10).setName("gui.slower");
floweringSlow = new AlleleInteger("floweringSlow", 15).setName("gui.slow");
floweringAverage = new AlleleInteger("floweringAverage", 20).setName("gui.average");
floweringFast = new AlleleInteger("floweringFast", 25).setName("gui.fast");
floweringFaster = new AlleleInteger("floweringFaster", 30).setName("gui.faster");
floweringFastest = new AlleleInteger("floweringFastest", 35).setName("gui.fastest");
floweringMaximum = new AlleleInteger("floweringMaximum", 99, true).setName("gui.maximum");
floweringSlowest = new AlleleInteger("floweringSlowest", 5, true).setName("flowering", "slowest");
floweringSlower = new AlleleInteger("floweringSlower", 10).setName("flowering", "slower");
floweringSlow = new AlleleInteger("floweringSlow", 15).setName("flowering", "slow");
floweringAverage = new AlleleInteger("floweringAverage", 20).setName("flowering", "average");
floweringFast = new AlleleInteger("floweringFast", 25).setName("flowering", "fast");
floweringFaster = new AlleleInteger("floweringFaster", 30).setName("flowering", "faster");
floweringFastest = new AlleleInteger("floweringFastest", 35).setName("flowering", "fastest");
floweringMaximum = new AlleleInteger("floweringMaximum", 99, true).setName("flowering", "maximum");
// BOTH // TERRITORY
territoryDefault = new AlleleArea("territoryDefault", new int[] {9, 6, 9}).setName("gui.average");
territoryLarge = new AlleleArea("territoryLarge", new int[] {11, 8, 11}).setName("gui.large");
territoryLarger = new AlleleArea("territoryLarger", new int[] {13, 12, 13}).setName("gui.larger");
territoryLargest = new AlleleArea("territoryLargest", new int[] {15, 13, 15}).setName("gui.largest");
territoryDefault = new AlleleArea("territoryDefault", new int[] {9, 6, 9}).setName("territory", "average");
territoryLarge = new AlleleArea("territoryLarge", new int[] {11, 8, 11}).setName("territory", "large");
territoryLarger = new AlleleArea("territoryLarger", new int[] {13, 12, 13}).setName("territory", "larger");
territoryLargest = new AlleleArea("territoryLargest", new int[] {15, 13, 15}).setName("territory", "largest");
// TREES // PLANTS
plantTypeNone = new AllelePlantType("plantTypeNone", EnumSet.noneOf(EnumPlantType.class), true);
plantTypePlains = new AllelePlantType("plantTypePlains", EnumPlantType.Plains);
;
plantTypeDesert = new AllelePlantType("plantTypeDesert", EnumPlantType.Desert);
plantTypeBeach = new AllelePlantType("plantTypeBeach", EnumPlantType.Beach);
plantTypeCave = new AllelePlantType("plantTypeCave", EnumPlantType.Cave);
@@ -550,6 +554,9 @@ public class Allele implements IAllele {
plantTypeNether = new AllelePlantType("plantTypeNether", EnumPlantType.Nether);
plantTypeCrop = new AllelePlantType("plantTypeCrop", EnumPlantType.Crop);
fireproofFalse = new AlleleBoolean("fireproofFalse", false);
fireproofTrue = new AlleleBoolean("fireproofTrue", true);
// LEGACY MAPPINGS
ILegacyHandler legacy = (ILegacyHandler) AlleleManager.alleleRegistry;
@@ -688,7 +695,7 @@ public class Allele implements IAllele {
@Override
public String getName() {
return StringUtil.localize(name);
return StringUtil.localize(getUnlocalizedName());
}
@Override
@@ -11,6 +11,7 @@
package forestry.core.genetics;
import forestry.api.genetics.IAlleleArea;
import forestry.core.utils.StringUtil;
import forestry.core.utils.Vect;
public class AlleleArea extends Allele implements IAlleleArea {
@@ -34,4 +35,13 @@ public class AlleleArea extends Allele implements IAlleleArea {
return new Vect(area);
}
public AlleleArea setName(String customPrefix, String name) {
String customName = "gui." + customPrefix + "." + name;
if (StringUtil.canTranslate(customName))
this.name = customName;
else
this.name = "gui." + name;
return this;
}
}
@@ -11,6 +11,7 @@
package forestry.core.genetics;
import forestry.api.genetics.IAlleleFloat;
import forestry.core.utils.StringUtil;
public class AlleleFloat extends Allele implements IAlleleFloat {
@@ -30,4 +31,12 @@ public class AlleleFloat extends Allele implements IAlleleFloat {
return value;
}
public AlleleFloat setName(String customPrefix, String name) {
String customName = "gui." + customPrefix + "." + name;
if (StringUtil.canTranslate(customName))
this.name = customName;
else
this.name = "gui." + name;
return this;
}
}
@@ -11,6 +11,7 @@
package forestry.core.genetics;
import forestry.api.genetics.IAlleleInteger;
import forestry.core.utils.StringUtil;
public class AlleleInteger extends Allele implements IAlleleInteger {
@@ -30,4 +31,13 @@ public class AlleleInteger extends Allele implements IAlleleInteger {
return value;
}
public AlleleInteger setName(String customPrefix, String name) {
String customName = "gui." + customPrefix + "." + name;
if (StringUtil.canTranslate(customName))
this.name = customName;
else
this.name = "gui." + name;
return this;
}
}
@@ -14,7 +14,6 @@ import java.util.Collection;
import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
@@ -36,7 +35,6 @@ import forestry.core.utils.StringUtil;
public abstract class AlleleSpecies extends Allele implements IAlleleSpecies {
private final String name;
private final String binomial;
private String description = null;
private int complexity = 3;
@@ -58,16 +56,6 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpecies {
AlleleManager.alleleRegistry.registerAllele(this);
}
@Override
public String getName() {
return StringUtil.localize(name);
}
@Override
public String getUnlocalizedName() {
return name;
}
@Override
public String getDescription() {
return description;
@@ -30,44 +30,43 @@ public class AlleleTolerance extends Allele implements IAlleleTolerance {
public EnumTolerance getValue() {
return value;
}
public String getName() {
public String getUnlocalizedName() {
switch(value) {
case BOTH_1:
return StringUtil.localize("gui.beealyzer.tolerance.both1");
case BOTH_2:
return StringUtil.localize("gui.beealyzer.tolerance.both2");
case BOTH_3:
return StringUtil.localize("gui.beealyzer.tolerance.both3");
case BOTH_4:
return StringUtil.localize("gui.beealyzer.tolerance.both4");
case BOTH_5:
return StringUtil.localize("gui.beealyzer.tolerance.both5");
case DOWN_1:
return StringUtil.localize("gui.beealyzer.tolerance.down1");
case DOWN_2:
return StringUtil.localize("gui.beealyzer.tolerance.down2");
case DOWN_3:
return StringUtil.localize("gui.beealyzer.tolerance.down3");
case DOWN_4:
return StringUtil.localize("gui.beealyzer.tolerance.down4");
case DOWN_5:
return StringUtil.localize("gui.beealyzer.tolerance.down5");
case NONE:
return StringUtil.localize("gui.beealyzer.tolerance.none");
case UP_1:
return StringUtil.localize("gui.beealyzer.tolerance.up1");
case UP_2:
return StringUtil.localize("gui.beealyzer.tolerance.up2");
case UP_3:
return StringUtil.localize("gui.beealyzer.tolerance.up3");
case UP_4:
return StringUtil.localize("gui.beealyzer.tolerance.up4");
case UP_5:
return StringUtil.localize("gui.beealyzer.tolerance.up5");
default:
return "";
case BOTH_1:
return "gui.beealyzer.tolerance.both1";
case BOTH_2:
return "gui.beealyzer.tolerance.both2";
case BOTH_3:
return "gui.beealyzer.tolerance.both3";
case BOTH_4:
return "gui.beealyzer.tolerance.both4";
case BOTH_5:
return "gui.beealyzer.tolerance.both5";
case DOWN_1:
return "gui.beealyzer.tolerance.down1";
case DOWN_2:
return "gui.beealyzer.tolerance.down2";
case DOWN_3:
return "gui.beealyzer.tolerance.down3";
case DOWN_4:
return "gui.beealyzer.tolerance.down4";
case DOWN_5:
return "gui.beealyzer.tolerance.down5";
case NONE:
return "gui.beealyzer.tolerance.none";
case UP_1:
return "gui.beealyzer.tolerance.up1";
case UP_2:
return "gui.beealyzer.tolerance.up2";
case UP_3:
return "gui.beealyzer.tolerance.up3";
case UP_4:
return "gui.beealyzer.tolerance.up4";
case UP_5:
return "gui.beealyzer.tolerance.up5";
default:
return "";
}
}
@@ -10,14 +10,18 @@
******************************************************************************/
package forestry.core.genetics;
import forestry.api.arboriculture.EnumTreeChromosome;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IChromosomeType;
import forestry.api.genetics.IGenome;
import forestry.apiculture.items.ItemBeeGE;
import forestry.core.config.Config;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IChromosome;
import forestry.api.genetics.IGenome;
import forestry.core.config.Config;
public abstract class Genome implements IGenome {
private static final String SLOT_TAG = "Slot";
@@ -40,6 +44,38 @@ public abstract class Genome implements IGenome {
this.chromosomes = chromosomes;
}
// NBT RETRIEVAL
public static Chromosome getChromosome(ItemStack itemStack, IChromosomeType chromosomeType) {
NBTTagCompound nbtTagCompound = itemStack.getTagCompound();
if (nbtTagCompound == null)
return null;
NBTTagCompound genome = nbtTagCompound.getCompoundTag("Genome");
if (genome == null)
return null;
NBTTagList chromosomes = genome.getTagList("Chromosomes", 10);
if (chromosomes == null)
return null;
for (int i = 0; i < chromosomes.tagCount(); i++) {
NBTTagCompound chromosomeTag = chromosomes.getCompoundTagAt(i);
byte byte0 = chromosomeTag.getByte(SLOT_TAG);
if (byte0 == chromosomeType.ordinal()) {
return Chromosome.loadChromosomeFromNBT(chromosomeTag);
}
}
return null;
}
public static IAllele getPrimaryAllele(ItemStack itemStack, IChromosomeType chromosomeType) {
Chromosome chromosome = getChromosome(itemStack, chromosomeType);
if (chromosome == null)
return null;
return chromosome.getPrimaryAllele();
}
// / SAVING & LOADING
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
@@ -61,6 +97,17 @@ public abstract class Genome implements IGenome {
throw new RuntimeException("Found Chromosome with invalid Alleles. See config option \"genetics.clear.invalid.chromosomes\".");
}
}
// handle old saves that have missing chromosomes
IChromosome speciesChromosome = chromosomes[EnumTreeChromosome.SPECIES.ordinal()];
if (speciesChromosome != null) {
IAlleleSpecies species = (IAlleleSpecies)speciesChromosome.getActiveAllele();
IAllele[] template = getSpeciesRoot().getTemplate(species.getUID());
for (int i = 0; i < chromosomes.length; i++) {
if ((chromosomes[i] == null) && (template[i] != null))
chromosomes[i] = new Chromosome(template[i]);
}
}
}
@Override
@@ -39,6 +39,8 @@ public abstract class ItemGE extends Item {
protected abstract IIndividual getIndividual(ItemStack itemstack);
protected abstract IAlleleSpecies getSpecies(ItemStack itemStack);
@Override
public boolean isDamageable() {
return false;
@@ -56,11 +58,8 @@ public abstract class ItemGE extends Item {
@Override
public boolean hasEffect(ItemStack itemstack, int pass) {
if (!itemstack.hasTagCompound())
return false;
IIndividual individual = getIndividual(itemstack);
return individual.hasEffect();
IAlleleSpecies species = getSpecies(itemstack);
return species != null && species.hasEffect();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@@ -235,7 +235,12 @@ public class ItemResearchNote extends ItemForestry {
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
ResearchNote note = new ResearchNote(itemstack.getTagCompound());
return StringUtil.localizeAndFormatRaw(getUnlocalizedName(itemstack) + ".name", note.researcher.getName());
String researcherName;
if (note.researcher == null)
researcherName = "Sengir";
else
researcherName = note.researcher.getName();
return StringUtil.localizeAndFormatRaw(getUnlocalizedName(itemstack) + ".name", researcherName);
}
@SuppressWarnings({"unchecked", "rawtypes"})
Loaded 100 of 982 files, more files were not shown because too many files have changed in this diff. Show more