Close #477 Auto-Format code with new formatting settings

This commit is contained in:
mezz committed 2015-01-26 22:26:21 -08:00
1 parent 8e92d16320
commit 5b8b0c78b0
763 files changed
+13174 -8868

No files matched your search

+17 -13
View File
@@ -4,12 +4,19 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
@@ -22,6 +29,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.Type;
import forestry.api.fuels.EngineBronzeFuel;
import forestry.api.fuels.EngineCopperFuel;
import forestry.api.fuels.FermenterFuel;
@@ -38,12 +46,6 @@ import forestry.core.proxy.Proxies;
import forestry.core.utils.FluidMap;
import forestry.core.utils.ItemStackMap;
import forestry.core.utils.StringUtil;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
/**
* Forestry Minecraft Mod
@@ -55,11 +57,11 @@ import net.minecraft.item.Item;
name = "Forestry",
version = Version.VERSION,
dependencies = "required-after:Forge@[10.13.0.1207,);"
+ "after:Buildcraft|Core@[6.1.7,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.0.140,);"
+ "before:UndergroundBiomes")
+ "after:Buildcraft|Core@[6.1.7,);"
+ "after:ExtrabiomesXL;"
+ "after:BiomesOPlenty;"
+ "after:IC2@[2.0.140,);"
+ "before:UndergroundBiomes")
//, certificateFingerprint = Version.FINGERPRINT)
public class Forestry {
@@ -91,6 +93,7 @@ public class Forestry {
FuelManager.copperEngineFuel = new ItemStackMap<EngineCopperFuel>();
FuelManager.generatorFuel = new FluidMap<GeneratorFuel>();
}
@SidedProxy(clientSide = "forestry.core.ForestryClient", serverSide = "forestry.core.ForestryCore")
public static ForestryCore core = new ForestryCore();
public static PacketHandler packetHandler;
@@ -137,7 +140,7 @@ public class Forestry {
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
for (MissingMapping mapping : event.get())
for (MissingMapping mapping : event.get()) {
if (mapping.type == Type.BLOCK) {
Block block = GameRegistry.findBlock(Defaults.MOD, StringUtil.cleanTags(mapping.name));
if (block != null) {
@@ -157,5 +160,6 @@ public class Forestry {
}
}
}
}
}
}
@@ -4,12 +4,18 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import java.util.Stack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.apiculture.IBee;
@@ -23,10 +29,6 @@ import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
import java.util.Stack;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class BeekeepingLogic implements IBeekeepingLogic {
@@ -295,14 +297,17 @@ public class BeekeepingLogic implements IBeekeepingLogic {
return;
}
if (breedingTime < totalBreedingTime)
if (breedingTime < totalBreedingTime) {
breedingTime++;
if (breedingTime < totalBreedingTime)
}
if (breedingTime < totalBreedingTime) {
return;
}
// Breeding done, create new queen if slot available
if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen()))
if (!ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
return;
}
// Replace
IBee princess = PluginApiculture.beeInterface.getMember(housing.getQueen());
@@ -322,22 +327,26 @@ public class BeekeepingLogic implements IBeekeepingLogic {
// Remove drone
housing.getDrone().stackSize--;
if (housing.getDrone().stackSize <= 0)
if (housing.getDrone().stackSize <= 0) {
housing.setDrone(null);
}
// Reset breeding time
breedingTime = 0;
}
private boolean tryBreed() {
if (housing.getDrone() == null || housing.getQueen() == null)
if (housing.getDrone() == null || housing.getQueen() == null) {
return false;
}
if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen()))
if (!ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()) || !ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
return false;
}
if (!housing.canBreed())
if (!housing.canBreed()) {
return false;
}
return true;
}
@@ -389,8 +398,9 @@ public class BeekeepingLogic implements IBeekeepingLogic {
while (!offspring.isEmpty()) {
ItemStack spawned = offspring.pop();
if (!housing.addProduct(spawned, true))
if (!housing.addProduct(spawned, true)) {
spawn.add(spawned);
}
}
housing.onPostQueenDeath(getQueen());
@@ -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
******************************************************************************/
@@ -51,56 +51,60 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
int cleanId = decodeGuiID(id);
int guiData = decodeGuiData(id);
if (cleanId >= GuiId.values().length)
if (cleanId >= GuiId.values().length) {
return null;
}
ItemStack equipped;
switch (GuiId.values()[cleanId]) {
case AlvearyGUI:
return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearyGUI:
return new GuiAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new GuiAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new GuiAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case ApiaristChestGUI:
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaristChestGUI:
return getNaturalistChestGui(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaryGUI:
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
case ApiaryGUI:
return new GuiApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z));
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
case BeehouseGUI:
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new GuiHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
case HygroregulatorGUI:
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
return new GuiBeealyzer(player, new BeealyzerInventory(player, equipped));
case BeehouseGUI:
return new GuiApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z));
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new GuiHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
case HygroregulatorGUI:
return new GuiAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new GuiImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
}
}
@@ -109,61 +113,65 @@ public class GuiHandlerApiculture extends GuiHandlerBase {
int cleanId = decodeGuiID(id);
int guiData = decodeGuiData(id);
if (cleanId >= GuiId.values().length)
if (cleanId >= GuiId.values().length) {
return null;
}
ItemStack equipped;
switch (GuiId.values()[cleanId]) {
case AlvearyGUI:
synchApiaristTracker(world, player);
return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearyGUI:
synchApiaristTracker(world, player);
return new ContainerAlveary(player.inventory, (TileAlvearyPlain) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySieveGUI:
return new ContainerAlvearySieve(player.inventory, (TileAlvearySieve) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case AlvearySwarmerGUI:
return new ContainerAlvearySwarmer(player.inventory, (TileAlvearySwarmer) getTileForestry(world, x, y, z));
case ApiaristChestGUI:
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaristChestGUI:
return getNaturalistChestContainer(BeeHelper.UID, player, world, x, y, z, guiData);
case ApiaryGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
case ApiaryGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileApiary) getTileForestry(world, x, y, z), true);
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
case BeealyzerGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
synchApiaristTracker(world, player);
return new ContainerAlyzer(new BeealyzerInventory(player, equipped), player);
case BeehouseGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false);
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new ContainerHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
case HygroregulatorGUI:
return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
synchApiaristTracker(world, player);
equipped = player.getCurrentEquippedItem();
if (equipped == null) {
return null;
}
return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
synchApiaristTracker(world, player);
return new ContainerAlyzer(new BeealyzerInventory(player, equipped), player);
case BeehouseGUI:
synchApiaristTracker(world, player);
return new ContainerApiary(player.inventory, (TileBeehouse) getTileForestry(world, x, y, z), false);
case HabitatLocatorGUI:
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new ContainerHabitatLocator(player.inventory, new HabitatLocatorInventory(equipped));
case HygroregulatorGUI:
return new ContainerAlvearyHygroregulator(player.inventory, (TileAlvearyHygroregulator) getTileForestry(world, x, y, z));
case ImprinterGUI:
synchApiaristTracker(world, player);
equipped = player.getCurrentEquippedItem();
if (equipped == null)
return null;
return new ContainerImprinter(player.inventory, new ImprinterInventory(player, equipped));
default:
return null;
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -17,8 +17,9 @@ public class MaterialBeehive extends Material {
public MaterialBeehive(boolean noHarvest) {
super(MapColor.stoneColor);
if (noHarvest)
if (noHarvest) {
this.setRequiresTool();
}
setImmovableMobility();
}
@@ -4,19 +4,21 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import java.io.DataInputStream;
import net.minecraft.entity.player.EntityPlayer;
import forestry.apiculture.gui.ContainerImprinter;
import forestry.core.interfaces.IPacketHandler;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketIds;
import forestry.core.proxy.Proxies;
import java.io.DataInputStream;
import net.minecraft.entity.player.EntityPlayer;
public class PacketHandlerApiculture implements IPacketHandler {
@@ -26,14 +28,14 @@ public class PacketHandlerApiculture implements IPacketHandler {
try {
switch (packetID) {
case PacketIds.HABITAT_BIOME_POINTER:
PacketCoordinates packetC = new PacketCoordinates();
packetC.readData(data);
Proxies.common.setHabitatLocatorCoordinates(player, packetC.getCoordinates());
break;
case PacketIds.IMPRINT_SELECTION_GET:
onImprintSelectionGet(player);
break;
case PacketIds.HABITAT_BIOME_POINTER:
PacketCoordinates packetC = new PacketCoordinates();
packetC.readData(data);
Proxies.common.setHabitatLocatorCoordinates(player, packetC.getCoordinates());
break;
case PacketIds.IMPRINT_SELECTION_GET:
onImprintSelectionGet(player);
break;
}
} catch (Exception ex) {
ex.printStackTrace();
@@ -42,8 +44,9 @@ public class PacketHandlerApiculture implements IPacketHandler {
private void onImprintSelectionGet(EntityPlayer playerEntity) {
if (!(playerEntity.openContainer instanceof ContainerImprinter))
if (!(playerEntity.openContainer instanceof ContainerImprinter)) {
return;
}
((ContainerImprinter) playerEntity.openContainer).sendSelection(playerEntity);
@@ -4,15 +4,16 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import net.minecraft.world.World;
import forestry.core.interfaces.ISaveEventHandler;
import forestry.plugins.PluginApiculture;
import net.minecraft.world.World;
public class SaveEventHandlerApiculture implements ISaveEventHandler {
@@ -4,25 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
import forestry.api.apiculture.EnumBeeType;
import forestry.apiculture.genetics.BeeTemplates;
import forestry.apiculture.items.ItemHoneycomb;
import forestry.apiculture.worldgen.ComponentVillageBeeHouse;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@@ -33,6 +23,19 @@ import net.minecraft.village.MerchantRecipeList;
import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraft.world.gen.structure.StructureVillagePieces;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageCreationHandler;
import cpw.mods.fml.common.registry.VillagerRegistry.IVillageTradeHandler;
import forestry.api.apiculture.EnumBeeType;
import forestry.apiculture.genetics.BeeTemplates;
import forestry.apiculture.items.ItemHoneycomb;
import forestry.apiculture.worldgen.ComponentVillageBeeHouse;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginApiculture;
public class VillageHandlerApiculture implements IVillageCreationHandler, IVillageTradeHandler {
public static void registerVillageComponents() {
@@ -10,12 +10,14 @@
******************************************************************************/
package forestry.apiculture.commands;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeekeepingMode;
import forestry.core.commands.ICommandModeHelper;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.world.World;
public class BeeModeHelper implements ICommandModeHelper {
@@ -24,8 +26,9 @@ public class BeeModeHelper implements ICommandModeHelper {
ArrayList<IBeekeepingMode> beekeepingModes = PluginApiculture.beeInterface.getBeekeepingModes();
int modeStringCount = beekeepingModes.size();
List<String> modeStrings = new ArrayList<String>(modeStringCount);
for (IBeekeepingMode mode : beekeepingModes)
for (IBeekeepingMode mode : beekeepingModes) {
modeStrings.add(mode.getName());
}
return modeStrings.toArray(new String[modeStringCount]);
}
@@ -33,8 +36,9 @@ public class BeeModeHelper implements ICommandModeHelper {
@Override
public String getModeNameMatching(String desired) {
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired);
if (mode == null)
if (mode == null) {
return null;
}
return mode.getName();
}
@@ -10,7 +10,14 @@
******************************************************************************/
package forestry.apiculture.commands;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.genetics.AlleleManager;
@@ -20,10 +27,6 @@ import forestry.api.genetics.IBreedingTracker;
import forestry.core.commands.IStatsSaveHelper;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.Collection;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
public class BeeStatsSaveHelper implements IStatsSaveHelper {
@@ -34,7 +37,7 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper {
@Override
public void addExtraInfo(Collection<String> statistics, IBreedingTracker breedingTracker) {
IApiaristTracker tracker = (IApiaristTracker)breedingTracker;
IApiaristTracker tracker = (IApiaristTracker) breedingTracker;
String discoveredLine = StatCollector.translateToLocal("for.chat.command.forestry.stats.save.key.discovered") + ":";
statistics.add(discoveredLine);
statistics.add(StringUtil.line(discoveredLine.length()));
@@ -51,9 +54,11 @@ public class BeeStatsSaveHelper implements IStatsSaveHelper {
@Override
public Collection<IAlleleSpecies> getSpecies() {
Collection<IAlleleSpecies> species = new ArrayList<IAlleleSpecies>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies) {
species.add((IAlleleBeeSpecies) allele);
}
}
return species;
}
@@ -4,12 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.commands;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
@@ -21,12 +29,6 @@ import forestry.core.commands.SpeciesNotFoundException;
import forestry.core.commands.SubCommand;
import forestry.core.commands.TemplateNotFoundException;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class CommandBeeGive extends SubCommand {
@@ -39,8 +41,9 @@ public class CommandBeeGive extends SubCommand {
List<String> beeTypeStrings = new ArrayList<String>();
for (EnumBeeType type : EnumBeeType.values()) {
if (type == EnumBeeType.NONE)
if (type == EnumBeeType.NONE) {
continue;
}
beeTypeStrings.add(type.getName());
}
@@ -52,8 +55,9 @@ public class CommandBeeGive extends SubCommand {
Iterator<String> iter = beeTypeStrings.iterator();
while (iter.hasNext()) {
beeTypeHelp.append(iter.next());
if (iter.hasNext())
if (iter.hasNext()) {
beeTypeHelp.append(separator);
}
}
beeTypeHelpString = beeTypeHelp.toString();
}
@@ -85,8 +89,9 @@ public class CommandBeeGive extends SubCommand {
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, beeGenome);
if(beeType == EnumBeeType.QUEEN)
if (beeType == EnumBeeType.QUEEN) {
bee.mate(bee);
}
ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal());
player.dropPlayerItemWithRandomChoice(beeStack, true);
@@ -99,8 +104,9 @@ public class CommandBeeGive extends SubCommand {
for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
if (!uid.equals(speciesName))
if (!uid.equals(speciesName)) {
continue;
}
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid);
@@ -117,13 +123,15 @@ public class CommandBeeGive extends SubCommand {
}
}
if (species == null)
if (species == null) {
throw new SpeciesNotFoundException(speciesName);
}
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
if (template == null)
if (template == null) {
throw new TemplateNotFoundException(species);
}
return PluginApiculture.beeInterface.templateAsGenome(template);
}
@@ -145,17 +153,20 @@ public class CommandBeeGive extends SubCommand {
String[] getSpecies() {
List<String> species = new ArrayList<String>();
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies) {
species.add(allele.getName());
}
}
return species.toArray(new String[species.size()]);
}
EnumBeeType getBeeType(String beeTypeName) {
for (EnumBeeType beeType : EnumBeeType.values()) {
if (beeType.getName().equalsIgnoreCase(beeTypeName))
if (beeType.getName().equalsIgnoreCase(beeTypeName)) {
return beeType;
}
}
return EnumBeeType.NONE;
}
@@ -10,18 +10,20 @@
******************************************************************************/
package forestry.apiculture.entities;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBee;
import forestry.core.config.Defaults;
import forestry.core.utils.ForestryResource;
import forestry.plugins.PluginApiculture;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class EntityBee extends EntityCreature implements IAnimals {
@@ -43,10 +45,11 @@ public class EntityBee extends EntityCreature implements IAnimals {
}
public EntityBee setIndividual(IBee bee) {
if (bee != null)
if (bee != null) {
contained = bee;
else
} else {
contained = PluginApiculture.beeInterface.templateAsIndividual(PluginApiculture.beeInterface.getDefaultTemplate());
}
//isImmuneToFire = contained.getGenome().getFireResist();
setSpecies(contained.getGenome().getPrimary());
@@ -81,8 +84,9 @@ public class EntityBee extends EntityCreature implements IAnimals {
@SideOnly(Side.CLIENT)
public ResourceLocation getTexture() {
if (textureResource == null || lastTextureUpdate != lastUpdate)
if (textureResource == null || lastTextureUpdate != lastUpdate) {
textureResource = new ForestryResource(beeTexture);
}
return textureResource;
}
@@ -32,8 +32,9 @@ final class Flower implements IFlower {
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Flower))
if (!(obj instanceof Flower)) {
return false;
}
Flower flower = (Flower) obj;
@@ -15,7 +15,9 @@ import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlower;
import forestry.api.genetics.IFlowerProvider;
@@ -41,7 +41,7 @@ public final class FlowerRegistry implements IFlowerRegistry {
public FlowerRegistry() {
this.registeredFlowers = ArrayListMultimap.create();
this.growthRules = ArrayListMultimap.create();
this.chances = new HashMap<String, TreeMap<Double, IFlower>>();
this.chances = new HashMap<String, TreeMap<Double, IFlower>>();
this.hasDeprecatedFlowersImported = false;
@@ -60,14 +60,18 @@ public final class FlowerRegistry implements IFlowerRegistry {
}
private void registerFlower(Block block, int meta, Double weight, String... flowerTypes) {
if (block == null)
if (block == null) {
return;
if (meta == Short.MAX_VALUE || meta == -1)
}
if (meta == Short.MAX_VALUE || meta == -1) {
return;
if (weight == null || weight <= 0.0)
}
if (weight == null || weight <= 0.0) {
weight = 0.0;
if (weight >= 1.0)
}
if (weight >= 1.0) {
weight = 1.0;
}
Flower newFlower = new Flower(block, meta, weight);
Integer index;
@@ -78,8 +82,7 @@ public final class FlowerRegistry implements IFlowerRegistry {
index = flowers.indexOf(newFlower);
if (index == -1) {
flowers.add(newFlower);
}
else if (flowers.get(index).getWeight() > newFlower.getWeight()) {
} else if (flowers.get(index).getWeight() > newFlower.getWeight()) {
flowers.get(index).setWeight(newFlower.getWeight());
}
@@ -94,18 +97,22 @@ public final class FlowerRegistry implements IFlowerRegistry {
@Override
public boolean isAcceptedFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
internalInitialize();
if (!this.registeredFlowers.containsKey(flowerType))
if (!this.registeredFlowers.containsKey(flowerType)) {
return false;
}
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (world.isAirBlock(x, y, z) || block.equals(Blocks.bedrock) || block.equals(Blocks.dirt) || block.equals(Blocks.grass))
if (world.isAirBlock(x, y, z) || block.equals(Blocks.bedrock) || block.equals(Blocks.dirt) || block.equals(Blocks.grass)) {
return false;
}
for (IFlower flower : this.registeredFlowers.get(flowerType))
if (Block.isEqualTo(flower.getBlock(), block) && flower.getMeta() == meta)
for (IFlower flower : this.registeredFlowers.get(flowerType)) {
if (Block.isEqualTo(flower.getBlock(), block) && flower.getMeta() == meta) {
return true;
}
}
return false;
}
@@ -113,12 +120,15 @@ public final class FlowerRegistry implements IFlowerRegistry {
@Override
public boolean growFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
internalInitialize();
if (!this.growthRules.containsKey(flowerType))
if (!this.growthRules.containsKey(flowerType)) {
return false;
}
for (IFlowerGrowthRule rule : this.growthRules.get(flowerType))
if (rule.growFlower(this, flowerType, world, individual, x, y, z))
for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) {
if (rule.growFlower(this, flowerType, world, individual, x, y, z)) {
return true;
}
}
return false;
}
@@ -132,8 +142,9 @@ public final class FlowerRegistry implements IFlowerRegistry {
@Override
public void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes) {
if (rule == null)
if (rule == null) {
return;
}
for (String flowerType : flowerTypes) {
this.growthRules.get(flowerType).add(rule);
@@ -11,6 +11,7 @@
package forestry.apiculture.flowers;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
@@ -24,12 +24,14 @@ public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (!world.isAirBlock(x, y, z))
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass)
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
IFlower flower = flowerRegistry.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
@@ -15,6 +15,7 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
import forestry.api.genetics.IIndividual;
@@ -34,12 +35,14 @@ public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule {
for (Block b : this.allowedItems) {
if (b == ground) {
groundMeta = world.getBlockMetadata(x, y, z);
if (groundMeta > 6)
if (groundMeta > 6) {
return false;
if (groundMeta < 6)
}
if (groundMeta < 6) {
groundMeta += world.rand.nextInt(1) + 1;
else
} else {
groundMeta = 7;
}
return world.setBlockMetadataWithNotify(x, y, z, groundMeta, 2);
}
@@ -13,6 +13,7 @@ package forestry.apiculture.flowers;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import forestry.api.apiculture.FlowerManager;
import forestry.api.genetics.IFlowerGrowthRule;
import forestry.api.genetics.IFlowerRegistry;
@@ -25,8 +26,9 @@ public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule {
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
Block ground = world.getBlock(x, y, z);
int groundMeta = world.getBlockMetadata(x, y, z);
if (ground != Blocks.flower_pot && groundMeta != 0)
if (ground != Blocks.flower_pot && groundMeta != 0) {
return false;
}
if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) {
groundMeta = world.rand.nextInt(1) + 1;
@@ -24,12 +24,14 @@ public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (!world.isAirBlock(x, y, z))
if (!world.isAirBlock(x, y, z)) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.mycelium)
if (ground != Blocks.mycelium) {
return false;
}
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
@@ -24,12 +24,14 @@ public class VanillaSnowGrowthRule implements IFlowerGrowthRule {
@Override
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
if (world.getBlock(x, y, z) != Blocks.snow)
if (world.getBlock(x, y, z) != Blocks.snow) {
return false;
}
Block ground = world.getBlock(x, y - 1, z);
if (ground != Blocks.dirt && ground != Blocks.grass)
if (ground != Blocks.dirt && ground != Blocks.grass) {
return false;
}
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
@@ -4,20 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.core.gadgets.BlockStructure;
import forestry.core.render.TextureManager;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -28,6 +23,14 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.core.gadgets.BlockStructure;
import forestry.core.render.TextureManager;
public class BlockAlveary extends BlockStructure {
public BlockAlveary() {
@@ -36,13 +39,14 @@ public class BlockAlveary extends BlockStructure {
setCreativeTab(Tabs.tabApiculture);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 8; i++) {
if (i == 1)
if (i == 1) {
continue;
}
list.add(new ItemStack(item, 1, i));
}
}
@@ -74,20 +78,20 @@ public class BlockAlveary extends BlockStructure {
@Override
public TileEntity createTileEntity(World world, int metadata) {
switch (metadata) {
case TileAlvearySwarmer.BLOCK_META:
return new TileAlvearySwarmer();
case TileAlvearyFan.BLOCK_META:
return new TileAlvearyFan();
case TileAlvearyHeater.BLOCK_META:
return new TileAlvearyHeater();
case TileAlvearyHygroregulator.BLOCK_META:
return new TileAlvearyHygroregulator();
case TileAlvearyStabiliser.BLOCK_META:
return new TileAlvearyStabiliser();
case TileAlvearySieve.BLOCK_META:
return new TileAlvearySieve();
default:
return new TileAlvearyPlain();
case TileAlvearySwarmer.BLOCK_META:
return new TileAlvearySwarmer();
case TileAlvearyFan.BLOCK_META:
return new TileAlvearyFan();
case TileAlvearyHeater.BLOCK_META:
return new TileAlvearyHeater();
case TileAlvearyHygroregulator.BLOCK_META:
return new TileAlvearyHygroregulator();
case TileAlvearyStabiliser.BLOCK_META:
return new TileAlvearyStabiliser();
case TileAlvearySieve.BLOCK_META:
return new TileAlvearySieve();
default:
return new TileAlvearyPlain();
}
}
@@ -140,28 +144,29 @@ public class BlockAlveary extends BlockStructure {
public IIcon getIcon(int side, int metadata) {
if ((metadata <= 1
|| metadata == TileAlvearySieve.BLOCK_META || metadata == TileAlvearySwarmer.BLOCK_META || metadata == TileAlvearyStabiliser.BLOCK_META)
&& (side == 1 || side == 0))
&& (side == 1 || side == 0)) {
return icons[BOTTOM];
}
switch (metadata) {
case TileAlvearyPlain.BLOCK_META:
return icons[PLAIN];
case 1:
return icons[ENTRANCE];
case TileAlvearySwarmer.BLOCK_META:
return icons[ALVEARY_SWARMER_OFF];
case TileAlvearyFan.BLOCK_META:
return icons[ALVEARY_FAN_OFF];
case TileAlvearyHeater.BLOCK_META:
return icons[ALVEARY_HEATER_OFF];
case TileAlvearyHygroregulator.BLOCK_META:
return icons[ALVEARY_HYGRO];
case TileAlvearyStabiliser.BLOCK_META:
return icons[STABILISER];
case TileAlvearySieve.BLOCK_META:
return icons[SIEVE];
default:
return null;
case TileAlvearyPlain.BLOCK_META:
return icons[PLAIN];
case 1:
return icons[ENTRANCE];
case TileAlvearySwarmer.BLOCK_META:
return icons[ALVEARY_SWARMER_OFF];
case TileAlvearyFan.BLOCK_META:
return icons[ALVEARY_FAN_OFF];
case TileAlvearyHeater.BLOCK_META:
return icons[ALVEARY_HEATER_OFF];
case TileAlvearyHygroregulator.BLOCK_META:
return icons[ALVEARY_HYGRO];
case TileAlvearyStabiliser.BLOCK_META:
return icons[STABILISER];
case TileAlvearySieve.BLOCK_META:
return icons[SIEVE];
default:
return null;
}
}
@@ -171,10 +176,11 @@ public class BlockAlveary extends BlockStructure {
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int meta = world.getBlockMetadata(x, y, z);
if (meta == 1)
if (meta == 1) {
return this.getIcon(side, meta);
else if (meta > 1)
} else if (meta > 1) {
return getBlockTextureFromSideAndTile(world, x, y, z, side);
}
Block blockXP = world.getBlock(x + 1, y, z);
Block blockXM = world.getBlock(x - 1, y, z);
@@ -183,24 +189,29 @@ public class BlockAlveary extends BlockStructure {
if (world.getBlockMetadata(x + 1, y, z) == 1) {
if (world.getBlock(x, y, z + 1) != this)
if (world.getBlock(x, y, z + 1) != this) {
return switchForSide(42, side);
else
} else {
return switchForSide(41, side);
}
} else
} else {
return this.getIcon(side, meta);
}
} else if (blockXP != this && blockXM == this)
} else if (blockXP != this && blockXM == this) {
if (world.getBlockMetadata(x - 1, y, z) == 1) {
if (world.getBlock(x, y, z + 1) != this)
if (world.getBlock(x, y, z + 1) != this) {
return switchForSide(41, side);
else
} else {
return switchForSide(42, side);
}
} else
} else {
return this.getIcon(side, meta);
}
}
return this.getIcon(side, meta);
}
@@ -208,8 +219,9 @@ public class BlockAlveary extends BlockStructure {
@SideOnly(Side.CLIENT)
private IIcon getBlockTextureFromSideAndTile(IBlockAccess world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile == null || !(tile instanceof TileAlveary))
if (tile == null || !(tile instanceof TileAlveary)) {
return getIcon(side, 0);
}
return icons[((TileAlveary) tile).getIcon(side, world.getBlockMetadata(x, y, z))];
}
@@ -218,14 +230,16 @@ public class BlockAlveary extends BlockStructure {
private IIcon switchForSide(int textureId, int side) {
if (side == 4 || side == 5) {
if (textureId == 41)
if (textureId == 41) {
return icons[LEFT];
else
} else {
return icons[RIGHT];
} else if (textureId == 41)
}
} else if (textureId == 41) {
return icons[RIGHT];
else
} else {
return icons[LEFT];
}
}
}
@@ -4,27 +4,16 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.IHiveDrop;
import forestry.apiculture.worldgen.HiveRegistry;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.core.config.Config;
import forestry.core.inventory.InvTools;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.BlockContainer;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -37,6 +26,19 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.core.Tabs;
import forestry.apiculture.MaterialBeehive;
import forestry.apiculture.worldgen.HiveRegistry;
import forestry.core.config.Config;
import forestry.core.inventory.InvTools;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.plugins.PluginApiculture;
public class BlockBeehives extends BlockContainer {
public BlockBeehives() {
@@ -65,10 +67,13 @@ public class BlockBeehives extends BlockContainer {
if (tile instanceof TileSwarm) {
TileSwarm swarm = (TileSwarm) tile;
if (swarm.containsBees())
for (ItemStack beeStack : InvTools.getStacks(swarm.contained))
if (beeStack != null)
if (swarm.containsBees()) {
for (ItemStack beeStack : InvTools.getStacks(swarm.contained)) {
if (beeStack != null) {
StackUtils.dropItemStackAsEntity(beeStack, world, x, y, z);
}
}
}
}
}
@@ -94,26 +99,29 @@ public class BlockBeehives extends BlockContainer {
while (tries <= 10 && !hasPrincess) {
tries++;
for (IHiveDrop drop : dropList)
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.add(drop.getPrincess(world, x, y, z, fortune));
hasPrincess = true;
break;
}
}
}
// Grab drones
for (IHiveDrop drop : dropList)
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.addAll(drop.getDrones(world, x, y, z, fortune));
break;
}
}
// Grab anything else on offer
for (IHiveDrop drop : dropList)
for (IHiveDrop drop : dropList) {
if (world.rand.nextInt(100) < drop.getChance(world, x, y, z)) {
ret.addAll(drop.getAdditional(world, x, y, z, fortune));
break;
}
}
return ret;
}
@@ -126,25 +134,33 @@ public class BlockBeehives extends BlockContainer {
private List<IHiveDrop> getDropsForHive(int meta) {
String hiveName = getHiveNameForMeta(meta);
if (hiveName == null)
if (hiveName == null) {
return Collections.emptyList();
}
return PluginApiculture.hiveRegistry.getDrops(hiveName);
}
private String getHiveNameForMeta(int meta) {
switch (meta) {
case 1: return HiveRegistry.forest;
case 2: return HiveRegistry.meadows;
case 3: return HiveRegistry.desert;
case 4: return HiveRegistry.jungle;
case 5: return HiveRegistry.end;
case 6: return HiveRegistry.snow;
case 7: return HiveRegistry.swamp;
case 1:
return HiveRegistry.forest;
case 2:
return HiveRegistry.meadows;
case 3:
return HiveRegistry.desert;
case 4:
return HiveRegistry.jungle;
case 5:
return HiveRegistry.end;
case 6:
return HiveRegistry.snow;
case 7:
return HiveRegistry.swamp;
}
return null;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 1));
@@ -152,7 +168,7 @@ public class BlockBeehives extends BlockContainer {
itemList.add(new ItemStack(this, 1, 3));
itemList.add(new ItemStack(this, 1, 4));
if (Config.isDebug) {
itemList.add(new ItemStack(this, 1 ,5));
itemList.add(new ItemStack(this, 1, 5));
}
itemList.add(new ItemStack(this, 1, 6));
itemList.add(new ItemStack(this, 1, 7));
@@ -176,18 +192,21 @@ public class BlockBeehives extends BlockContainer {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j) {
if (j == 0 || j > 8)
if (j == 0 || j > 8) {
return null;
}
if (i == 0 || i == 1) {
if (j * 2 < icons.length && icons[j * 2] != null)
if (j * 2 < icons.length && icons[j * 2] != null) {
return icons[j * 2];
else
} else {
return icons[2];
} else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null)
}
} else if (j * 2 + 1 < icons.length && icons[j * 2 + 1] != null) {
return icons[j * 2 + 1];
else
} else {
return icons[3];
}
}
}
@@ -4,23 +4,16 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.core.ForestryClient;
import forestry.core.config.Defaults;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -36,9 +29,20 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.core.ForestryClient;
import forestry.core.config.Defaults;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
public class BlockCandle extends BlockTorch {
private final ArrayList<Item> lightingItems = new ArrayList<Item>();
@@ -92,7 +96,7 @@ public class BlockCandle extends BlockTorch {
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return (isLit(meta))? 14 : 0;
return (isLit(meta)) ? 14 : 0;
}
/*@SideOnly(Side.CLIENT)
@@ -111,16 +115,13 @@ public class BlockCandle extends BlockTorch {
if (pass == 0) {
if (isLit(meta)) {
i = this.litTip;
}
else {
} else {
i = this.unlitTip;
}
}
else {
} else {
if (isLit(meta)) {
i = this.litStump;
}
else {
} else {
i = this.unlitStump;
}
}
@@ -136,22 +137,22 @@ public class BlockCandle extends BlockTorch {
return colour;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 0));
}
// Dye names correspond to colour values as below.
private static final String[] dyes = { "dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue",
"dyeYellow", "dyeLime", "dyePink", "dyeGray",
"dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue",
"dyeBrown", "dyeGreen", "dyeRed", "dyeBlack" };
private static final String[] dyes = {"dyeWhite", "dyeOrange", "dyeMagenta", "dyeLightBlue",
"dyeYellow", "dyeLime", "dyePink", "dyeGray",
"dyeLightGray", "dyeCyan", "dyePurple", "dyeBlue",
"dyeBrown", "dyeGreen", "dyeRed", "dyeBlack"};
private static final int[][] colours = { { 255, 255, 255 } , { 219, 125, 62 } , { 255, 20, 255 } , { 107, 138, 201 } ,
{ 255, 255, 20 } , { 20, 255, 20 } , { 208, 132, 153 } , { 74, 74, 74 } ,
{ 154, 161, 161 } , { 20, 255, 255 } , { 126, 61, 181 } , { 20, 20, 255 } ,
{ 79, 50, 31 } , { 53, 70, 27 } , { 150, 52, 48 } , { 20, 20, 20 } };
private static final int[][] colours = {{255, 255, 255}, {219, 125, 62}, {255, 20, 255}, {107, 138, 201},
{255, 255, 20}, {20, 255, 20}, {208, 132, 153}, {74, 74, 74},
{154, 161, 161}, {20, 255, 255}, {126, 61, 181}, {20, 20, 255},
{79, 50, 31}, {53, 70, 27}, {150, 52, 48}, {20, 20, 20}};
public static final String colourTagName = "colour";
@@ -165,18 +166,17 @@ public class BlockCandle extends BlockTorch {
if (!isLit(meta)) {
if (held == null || !lightingItems.contains(held.getItem())) {
toggleLitState = false;
}
else if (StackUtils.equals(this, held) && isLit(held)) {
} else if (StackUtils.equals(this, held) && isLit(held)) {
toggleLitState = true;
}
}
if (held != null) {
// Ensure a TileEntity exists. May be able to remove this in future versions.
TileCandle te = (TileCandle)world.getTileEntity(x, y, z);
TileCandle te = (TileCandle) world.getTileEntity(x, y, z);
if (te == null) {
world.setTileEntity(x, y, z, this.createTileEntity(world, meta));
te = (TileCandle)world.getTileEntity(x, y, z);
te = (TileCandle) world.getTileEntity(x, y, z);
}
if (StackUtils.equals(this, held)) {
@@ -184,18 +184,15 @@ public class BlockCandle extends BlockTorch {
// Copy the colour of an unlit, coloured candle.
if (held.hasTagCompound() && held.getTagCompound().hasKey(colourTagName)) {
te.setColour(held.getTagCompound().getInteger(colourTagName));
}
else {
} else {
// Reset to white if item has no
te.setColour(0xffffff);
}
}
else {
} else {
toggleLitState = true;
}
flag = true;
}
else {
} else {
// Check for dye-able ness.
boolean matched = false;
for (int i = 0; i < dyes.length; ++i) {
@@ -203,8 +200,7 @@ public class BlockCandle extends BlockTorch {
if (OreDictionary.itemMatches(stack, held, true)) {
if (isLit(meta)) {
te.setColour(colours[i][0], colours[i][1], colours[i][2]);
}
else {
} else {
te.addColour(colours[i][0], colours[i][1], colours[i][2]);
}
world.markBlockForUpdate(x, y, z);
@@ -232,7 +228,7 @@ public class BlockCandle extends BlockTorch {
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!world.isRemote) {
TileCandle tc = (TileCandle)world.getTileEntity(x, y, z);
TileCandle tc = (TileCandle) world.getTileEntity(x, y, z);
int newMeta = isLit(meta) ? 1 : 0;
ItemStack stack = new ItemStack(this, 1, newMeta);
if (tc != null && tc.getColour() != 0xffffff) {
@@ -248,7 +244,7 @@ public class BlockCandle extends BlockTorch {
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
TileCandle tc = (TileCandle)(world.getTileEntity(x, y, z));
TileCandle tc = (TileCandle) (world.getTileEntity(x, y, z));
tc.setColour(this.getColourValueFromItemStack(itemStack));
if (isLit(itemStack)) {
int meta = world.getBlockMetadata(x, y, z);
@@ -274,8 +270,7 @@ public class BlockCandle extends BlockTorch {
world.setBlockToAir(x, y, z);
}
return false;
}
else {
} else {
return true;
}
}
@@ -291,28 +286,19 @@ public class BlockCandle extends BlockTorch {
double d3 = 0.2199999988079071D;
double d4 = 0.27000001072883606D;
if (l == 1)
{
if (l == 1) {
world.spawnParticle("smoke", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0 - d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
}
else if (l == 2)
{
} else if (l == 2) {
world.spawnParticle("smoke", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0 + d4, d1 + d3, d2, 0.0D, 0.0D, 0.0D);
}
else if (l == 3)
{
} else if (l == 3) {
world.spawnParticle("smoke", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1 + d3, d2 - d4, 0.0D, 0.0D, 0.0D);
}
else if (l == 4)
{
} else if (l == 4) {
world.spawnParticle("smoke", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1 + d3, d2 + d4, 0.0D, 0.0D, 0.0D);
}
else
{
} else {
world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
@@ -320,64 +306,48 @@ public class BlockCandle extends BlockTorch {
}
@Override
protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block)
{
if (this.func_150109_e(par1World, par2, par3, par4))
{
protected boolean func_150108_b(World par1World, int par2, int par3, int par4, Block block) {
if (this.func_150109_e(par1World, par2, par3, par4)) {
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 0x07;
boolean flag = false;
if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1)
{
if (!par1World.isSideSolid(par2 - 1, par3, par4, ForgeDirection.EAST, true) && i1 == 1) {
flag = true;
}
if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2)
{
if (!par1World.isSideSolid(par2 + 1, par3, par4, ForgeDirection.WEST, true) && i1 == 2) {
flag = true;
}
if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3)
{
if (!par1World.isSideSolid(par2, par3, par4 - 1, ForgeDirection.SOUTH, true) && i1 == 3) {
flag = true;
}
if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4)
{
if (!par1World.isSideSolid(par2, par3, par4 + 1, ForgeDirection.NORTH, true) && i1 == 4) {
flag = true;
}
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5)
{
if (!this.canPlaceTorchOn(par1World, par2, par3 - 1, par4) && i1 == 5) {
flag = true;
}
if (flag)
{
if (flag) {
this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
par1World.setBlockToAir(par2, par3, par4);
return true;
}
else
{
} else {
return false;
}
}
else
{
} else {
return true;
}
}
// Yes, function hiding. Go away.
public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4)
{
if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4))
{
public boolean canPlaceTorchOn(World par1World, int par2, int par3, int par4) {
if (World.doesBlockHaveSolidTopSurface(par1World, par2, par3, par4)) {
return true;
}
else
{
} else {
Block block = par1World.getBlock(par2, par3, par4);
return block.canPlaceTorchOnTop(par1World, par2, par3, par4);
}
@@ -407,7 +377,9 @@ public class BlockCandle extends BlockTorch {
}
public void addItemToLightingList(Item item) {
if (item == null) throw new NullPointerException();
if (item == null) {
throw new NullPointerException();
}
if (!this.lightingItems.contains(item)) {
this.lightingItems.add(item);
@@ -4,22 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
import java.util.List;
import java.util.Random;
import net.minecraft.block.BlockTorch;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -30,6 +23,16 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
import forestry.core.config.Defaults;
import forestry.core.config.ForestryBlock;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import forestry.core.utils.StringUtil;
public class BlockStump extends BlockTorch {
public BlockStump() {
@@ -45,7 +48,7 @@ public class BlockStump extends BlockTorch {
this.blockIcon = TextureManager.getInstance().registerTex(register, StringUtil.cleanBlockName(this));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
itemList.add(new ItemStack(this, 1, 0));
@@ -57,8 +60,8 @@ public class BlockStump extends BlockTorch {
ItemStack held = player.getCurrentEquippedItem();
if (held != null &&
(held.getItem() == Items.flint_and_steel ||
held.getItem() == Items.flint ||
StackUtils.equals(Blocks.torch, held))) {
held.getItem() == Items.flint ||
StackUtils.equals(Blocks.torch, held))) {
world.setBlock(x, y, z, ForestryBlock.candle.block(), world.getBlockMetadata(x, y, z) | 0x08, Defaults.FLAG_BLOCK_SYNCH);
TileCandle tc = new TileCandle();
tc.setColour(0); // default to white
@@ -4,12 +4,18 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import java.util.HashSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.api.core.ITileStructure;
import forestry.core.config.ForestryBlock;
@@ -18,10 +24,6 @@ import forestry.core.gadgets.StructureLogic;
import forestry.core.utils.Schemata;
import forestry.core.utils.Schemata.EnumStructureBlock;
import forestry.core.vect.Vect;
import java.util.HashSet;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
public class StructureLogicAlveary extends StructureLogic {
@@ -32,6 +34,7 @@ public class StructureLogicAlveary extends StructureLogic {
"FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF", "FFFFF").setOffsets(-2, -3, -2);
public static final HashSet<Block> slabBlocks = new HashSet<Block>();
static {
slabBlocks.add(Blocks.wooden_slab);
slabBlocks.add(ForestryBlock.slabs1.block());
@@ -42,7 +45,7 @@ public class StructureLogicAlveary extends StructureLogic {
public StructureLogicAlveary(ITileStructure structure) {
super(UID_ALVEARY, structure);
schematas = new Schemata[] { SCHEMATA_ALVEARY };
schematas = new Schemata[]{SCHEMATA_ALVEARY};
metaOnValid.put(EnumStructureBlock.BLOCK_B, 1);
}
@@ -57,57 +60,69 @@ public class StructureLogicAlveary extends StructureLogic {
offsetZ = schemata.getxOffset();
}
for (int i = 0; i < dimensions.x; i++)
for (int j = 0; j < schemata.getHeight(); j++)
for (int i = 0; i < dimensions.x; i++) {
for (int j = 0; j < schemata.getHeight(); j++) {
for (int k = 0; k < dimensions.z; k++) {
int x = structureTile.xCoord + i + offsetX;
int y = structureTile.yCoord + j + schemata.getyOffset();
int z = structureTile.zCoord + k + offsetZ;
if (!structureTile.getWorldObj().blockExists(x, y, z))
if (!structureTile.getWorldObj().blockExists(x, y, z)) {
return EnumStructureState.INDETERMINATE;
}
EnumStructureBlock required = schemata.getAt(i, j, k, rotate);
if (required == EnumStructureBlock.ANY)
if (required == EnumStructureBlock.ANY) {
continue;
}
TileEntity tile = structureTile.getWorldObj().getTileEntity(x, y, z);
Block block = structureTile.getWorldObj().getBlock(x, y, z);
switch (required) {
case AIR:
if (!block.isAir(structureTile.getWorldObj(), x, y, z))
return EnumStructureState.INVALID;
break;
case BLOCK_A:
if (tile == null || !(tile instanceof IAlvearyComponent))
return EnumStructureState.INVALID;
if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY))
return EnumStructureState.INVALID;
break;
case MASTER:
case BLOCK_B:
if (tile == null || !(tile instanceof TileAlvearyPlain))
return EnumStructureState.INVALID;
break;
case BLOCK_C:
if (!slabBlocks.contains(block))
return EnumStructureState.INVALID;
if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0)
return EnumStructureState.INVALID;
break;
case BLOCK_D:
if (block != Blocks.spruce_stairs)
return EnumStructureState.INVALID;
break;
case FOREIGN:
if (tile instanceof ITileStructure)
return EnumStructureState.INVALID;
break;
default:
return EnumStructureState.INDETERMINATE;
case AIR:
if (!block.isAir(structureTile.getWorldObj(), x, y, z)) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_A:
if (tile == null || !(tile instanceof IAlvearyComponent)) {
return EnumStructureState.INVALID;
}
if (!((ITileStructure) tile).getTypeUID().equals(UID_ALVEARY)) {
return EnumStructureState.INVALID;
}
break;
case MASTER:
case BLOCK_B:
if (tile == null || !(tile instanceof TileAlvearyPlain)) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_C:
if (!slabBlocks.contains(block)) {
return EnumStructureState.INVALID;
}
if ((structureTile.getWorldObj().getBlockMetadata(x, y, z) & 8) != 0) {
return EnumStructureState.INVALID;
}
break;
case BLOCK_D:
if (block != Blocks.spruce_stairs) {
return EnumStructureState.INVALID;
}
break;
case FOREIGN:
if (tile instanceof ITileStructure) {
return EnumStructureState.INVALID;
}
break;
default:
return EnumStructureState.INDETERMINATE;
}
}
}
}
return EnumStructureState.VALID;
}
@@ -4,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
******************************************************************************/
@@ -31,7 +31,6 @@ import forestry.core.config.ForestryBlock;
import forestry.core.gadgets.TileForestry;
import forestry.core.inventory.FakeInventoryAdapter;
import forestry.core.inventory.IInventoryAdapter;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.network.PacketPayload;
import forestry.core.proxy.Proxies;
@@ -63,17 +62,18 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
@Override
public void updateEntity() {
if (!Proxies.common.isSimulating(worldObj))
if (!Proxies.common.isSimulating(worldObj)) {
updateClientSide();
else {
} else {
if (!isInited) {
initialize();
isInited = true;
}
// Periodic validation if needed
if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster()))
if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster())) {
validateStructure();
}
updateServerSide();
}
@@ -99,8 +99,9 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
this.masterZ = nbttagcompound.getInteger("MasterZ");
// Init for master state
if (isMaster)
makeMaster();
if (isMaster) {
makeMaster();
}
super.readFromNBT(nbttagcompound);
@@ -135,8 +136,9 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
@Override
public void fromPacketPayload(PacketPayload payload) {
if (payload.shortPayload[0] > 0)
if (payload.shortPayload[0] > 0) {
makeMaster();
}
// so the client can know if it is part of an integrated structure
this.masterY = payload.shortPayload[1];
@@ -158,15 +160,17 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
setCentralTE(null);
isMaster = true;
if (getInternalInventory() instanceof FakeInventoryAdapter)
if (getInternalInventory() instanceof FakeInventoryAdapter) {
createInventory();
}
}
@Override
public void onStructureReset() {
setCentralTE(null);
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1)
if (worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 1) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 0);
}
isMaster = false;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@@ -174,21 +178,25 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
@Override
public ITileStructure getCentralTE() {
if (!isIntegratedIntoStructure())
if (!isIntegratedIntoStructure()) {
return null;
}
if (!isMaster()) {
TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ);
if (tile instanceof ITileStructure) {
ITileStructure master = (ITileStructure) worldObj.getTileEntity(masterX, masterY, masterZ);
if (master.isMaster())
if (master.isMaster()) {
return master;
else
} else {
return null;
} else
}
} else {
return null;
} else
}
} else {
return this;
}
}
@@ -4,19 +4,22 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import cofh.api.energy.IEnergyHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.apiculture.IAlvearyComponent;
import forestry.core.network.PacketPayload;
import forestry.energy.EnergyManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import cofh.api.energy.IEnergyHandler;
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler {
@@ -32,6 +35,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
this.boundaryUp = boundaryUp;
}
}
protected final EnergyManager energyManager;
private final ClimateControl climateControl;
private int workingTime = 0;
@@ -56,8 +60,9 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
protected void updateServerSide() {
super.updateServerSide();
if (!this.hasMaster())
if (!this.hasMaster()) {
return;
}
boolean wasInactive = (workingTime == 0);
@@ -69,8 +74,9 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
if (workingTime > 0) {
workingTime--;
IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE();
if (component != null)
if (component != null) {
component.addTemperatureChange(climateControl.changePerTransfer, climateControl.boundaryDown, climateControl.boundaryUp);
}
}
if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
@@ -86,10 +92,11 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if (workingTime > 0)
if (workingTime > 0) {
return textureOn;
else
} else {
return textureOff;
}
}
/* LOADING & SAVING */
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -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
******************************************************************************/
@@ -88,8 +88,8 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
tankManager = new TankManager(liquidTank);
recipes = new HygroregulatorRecipe[]{new HygroregulatorRecipe(new FluidStack(water, 1), 1, 0.01f, -0.005f),
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f)};
new HygroregulatorRecipe(new FluidStack(lava, 1), 10, -0.01f, +0.005f),
new HygroregulatorRecipe(new FluidStack(liquidIce, 1), 10, 0.02f, -0.01f)};
}
@Override
@@ -131,18 +131,21 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
component.addHumidityChange(currentRecipe.humidChange, 0.0f, 1.0f);
component.addTemperatureChange(currentRecipe.tempChange, 0.0f, 2.0f);
}
} else
} else {
transferTime = 0;
}
}
if (worldObj.getTotalWorldTime() % 20 * 10 != 0)
if (worldObj.getTotalWorldTime() % 20 * 10 != 0) {
return;
}
IInventoryAdapter canInventory = getInternalInventory();
// Check if we have suitable items waiting in the item slot
if (canInventory.getStackInSlot(0) != null)
if (canInventory.getStackInSlot(0) != null) {
FluidHelper.drainContainers(tankManager, canInventory, 0);
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -40,7 +40,6 @@ import forestry.api.genetics.IIndividual;
import forestry.apiculture.gui.ContainerAlveary;
import forestry.core.EnumErrorCode;
import forestry.core.config.Config;
import forestry.core.config.Defaults;
import forestry.core.interfaces.IClimatised;
import forestry.core.interfaces.IErrorSource;
import forestry.core.interfaces.IHintSource;
@@ -77,10 +76,11 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public void openGui(EntityPlayer player) {
if (isMaster())
if (isMaster()) {
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, xCoord, yCoord, zCoord);
else if (this.hasMaster())
} else if (this.hasMaster()) {
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, masterX, masterY, masterZ);
}
}
@Override
@@ -102,8 +102,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
this.tempChange = nbttagcompound.getFloat("TempChange");
this.humidChange = nbttagcompound.getFloat("HumidChange");
if (beekeepingLogic != null)
if (beekeepingLogic != null) {
beekeepingLogic.readFromNBT(nbttagcompound);
}
}
@@ -114,8 +115,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
nbttagcompound.setFloat("TempChange", tempChange);
nbttagcompound.setFloat("HumidChange", humidChange);
if (beekeepingLogic != null)
if (beekeepingLogic != null) {
beekeepingLogic.writeToNBT(nbttagcompound);
}
}
@@ -129,10 +131,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
protected void updateServerSide() {
if (beekeepingLogic == null)
if (beekeepingLogic == null) {
return;
if (!isMaster())
}
if (!isMaster()) {
return;
}
beekeepingLogic.update();
@@ -141,18 +145,21 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
equalizeHumidity();
IBee queen = beekeepingLogic.getQueen();
if (queen == null)
if (queen == null) {
return;
}
// Add swarm effects
if (worldObj.getTotalWorldTime() % 200 == 0) {
ISidedInventory inventory = getStructureInventory();
if (inventory != null)
if (inventory != null) {
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
}
}
if (getErrorState() == EnumErrorCode.OK)
if (getErrorState() == EnumErrorCode.OK) {
queen.doFX(beekeepingLogic.getEffectData(), this);
}
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) {
float f = xCoord + 0.5F;
@@ -172,12 +179,14 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
protected void updateClientSide() {
if (!isMaster())
if (!isMaster()) {
return;
}
ISidedInventory inventory = getStructureInventory();
if (inventory == null)
if (inventory == null) {
return;
}
// / Multiplayer FX
ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN);
@@ -190,53 +199,62 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
}
private void equalizeTemperature() {
if (tempChange == 0)
if (tempChange == 0) {
return;
}
tempChange -= 0.05f * tempChange;
if (tempChange <= 0.001f && tempChange >= -0.001f)
if (tempChange <= 0.001f && tempChange >= -0.001f) {
tempChange = 0;
}
}
private void equalizeHumidity() {
if (humidChange == 0)
if (humidChange == 0) {
return;
}
humidChange -= 0.05f * humidChange;
if (humidChange <= 0.001f && humidChange >= 0.001f)
if (humidChange <= 0.001f && humidChange >= 0.001f) {
humidChange = 0;
}
}
/* STATE INFORMATION */
private int getHealthDisplay() {
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) {
return 0;
}
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN)))
} else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealth;
else
} else {
return 0;
}
}
private int getMaxHealthDisplay() {
IInventory inventory = getStructureInventory();
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null)
if (inventory == null || inventory.getStackInSlot(SLOT_QUEEN) == null) {
return 0;
}
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN)))
} else if (!PluginApiculture.beeInterface.isDrone(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealthMax;
else
} else {
return 0;
}
}
public int getHealthScaled(int i) {
if (getMaxHealthDisplay() == 0)
if (getMaxHealthDisplay() == 0) {
return 0;
}
return (getHealthDisplay() * i) / getMaxHealthDisplay();
}
@@ -254,6 +272,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
}
return false;
}
@Override
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE;
@@ -264,8 +283,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public void makeMaster() {
super.makeMaster();
if (beekeepingLogic == null)
if (beekeepingLogic == null) {
this.beekeepingLogic = PluginApiculture.beeInterface.createBeekeepingLogic(this);
}
}
@Override
@@ -359,8 +379,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public EnumTemperature getTemperature() {
if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0)
if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0) {
return EnumTemperature.HELLISH;
}
return EnumTemperature.getFromValue(getExactTemperature());
}
@@ -447,8 +468,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean addProduct(ItemStack product, boolean all) {
IInventoryAdapter inventory = getStructureInventory();
if (inventory == null)
if (inventory == null) {
return false;
}
return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all);
}
@@ -462,8 +484,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public void onQueenChange(ItemStack queenStack) {
if (!Proxies.common.isSimulating(worldObj))
if (!Proxies.common.isSimulating(worldObj)) {
return;
}
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
zCoord);
@@ -491,8 +514,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
for (IBeeListener eventHandler : eventHandlers) {
if (eventHandler.onPollenRetrieved(queen, pollen, isHandled))
if (eventHandler.onPollenRetrieved(queen, pollen, isHandled)) {
isHandled = true;
}
}
return isHandled;
@@ -501,8 +525,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean onEggLaid(IBee queen) {
for (IBeeListener eventHandler : eventHandlers) {
if (eventHandler.onEggLaid(queen))
if (eventHandler.onEggLaid(queen)) {
return true;
}
}
return false;
@@ -511,8 +536,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean isSealed() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isSealed())
if (modifier.isSealed()) {
return true;
}
}
return false;
}
@@ -520,8 +546,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean isSelfLighted() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isSelfLighted())
if (modifier.isSelfLighted()) {
return true;
}
}
return false;
}
@@ -529,8 +556,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean isSunlightSimulated() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isSunlightSimulated())
if (modifier.isSunlightSimulated()) {
return true;
}
}
return false;
}
@@ -538,8 +566,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
@Override
public boolean isHellish() {
for (IBeeModifier modifier : modifiers) {
if (modifier.isHellish())
if (modifier.isHellish()) {
return true;
}
}
return false;
}
@@ -552,8 +581,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
return inventory;
} else if (hasMaster()) {
ITileStructure central = getCentralTE();
if (central instanceof TileAlveary)
if (central instanceof TileAlveary) {
return ((TileAlveary) central).getInternalInventory();
}
}
return inventory;
}
@@ -561,29 +591,30 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
/* SMP GUI */
public void getGUINetworkData(int i, int j) {
switch (i) {
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
case 4:
this.tempChange = (float) j / 100;
break;
case 5:
this.humidChange = (float) j / 100;
break;
case 6: {
this.biome = BiomeGenBase.getBiome(j);
break;
}
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
case 4:
this.tempChange = (float) j / 100;
break;
case 5:
this.humidChange = (float) j / 100;
break;
case 6: {
this.biome = BiomeGenBase.getBiome(j);
break;
}
}
}
public void sendGUINetworkData(ContainerAlveary container, ICrafting iCrafting) {
if (beekeepingLogic == null)
if (beekeepingLogic == null) {
return;
}
iCrafting.sendProgressBarUpdate(container, 0, beekeepingLogic.getBreedingTime());
iCrafting.sendProgressBarUpdate(container, 1, beekeepingLogic.getTotalBreedingTime());
@@ -597,8 +628,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
public IErrorState getErrorState() {
if (hasMaster()) {
ITileStructure tile = this.getCentralTE();
if (tile != null)
if (tile != null) {
return ((IErrorSource) tile).getErrorState();
}
}
return errorState;
@@ -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
******************************************************************************/
@@ -61,29 +61,33 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
public void initialize() {
super.initialize();
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure()) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
((IAlvearyComponent) getCentralTE()).registerBeeListener(this);
}
@Override
protected void updateServerSide() {
super.updateServerSide();
if(worldObj.getTotalWorldTime() % 200 != 0)
if (worldObj.getTotalWorldTime() % 200 != 0) {
return;
}
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure()) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
((IAlvearyComponent) getCentralTE()).registerBeeListener(this);
}
/* TEXTURES & INTERNAL */
@Override
public int getIcon(int side, int metadata) {
if(side == 0 || side == 1)
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
return BlockAlveary.SIEVE;
}
@@ -94,19 +98,21 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
private void destroyPollen() {
IInventoryAdapter inventory = getInternalInventory();
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
inventory.setInventorySlotContents(i, null);
}
}
private boolean canStorePollen() {
IInventoryAdapter inventory = getInternalInventory();
if(inventory.getStackInSlot(SLOT_SIEVE) == null)
if (inventory.getStackInSlot(SLOT_SIEVE) == null) {
return false;
}
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if(inventory.getStackInSlot(i) == null)
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if (inventory.getStackInSlot(i) == null) {
return true;
}
}
return false;
@@ -114,8 +120,8 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
private void storePollenStack(ItemStack itemstack) {
IInventoryAdapter inventory = getInternalInventory();
for(int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if(inventory.getStackInSlot(i) == null) {
for (int i = SLOT_POLLEN_1; i < SLOT_POLLEN_1 + SLOTS_POLLEN_COUNT; i++) {
if (inventory.getStackInSlot(i) == null) {
inventory.setInventorySlotContents(i, itemstack);
return;
}
@@ -131,7 +137,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
@Override
public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) {
IInventoryAdapter inventory = getInternalInventory();
if(slotIndex == SLOT_SIEVE) {
if (slotIndex == SLOT_SIEVE) {
destroyPollen();
return inventory.getStackInSlot(SLOT_SIEVE);
} else {
@@ -146,18 +152,31 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
}
/* IBEELISTENER */
@Override public void onQueenChange(ItemStack queen) {}
@Override public void wearOutEquipment(int amount) {}
@Override public void onQueenDeath(IBee queen) {}
@Override public void onPostQueenDeath(IBee queen) {}
@Override
public void onQueenChange(ItemStack queen) {
}
@Override
public void wearOutEquipment(int amount) {
}
@Override
public void onQueenDeath(IBee queen) {
}
@Override
public void onPostQueenDeath(IBee queen) {
}
@Override
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
if(isHandled)
if (isHandled) {
return true;
if(!canStorePollen())
}
if (!canStorePollen()) {
return false;
}
storePollenStack(AlleleManager.alleleRegistry.getSpeciesRoot(pollen.getClass()).getMemberStack(pollen, EnumGermlingType.POLLEN.ordinal()));
return true;
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -27,23 +27,26 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
public void initialize() {
super.initialize();
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure()) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
}
@Override
protected void updateServerSide() {
super.updateServerSide();
if(worldObj.getTotalWorldTime() % 200 != 0)
if (worldObj.getTotalWorldTime() % 200 != 0) {
return;
}
if(!hasMaster() || !isIntegratedIntoStructure())
if (!hasMaster() || !isIntegratedIntoStructure()) {
return;
}
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
}
@@ -55,8 +58,9 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if(side == 0 || side == 1)
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
return BlockAlveary.STABILISER;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -66,25 +66,31 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
if (pendingSpawns.size() > 0) {
setIsActive(true);
if (worldObj.getTotalWorldTime() % 1000 == 0)
if (worldObj.getTotalWorldTime() % 1000 == 0) {
trySpawnSwarm();
} else
}
} else {
setIsActive(false);
}
if (worldObj.getTotalWorldTime() % 500 != 0)
if (worldObj.getTotalWorldTime() % 500 != 0) {
return;
}
ItemStack princessStack = getPrincessStack();
if (princessStack == null)
if (princessStack == null) {
return;
}
int chance = consumeInducerAndGetChance();
if (chance == 0)
if (chance == 0) {
return;
}
// Try to spawn princess
if (worldObj.rand.nextInt(1000) >= chance)
if (worldObj.rand.nextInt(1000) >= chance) {
return;
}
// Queue swarm spawn
IBee princess = PluginApiculture.beeInterface.getMember(princessStack);
@@ -93,24 +99,28 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
}
private ItemStack getPrincessStack() {
if (!this.hasMaster())
if (!this.hasMaster()) {
return null;
}
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
if (!(master instanceof IBeeHousing))
if (!(master instanceof IBeeHousing)) {
return null;
}
IBeeHousing housing = (IBeeHousing) master;
ItemStack princessStack = housing.getQueen();
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack))
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack)) {
return null;
}
return princessStack;
}
private int consumeInducerAndGetChance() {
if (getInternalInventory() == null)
if (getInternalInventory() == null) {
return 0;
}
for (IInvSlot slot : InventoryIterator.getIterable(getInternalInventory())) {
ItemStack stack = slot.getStackInSlot();
@@ -134,8 +144,9 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive))
if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive)) {
pendingSpawns.pop();
}
}
private void setIsActive(boolean isActive) {
@@ -170,13 +181,15 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
/* TEXTURES */
@Override
public int getIcon(int side, int metadata) {
if (side == 0 || side == 1)
if (side == 0 || side == 1) {
return BlockAlveary.BOTTOM;
}
if (isActive)
if (isActive) {
return BlockAlveary.ALVEARY_SWARMER_ON;
else
} else {
return BlockAlveary.ALVEARY_SWARMER_OFF;
}
}
/* SAVING & LOADING */
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -48,10 +48,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1.0f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getTerritoryModifier(genome, mod);
}
}
return mod;
}
@@ -61,10 +63,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 0.1f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getProductionModifier(genome, mod);
}
}
return mod;
}
@@ -74,10 +78,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1.0f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getMutationModifier(genome, mate, mod);
}
}
return mod;
}
@@ -87,10 +93,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1.0f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getLifespanModifier(genome, mate, mod);
}
}
return mod;
}
@@ -100,10 +108,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getFloweringModifier(genome, mod);
}
}
return mod;
}
@@ -113,10 +123,12 @@ public class TileApiary extends TileBeehouse {
IInventoryAdapter inventory = getInternalInventory();
float mod = 1f;
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)
}
if (inventory.getStackInSlot(i).getItem() instanceof IHiveFrame) {
mod *= ((IHiveFrame) inventory.getStackInSlot(i).getItem()).getGeneticDecay(genome, mod);
}
}
return mod;
}
@@ -127,10 +139,12 @@ public class TileApiary extends TileBeehouse {
int wear = Math.round(amount * PluginApiculture.beeInterface.getBeekeepingMode(worldObj).getWearModifier());
for (int i = SLOT_FRAMES_1; i < SLOT_FRAMES_1 + SLOT_FRAMES_COUNT; i++) {
if (inventory.getStackInSlot(i) == null)
if (inventory.getStackInSlot(i) == null) {
continue;
if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame))
}
if (!(inventory.getStackInSlot(i).getItem() instanceof IHiveFrame)) {
continue;
}
inventory.setInventorySlotContents(
i,
@@ -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
******************************************************************************/
@@ -103,8 +103,9 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
super.writeToNBT(nbttagcompound);
nbttagcompound.setInteger("BiomeId", biome.biomeID);
if (logic != null)
if (logic != null) {
logic.writeToNBT(nbttagcompound);
}
}
@Override
@@ -159,11 +160,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
public void updateClientSide() {
// / Multiplayer FX
if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN)))
if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) {
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) {
IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN));
displayQueen.doFX(logic.getEffectData(), this);
}
}
}
@@ -173,12 +175,14 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
logic.update();
IBee queen = logic.getQueen();
if (queen == null)
if (queen == null) {
return;
}
// Add swarm effects
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
if (worldObj.getTotalWorldTime() % 200 * 10 == 0) {
onQueenChange(getInternalInventory().getStackInSlot(SLOT_QUEEN));
}
/* These should get already done on the client / doesn't work server-side anyway
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0)
queen.doFX(logic.getEffectData(), this);
@@ -211,8 +215,9 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* NETWORK SYNCH */
@Override
public void onQueenChange(ItemStack queenStack) {
if (!Proxies.common.isSimulating(worldObj))
if (!Proxies.common.isSimulating(worldObj)) {
return;
}
Proxies.net.sendNetworkPacket(new PacketInventoryStack(PacketIds.IINVENTORY_STACK, xCoord, yCoord, zCoord, SLOT_QUEEN, queenStack), xCoord, yCoord,
zCoord);
@@ -222,36 +227,41 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* STATE INFORMATION */
private int getHealthDisplay() {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
if (inventory.getStackInSlot(SLOT_QUEEN) == null) {
return 0;
}
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getHealth();
else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
} else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealth;
else
} else {
return 0;
}
}
private int getMaxHealthDisplay() {
IInventoryAdapter inventory = getInternalInventory();
if (inventory.getStackInSlot(SLOT_QUEEN) == null)
if (inventory.getStackInSlot(SLOT_QUEEN) == null) {
return 0;
}
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
if (ForestryItem.beeQueenGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN)).getMaxHealth();
else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN)))
} else if (ForestryItem.beePrincessGE.isItemEqual(inventory.getStackInSlot(SLOT_QUEEN))) {
return displayHealthMax;
else
} else {
return 0;
}
}
/**
* Returns scaled queen health or breeding progress
*/
public int getHealthScaled(int i) {
if (getMaxHealthDisplay() == 0)
if (getMaxHealthDisplay() == 0) {
return 0;
}
return (getHealthDisplay() * i) / getMaxHealthDisplay();
}
@@ -277,23 +287,25 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
/* SMP */
// @Override
public void getGUINetworkData(int i, int j) {
if (logic == null)
if (logic == null) {
return;
}
switch (i) {
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
case 0:
displayHealth = j;
break;
case 1:
displayHealthMax = j;
break;
}
}
// @Override
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
if (logic == null)
if (logic == null) {
return;
}
iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime());
iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime());
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,18 +4,19 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gadgets;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.InventoryAdapter;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.InventoryAdapter;
public class TileSwarm extends TileEntity {
public final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
@@ -26,16 +27,19 @@ public class TileSwarm extends TileEntity {
}
public TileSwarm setContained(ItemStack[] bees) {
for (ItemStack itemstack : bees)
for (ItemStack itemstack : bees) {
InvTools.addStack(contained, itemstack, false, true);
}
return this;
}
public boolean containsBees() {
for (int i = 0; i < contained.getSizeInventory(); i++)
if (contained.getStackInSlot(i) != null)
for (int i = 0; i < contained.getSizeInventory(); i++) {
if (contained.getStackInSlot(i) != null) {
return true;
}
}
return false;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -46,20 +46,24 @@ public class AIAvoidPlayers extends EntityAIBase {
player = mob.worldObj.getClosestPlayerToEntity(mob, minDistance);
if (player == null)
if (player == null) {
return false;
}
if (!mob.getEntitySenses().canSee(player))
if (!mob.getEntitySenses().canSee(player)) {
return false;
}
Vec3 randomTarget = RandomPositionGenerator.findRandomTargetBlockAwayFrom(mob, 16, 7,
Vec3.createVectorHelper(player.posX, player.posY, player.posZ));
if (randomTarget == null)
if (randomTarget == null) {
return false;
}
if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob))
if (player.getDistanceSq(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord) < player.getDistanceSqToEntity(mob)) {
return false;
}
pathing = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord);
return pathing != null && pathing.isDestinationSame(randomTarget);
@@ -82,9 +86,10 @@ public class AIAvoidPlayers extends EntityAIBase {
@Override
public void updateTask() {
if (mob.getDistanceSqToEntity(player) < 49.0D)
if (mob.getDistanceSqToEntity(player) < 49.0D) {
mob.getNavigator().setSpeed(nearSpeed);
else
} else {
mob.getNavigator().setSpeed(farSpeed);
}
}
}
@@ -4,15 +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.genetics;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -29,14 +41,6 @@ import forestry.core.config.Defaults;
import forestry.core.genetics.AlleleSpecies;
import forestry.core.render.TextureManager;
import forestry.core.utils.StackUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies, IIconProvider {
@@ -65,7 +69,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
IJubilanceProvider jubilanceProvider) {
super(uid, dominant, name, branch, binomial);
this.root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
this.root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
this.primaryColour = primaryColor;
this.secondaryColour = secondaryColor;
this.jubilanceProvider = jubilanceProvider;
@@ -83,8 +87,9 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
}
public AlleleBeeSpecies addProduct(ItemStack product, int chance) {
if (product == null || product.getItem() == null)
if (product == null || product.getItem() == null) {
throw new IllegalArgumentException("Tried to add null product");
}
this.products.put(product, chance);
return this;
}
@@ -111,16 +116,18 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
int highest = 0;
exclude.add(species);
for(IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) {
if(!exclude.contains(mutation.getAllele0())) {
for (IMutation mutation : getRoot().getPaths(species, EnumBeeChromosome.SPECIES)) {
if (!exclude.contains(mutation.getAllele0())) {
int otherAdvance = getGeneticAdvancement(mutation.getAllele0(), exclude);
if(otherAdvance > highest)
if (otherAdvance > highest) {
highest = otherAdvance;
}
}
if(!exclude.contains(mutation.getAllele1())) {
if (!exclude.contains(mutation.getAllele1())) {
int otherAdvance = getGeneticAdvancement(mutation.getAllele1(), exclude);
if(otherAdvance > highest)
if (otherAdvance > highest) {
highest = otherAdvance;
}
}
}
@@ -129,15 +136,20 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
public float getResearchSuitability(ItemStack itemstack) {
if(itemstack == null)
if (itemstack == null) {
return 0f;
}
for(ItemStack stack : products.keySet())
if(stack.isItemEqual(itemstack))
for (ItemStack stack : products.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
for(ItemStack stack : specialty.keySet())
if(stack.isItemEqual(itemstack))
}
}
for (ItemStack stack : specialty.keySet()) {
if (stack.isItemEqual(itemstack)) {
return 1.0f;
}
}
return super.getResearchSuitability(itemstack);
}
@@ -147,13 +159,13 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
ArrayList<ItemStack> bounty = new ArrayList<ItemStack>();
Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel));
if(bountyLevel > 10) {
for(ItemStack stack : specialty.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
if (bountyLevel > 10) {
for (ItemStack stack : specialty.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
}
}
for(ItemStack stack : products.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
for (ItemStack stack : products.keySet()) {
bounty.add(StackUtils.copyWithRandomSize(stack, (int) ((float) bountyLevel / 2), world.rand));
}
return bounty.toArray(new ItemStack[bounty.size()]);
}
@@ -186,10 +198,12 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
@Override
public int getIconColour(int renderPass) {
if (renderPass == 0)
if (renderPass == 0) {
return primaryColour;
if (renderPass == 1)
}
if (renderPass == 1) {
return secondaryColour;
}
return 0xffffff;
}
@@ -204,8 +218,9 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
IIcon body1 = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/body1");
for (int i = 0; i < EnumBeeType.values().length; i++) {
if(EnumBeeType.values()[i] == EnumBeeType.NONE)
if (EnumBeeType.values()[i] == EnumBeeType.NONE) {
continue;
}
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");
icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1
@@ -4,22 +4,24 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.utils.DamageSourceForestry;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
public class AlleleEffectAggressive extends AlleleEffectThrottled {
@@ -32,8 +34,9 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -49,14 +52,15 @@ public class AlleleEffectAggressive extends AlleleEffectThrottled {
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
damage = 1;
else if (count > 1)
} else if (count > 1) {
damage = 2;
else if (count > 0)
} else if (count > 0) {
damage = 3;
}
}
entity.attackEntityFrom(damageSourceBeeAggressive, damage);
@@ -4,21 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.genetics.EffectData;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class AlleleEffectCreeper extends AlleleEffectThrottled {
@@ -33,11 +35,13 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
@Override
public IEffectData validateStorage(IEffectData storedData) {
if (!(storedData instanceof EffectData))
if (!(storedData instanceof EffectData)) {
return new EffectData(3, 0);
}
if (((EffectData) storedData).getIntSize() < 3)
if (((EffectData) storedData).getIntSize() < 3) {
return new EffectData(3, 0);
}
return storedData;
}
@@ -47,8 +51,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
// If we are already triggered, we continue the explosion sequence.
if (storedData.getInteger(indexExplosionTimer) > 0) {
@@ -72,9 +77,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
// armor.
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2) {
} else if (count > 2) {
chance = 5;
storedData.setInteger(indexExplosionForce, 6);
} else if (count > 1) {
@@ -85,8 +90,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
storedData.setInteger(indexExplosionForce, 10);
}
if (world.rand.nextInt(1000) >= chance)
if (world.rand.nextInt(1000) >= chance) {
continue;
}
world.playSoundEffect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord(), "mob.creeper", 4F,
(1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
@@ -103,8 +109,9 @@ public class AlleleEffectCreeper extends AlleleEffectThrottled {
explosionTimer--;
storedData.setInteger(indexExplosionTimer, explosionTimer);
if (explosionTimer > 0)
if (explosionTimer > 0) {
return;
}
world.createExplosion(null, x, y, z, storedData.getInteger(indexExplosionForce), false);
}
@@ -4,18 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
public class AlleleEffectExploration extends AlleleEffectThrottled {
@@ -26,8 +28,9 @@ public class AlleleEffectExploration extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -1,11 +1,13 @@
package forestry.apiculture.genetics;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.world.World;
public class AlleleEffectFertile extends AlleleEffectThrottled {
@@ -1,13 +1,9 @@
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.EffectData;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityMooshroom;
import net.minecraft.init.Blocks;
@@ -15,6 +11,11 @@ import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.EffectData;
public class AlleleEffectFungification extends AlleleEffectThrottled {
public static final int MAX_BLOCK_FIND_TRIES = 10;
@@ -48,7 +49,7 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
} else {
++entityThrottle;
}
storedData.setInteger(1, entityThrottle);
storedData.setInteger(1, entityThrottle);
return storedData;
}
@@ -74,7 +75,7 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
blockY = getRandomOffset(world.rand, housing.getYCoord(), territorySize[1]);
blockZ = getRandomOffset(world.rand, housing.getZCoord(), territorySize[2]);
}
}
private void doEntityEffect(IBeeGenome genome, IBeeHousing housing) {
@@ -84,8 +85,8 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
List entities = world.getEntitiesWithinAABB(EntityCow.class, aabb);
for (Object entity : entities) {
if (entity instanceof EntityCow && !(entity instanceof EntityMooshroom)) {
convertCowToMooshroom((EntityCow)entity);
break;
convertCowToMooshroom((EntityCow) entity);
break;
}
}
}
@@ -104,25 +105,25 @@ public class AlleleEffectFungification extends AlleleEffectThrottled {
private static void convertCowToMooshroom(EntityCow cow) {
World worldObj = cow.worldObj;
cow.setDead();
EntityMooshroom mooshroom = new EntityMooshroom(worldObj);
mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch);
mooshroom.setHealth(cow.getHealth());
mooshroom.renderYawOffset = cow.renderYawOffset;
worldObj.spawnEntityInWorld(mooshroom);
worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double)(cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D);
cow.setDead();
EntityMooshroom mooshroom = new EntityMooshroom(worldObj);
mooshroom.setLocationAndAngles(cow.posX, cow.posY, cow.posZ, cow.rotationYaw, cow.rotationPitch);
mooshroom.setHealth(cow.getHealth());
mooshroom.renderYawOffset = cow.renderYawOffset;
worldObj.spawnEntityInWorld(mooshroom);
worldObj.spawnParticle("largeexplode", cow.posX, cow.posY + (double) (cow.height / 2.0F), cow.posZ, 0.0D, 0.0D, 0.0D);
}
private void doMushroomGrowth(Block block, World world, int blockX, int blockY, int blockZ) {
WorldGenBigMushroom giantMushroomGenerator;
if (block == Blocks.brown_mushroom) {
giantMushroomGenerator = new WorldGenBigMushroom(0);
} else {
giantMushroomGenerator = new WorldGenBigMushroom(1);
}
world.setBlockToAir(blockX, blockY, blockZ);
giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ);
WorldGenBigMushroom giantMushroomGenerator;
if (block == Blocks.brown_mushroom) {
giantMushroomGenerator = new WorldGenBigMushroom(0);
} else {
giantMushroomGenerator = new WorldGenBigMushroom(1);
}
world.setBlockToAir(blockX, blockY, blockZ);
giantMushroomGenerator.generate(world, world.rand, blockX, blockY, blockZ);
}
}
@@ -4,22 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IEffectData;
import forestry.core.proxy.Proxies;
import forestry.core.vect.Vect;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
public class AlleleEffectGlacial extends AlleleEffectThrottled {
@@ -32,17 +33,18 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
switch (temp) {
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
}
int[] areaAr = genome.getTerritory();
@@ -58,11 +60,13 @@ public class AlleleEffectGlacial extends AlleleEffectThrottled {
// Freeze water
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
if (block != Blocks.water)
if (block != Blocks.water) {
continue;
}
if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z))
if (!world.isAirBlock(posBlock.x, posBlock.y + 1, posBlock.z)) {
continue;
}
Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.ice);
}
@@ -4,20 +4,22 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import java.util.List;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
public class AlleleEffectHeroic extends AlleleEffectThrottled {
public AlleleEffectHeroic(String uid) {
@@ -27,8 +29,9 @@ public class AlleleEffectHeroic extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -4,22 +4,24 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.plugins.PluginApiculture;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class AlleleEffectIgnition extends AlleleEffectThrottled {
@@ -35,8 +37,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -53,9 +56,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2) {
} else if (count > 2) {
chance = 5;
duration = 50;
} else if (count > 1) {
@@ -67,8 +70,9 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
}
}
if (world.rand.nextInt(1000) >= chance)
if (world.rand.nextInt(1000) >= chance) {
continue;
}
entity.setFire(duration);
}
@@ -81,12 +85,13 @@ public class AlleleEffectIgnition extends AlleleEffectThrottled {
int[] area = getModifiedArea(genome, housing);
if (housing.getWorld().rand.nextBoolean())
if (housing.getWorld().rand.nextBoolean()) {
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
else
} else {
PluginApiculture.proxy.addBeeHiveFX("particles/ember", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), 0xffffff, area[0], area[1], area[2]);
}
return storedData;
}
@@ -4,23 +4,25 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.plugins.PluginApiculture;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class AlleleEffectMiasmic extends AlleleEffectThrottled {
@@ -35,8 +37,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB infectionBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -44,8 +47,9 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
for (Object obj : list) {
if (world.rand.nextInt(1000) >= infectionChance)
if (world.rand.nextInt(1000) >= infectionChance) {
continue;
}
EntityPlayer player = (EntityPlayer) obj;
@@ -55,14 +59,15 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
// armor.
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
duration = 200;
else if (count > 1)
} else if (count > 1) {
duration = 400;
else if (count > 0)
} else if (count > 0) {
duration = 600;
}
player.addPotionEffect(new PotionEffect(Potion.poison.id, duration, 0));
}
@@ -75,12 +80,13 @@ public class AlleleEffectMiasmic extends AlleleEffectThrottled {
int[] area = getModifiedArea(genome, housing);
if (housing.getWorld().rand.nextBoolean())
if (housing.getWorld().rand.nextBoolean()) {
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
else
} else {
PluginApiculture.proxy.addBeeHiveFX("particles/poison", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), 0xffffff, area[0], area[1], area[2]);
}
return storedData;
}
@@ -4,21 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.utils.DamageSourceForestry;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
@@ -31,8 +33,9 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -47,14 +50,15 @@ public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
// armor.
int count = ItemArmorApiarist.wearsItems(player, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
damage = 1;
else if (count > 1)
} else if (count > 1) {
damage = 2;
else if (count > 0)
} else if (count > 0) {
damage = 3;
}
player.attackEntityFrom(damageSourceBeeEnd, damage);
}
@@ -4,19 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.world.World;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.genetics.Allele;
import forestry.plugins.PluginApiculture;
import net.minecraft.world.World;
public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
@@ -56,12 +57,15 @@ public class AlleleEffectNone extends Allele implements IAlleleBeeEffect {
area[1] *= housing.getTerritoryModifier(genome, 1f);
area[2] *= housing.getTerritoryModifier(genome, 1f);
if (area[0] < 1)
if (area[0] < 1) {
area[0] = 1;
if (area[1] < 1)
}
if (area[1] < 1) {
area[1] = 1;
if (area[2] < 1)
}
if (area[2] < 1) {
area[2] = 1;
}
PluginApiculture.proxy.addBeeHiveFX("particles/swarm_bee", housing.getWorld(), housing.getXCoord(), housing.getYCoord(),
housing.getZCoord(), genome.getPrimary().getIconColour(0), area[0], area[1], area[2]);
@@ -4,23 +4,26 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import cpw.mods.fml.relauncher.ReflectionHelper;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.proxy.Proxies;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
public class AlleleEffectPotion extends AlleleEffectThrottled {
@@ -38,15 +41,17 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB beatifyBox = getBounding(genome, housing, 1.0f);
List list = housing.getWorld().getEntitiesWithinAABB(EntityPlayer.class, beatifyBox);
for (Object entity : list) {
if (!(entity instanceof EntityPlayer))
if (!(entity instanceof EntityPlayer)) {
continue;
}
EntityPlayer player = (EntityPlayer) entity;
@@ -54,14 +59,15 @@ public class AlleleEffectPotion extends AlleleEffectThrottled {
if (isBadEffect) {
// Players are not attacked if they wear a full set of apiarist's armor.
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
if (count >= 4)
if (count >= 4) {
continue; // Full set, no damage/effect
else if (count == 3)
} else if (count == 3) {
dur = this.duration / 4;
else if (count == 2)
} else if (count == 2) {
dur = this.duration / 2;
else if (count == 1)
} else if (count == 1) {
dur = this.duration * 3 / 4;
}
}
player.addPotionEffect(new PotionEffect(potion.getId(), dur, 0));
@@ -4,12 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
@@ -18,15 +29,6 @@ import forestry.apiculture.gadgets.TileAlveary;
import forestry.apiculture.items.ItemArmorApiarist;
import forestry.core.utils.DamageSourceForestry;
import forestry.core.vect.Vect;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public class AlleleEffectRadioactive extends AlleleEffectThrottled {
@@ -41,8 +43,9 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
int[] areaAr = genome.getTerritory();
Vect area = new Vect(areaAr[0] * 2, areaAr[1] * 2, areaAr[2] * 2);
@@ -67,14 +70,15 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
if (entity instanceof EntityPlayer) {
int count = ItemArmorApiarist.wearsItems((EntityPlayer) entity, getUID(), true);
// Full set, no damage/effect
if (count > 3)
if (count > 3) {
continue;
else if (count > 2)
} else if (count > 2) {
damage = 1;
else if (count > 1)
} else if (count > 1) {
damage = 2;
else if (count > 0)
} else if (count > 0) {
damage = 3;
}
}
entity.attackEntityFrom(damageSourceBeeRadioactive, damage);
@@ -90,29 +94,36 @@ public class AlleleEffectRadioactive extends AlleleEffectThrottled {
Vect posBlock = randomPos.add(new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord()));
posBlock = posBlock.add(offset);
if(posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight())
if (posBlock.y <= 1 || posBlock.y >= housing.getWorld().getActualHeight()) {
continue;
}
// Don't destroy ourself and blocks below us.
if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord())
if (posBlock.x == housing.getXCoord() && posBlock.z == housing.getZCoord() && posBlock.y <= housing.getYCoord()) {
continue;
}
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z))
if (world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
continue;
}
Block block = world.getBlock(posBlock.x, posBlock.y, posBlock.z);
if (block instanceof BlockAlveary)
if (block instanceof BlockAlveary) {
continue;
}
TileEntity tile = world.getTileEntity(posBlock.x, posBlock.y, posBlock.z);
if (tile instanceof IBeeHousing)
if (tile instanceof IBeeHousing) {
continue;
if (tile instanceof TileAlveary)
}
if (tile instanceof TileAlveary) {
continue;
}
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0)
if (block.getBlockHardness(world, posBlock.x, posBlock.y, posBlock.z) < 0) {
continue;
}
world.setBlockToAir(posBlock.x, posBlock.y, posBlock.z);
break;
@@ -4,20 +4,22 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import java.util.List;
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
public class AlleleEffectRepulsion extends AlleleEffectThrottled {
public AlleleEffectRepulsion(String uid) {
@@ -26,11 +28,13 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
if (housing.getOwnerName() == null)
if (housing.getOwnerName() == null) {
return storedData;
}
AxisAlignedBB hurtBox = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
@@ -41,8 +45,9 @@ public class AlleleEffectRepulsion extends AlleleEffectThrottled {
for (Object objT : mob.tasks.taskEntries) {
EntityAITaskEntry task = (EntityAITaskEntry) objT;
if (task.action instanceof AIAvoidPlayers)
if (task.action instanceof AIAvoidPlayers) {
return storedData;
}
}
mob.tasks.addTask(3, new AIAvoidPlayers(mob, 6.0f, 0.25f, 0.3f));
@@ -4,20 +4,16 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.utils.StackUtils;
import forestry.core.utils.Utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.item.EntityItem;
@@ -34,6 +30,12 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IEffectData;
import forestry.core.utils.StackUtils;
import forestry.core.utils.Utils;
public class AlleleEffectResurrection extends AlleleEffectThrottled {
public static class Resurrectable {
@@ -77,30 +79,35 @@ public class AlleleEffectResurrection extends AlleleEffectThrottled {
@Override
public IEffectData doEffect(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
AxisAlignedBB bounding = getBounding(genome, housing, 1.0f);
@SuppressWarnings("rawtypes")
List list = housing.getWorld().getEntitiesWithinAABB(EntityItem.class, bounding);
if (list.size() > 0)
if (list.size() > 0) {
Collections.shuffle(resurrectables);
}
for (Object obj : list) {
EntityItem item = (EntityItem) obj;
if (item.isDead)
if (item.isDead) {
continue;
}
ItemStack contained = item.getEntityItem();
for (Resurrectable entry : resurrectables)
for (Resurrectable entry : resurrectables) {
if (StackUtils.isIdenticalItem(entry.res, contained)) {
Utils.spawnEntity(housing.getWorld(), entry.risen, item.posX, item.posY, item.posZ);
contained.stackSize--;
if (contained.stackSize <= 0)
if (contained.stackSize <= 0) {
item.setDead();
}
break;
}
}
}
return storedData;
@@ -4,22 +4,24 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.EnumTemperature;
import forestry.api.genetics.IEffectData;
import forestry.core.proxy.Proxies;
import forestry.core.vect.Vect;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.util.ForgeDirection;
public class AlleleEffectSnowing extends AlleleEffectThrottled {
@@ -32,17 +34,18 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
World world = housing.getWorld();
if (isHalted(storedData, housing))
if (isHalted(storedData, housing)) {
return storedData;
}
EnumTemperature temp = EnumTemperature.getFromValue(BiomeGenBase.getBiome(housing.getBiomeId()).temperature);
switch (temp) {
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
case HELLISH:
case HOT:
case WARM:
return storedData;
default:
}
int[] areaAr = genome.getTerritory();
@@ -57,11 +60,13 @@ public class AlleleEffectSnowing extends AlleleEffectThrottled {
posBlock = posBlock.add(offset);
// Put snow on the ground
if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false))
if (!world.isSideSolid(posBlock.x, posBlock.y - 1, posBlock.z, ForgeDirection.UP, false)) {
continue;
}
if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z))
if (!world.isAirBlock(posBlock.x, posBlock.y, posBlock.z)) {
continue;
}
Proxies.common.setBlockWithNotify(world, posBlock.x, posBlock.y, posBlock.z, Blocks.snow_layer);
}
@@ -4,12 +4,14 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
@@ -19,7 +21,6 @@ import forestry.core.genetics.Allele;
import forestry.core.genetics.EffectData;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.util.AxisAlignedBB;
public abstract class AlleleEffectThrottled extends Allele implements IAlleleBeeEffect {
@@ -46,23 +47,26 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
@Override
public IEffectData validateStorage(IEffectData storedData) {
if (storedData instanceof EffectData)
if (storedData instanceof EffectData) {
return storedData;
}
return new EffectData(1, 0);
}
public boolean isHalted(IEffectData storedData, IBeeHousing housing) {
if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK)
if (requiresWorkingQueen && housing.getErrorState() != EnumErrorCode.OK) {
return true;
}
int throt = storedData.getInteger(0);
throt++;
storedData.setInteger(0, throt);
if (throt < getThrottle())
if (throt < getThrottle()) {
return true;
}
// Reset since we are done throttling.
storedData.setInteger(0, 0);
@@ -85,12 +89,15 @@ public abstract class AlleleEffectThrottled extends Allele implements IAlleleBee
area[1] *= housing.getTerritoryModifier(genome, 1f) * 3;
area[2] *= housing.getTerritoryModifier(genome, 1f) * 3;
if (area[0] < 1)
if (area[0] < 1) {
area[0] = 1;
if (area[1] < 1)
}
if (area[1] < 1) {
area[1] = 1;
if (area[2] < 1)
}
if (area[2] < 1) {
area[2] = 1;
}
return area;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,21 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import com.mojang.authlib.GameProfile;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IApiaristTracker;
import forestry.api.genetics.IBreedingTracker;
import forestry.api.genetics.IIndividual;
import forestry.core.genetics.BreedingTracker;
import forestry.plugins.PluginApiculture;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
public class ApiaristTracker extends BreedingTracker implements IApiaristTracker {
@@ -58,12 +60,15 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
@Override
public void registerPickup(IIndividual individual) {
if(!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID))
if (!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID)) {
return;
if(!individual.isPureBred(EnumBeeChromosome.SPECIES))
}
if (!individual.isPureBred(EnumBeeChromosome.SPECIES)) {
return;
if(PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0)
}
if (PluginApiculture.beeInterface.getCombinations(individual.getGenome().getPrimary()).size() > 0) {
return;
}
registerSpecies(individual.getGenome().getPrimary());
}
@@ -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
******************************************************************************/
@@ -97,19 +97,23 @@ public class Bee extends IndividualLiving implements IBee {
super.readFromNBT(nbttagcompound);
if (nbttagcompound.hasKey("NA"))
if (nbttagcompound.hasKey("NA")) {
isNatural = nbttagcompound.getBoolean("NA");
}
if (nbttagcompound.hasKey("GEN"))
if (nbttagcompound.hasKey("GEN")) {
generation = nbttagcompound.getInteger("GEN");
}
if (nbttagcompound.hasKey("Genome"))
if (nbttagcompound.hasKey("Genome")) {
genome = new BeeGenome(nbttagcompound.getCompoundTag("Genome"));
else
} else {
genome = PluginApiculture.beeInterface.templateAsGenome(BeeTemplates.getForestTemplate());
}
if (nbttagcompound.hasKey("Mate"))
if (nbttagcompound.hasKey("Mate")) {
mate = new BeeGenome(nbttagcompound.getCompoundTag("Mate"));
}
}
@@ -118,11 +122,13 @@ public class Bee extends IndividualLiving implements IBee {
super.writeToNBT(nbttagcompound);
if (!isNatural)
if (!isNatural) {
nbttagcompound.setBoolean("NA", false);
}
if (generation > 0)
if (generation > 0) {
nbttagcompound.setInteger("GEN", generation);
}
}
public void setIsNatural(boolean flag) {
@@ -144,10 +150,11 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public void mate(IIndividual individual) {
if(!(individual instanceof IBee))
if (!(individual instanceof IBee)) {
return;
}
IBee drone = (IBee)individual;
IBee drone = (IBee) individual;
mate = drone.getGenome();
}
@@ -156,18 +163,21 @@ public class Bee extends IndividualLiving implements IBee {
public IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing) {
IAlleleBeeEffect effect = genome.getEffect();
if (effect == null)
if (effect == null) {
return null;
}
storedData[0] = doEffect(effect, storedData[0], housing);
// Return here if the primary can already not be combined
if (!effect.isCombinable())
if (!effect.isCombinable()) {
return storedData;
}
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
if (!secondary.isCombinable())
if (!secondary.isCombinable()) {
return storedData;
}
storedData[1] = doEffect(secondary, storedData[1], housing);
@@ -183,18 +193,21 @@ public class Bee extends IndividualLiving implements IBee {
public IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing) {
IAlleleBeeEffect effect = genome.getEffect();
if (effect == null)
if (effect == null) {
return null;
}
storedData[0] = doFX(effect, storedData[0], housing);
// Return here if the primary can already not be combined
if (!effect.isCombinable())
if (!effect.isCombinable()) {
return storedData;
}
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
if (!secondary.isCombinable())
if (!secondary.isCombinable()) {
return storedData;
}
storedData[1] = doFX(secondary, storedData[1], housing);
@@ -244,29 +257,36 @@ public class Bee extends IndividualLiving implements IBee {
}
// / Night or darkness requires nocturnal species
if(world.isDaytime()) {
if(!canWorkDuringDay())
if (world.isDaytime()) {
if (!canWorkDuringDay()) {
return EnumErrorCode.NOTNIGHT;
} else if (!canWorkAtNight() && !housing.isSelfLighted())
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
return EnumErrorCode.NOTDAY;
}
if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) {
if(!canWorkDuringDay())
if (!canWorkDuringDay()) {
return EnumErrorCode.NOTGLOOMY;
} else if(!canWorkAtNight() && !housing.isSelfLighted())
}
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
return EnumErrorCode.NOTLUCID;
}
// / No sky, except if in hell
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if(biome == null)
if (biome == null) {
return EnumErrorCode.NOSKY;
}
if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated())
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated()) {
return EnumErrorCode.NOSKY;
}
// / And finally climate check
if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity()))
if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
return EnumErrorCode.INVALIDBIOME;
}
return EnumErrorCode.OK;
}
@@ -280,8 +300,9 @@ public class Bee extends IndividualLiving implements IBee {
}
private boolean checkBiomeHazard(BiomeGenBase biome) {
if (biome == null)
if (biome == null) {
return false;
}
EnumTemperature temperature = EnumTemperature.getFromBiome(biome);
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
@@ -326,9 +347,11 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public ArrayList<Integer> getSuitableBiomeIds() {
ArrayList<Integer> suitableBiomes = new ArrayList<Integer>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
if (checkBiomeHazard(biome))
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (checkBiomeHazard(biome)) {
suitableBiomes.add(biome.biomeID);
}
}
return suitableBiomes;
}
@@ -336,9 +359,11 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public ArrayList<BiomeGenBase> getSuitableBiomes() {
ArrayList<BiomeGenBase> suitableBiomes = new ArrayList<BiomeGenBase>();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
if (checkBiomeHazard(biome))
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (checkBiomeHazard(biome)) {
suitableBiomes.add(biome);
}
}
return suitableBiomes;
}
@@ -355,34 +380,37 @@ public class Bee extends IndividualLiving implements IBee {
// You analyzed it? Juicy tooltip coming up!
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
if (!isPureBred(EnumBeeChromosome.SPECIES))
list.add(EnumChatFormatting.BLUE + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY",primary.getName()).replaceAll("%SECONDARY",secondary.getName()));
if (!isPureBred(EnumBeeChromosome.SPECIES)) {
list.add(EnumChatFormatting.BLUE + StringUtil.localize("bees.hybrid").replaceAll("%PRIMARY", primary.getName()).replaceAll("%SECONDARY", secondary.getName()));
}
if (generation > 0) {
EnumRarity rarity;
if (generation >= 1000)
if (generation >= 1000) {
rarity = EnumRarity.epic;
else if (generation >= 100)
} else if (generation >= 100) {
rarity = EnumRarity.rare;
else if (generation >= 10)
} else if (generation >= 10) {
rarity = EnumRarity.uncommon;
else
} else {
rarity = EnumRarity.common;
}
String generationString = rarity.rarityColor + StringUtil.localizeAndFormat("gui.beealyzer.generations", generation);
list.add(generationString);
}
IAllele speedAllele = genome.getActiveAllele(EnumBeeChromosome.SPEED);
IAlleleTolerance tempToleranceAllele = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance humidToleranceAllele = (IAlleleTolerance)getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
IAlleleTolerance tempToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance humidToleranceAllele = (IAlleleTolerance) getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
String unlocalizedCustomSpeed = "tooltip.worker." + speedAllele.getUnlocalizedName().replaceFirst("gui.", "");
String speed;
if (StringUtil.canTranslate(unlocalizedCustomSpeed))
if (StringUtil.canTranslate(unlocalizedCustomSpeed)) {
speed = StringUtil.localize(unlocalizedCustomSpeed);
else
} else {
speed = speedAllele.getName() + " " + StringUtil.localize("gui.worker");
}
String lifespan = genome.getActiveAllele(EnumBeeChromosome.LIFESPAN).getName() + " " + StringUtil.localize("gui.life");
String tempTolerance = EnumChatFormatting.GREEN + "T: " + AlleleManager.climateHelper.toDisplay(genome.getPrimary().getTemperature()) + " / " + tempToleranceAllele.getName();
@@ -395,8 +423,9 @@ public class Bee extends IndividualLiving implements IBee {
list.add(humidTolerance);
list.add(flowers);
if (genome.getNocturnal())
if (genome.getNocturnal()) {
list.add(EnumChatFormatting.RED + GenericRatings.rateActivityTime(genome.getNocturnal(), false));
}
}
@Override
@@ -422,14 +451,16 @@ public class Bee extends IndividualLiving implements IBee {
for (ItemStack second : secondaryProducts) {
boolean skip = false;
for (ItemStack compare : products)
for (ItemStack compare : products) {
if (second.isItemEqual(compare)) {
skip = true;
break;
}
}
if (!skip)
if (!skip) {
products.add(second);
}
}
@@ -444,8 +475,9 @@ public class Bee extends IndividualLiving implements IBee {
@Override
public ItemStack[] produceStacks(IBeeHousing housing) {
if (!hasFlower(housing))
if (!hasFlower(housing)) {
return null;
}
if (housing == null) {
Proxies.log.warning("Failed to produce in an apiary because the beehousing was null.");
@@ -463,29 +495,37 @@ public class Bee extends IndividualLiving implements IBee {
IAlleleBeeSpecies secondary = genome.getSecondary();
// All work and no play makes queen a dull girl.
if(mode.isOverworked(this, housing))
if (mode.isOverworked(this, housing)) {
setIsNatural(false);
}
// Bee genetic speed * beehousing * beekeeping mode
float speed = genome.getSpeed() * housing.getProductionModifier(genome, 1f) * mode.getProductionModifier(genome, 1f);
// / Primary Products
for (Map.Entry<ItemStack, Integer> entry : primary.getProducts().entrySet())
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed)
for (Map.Entry<ItemStack, Integer> entry : primary.getProducts().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
products.add(entry.getKey().copy());
}
}
// / Secondary Products
for (Map.Entry<ItemStack, Integer> entry : secondary.getProducts().entrySet())
if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed)
for (Map.Entry<ItemStack, Integer> entry : secondary.getProducts().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < Math.round(entry.getValue() / 2) * speed) {
products.add(entry.getKey().copy());
}
}
// We are done if the we are not jubilant.
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing))
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing)) {
return products.toArray(new ItemStack[products.size()]);
}
// / Specialty products
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet())
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed)
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet()) {
if (housing.getWorld().rand.nextInt(100) < entry.getValue() * speed) {
products.add(entry.getKey().copy());
}
}
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(),
products.toArray(new ItemStack[products.size()]));
@@ -496,12 +536,14 @@ public class Bee extends IndividualLiving implements IBee {
public IBee spawnPrincess(IBeeHousing housing) {
// We need a mated queen to produce offspring.
if (mate == null)
if (mate == null) {
return null;
}
// Fatigued queens do not produce princesses.
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing))
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing)) {
return null;
}
return createOffspring(housing, getGeneration() + 1);
}
@@ -512,16 +554,18 @@ public class Bee extends IndividualLiving implements IBee {
World world = housing.getWorld();
// We need a mated queen to produce offspring.
if (mate == null)
if (mate == null) {
return null;
}
ArrayList<IBee> bees = new ArrayList<IBee>();
int toCreate = PluginApiculture.beeInterface.getBeekeepingMode(world).getFinalFertility(this, world, housing.getXCoord(), housing.getYCoord(),
housing.getZCoord());
if (toCreate <= 0)
if (toCreate <= 0) {
toCreate = 1;
}
for (int i = 0; i < toCreate; i++) {
IBee offspring = createOffspring(housing, 0);
@@ -531,10 +575,11 @@ public class Bee extends IndividualLiving implements IBee {
}
}
if (bees.size() > 0)
if (bees.size() > 0) {
return bees.toArray(new IBee[bees.size()]);
else
} else {
return null;
}
}
private IBee createOffspring(IBeeHousing housing, int generation) {
@@ -548,15 +593,19 @@ public class Bee extends IndividualLiving implements IBee {
// Check for mutation. Replace one of the parents with the mutation
// template if mutation occured.
IChromosome[] mutated1 = mutateSpecies(housing, genome, mate);
if (mutated1 != null)
if (mutated1 != null) {
parent1 = mutated1;
}
IChromosome[] mutated2 = mutateSpecies(housing, mate, genome);
if (mutated2 != null)
if (mutated2 != null) {
parent2 = mutated2;
}
for (int i = 0; i < parent1.length; i++)
if (parent1[i] != null && parent2[i] != null)
for (int i = 0; i < parent1.length; i++) {
if (parent1[i] != null && parent2[i] != null) {
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
}
}
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
IBee offspring = new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
@@ -617,8 +666,9 @@ public class Bee extends IndividualLiving implements IBee {
Random random = world.rand;
// Correct speed
if (random.nextInt(100) >= chance)
if (random.nextInt(100) >= chance) {
return null;
}
Vect area = getArea(genome, housing);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
@@ -633,14 +683,16 @@ public class Bee extends IndividualLiving implements IBee {
if (tile instanceof IPollinatable) {
IPollinatable pitcher = (IPollinatable) tile;
if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher))
if (genome.getFlowerProvider().isAcceptedPollinatable(world, pitcher)) {
pollen = pitcher.getPollen();
}
} else {
pollen = GeneticsUtil.getErsatzPollen(world, blockPos.x, blockPos.y, blockPos.z);
}
if (pollen != null)
if (pollen != null) {
return pollen;
}
}
return null;
@@ -655,8 +707,9 @@ public class Bee extends IndividualLiving implements IBee {
Random random = world.rand;
// Correct speed
if (random.nextInt(100) >= chance)
if (random.nextInt(100) >= chance) {
return false;
}
Vect area = getArea(genome, housing);
Vect offset = new Vect(-area.x / 2, -area.y / 4, -area.z / 2);
@@ -668,13 +721,16 @@ public class Bee extends IndividualLiving implements IBee {
Vect posBlock = Vect.add(housingPos, randomPos, offset);
IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z);
if(receiver == null)
if (receiver == null) {
continue;
}
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver))
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver)) {
continue;
if (!receiver.canMateWith(pollen))
}
if (!receiver.canMateWith(pollen)) {
continue;
}
receiver.mateWith(pollen);
return true;
@@ -692,8 +748,9 @@ public class Bee extends IndividualLiving implements IBee {
Random random = world.rand;
// Correct speed
if (random.nextInt(100) >= chance)
if (random.nextInt(100) >= chance) {
return;
}
// Gather required info
IFlowerProvider provider = genome.getFlowerProvider();
@@ -705,8 +762,9 @@ public class Bee extends IndividualLiving implements IBee {
Vect randomPos = Vect.getRandomPositionInArea(random, area);
Vect posBlock = Vect.add(housingPos, randomPos, offset);
if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z))
if (provider.growFlower(world, this, posBlock.x, posBlock.y, posBlock.z)) {
break;
}
}
}
@@ -4,12 +4,15 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.apiculture.IAlleleBeeEffect;
import forestry.api.apiculture.IAlleleBeeSpecies;
@@ -28,37 +31,35 @@ import forestry.core.genetics.AlleleTolerance;
import forestry.core.genetics.Genome;
import forestry.core.vect.Vect;
import forestry.plugins.PluginApiculture;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class BeeGenome extends Genome implements IBeeGenome {
/**
* 0 - Species (determines product)
*
*
* 1 - Speed
*
*
* 2 - Lifespan
*
*
* 3 - Fertility (Maximum number of offspring)
*
*
* 4 - Preferred temperature Icy: Snow biomes Cold: Tundra/Steppe, Extreme Mountains/Hills? Normal: Plains, Forests, Mountains Hot: Desert Hellish: Nether
*
*
* 5 - Temperature tolerance (Range +/-)
*
*
* 6 - Nocturnal
*
*
* 7 - Preferred humidity (Arid - Normal - Damp)
*
*
* 8 - Humidity tolerance (Range +/-)
*
*
* 9 - Flight interference tolerance (stuff falling from the sky/other hindrances -> tolerates dampness + flight interference tolerance => rain resistance)
*
*
* 10 - Cave dwelling
*
*
* 11 - Required flowers
*
*
* 12 - Flower plant chance
*
*
* 13 - Territory
*/
/* CONSTRUCTOR */
@@ -73,10 +74,11 @@ public class BeeGenome extends Genome implements IBeeGenome {
// NBT RETRIEVAL
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
IAllele speciesAllele = Genome.getActiveAllele(itemStack, EnumBeeChromosome.SPECIES);
if (speciesAllele instanceof IAlleleBeeSpecies)
return (IAlleleBeeSpecies)speciesAllele;
else
if (speciesAllele instanceof IAlleleBeeSpecies) {
return (IAlleleBeeSpecies) speciesAllele;
} else {
return null;
}
}
// / INFORMATION RETRIEVAL
@@ -143,7 +145,7 @@ public class BeeGenome extends Genome implements IBeeGenome {
@Override
public int[] getTerritory() {
Vect area = ((AlleleArea) getActiveAllele(EnumBeeChromosome.TERRITORY)).getArea();
return new int[] { area.x, area.y, area.z };
return new int[]{area.x, area.y, area.z};
}
@Override
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -69,9 +69,11 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
if (beeSpeciesCount < 0) {
beeSpeciesCount = 0;
for (Entry<String, IAllele> entry : AlleleManager.alleleRegistry.getRegisteredAlleles().entrySet()) {
if (entry.getValue() instanceof IAlleleBeeSpecies)
if (((IAlleleBeeSpecies) entry.getValue()).isCounted())
if (entry.getValue() instanceof IAlleleBeeSpecies) {
if (((IAlleleBeeSpecies) entry.getValue()).isCounted()) {
beeSpeciesCount++;
}
}
}
}
@@ -95,25 +97,26 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public ItemStack getMemberStack(IIndividual bee, int type) {
if (!isMember(bee))
if (!isMember(bee)) {
return null;
}
Item beeItem;
switch (EnumBeeType.VALUES[type]) {
case QUEEN:
beeItem = ForestryItem.beeQueenGE.item();
break;
case PRINCESS:
beeItem = ForestryItem.beePrincessGE.item();
break;
case DRONE:
beeItem = ForestryItem.beeDroneGE.item();
break;
case LARVAE:
beeItem = ForestryItem.beeLarvaeGE.item();
break;
default:
throw new RuntimeException("Cannot instantiate a bee of type " + type);
case QUEEN:
beeItem = ForestryItem.beeQueenGE.item();
break;
case PRINCESS:
beeItem = ForestryItem.beePrincessGE.item();
break;
case DRONE:
beeItem = ForestryItem.beeDroneGE.item();
break;
case LARVAE:
beeItem = ForestryItem.beeLarvaeGE.item();
break;
default:
throw new RuntimeException("Cannot instantiate a bee of type " + type);
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -125,17 +128,19 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public EnumBeeType getType(ItemStack stack) {
if (stack == null)
if (stack == null) {
return EnumBeeType.NONE;
}
if (ForestryItem.beeDroneGE.isItemEqual(stack))
if (ForestryItem.beeDroneGE.isItemEqual(stack)) {
return EnumBeeType.DRONE;
else if (ForestryItem.beePrincessGE.isItemEqual(stack))
} else if (ForestryItem.beePrincessGE.isItemEqual(stack)) {
return EnumBeeType.PRINCESS;
else if (ForestryItem.beeQueenGE.isItemEqual(stack))
} else if (ForestryItem.beeQueenGE.isItemEqual(stack)) {
return EnumBeeType.QUEEN;
else if (ForestryItem.beeLarvaeGE.isItemEqual(stack))
} else if (ForestryItem.beeLarvaeGE.isItemEqual(stack)) {
return EnumBeeType.LARVAE;
}
return EnumBeeType.NONE;
}
@@ -147,8 +152,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public boolean isMated(ItemStack stack) {
if (getType(stack) != EnumBeeType.QUEEN)
if (getType(stack) != EnumBeeType.QUEEN) {
return false;
}
IBee bee = getMember(stack);
return bee.getMate() != null;
@@ -156,8 +162,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IBee getMember(ItemStack stack) {
if (!isMember(stack))
if (!isMember(stack)) {
return null;
}
return new Bee(stack.getTagCompound());
}
@@ -225,19 +232,23 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public Collection<IBeeMutation> getMutations(boolean shuffle) {
if (shuffle)
if (shuffle) {
Collections.shuffle(beeMutations);
}
return beeMutations;
}
@Override
public void registerMutation(IMutation mutation) {
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID()))
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) {
return;
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID()))
}
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) {
return;
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID()))
}
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) {
return;
}
beeMutations.add((IBeeMutation) mutation);
}
@@ -258,14 +269,16 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IBeekeepingMode getBeekeepingMode(World world) {
if (activeBeekeepingMode != null)
if (activeBeekeepingMode != null) {
return activeBeekeepingMode;
}
// No beekeeping mode yet, get it.
IApiaristTracker tracker = getBreedingTracker(world, null);
String mode = tracker.getModeName();
if (mode == null || mode.isEmpty())
if (mode == null || mode.isEmpty()) {
mode = PluginApiculture.beekeepingMode;
}
setBeekeepingMode(world, mode);
FMLCommonHandler.instance().getFMLLogger().debug("Set beekeeping mode for a world to " + mode);
@@ -287,8 +300,9 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
@Override
public IBeekeepingMode getBeekeepingMode(String name) {
for (IBeekeepingMode mode : beekeepingModes) {
if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH)))
if (mode.getName().equals(name) || mode.getName().equals(name.toLowerCase(Locale.ENGLISH))) {
return mode;
}
}
FMLCommonHandler.instance().getFMLLogger().debug("Failed to find a beekeeping mode called '%s', reverting to fallback.");
@@ -4,12 +4,19 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeeMutation;
@@ -19,10 +26,6 @@ import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.genetics.Mutation;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
public class BeeMutation extends Mutation implements IBeeMutation {
@@ -37,7 +40,7 @@ public class BeeMutation extends Mutation implements IBeeMutation {
public BeeMutation(IAllele allele0, IAllele allele1, IAllele[] template, int chance) {
super(allele0, allele1, template, chance);
root = (IBeeRoot)AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
root = (IBeeRoot) AlleleManager.alleleRegistry.getSpeciesRoot("rootBees");
PluginApiculture.beeInterface.registerMutation(this);
}
@@ -75,49 +78,58 @@ public class BeeMutation extends Mutation implements IBeeMutation {
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
World world = housing.getWorld();
if (requiresDay && !world.isDaytime())
if (requiresDay && !world.isDaytime()) {
return 0;
}
if (requiresNight && world.isDaytime())
if (requiresNight && world.isDaytime()) {
return 0;
}
// Skip if we are restricted by biomes and this one does not match.
if (restrictBiomeTypes.size() > 0) {
boolean noneMatched = true;
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if(strictBiomeCheck) {
if (strictBiomeCheck) {
BiomeDictionary.Type[] types = BiomeDictionary.getTypesForBiome(biome);
if(types.length == 1 && restrictBiomeTypes.contains(types[0]))
if (types.length == 1 && restrictBiomeTypes.contains(types[0])) {
noneMatched = false;
}
} else {
for(BiomeDictionary.Type type : restrictBiomeTypes) {
if(BiomeDictionary.isBiomeOfType(biome, type)) {
for (BiomeDictionary.Type type : restrictBiomeTypes) {
if (BiomeDictionary.isBiomeOfType(biome, type)) {
noneMatched = false;
break;
}
}
}
if (noneMatched)
if (noneMatched) {
return 0;
}
}
BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(housing.getXCoord(), housing.getZCoord());
if (biome.temperature < minTemperature || biome.temperature > maxTemperature)
if (biome.temperature < minTemperature || biome.temperature > maxTemperature) {
return 0;
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall)
}
if (biome.rainfall < minRainfall || biome.rainfall > maxRainfall) {
return 0;
}
float processedChance = chance * housing.getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f)
* PluginApiculture.beeInterface.getBeekeepingMode(world).getMutationModifier((IBeeGenome) genome0, (IBeeGenome) genome1, 1f);
if(processedChance <= 0)
if (processedChance <= 0) {
return 0;
}
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID()))
if (this.allele0.getUID().equals(allele0.getUID()) && this.allele1.getUID().equals(allele1.getUID())) {
return processedChance;
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID()))
}
if (this.allele1.getUID().equals(allele0.getUID()) && this.allele0.getUID().equals(allele1.getUID())) {
return processedChance;
}
return 0;
@@ -4,17 +4,18 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.Arrays;
import forestry.api.apiculture.EnumBeeChromosome;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IMutation;
import forestry.core.genetics.Allele;
import java.util.Arrays;
public class BeeTemplates {
@@ -598,7 +599,7 @@ public class BeeTemplates {
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMycophilic;
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryLarger;
return alleles;
return alleles;
}
/* MONASTIC BRANCH */
@@ -4,20 +4,22 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Random;
import net.minecraft.world.World;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IBeekeepingMode;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Random;
import net.minecraft.world.World;
public class BeekeepingMode implements IBeekeepingMode {
@@ -96,23 +98,27 @@ public class BeekeepingMode implements IBeekeepingMode {
public int getFinalFertility(IBee queen, World world, int x, int y, int z) {
int toCreate = queen.getGenome().getFertility();
if (reducesFertility)
if (reducesFertility) {
toCreate = new Random().nextInt(toCreate);
}
return toCreate;
}
@Override
public boolean isFatigued(IBee queen, IBeeHousing housing) {
if (!canFatigue)
if (!canFatigue) {
return false;
}
if (queen.isNatural())
if (queen.isNatural()) {
return false;
}
if (queen.getGeneration() > 96 + rand.nextInt(6) + rand.nextInt(6) &&
rand.nextFloat() < 0.02f * housing.getGeneticDecay(queen.getGenome(), 1f))
rand.nextFloat() < 0.02f * housing.getGeneticDecay(queen.getGenome(), 1f)) {
return true;
}
return false;
}
@@ -120,9 +126,10 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isOverworked(IBee queen, IBeeHousing housing) {
float productionModifier = housing.getProductionModifier(queen.getGenome(), 1f);
if(productionModifier > 16) {
if(housing.getWorld().rand.nextFloat()*100 < 0.01 * ((productionModifier*productionModifier) - 100))
if (productionModifier > 16) {
if (housing.getWorld().rand.nextFloat() * 100 < 0.01 * ((productionModifier * productionModifier) - 100)) {
return true;
}
}
return false;
@@ -131,9 +138,10 @@ public class BeekeepingMode implements IBeekeepingMode {
@Override
public boolean isDegenerating(IBee queen, IBee offspring, IBeeHousing housing) {
float mutationModifier = housing.getMutationModifier(queen.getGenome(), queen.getMate(), 1.0f);
if(mutationModifier > 10) {
if(housing.getWorld().rand.nextFloat()*100 < 0.4 * ((mutationModifier*mutationModifier) - 100))
if (mutationModifier > 10) {
if (housing.getWorld().rand.nextFloat() * 100 < 0.4 * ((mutationModifier * mutationModifier) - 100)) {
return true;
}
}
return false;
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,21 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.ArrayList;
import java.util.Collections;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.apiculture.EnumBeeType;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IHiveDrop;
import forestry.api.genetics.IAllele;
import forestry.plugins.PluginApiculture;
import java.util.ArrayList;
import java.util.Collections;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class HiveDrop implements IHiveDrop {
@@ -46,8 +48,9 @@ public class HiveDrop implements IHiveDrop {
@Override
public ItemStack getPrincess(World world, int x, int y, int z, int fortune) {
IBee bee = createBee(world);
if(world.rand.nextFloat() < ignobleShare)
if (world.rand.nextFloat() < ignobleShare) {
bee.setIsNatural(false);
}
return PluginApiculture.beeInterface.getMemberStack(bee, EnumBeeType.PRINCESS.ordinal());
}
@@ -62,8 +65,9 @@ public class HiveDrop implements IHiveDrop {
@Override
public ArrayList<ItemStack> getAdditional(World world, int x, int y, int z, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
for (ItemStack stack : additional)
for (ItemStack stack : additional) {
ret.add(stack.copy());
}
return ret;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,20 +4,21 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.biome.BiomeGenBase;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.core.vect.Vect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.biome.BiomeGenBase;
public class JubilanceDefault implements IJubilanceProvider {
@@ -26,8 +27,9 @@ public class JubilanceDefault implements IJubilanceProvider {
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
if (EnumTemperature.getFromValue(biome.temperature) != species.getTemperature() ||
EnumHumidity.getFromValue(biome.rainfall) != species.getHumidity())
EnumHumidity.getFromValue(biome.rainfall) != species.getHumidity()) {
return false;
}
return true;
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,18 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.List;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.AxisAlignedBB;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import java.util.List;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.AxisAlignedBB;
/**
* Hermits will not produce if there are any other living creatures nearby.
@@ -4,19 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.apiculture.IAlleleBeeSpecies;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.core.utils.StackUtils;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class JubilanceReqRes implements IJubilanceProvider {
@@ -29,8 +30,9 @@ public class JubilanceReqRes implements IJubilanceProvider {
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
if (blockRequired == null)
if (blockRequired == null) {
return true;
}
World world = housing.getWorld();
@@ -4,21 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.lang.reflect.Field;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.proxy.Proxies;
import forestry.core.vect.Vect;
import java.lang.reflect.Field;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class MutationEMC extends MutationReqRes {
@@ -40,26 +42,30 @@ public class MutationEMC extends MutationReqRes {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
// If we don't have any chance, return at once.
if (chance <= 0)
if (chance <= 0) {
return 0;
}
if (emcRequired <= 0)
if (emcRequired <= 0) {
return chance;
}
World world = housing.getWorld();
Vect[] possibleTargets = new Vect[] { new Vect(housing.getXCoord() + 1, housing.getYCoord(), housing.getZCoord()),
Vect[] possibleTargets = new Vect[]{new Vect(housing.getXCoord() + 1, housing.getYCoord(), housing.getZCoord()),
new Vect(housing.getXCoord() - 1, housing.getYCoord(), housing.getZCoord()),
new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() + 1),
new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() - 1) };
new Vect(housing.getXCoord(), housing.getYCoord(), housing.getZCoord() - 1)};
for (Vect target : possibleTargets) {
if (!world.blockExists(target.x, target.y, target.z))
if (!world.blockExists(target.x, target.y, target.z)) {
continue;
}
TileEntity entity = world.getTileEntity(target.x, target.y, target.z);
if (entity == null)
if (entity == null) {
continue;
}
if (!condenserClass.isInstance(entity)) {
Proxies.log.warning("Did not find a relay at " + target.toString());
@@ -73,8 +79,9 @@ public class MutationEMC extends MutationReqRes {
Proxies.log.warning("Failed to fetch EMC information.");
}
if (emc < emcRequired * 80)
if (emc < emcRequired * 80) {
continue;
}
boolean removedEMC = false;
try {
@@ -84,8 +91,9 @@ public class MutationEMC extends MutationReqRes {
Proxies.log.warning("Failed to set EMC information.");
}
if (removedEMC)
if (removedEMC) {
return chance;
}
}
@@ -4,19 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import forestry.core.utils.StackUtils;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class MutationReqRes extends BeeMutation {
@@ -32,18 +33,21 @@ public class MutationReqRes extends BeeMutation {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
// If we have no chance anyway, we don't need to check.
if (chance <= 0)
if (chance <= 0) {
return 0;
}
World world = housing.getWorld();
if (blockRequired == null)
if (blockRequired == null) {
return chance;
}
Block block = world.getBlock(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
int meta = world.getBlockMetadata(housing.getXCoord(), housing.getYCoord() - 1, housing.getZCoord());
if (StackUtils.equals(block, blockRequired) && meta == blockRequired.getItemDamage())
if (StackUtils.equals(block, blockRequired) && meta == blockRequired.getItemDamage()) {
return chance;
else
} else {
return 0;
}
}
}
@@ -4,16 +4,17 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.genetics;
import java.util.Calendar;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IGenome;
import java.util.Calendar;
public class MutationTimeLimited extends BeeMutation {
@@ -36,31 +37,37 @@ public class MutationTimeLimited extends BeeMutation {
}
public boolean between(DayMonth start, DayMonth end) {
if (equals(start) || equals(end))
if (equals(start) || equals(end)) {
return true;
if (start.month > end.month)
}
if (start.month > end.month) {
return after(start) || before(end);
}
return after(start) && before(end);
}
public boolean before(DayMonth other) {
if (other.month > this.month)
if (other.month > this.month) {
return true;
}
if (other.month < this.month)
if (other.month < this.month) {
return false;
}
return this.day < other.day;
}
public boolean after(DayMonth other) {
if (other.month < this.month)
if (other.month < this.month) {
return true;
}
if (other.month > this.month)
if (other.month > this.month) {
return false;
}
return this.day > other.day;
}
@@ -75,15 +82,19 @@ public class MutationTimeLimited extends BeeMutation {
@Override
public boolean equals(Object obj) {
if (obj == null)
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
final DayMonth other = (DayMonth) obj;
if (this.day != other.day)
if (this.day != other.day) {
return false;
if (this.month != other.month)
}
if (this.month != other.month) {
return false;
}
return true;
}
@@ -110,29 +121,35 @@ public class MutationTimeLimited extends BeeMutation {
public float getChance(IBeeHousing housing, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1) {
float chance = super.getChance(housing, allele0, allele1, genome0, genome1);
if (chance == 0)
if (chance == 0) {
return 0;
}
if (start == null)
if (start == null) {
return chance;
}
DayMonth now = new DayMonth();
// If we are equal to start day, return chance.
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == start.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == start.month)
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == start.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == start.month) {
return chance;
}
// Still here but not time span? No mutation!
if (end == null)
if (end == null) {
return 0;
}
// Equal to end date, return chance.
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == end.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == end.month)
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == end.day && Calendar.getInstance().get(Calendar.MONTH) + 1 == end.month) {
return chance;
}
// Still a chance we are in between
if (now.between(start, end))
if (now.between(start, end)) {
return chance;
}
// Now we finally failed.
return 0;
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -45,12 +45,15 @@ public class ContainerAlveary extends ContainerForestry {
this.addSlotToContainer(new SlotOutput(tile, 8, 116, 26));
// Player inventory
for (int i = 0; i < 3; i++)
for (int j = 0; j < 9; j++)
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 108 + i * 18));
}
}
// Player hotbar
for (int i = 0; i < 9; i++)
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(player, i, 8 + i * 18, 166));
}
}
@Override
@@ -61,8 +64,9 @@ public class ContainerAlveary extends ContainerForestry {
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
for (Object crafter : crafters)
for (Object crafter : crafters) {
tile.sendGUINetworkData(this, (ICrafting) crafter);
}
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -24,12 +24,15 @@ public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks {
this.addSlotToContainer(new SlotFiltered(tile, TileAlvearyHygroregulator.SLOT_INPUT, 56, 38));
for (int i = 0; i < 3; ++i)
for (int var4 = 0; var4 < 9; ++var4)
for (int i = 0; i < 3; ++i) {
for (int var4 = 0; var4 < 9; ++var4) {
this.addSlotToContainer(new Slot(playerInventory, var4 + i * 9 + 9, 8 + var4 * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; ++i)
for (int i = 0; i < 9; ++i) {
this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142));
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -28,12 +28,15 @@ public class ContainerAlvearySwarmer extends ContainerForestry {
this.addSlotToContainer(new SlotFiltered(tile, 3, 79, 26));
// Player inventory
for (int i = 0; i < 3; i++)
for (int j = 0; j < 9; j++)
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 87 + i * 18));
}
}
// Player hotbar
for (int i = 0; i < 9; i++)
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(player, i, 8 + i * 18, 145));
}
}
}
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -31,11 +31,14 @@ public class ContainerHabitatLocator extends ContainerItemInventory {
this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 75));
// Player inventory
for (int i1 = 0; i1 < 3; i1++)
for (int l1 = 0; l1 < 9; l1++)
for (int i1 = 0; i1 < 3; i1++) {
for (int l1 = 0; l1 < 9; l1++) {
addSecuredSlot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 102 + i1 * 18);
}
}
// Player hotbar
for (int j1 = 0; j1 < 9; j1++)
for (int j1 = 0; j1 < 9; j1++) {
addSecuredSlot(inventoryplayer, j1, 8 + j1 * 18, 160);
}
}
}
@@ -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
******************************************************************************/
@@ -41,25 +41,30 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta
this.addSlotToContainer(new SlotOutput(inventory, 1, 152, 72));
// Player inventory
for (int i1 = 0; i1 < 3; i1++)
for (int l1 = 0; l1 < 9; l1++)
for (int i1 = 0; i1 < 3; i1++) {
for (int l1 = 0; l1 < 9; l1++) {
addSlotToContainer(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 103 + i1 * 18));
}
}
// Player hotbar
for (int j1 = 0; j1 < 9; j1++)
for (int j1 = 0; j1 < 9; j1++) {
addSlotToContainer(new Slot(inventoryplayer, j1, 8 + j1 * 18, 161));
}
}
@Override
public void onContainerClosed(EntityPlayer entityplayer) {
if (!Proxies.common.isSimulating(entityplayer.worldObj))
if (!Proxies.common.isSimulating(entityplayer.worldObj)) {
return;
}
// Drop everything still in there.
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack == null)
if (stack == null) {
continue;
}
Proxies.common.dropItemPlayer(entityplayer, stack);
inventory.setInventorySlotContents(i, null);
@@ -104,15 +109,17 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta
public void handleSelectionChange(EntityPlayer player, PacketUpdate packet) {
if (packet.payload.intPayload[1] == 0) {
if (packet.payload.intPayload[0] == 0)
if (packet.payload.intPayload[0] == 0) {
inventory.advancePrimary();
else
} else {
inventory.advanceSecondary();
}
} else if (packet.payload.intPayload[0] == 0)
} else if (packet.payload.intPayload[0] == 0) {
inventory.regressPrimary();
else
} else {
inventory.regressSecondary();
}
}
public void sendSelection(EntityPlayer player) {
@@ -4,18 +4,19 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.gadgets.TileAlvearyPlain;
import forestry.core.config.Defaults;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.utils.EnumTankLevel;
import forestry.core.utils.Utils;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlveary extends GuiForestryTitled<TileAlvearyPlain> {
@@ -37,20 +38,20 @@ public class GuiAlveary extends GuiForestryTitled<TileAlvearyPlain> {
int i = 176;
int k = 0;
switch (rated) {
case EMPTY:
break;
case LOW:
i += 4;
break;
case MEDIUM:
i += 8;
break;
case HIGH:
i += 12;
break;
case MAXIMUM:
i += 16;
break;
case EMPTY:
break;
case LOW:
i += 4;
break;
case MEDIUM:
i += 8;
break;
case HIGH:
i += 12;
break;
case MAXIMUM:
i += 16;
break;
}
this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
@@ -4,17 +4,18 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.gadgets.TileAlvearyHygroregulator;
import forestry.core.config.Defaults;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.gui.widgets.TankWidget;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlvearyHygroregulator extends GuiForestryTitled<TileAlvearyHygroregulator> {
@@ -4,16 +4,17 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.gadgets.TileAlvearySieve;
import forestry.core.config.Defaults;
import forestry.core.gui.GuiForestry;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlvearySieve extends GuiForestry<TileAlvearySieve> {
@@ -4,16 +4,17 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.gadgets.TileAlvearySwarmer;
import forestry.core.config.Defaults;
import forestry.core.gui.GuiForestry;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiAlvearySwarmer extends GuiForestry<TileAlvearySwarmer> {
@@ -4,19 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.gui;
import net.minecraft.entity.player.InventoryPlayer;
import forestry.apiculture.gadgets.TileApiary;
import forestry.apiculture.gadgets.TileBeehouse;
import forestry.core.config.Defaults;
import forestry.core.gui.GuiForestryTitled;
import forestry.core.utils.EnumTankLevel;
import forestry.core.utils.Utils;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiApiary extends GuiForestryTitled<TileBeehouse> {
@@ -44,20 +45,20 @@ public class GuiApiary extends GuiForestryTitled<TileBeehouse> {
int i = 176;
int k = 0;
switch (rated) {
case EMPTY:
break;
case LOW:
i += 4;
break;
case MEDIUM:
i += 8;
break;
case HIGH:
i += 12;
break;
case MAXIMUM:
i += 16;
break;
case EMPTY:
break;
case LOW:
i += 4;
break;
case MEDIUM:
i += 8;
break;
case HIGH:
i += 12;
break;
case MAXIMUM:
i += 16;
break;
}
this.drawTexturedModalRect(x, y + 46 - height, i, k + 46 - height, 4, height);
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -40,8 +40,9 @@ public class GuiBeealyzer extends GuiAlyzer {
ArrayList<ItemStack> beeList = new ArrayList<ItemStack>();
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList)
for (ItemStack beeStack : beeList) {
iconStacks.put(BeeGenome.getSpecies(beeStack).getUID(), beeStack);
}
}
@Override
@@ -53,38 +54,41 @@ public class GuiBeealyzer extends GuiAlyzer {
EnumBeeType beeType = EnumBeeType.DRONE;
for (int k = BeealyzerInventory.SLOT_SPECIMEN; k <= BeealyzerInventory.SLOT_ANALYZE_5; k++) {
if (k == BeealyzerInventory.SLOT_ENERGY)
if (k == BeealyzerInventory.SLOT_ENERGY) {
continue;
}
if (inventory.getStackInSlot(k) == null)
if (inventory.getStackInSlot(k) == null) {
continue;
}
bee = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(k));
beeType = PluginApiculture.beeInterface.getType(inventory.getStackInSlot(k));
if (bee == null || !bee.isAnalyzed())
if (bee == null || !bee.isAnalyzed()) {
continue;
}
page = k;
break;
}
switch (page) {
case 1:
drawAnalyticsPage1(bee, beeType);
break;
case 2:
drawAnalyticsPage2(bee, beeType);
break;
case 3:
drawAnalyticsPage3(bee, beeType);
break;
case 4:
drawAnalyticsPage4(bee);
break;
case 6:
drawAnalyticsPageClassification(bee);
break;
default:
drawAnalyticsOverview();
case 1:
drawAnalyticsPage1(bee, beeType);
break;
case 2:
drawAnalyticsPage2(bee, beeType);
break;
case 3:
drawAnalyticsPage3(bee, beeType);
break;
case 4:
drawAnalyticsPage4(bee);
break;
case 6:
drawAnalyticsPageClassification(bee);
break;
default:
drawAnalyticsOverview();
}
}
@@ -114,15 +118,15 @@ public class GuiBeealyzer extends GuiAlyzer {
drawChromosomeRow(StringUtil.localize("gui.flowers"), bee, EnumBeeChromosome.FLOWER_PROVIDER);
drawLine(StringUtil.localize("gui.fertility"), COLUMN_0);
IAlleleInteger primaryFertility = (IAlleleInteger)bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY);
IAlleleInteger secondaryFertility = (IAlleleInteger)bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY);
IAlleleInteger primaryFertility = (IAlleleInteger) bee.getGenome().getActiveAllele(EnumBeeChromosome.FERTILITY);
IAlleleInteger secondaryFertility = (IAlleleInteger) bee.getGenome().getInactiveAllele(EnumBeeChromosome.FERTILITY);
drawFertilityInfo(primaryFertility.getValue(), COLUMN_1, getColorCoding(primaryFertility.isDominant()), 0);
drawFertilityInfo(secondaryFertility.getValue(), COLUMN_2, getColorCoding(secondaryFertility.isDominant()), 0);
newLine();
IAlleleArea activeTerritory = (IAlleleArea)bee.getGenome().getActiveAllele(EnumBeeChromosome.TERRITORY);
IAlleleArea inactiveTerritory = (IAlleleArea)bee.getGenome().getInactiveAllele(EnumBeeChromosome.TERRITORY);
IAlleleArea activeTerritory = (IAlleleArea) bee.getGenome().getActiveAllele(EnumBeeChromosome.TERRITORY);
IAlleleArea inactiveTerritory = (IAlleleArea) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TERRITORY);
drawRow(StringUtil.localize("gui.area"),
new Vect(activeTerritory.getValue()).toString(),
new Vect(inactiveTerritory.getValue()).toString(),
@@ -148,8 +152,8 @@ 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);
IAlleleTolerance tempToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance tempToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
IAlleleTolerance tempToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.TEMPERATURE_TOLERANCE);
drawLine(StringUtil.localize("gui.temptol"), COLUMN_0);
drawToleranceInfo(tempToleranceActive, COLUMN_1);
drawToleranceInfo(tempToleranceInactive, COLUMN_2);
@@ -159,8 +163,8 @@ public class GuiBeealyzer extends GuiAlyzer {
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);
IAlleleTolerance humidToleranceInactive = (IAlleleTolerance)bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
IAlleleTolerance humidToleranceActive = (IAlleleTolerance) bee.getGenome().getActiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
IAlleleTolerance humidToleranceInactive = (IAlleleTolerance) bee.getGenome().getInactiveAllele(EnumBeeChromosome.HUMIDITY_TOLERANCE);
drawLine(StringUtil.localize("gui.humidtol"), COLUMN_0);
drawToleranceInfo(humidToleranceActive, COLUMN_1);
drawToleranceInfo(humidToleranceInactive, COLUMN_2);
@@ -172,13 +176,13 @@ public class GuiBeealyzer extends GuiAlyzer {
String no = StringUtil.localize("no");
String diurnal0, diurnal1, nocturnal0, nocturnal1;
if(bee.getGenome().getNocturnal()) {
if (bee.getGenome().getNocturnal()) {
nocturnal0 = diurnal0 = yes;
} else {
nocturnal0 = bee.getGenome().getPrimary().isNocturnal() ? yes : no;
diurnal0 = !bee.getGenome().getPrimary().isNocturnal() ? yes : no;
}
if(((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.NOCTURNAL)).getValue()) {
if (((AlleleBoolean) bee.getGenome().getInactiveAllele(EnumBeeChromosome.NOCTURNAL)).getValue()) {
nocturnal1 = diurnal1 = yes;
} else {
nocturnal1 = bee.getGenome().getSecondary().isNocturnal() ? yes : no;
@@ -212,8 +216,9 @@ public class GuiBeealyzer extends GuiAlyzer {
String displayText;
if (type == EnumBeeType.PRINCESS || type == EnumBeeType.QUEEN) {
displayText = "bees.stock.pristine";
if (!bee.isNatural())
if (!bee.isNatural()) {
displayText = "bees.stock.ignoble";
}
displayText = StringUtil.localize(displayText);
drawCenteredLine(displayText, 8, 208, fontColor.get("gui.beealyzer.binomial"));
}
@@ -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
******************************************************************************/
@@ -36,8 +36,6 @@ import forestry.core.proxy.Proxies;
import forestry.core.render.SpriteSheet;
import forestry.core.render.TextureManager;
import static net.minecraftforge.common.BiomeDictionary.Type.MOUNTAIN;
public class GuiHabitatLocator extends GuiForestry<TileForestry> {
public class HabitatSlot extends Widget {
@@ -74,10 +72,11 @@ public class GuiHabitatLocator extends GuiForestry<TileForestry> {
if (getIcon() != null) {
GL11.glDisable(GL11.GL_LIGHTING);
if (!isActive)
if (!isActive) {
GL11.glColor4f(0.2f, 0.2f, 0.2f, 0.2f);
else
} else {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
Proxies.common.bindTexture(SpriteSheet.ITEMS);
manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos, getIcon(), 16, 16);
@@ -87,7 +86,7 @@ public class GuiHabitatLocator extends GuiForestry<TileForestry> {
}
private final HabitatSlot[] habitatSlots = new HabitatSlot[] {
private final HabitatSlot[] habitatSlots = new HabitatSlot[]{
new HabitatSlot(0, "Ocean"), // ocean, beach
new HabitatSlot(1, "Plains"),
new HabitatSlot(2, "Desert"), // desert, desert hills
@@ -99,7 +98,7 @@ public class GuiHabitatLocator extends GuiForestry<TileForestry> {
new HabitatSlot(8, "Snow"), // Ice plains, mountains, frozen rivers, frozen oceans
new HabitatSlot(9, "Mushroom"),
new HabitatSlot(10, "Nether"),
new HabitatSlot(11, "End") };
new HabitatSlot(11, "End")};
private final Map<BiomeDictionary.Type, HabitatSlot> biomeToHabitat = new HashMap<BiomeDictionary.Type, HabitatSlot>();
private int startX;
@@ -166,12 +165,14 @@ public class GuiHabitatLocator extends GuiForestry<TileForestry> {
for (BiomeDictionary.Type biomeType : activeBiomeTypes) {
HabitatSlot habitatSlot = biomeToHabitat.get(biomeType);
if (habitatSlot != null)
if (habitatSlot != null) {
habitatSlot.isActive = true;
}
}
for (HabitatSlot slot : habitatSlots)
for (HabitatSlot slot : habitatSlots) {
slot.draw(startX, startY);
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Reset afterwards.
}
@@ -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
******************************************************************************/
@@ -51,8 +51,9 @@ public class GuiImprinter extends GuiForestry<TileForestry> {
List<ItemStack> beeList = new ArrayList<ItemStack>();
((ItemBeeGE) ForestryItem.beeDroneGE.item()).addCreativeItems(beeList, false);
for (ItemStack beeStack : beeList)
for (ItemStack beeStack : beeList) {
iconStacks.put(BeeGenome.getSpecies(beeStack).getUID(), beeStack);
}
}
@@ -85,12 +86,14 @@ public class GuiImprinter extends GuiForestry<TileForestry> {
}
private int getHabitatSlotAtPosition(int i, int j) {
int[] xPos = new int[] { 12, 12 };
int[] yPos = new int[] { 32, 52 };
int[] xPos = new int[]{12, 12};
int[] yPos = new int[]{32, 52};
for (int l = 0; l < xPos.length; l++)
if (i >= xPos[l] && i <= xPos[l] + 16 && j >= yPos[l] && j <= yPos[l] + 16)
for (int l = 0; l < xPos.length; l++) {
if (i >= xPos[l] && i <= xPos[l] + 16 && j >= yPos[l] && j <= yPos[l] + 16) {
return l;
}
}
return -1;
}
@@ -103,13 +106,15 @@ public class GuiImprinter extends GuiForestry<TileForestry> {
int cornerY = (height - ySize) / 2;
int slot = getHabitatSlotAtPosition(i - cornerX, j - cornerY);
if (slot < 0)
if (slot < 0) {
return;
}
if (k == 0)
if (k == 0) {
container.advanceSelection(slot, Proxies.common.getRenderWorld());
else
} else {
container.regressSelection(slot, Proxies.common.getRenderWorld());
}
}
@Override
@@ -4,18 +4,18 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.items;
import forestry.core.gadgets.IStructureBlockItem;
import forestry.core.items.ItemForestryBlock;
import net.minecraft.block.Block;
import forestry.core.gadgets.IStructureBlockItem;
import forestry.core.items.ItemForestryBlock;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class ItemAlvearyBlock extends ItemForestryBlock implements IStructureBlockItem {
@@ -4,14 +4,22 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.items;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.apiculture.IArmorApiarist;
import forestry.api.core.IArmorNaturalist;
import forestry.api.core.Tabs;
@@ -19,12 +27,6 @@ import forestry.core.config.Defaults;
import forestry.core.config.ForestryItem;
import forestry.core.render.TextureManager;
import forestry.core.utils.StringUtil;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArmorNaturalist {
@@ -36,10 +38,11 @@ public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArm
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if (ForestryItem.apiaristLegs.isItemEqual(stack))
if (ForestryItem.apiaristLegs.isItemEqual(stack)) {
return Defaults.ID + ":" + Defaults.TEXTURE_APIARIST_ARMOR_SECONDARY;
else
} else {
return Defaults.ID + ":" + Defaults.TEXTURE_APIARIST_ARMOR_PRIMARY;
}
}
@SideOnly(Side.CLIENT)
@@ -106,14 +109,18 @@ public class ItemArmorApiarist extends ItemArmor implements IArmorApiarist, IArm
public static int wearsItems(EntityPlayer player, String cause, boolean protect) {
int count = 0;
if (wearsHelmet(player, cause, protect))
if (wearsHelmet(player, cause, protect)) {
count++;
if (wearsChest(player, cause, protect))
}
if (wearsChest(player, cause, protect)) {
count++;
if (wearsLegs(player, cause, protect))
}
if (wearsLegs(player, cause, protect)) {
count++;
if (wearsBoots(player, cause, protect))
}
if (wearsBoots(player, cause, protect)) {
count++;
}
return count;
}
@@ -10,8 +10,20 @@
******************************************************************************/
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.EnumChatFormatting;
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;
@@ -27,15 +39,6 @@ import forestry.core.config.Config;
import forestry.core.genetics.ItemGE;
import forestry.core.utils.StringUtil;
import forestry.plugins.PluginApiculture;
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.EnumChatFormatting;
import net.minecraft.util.IIcon;
public class ItemBeeGE extends ItemGE {
@@ -45,8 +48,9 @@ public class ItemBeeGE extends ItemGE {
super();
this.type = type;
setCreativeTab(Tabs.tabApiculture);
if (type != EnumBeeType.DRONE)
if (type != EnumBeeType.DRONE) {
setMaxStackSize(1);
}
}
@Override
@@ -72,12 +76,13 @@ public class ItemBeeGE extends ItemGE {
@Override
public String getItemStackDisplayName(ItemStack itemstack) {
if (itemstack.getTagCompound() == null)
if (itemstack.getTagCompound() == null) {
return super.getItemStackDisplayName(itemstack);
}
IBee individual = new Bee(itemstack.getTagCompound());
String customBeeKey = "bees.custom." + type.getName() + "." + individual.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.","");
if(StringUtil.canTranslate(customBeeKey)){
String customBeeKey = "bees.custom." + type.getName() + "." + individual.getGenome().getPrimary().getUnlocalizedName().replace("bees.species.", "");
if (StringUtil.canTranslate(customBeeKey)) {
return StringUtil.localize(customBeeKey);
}
String beeGrammar = StringUtil.localize("bees.grammar." + type.getName());
@@ -86,18 +91,20 @@ public class ItemBeeGE extends ItemGE {
return beeGrammar.replaceAll("%SPECIES", beeSpecies).replaceAll("%TYPE", beeType);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
if(!itemstack.hasTagCompound())
if (!itemstack.hasTagCompound()) {
return;
}
if(type != EnumBeeType.DRONE) {
if (type != EnumBeeType.DRONE) {
IBee individual = new Bee(itemstack.getTagCompound());
if (individual.isNatural())
if (individual.isNatural()) {
list.add(EnumChatFormatting.YELLOW + EnumChatFormatting.ITALIC.toString() + StringUtil.localize("bees.stock.pristine"));
else
} else {
list.add(EnumChatFormatting.YELLOW + StringUtil.localize("bees.stock.ignoble"));
}
}
super.addInformation(itemstack, player, list, flag);
@@ -106,19 +113,21 @@ public class ItemBeeGE extends ItemGE {
@SuppressWarnings("rawtypes")
@Override
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
if (type == EnumBeeType.QUEEN)
if (type == EnumBeeType.QUEEN) {
return;
}
addCreativeItems(itemList, true);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public void addCreativeItems(List itemList, boolean hideSecrets) {
for (IIndividual individual : PluginApiculture.beeInterface.getIndividualTemplates()) {
// Don't show secret bees unless ordered to.
if (hideSecrets && individual.isSecret() && !Config.isDebug)
if (hideSecrets && individual.isSecret() && !Config.isDebug) {
continue;
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
ItemStack someStack = new ItemStack(this);
@@ -131,8 +140,9 @@ public class ItemBeeGE extends ItemGE {
/* RENDERING */
@Override
public int getColorFromItemStack(ItemStack itemstack, int renderPass) {
if (!itemstack.hasTagCompound())
if (!itemstack.hasTagCompound()) {
return super.getColorFromItemStack(itemstack, renderPass);
}
return getColourFromSpecies(BeeGenome.getSpecies(itemstack), renderPass);
}
@@ -140,10 +150,11 @@ public class ItemBeeGE extends ItemGE {
@Override
public int getColourFromSpecies(IAlleleSpecies species, int renderPass) {
if (species != null && species instanceof IAlleleBeeSpecies)
if (species != null && species instanceof IAlleleBeeSpecies) {
return species.getIconColour(renderPass);
else
} else {
return 0xffffff;
}
}
@@ -161,9 +172,11 @@ public class ItemBeeGE extends ItemGE {
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister register) {
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
if (allele instanceof IAlleleBeeSpecies)
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
if (allele instanceof IAlleleBeeSpecies) {
((IAlleleBeeSpecies) allele).getIconProvider().registerIcons(register);
}
}
}
@SideOnly(Side.CLIENT)
@@ -174,8 +187,9 @@ public class ItemBeeGE extends ItemGE {
@SideOnly(Side.CLIENT)
public IIcon getIconFromSpecies(IAlleleBeeSpecies species, int renderPass) {
if (species == null)
if (species == null) {
species = (IAlleleBeeSpecies) PluginApiculture.beeInterface.getDefaultTemplate()[EnumBeeChromosome.SPECIES.ordinal()];
}
return species.getIcon(type, renderPass);
}
@@ -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
******************************************************************************/
@@ -44,23 +44,26 @@ public class ItemBeealyzer extends ItemInventoried {
private void tryAnalyze() {
// Source slot to analyze empty
if (getStackInSlot(SLOT_SPECIMEN) == null)
if (getStackInSlot(SLOT_SPECIMEN) == null) {
return;
}
IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_SPECIMEN));
// No bee, abort
if (bee == null)
if (bee == null) {
return;
}
// Analyze if necessary
if (!bee.isAnalyzed()) {
// Requires energy
if (!isEnergy(getStackInSlot(SLOT_ENERGY)))
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
return;
}
bee.analyze();
if(player != null) {
if (player != null) {
PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getPrimary());
PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile()).registerSpecies(bee.getGenome().getSecondary());
}
@@ -103,8 +106,9 @@ public class ItemBeealyzer extends ItemInventoried {
@Override
public EnumErrorCode getErrorState() {
if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY)))
if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) {
return EnumErrorCode.NOHONEY;
}
return EnumErrorCode.OK;
}
@@ -118,8 +122,9 @@ public class ItemBeealyzer extends ItemInventoried {
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
if (Proxies.common.isSimulating(world))
if (Proxies.common.isSimulating(world)) {
entityplayer.openGui(ForestryAPI.instance, GuiId.BeealyzerGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ);
}
return itemstack;
}
@@ -4,21 +4,23 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.items;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.apiculture.gadgets.BlockCandle;
import forestry.core.items.ItemForestryBlock;
import net.minecraft.block.Block;
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.apiculture.gadgets.BlockCandle;
import forestry.core.items.ItemForestryBlock;
public class ItemCandleBlock extends ItemForestryBlock {
public ItemCandleBlock(Block block) {
@@ -47,8 +49,7 @@ public class ItemCandleBlock extends ItemForestryBlock {
if (BlockCandle.isLit(itemStack)) {
value = value + ".lit";
}
else {
} else {
value = value + ".stump";
}
return value;
@@ -57,7 +58,7 @@ public class ItemCandleBlock extends ItemForestryBlock {
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamageForRenderPass(int meta, int pass) {
return ((BlockCandle)this.getBlock()).getTextureFromPassAndMeta((meta != 0) ? 8 : 0, pass);
return ((BlockCandle) this.getBlock()).getTextureFromPassAndMeta((meta != 0) ? 8 : 0, pass);
}
@Override
@@ -4,7 +4,7 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
@@ -16,13 +16,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChunkCoordinates;
@@ -30,12 +28,10 @@ import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.Forestry;
import forestry.api.apiculture.IBee;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
@@ -51,8 +47,6 @@ import forestry.core.interfaces.IHintSource;
import forestry.core.inventory.ItemInventory;
import forestry.core.items.ItemInventoried;
import forestry.core.network.GuiId;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketIds;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
import forestry.core.vect.Vect;
@@ -71,12 +65,13 @@ public class ItemHabitatLocator extends ItemInventoried {
public HabitatLocatorInventory(ItemStack itemstack) {
super(ItemHabitatLocator.class, 3, itemstack);
this.habitatLocator = (ItemHabitatLocator)itemstack.getItem();
this.habitatLocator = (ItemHabitatLocator) itemstack.getItem();
}
private boolean isEnergy(ItemStack itemstack) {
if (itemstack == null || itemstack.stackSize <= 0)
if (itemstack == null || itemstack.stackSize <= 0) {
return false;
}
return ForestryItem.honeyDrop.isItemEqual(itemstack) || ForestryItem.honeydew.isItemEqual(itemstack);
}
@@ -85,8 +80,9 @@ public class ItemHabitatLocator extends ItemInventoried {
if (getStackInSlot(SLOT_SPECIMEN) != null) {
// Requires energy
if (!isEnergy(getStackInSlot(SLOT_ENERGY)))
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
return;
}
// Decrease energy
decrStackSize(SLOT_ENERGY, 1);
@@ -98,8 +94,9 @@ public class ItemHabitatLocator extends ItemInventoried {
IBee bee = PluginApiculture.beeInterface.getMember(getStackInSlot(SLOT_ANALYZED));
// No bee, abort
if (bee == null)
if (bee == null) {
return;
}
biomesToSearch = new HashSet<BiomeGenBase>(bee.getSuitableBiomes());
habitatLocator.startBiomeSearch(biomesToSearch);
@@ -129,8 +126,9 @@ public class ItemHabitatLocator extends ItemInventoried {
@Override
public EnumErrorCode getErrorState() {
if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY)))
if (PluginApiculture.beeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) {
return EnumErrorCode.NOHONEY;
}
return EnumErrorCode.OK;
}
@@ -163,8 +161,9 @@ public class ItemHabitatLocator extends ItemInventoried {
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
if (Proxies.common.isSimulating(world))
if (Proxies.common.isSimulating(world)) {
entityplayer.openGui(ForestryAPI.instance, GuiId.HabitatLocatorGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY, (int) entityplayer.posZ);
}
return itemstack;
}
@@ -173,14 +172,14 @@ public class ItemHabitatLocator extends ItemInventoried {
@SideOnly(Side.CLIENT)
@Override
public void registerIcons(IIconRegister register) {
if(register instanceof TextureMap) {
if (register instanceof TextureMap) {
TextureAtlasSprite texture = new TextureHabitatLocator();
((TextureMap)register).setTextureEntry("forestry:biomefinder", texture);
((TextureMap) register).setTextureEntry("forestry:biomefinder", texture);
itemIcon = texture;
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
BiomeGenBase currentBiome = player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ);
@@ -208,8 +207,9 @@ public class ItemHabitatLocator extends ItemInventoried {
@Override
public void onUpdate(ItemStack p_77663_1_, World world, Entity player, int p_77663_4_, boolean p_77663_5_) {
if (!Proxies.common.isSimulating(world))
if (!Proxies.common.isSimulating(world)) {
return;
}
if (this.searchCenter == null) {
this.searchCenter = new Vect((int) player.posX, (int) player.posY, (int) player.posZ);
@@ -218,8 +218,9 @@ public class ItemHabitatLocator extends ItemInventoried {
removeInvalidBiomes(currentBiome, biomesToSearch);
}
if (biomesToSearch.isEmpty())
if (biomesToSearch.isEmpty()) {
return;
}
// once we've found the biome, slow down to conserve cpu and network data
if (biomeFound && world.getTotalWorldTime() % 20 != 0) {
@@ -299,24 +300,29 @@ public class ItemHabitatLocator extends ItemInventoried {
BiomeGenBase biome;
biome = world.getBiomeGenForCoords(pos.x, pos.z);
if (!biomesToSearch.contains(biome))
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x - minBiomeRadius, pos.z);
if (!biomesToSearch.contains(biome))
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x + minBiomeRadius, pos.z);
if (!biomesToSearch.contains(biome))
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x, pos.z - minBiomeRadius);
if (!biomesToSearch.contains(biome))
if (!biomesToSearch.contains(biome)) {
return null;
}
biome = world.getBiomeGenForCoords(pos.x, pos.z + minBiomeRadius);
if (!biomesToSearch.contains(biome))
if (!biomesToSearch.contains(biome)) {
return null;
}
return new ChunkCoordinates(pos.x, pos.y, pos.z);
}
@@ -324,6 +330,7 @@ public class ItemHabitatLocator extends ItemInventoried {
private static final Set<BiomeGenBase> waterBiomes = new HashSet<BiomeGenBase>();
private static final Set<BiomeGenBase> netherBiomes = new HashSet<BiomeGenBase>();
private static final Set<BiomeGenBase> endBiomes = new HashSet<BiomeGenBase>();
static {
Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.BEACH));
Collections.addAll(waterBiomes, BiomeDictionary.getBiomesForType(BiomeDictionary.Type.OCEAN));
@@ -4,19 +4,20 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.items;
import net.minecraft.item.ItemStack;
import forestry.api.apiculture.IBee;
import forestry.api.apiculture.IBeeGenome;
import forestry.api.apiculture.IBeeHousing;
import forestry.api.apiculture.IHiveFrame;
import forestry.api.core.Tabs;
import forestry.core.items.ItemForestry;
import net.minecraft.item.ItemStack;
public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
@@ -33,10 +34,11 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
@Override
public ItemStack frameUsed(IBeeHousing housing, ItemStack frame, IBee queen, int wear) {
frame.setItemDamage(frame.getItemDamage() + wear);
if (frame.getItemDamage() >= frame.getMaxDamage())
if (frame.getItemDamage() >= frame.getMaxDamage()) {
return null;
else
} else {
return frame;
}
}
@Override
@@ -4,22 +4,24 @@
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.items;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import forestry.api.core.Tabs;
import forestry.core.config.Config;
import forestry.core.config.ForestryItem;
import forestry.core.items.ItemForestryMultiPass;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemHoneycomb extends ItemForestryMultiPass {
@@ -41,25 +43,26 @@ public class ItemHoneycomb extends ItemForestryMultiPass {
return this;
}
}
public final CombInfo[] combs = new CombInfo[]{
new CombInfo("honey", 0xe8d56a, 0xffa12b), // 0
new CombInfo("cocoa", 0x674016, 0xffb62b).setIsSecret(), // 1
new CombInfo("simmering", 0x981919, 0xffb62b), // 2
new CombInfo("stringy", 0xc8be67, 0xbda93e), // 3
new CombInfo("frozen", 0xf9ffff, 0xa0ffff), // 4
new CombInfo("dripping", 0xdc7613, 0xffff00), // 5
new CombInfo("silky", 0x508907, 0xddff00), // 6
new CombInfo("parched", 0xdcbe13, 0xffff00), // 7
new CombInfo("mysterious", 0x161616, 0xe099ff).setIsSecret(), // 8
new CombInfo("irradiated", 0xeafff3, 0xeeff00).setIsSecret(), // 9
new CombInfo("powdery", 0xe4e4e4, 0xffffff).setIsSecret(), // 10
new CombInfo("reddened", 0x4b0000, 0x6200e7).setIsSecret(), // 11
new CombInfo("darkened", 0x353535, 0x33ebcb).setIsSecret(), // 12
new CombInfo("omega", 0x191919, 0x6dcff6).setIsSecret(), // 13
new CombInfo("wheaten", 0xfeff8f, 0xffffff).setIsSecret(), // 14
new CombInfo("mossy", 0x2a3313, 0x7e9939), // 15
new CombInfo("mellow", 0x886000, 0xfff960) // 16
// new CombInfo("", 0xd7bee5, 0xfd58ab), // kindof pinkish
new CombInfo("honey", 0xe8d56a, 0xffa12b), // 0
new CombInfo("cocoa", 0x674016, 0xffb62b).setIsSecret(), // 1
new CombInfo("simmering", 0x981919, 0xffb62b), // 2
new CombInfo("stringy", 0xc8be67, 0xbda93e), // 3
new CombInfo("frozen", 0xf9ffff, 0xa0ffff), // 4
new CombInfo("dripping", 0xdc7613, 0xffff00), // 5
new CombInfo("silky", 0x508907, 0xddff00), // 6
new CombInfo("parched", 0xdcbe13, 0xffff00), // 7
new CombInfo("mysterious", 0x161616, 0xe099ff).setIsSecret(), // 8
new CombInfo("irradiated", 0xeafff3, 0xeeff00).setIsSecret(), // 9
new CombInfo("powdery", 0xe4e4e4, 0xffffff).setIsSecret(), // 10
new CombInfo("reddened", 0x4b0000, 0x6200e7).setIsSecret(), // 11
new CombInfo("darkened", 0x353535, 0x33ebcb).setIsSecret(), // 12
new CombInfo("omega", 0x191919, 0x6dcff6).setIsSecret(), // 13
new CombInfo("wheaten", 0xfeff8f, 0xffffff).setIsSecret(), // 14
new CombInfo("mossy", 0x2a3313, 0x7e9939), // 15
new CombInfo("mellow", 0x886000, 0xfff960) // 16
// new CombInfo("", 0xd7bee5, 0xfd58ab), // kindof pinkish
};
public ItemHoneycomb() {
@@ -86,18 +89,21 @@ public class ItemHoneycomb extends ItemForestryMultiPass {
@Override
public int getColorFromItemStack(ItemStack itemstack, int j) {
if (j == 0)
if (j == 0) {
return combs[itemstack.getItemDamage()].primaryColor;
else
} else {
return combs[itemstack.getItemDamage()].secondaryColor;
}
}
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
for (int i = 0; i < combs.length; i++)
if (!combs[i].isSecret || Config.isDebug)
for (int i = 0; i < combs.length; i++) {
if (!combs[i].isSecret || Config.isDebug) {
itemList.add(new ItemStack(this, 1, i));
}
}
}
public int getCombTypeCount() {
@@ -106,14 +112,17 @@ public class ItemHoneycomb extends ItemForestryMultiPass {
public int getRandomCombType(Random random, boolean includeSecret) {
List<Integer> validCombs = new ArrayList<Integer>(getCombTypeCount());
for (int i = 0; i < combs.length; i++)
if (!combs[i].isSecret || includeSecret)
for (int i = 0; i < combs.length; i++) {
if (!combs[i].isSecret || includeSecret) {
validCombs.add(i);
}
}
if (validCombs.isEmpty())
if (validCombs.isEmpty()) {
return 0;
else
} else {
return validCombs.get(random.nextInt(validCombs.size()));
}
}
public static ItemStack getRandomComb(int qty, Random random, boolean includeSecret) {
@@ -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
******************************************************************************/
@@ -44,31 +44,35 @@ public class ItemImprinter extends ItemForestry {
}
public void advancePrimary() {
if (primaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1)
if (primaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1) {
primaryIndex++;
else
} else {
primaryIndex = 0;
}
}
public void advanceSecondary() {
if (secondaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1)
if (secondaryIndex < PluginApiculture.beeInterface.getIndividualTemplates().size() - 1) {
secondaryIndex++;
else
} else {
secondaryIndex = 0;
}
}
public void regressPrimary() {
if (primaryIndex > 0)
if (primaryIndex > 0) {
primaryIndex--;
else
} else {
primaryIndex = PluginApiculture.beeInterface.getIndividualTemplates().size() - 1;
}
}
public void regressSecondary() {
if (secondaryIndex > 0)
if (secondaryIndex > 0) {
secondaryIndex--;
else
} else {
secondaryIndex = PluginApiculture.beeInterface.getIndividualTemplates().size() - 1;
}
}
public IAlleleBeeSpecies getPrimary() {
@@ -103,20 +107,24 @@ public class ItemImprinter extends ItemForestry {
private void tryImprint() {
if (inventoryStacks[specimenSlot] == null)
if (inventoryStacks[specimenSlot] == null) {
return;
}
// Only imprint bees
if (!PluginApiculture.beeInterface.isMember(inventoryStacks[specimenSlot]))
if (!PluginApiculture.beeInterface.isMember(inventoryStacks[specimenSlot])) {
return;
}
// Needs space
if (inventoryStacks[imprintedSlot] != null)
if (inventoryStacks[imprintedSlot] != null) {
return;
}
IBee imprint = getSelectedBee();
if (imprint == null)
if (imprint == null) {
return;
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
imprint.writeToNBT(nbttagcompound);
@@ -128,8 +136,9 @@ public class ItemImprinter extends ItemForestry {
@Override
public void markDirty() {
if (!Proxies.common.isSimulating(player.worldObj))
if (!Proxies.common.isSimulating(player.worldObj)) {
return;
}
tryImprint();
}
@@ -153,9 +162,10 @@ public class ItemImprinter extends ItemForestry {
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
if (Proxies.common.isSimulating(world))
if (Proxies.common.isSimulating(world)) {
entityplayer.openGui(ForestryAPI.instance, GuiId.ImprinterGUI.ordinal(), world, (int) entityplayer.posX, (int) entityplayer.posY,
(int) entityplayer.posZ);
}
return itemstack;
}
Loaded 100 of 763 files, more files were not shown because too many files have changed in this diff. Show more