mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfbab6b988 | ||
|
|
3978a068d1 | ||
|
|
9d2d0af432 | ||
|
|
d451309170 | ||
|
|
c82dd0fbfb | ||
|
|
803911e10a | ||
|
|
29eedf9011 | ||
|
|
882848a00f | ||
|
|
4d253e1dd6 | ||
|
|
f0c535f30a | ||
|
|
1d162bf5ca | ||
|
|
af036b64e8 | ||
|
|
06a86742bb | ||
|
|
e48fbe948e | ||
|
|
d4cd2153ef | ||
|
|
4887926994 | ||
|
|
9989451c1c | ||
|
|
ce3d891eaa | ||
|
|
e8c2223f01 | ||
|
|
714206d8c8 | ||
|
|
6593d75234 | ||
|
|
97a96b8f3f | ||
|
|
5bc0f0156e | ||
|
|
b922c89bb1 | ||
|
|
8eb601b6cf | ||
|
|
f86031f884 | ||
|
|
d59072b771 | ||
|
|
c780ec6aaf | ||
|
|
558d78bc63 | ||
|
|
0f61cea75e | ||
|
|
08a9badc54 | ||
|
|
d71b0e5646 | ||
|
|
8a870b9c76 | ||
|
|
59885f1916 | ||
|
|
7f54ddaa83 | ||
|
|
eb502ac0ca | ||
|
|
2b2370be43 | ||
|
|
0aec8b65e9 | ||
|
|
3de7766db6 | ||
|
|
671752d1cf | ||
|
|
b42837ef70 | ||
|
|
f5407f9e88 | ||
|
|
fc0ef3eef0 | ||
|
|
76ceb7a46c | ||
|
|
d169666f43 | ||
|
|
5802178bbd | ||
|
|
d30b2482df | ||
|
|
f4e9c61e3a | ||
|
|
7362286ead | ||
|
|
90b13eac1d | ||
|
|
f76af59569 | ||
|
|
5d12fa7550 | ||
|
|
16922e6b99 | ||
|
|
46b24745a4 | ||
|
|
4b355a6c4a | ||
|
|
9efe1a940e | ||
|
|
ee114f82ec | ||
|
|
12a81c5357 | ||
|
|
a149a29171 | ||
|
|
82556c850e | ||
|
|
e265ffe09e | ||
|
|
b9b71cf015 | ||
|
|
9536bf1b78 | ||
|
|
298795690e | ||
|
|
af59a2ad6a | ||
|
|
4d7988ee0f | ||
|
|
ab0952ac2b | ||
|
|
042b36a350 | ||
|
|
1ac0cf5489 | ||
|
|
5f8661a17f | ||
|
|
6a607e4551 | ||
|
|
172a2c00ac | ||
|
|
7dff774368 | ||
|
|
272152d48e | ||
|
|
2fce803456 | ||
|
|
a679d46c57 | ||
|
|
2b4dfcdae3 | ||
|
|
786dbd82c7 | ||
|
|
0848cfb891 | ||
|
|
7fc90fb76e | ||
|
|
08741959b3 | ||
|
|
93062955ba | ||
|
|
fd41fb9ff7 | ||
|
|
a9b90f4fef | ||
|
|
f5245e766b | ||
|
|
4d43e918f1 | ||
|
|
bf2da35086 | ||
|
|
e0737d2851 | ||
|
|
dceffe23c3 | ||
|
|
f6e1147271 | ||
|
|
7028a17649 | ||
|
|
b08a618baa | ||
|
|
433c516166 | ||
|
|
1ce2d45417 | ||
|
|
b18cee80cb | ||
|
|
62fcb24160 | ||
|
|
f6b92ad6ac | ||
|
|
c576f745fb | ||
|
|
870906188c | ||
|
|
9df241b1ac | ||
|
|
c218d6c9e1 | ||
|
|
ee55d90746 | ||
|
|
8597d67416 | ||
|
|
56dfae034d | ||
|
|
636201ce5a | ||
|
|
f6bbf33b7a | ||
|
|
9eec976f7b | ||
|
|
5b8b0c78b0 | ||
|
|
8e92d16320 | ||
|
|
853d69a0f1 | ||
|
|
97285cfcb2 | ||
|
|
d4f3f0d327 | ||
|
|
0b71684778 | ||
|
|
0f085e0691 | ||
|
|
c3f37a379a | ||
|
|
5a7bd9f57a | ||
|
|
7ec3b8bf9b | ||
|
|
dab217eab0 | ||
|
|
dffa845851 | ||
|
|
1aefd5863e | ||
|
|
8745f56f8b | ||
|
|
273dae3298 | ||
|
|
b1b877f530 | ||
|
|
6870dafe02 | ||
|
|
b3b1a6a415 | ||
|
|
953a84f346 | ||
|
|
3ac0ac9625 | ||
|
|
c6dae0318c | ||
|
|
7ace6d7faa | ||
|
|
8eb366997d | ||
|
|
dc1449855e | ||
|
|
f832025f6d | ||
|
|
b36d10308b | ||
|
|
195c8fc524 | ||
|
|
bdd386c431 |
No files matched your search
+1
-1
Submodule api/forestry updated: b41c05d38a...3e5b83d1b9.
@@ -1,6 +1,5 @@
|
||||
mcversion=1.7.10
|
||||
forgeversion=10.13.2.1286
|
||||
version_major=3
|
||||
version_minor=4
|
||||
version_patch=0
|
||||
|
||||
version_minor=5
|
||||
version_patch=3
|
||||
@@ -0,0 +1,3 @@
|
||||
Account;Email;Date;
|
||||
samtrion;[email protected];2015-01-18
|
||||
GenuineSounds;[email protected];2015-02-26
|
||||
Binary file not shown.
+1
-1
Submodule lang updated: 1b85a75323...fa0f81998b.
Executable → Regular
+17
-12
@@ -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,10 +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,)")
|
||||
+ "after:Buildcraft|Core@[6.1.7,);"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
+ "after:BiomesOPlenty;"
|
||||
+ "after:IC2@[2.0.140,);"
|
||||
+ "after:Natura@[2.2.0,);")
|
||||
//, certificateFingerprint = Version.FINGERPRINT)
|
||||
public class Forestry {
|
||||
|
||||
@@ -90,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;
|
||||
@@ -136,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) {
|
||||
@@ -156,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;
|
||||
}
|
||||
@@ -372,11 +381,16 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
housing.onQueenDeath(getQueen());
|
||||
|
||||
// Princess
|
||||
IBee heiress = queen.spawnPrincess(housing);
|
||||
if (heiress != null) {
|
||||
ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
|
||||
breedingTracker.registerPrincess(heiress);
|
||||
offspring.push(princess);
|
||||
boolean secondPrincess = this.housing.getWorld().rand.nextInt(100) < PluginApiculture.getSecondPrincessChance();
|
||||
int count = secondPrincess ? 2 : 1;
|
||||
while (count > 0) {
|
||||
count--;
|
||||
IBee heiress = queen.spawnPrincess(housing);
|
||||
if (heiress != null) {
|
||||
ItemStack princess = PluginApiculture.beeInterface.getMemberStack(heiress, EnumBeeType.PRINCESS.ordinal());
|
||||
breedingTracker.registerPrincess(heiress);
|
||||
offspring.push(princess);
|
||||
}
|
||||
}
|
||||
|
||||
// Drones
|
||||
@@ -389,8 +403,9 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
|
||||
while (!offspring.isEmpty()) {
|
||||
ItemStack spawned = offspring.pop();
|
||||
if (!housing.addProduct(spawned, true))
|
||||
if (!housing.addProduct(spawned, true)) {
|
||||
spawn.add(spawned);
|
||||
}
|
||||
}
|
||||
|
||||
housing.onPostQueenDeath(getQueen());
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public class FlowerProviderCacti implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// Specific check for flower pots.
|
||||
if (block == Blocks.flower_pot)
|
||||
return checkFlowerPot(world.getBlockMetadata(x, y, z));
|
||||
|
||||
return block == Blocks.cactus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
return pollinatable.getPlantType().contains(EnumPlantType.Desert);
|
||||
}
|
||||
|
||||
private boolean checkFlowerPot(int meta) {
|
||||
return meta == 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0)
|
||||
return growInPot(world, x, y, z);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean growInPot(World world, int x, int y, int z) {
|
||||
if (world.rand.nextBoolean())
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 9, Defaults.FLAG_BLOCK_SYNCH);
|
||||
else
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 10, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.cacti");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.cactus) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public class FlowerProviderEnd implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == Blocks.dragon_egg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.end");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.dragon_egg) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public class FlowerProviderGourd implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == Blocks.pumpkin_stem || block == Blocks.melon_stem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// We only grow wheat, we don't plant it
|
||||
if (block != Blocks.pumpkin_stem && block != Blocks.melon_stem)
|
||||
return false;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta > 6)
|
||||
return false;
|
||||
|
||||
if (meta < 6)
|
||||
meta += 2;
|
||||
else
|
||||
meta = 7;
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.gourd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public class FlowerProviderMushroom implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// Specific check for flower pots.
|
||||
if (block == Blocks.flower_pot)
|
||||
return checkFlowerPot(world.getBlockMetadata(x, y, z));
|
||||
|
||||
return block == Blocks.brown_mushroom || block == Blocks.red_mushroom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
private boolean checkFlowerPot(int meta) {
|
||||
return meta == 7 || meta == 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (!block.isAir(world, x, y, z))
|
||||
if (block == Blocks.flower_pot)
|
||||
return growInPot(world, x, y, z);
|
||||
else
|
||||
return false;
|
||||
|
||||
// Check ground
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
|
||||
if (ground != Blocks.mycelium)
|
||||
return false;
|
||||
|
||||
Block mushroom;
|
||||
if (world.rand.nextBoolean())
|
||||
mushroom = Blocks.brown_mushroom;
|
||||
else
|
||||
mushroom = Blocks.red_mushroom;
|
||||
|
||||
world.setBlock(x, y, z, mushroom, 0, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean growInPot(World world, int x, int y, int z) {
|
||||
if (world.rand.nextBoolean())
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 7, Defaults.FLAG_BLOCK_SYNCH);
|
||||
else
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 8, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.mushroom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.brown_mushroom), new ItemStack(Blocks.red_mushroom) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public class FlowerProviderNetherwart implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == Blocks.nether_wart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
return pollinatable.getPlantType().contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// We only grow netherwart, we don't plant it
|
||||
if (block != Blocks.nether_wart)
|
||||
return false;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta >= 3)
|
||||
return false;
|
||||
|
||||
if (meta == 2)
|
||||
meta = 3;
|
||||
else
|
||||
meta = 2;
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.nether");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.nether_wart) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public class FlowerProviderVanilla implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
// Specific check for flower pots.
|
||||
if (block == Blocks.flower_pot)
|
||||
return checkFlowerPot(meta);
|
||||
|
||||
ItemStack flower = new ItemStack(block, 1, meta);
|
||||
|
||||
for (ItemStack stack : FlowerManager.plainFlowers)
|
||||
if (flower.isItemEqual(stack))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
private boolean checkFlowerPot(int meta) {
|
||||
return meta == 1 || meta == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (!block.isAir(world, x, y, z))
|
||||
if (block == Blocks.flower_pot && world.getBlockMetadata(x, y, z) == 0)
|
||||
return growInPot(world, x, y, z);
|
||||
else
|
||||
return false;
|
||||
|
||||
// Check ground
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
|
||||
if (ground != Blocks.dirt && ground != Blocks.grass)
|
||||
return false;
|
||||
|
||||
// Determine flower to plant
|
||||
Collections.shuffle(FlowerManager.plainFlowers);
|
||||
ItemStack flower = FlowerManager.plainFlowers.get(world.rand.nextInt(FlowerManager.plainFlowers.size() - 1));
|
||||
world.setBlock(x, y, z, StackUtils.getBlock(flower), flower.getItemDamage(), Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean growInPot(World world, int x, int y, int z) {
|
||||
if (world.rand.nextBoolean())
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 1, Defaults.FLAG_BLOCK_SYNCH);
|
||||
else
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 2, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.vanilla");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return FlowerManager.plainFlowers.toArray(new ItemStack[FlowerManager.plainFlowers.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public class FlowerProviderWheat implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == Blocks.wheat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
// We only grow wheat, we don't plant it
|
||||
if (block != Blocks.wheat)
|
||||
return false;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta > 6)
|
||||
return false;
|
||||
|
||||
if (meta < 6)
|
||||
meta += 2;
|
||||
else
|
||||
meta = 7;
|
||||
|
||||
world.setBlockMetadataWithNotify(x, y, z, meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.wheat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] affectProducts(World world, IIndividual individual, int x, int y, int z, ItemStack[] products) {
|
||||
return products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.wheat, 1, 8) };
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
******************************************************************************/
|
||||
@@ -37,7 +37,7 @@ import forestry.apiculture.gui.GuiBeealyzer;
|
||||
import forestry.apiculture.gui.GuiHabitatLocator;
|
||||
import forestry.apiculture.gui.GuiImprinter;
|
||||
import forestry.apiculture.items.ItemBeealyzer.BeealyzerInventory;
|
||||
import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory;
|
||||
import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory;
|
||||
import forestry.apiculture.items.ItemImprinter.ImprinterInventory;
|
||||
import forestry.core.GuiHandlerBase;
|
||||
import forestry.core.gui.ContainerAlyzer;
|
||||
@@ -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 BiomefinderInventory(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 BiomefinderInventory(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,46 +4,47 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
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 {
|
||||
|
||||
@Override
|
||||
public void onPacketData(int packetID, DataInputStream data, EntityPlayer player) {
|
||||
public boolean onPacketData(int packetID, DataInputStream data, EntityPlayer player) throws IOException {
|
||||
|
||||
try {
|
||||
|
||||
switch (packetID) {
|
||||
switch (packetID) {
|
||||
case PacketIds.HABITAT_BIOME_POINTER:
|
||||
PacketCoordinates packetC = new PacketCoordinates();
|
||||
packetC.readData(data);
|
||||
Proxies.common.setBiomefinderCoordinates(player, packetC.getCoordinates());
|
||||
break;
|
||||
Proxies.common.setHabitatLocatorCoordinates(player, packetC.getCoordinates());
|
||||
return true;
|
||||
case PacketIds.IMPRINT_SELECTION_GET:
|
||||
onImprintSelectionGet(player);
|
||||
break;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void onImprintSelectionGet(EntityPlayer playerEntity) {
|
||||
|
||||
if (!(playerEntity.openContainer instanceof ContainerImprinter))
|
||||
if (!(playerEntity.openContainer instanceof ContainerImprinter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerImprinter) playerEntity.openContainer).sendSelection(playerEntity);
|
||||
|
||||
|
||||
@@ -4,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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
|
||||
final class Flower implements IFlower {
|
||||
|
||||
private final Block block;
|
||||
private final int meta;
|
||||
private Double weight;
|
||||
|
||||
public Flower(Block block, int meta, double weight) {
|
||||
this.block = block;
|
||||
this.meta = meta;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public boolean isPlantable() {
|
||||
return this.weight != 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof IFlower)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFlower flower = (IFlower) obj;
|
||||
|
||||
return Block.isEqualTo(this.block, flower.getBlock()) && (this.meta == OreDictionary.WILDCARD_VALUE || flower.getMeta() == OreDictionary.WILDCARD_VALUE || this.meta == flower.getMeta());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IFlower other) {
|
||||
return this.weight.compareTo(other.getWeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeight(double weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
}
|
||||
Executable → Regular
+35
-37
@@ -4,66 +4,64 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
public class FlowerProviderJungle implements IFlowerProvider {
|
||||
public class FlowerProvider implements IFlowerProvider {
|
||||
|
||||
private final String flowerType;
|
||||
private final String description;
|
||||
|
||||
public FlowerProvider(String flowerType, String description) {
|
||||
this.flowerType = flowerType;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
// Specific check for flower pots.
|
||||
if (block == Blocks.flower_pot)
|
||||
return checkFlowerPot(meta);
|
||||
|
||||
return block == Blocks.vine || (block == Blocks.tallgrass && meta == 2);
|
||||
return FlowerManager.flowerRegistry.isAcceptedFlower(this.flowerType, world, individual, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
|
||||
EnumSet<EnumPlantType> types = pollinatable.getPlantType();
|
||||
return types.size() > 1 || !types.contains(EnumPlantType.Nether);
|
||||
}
|
||||
|
||||
private boolean checkFlowerPot(int meta) {
|
||||
return meta == 11;
|
||||
EnumSet<EnumPlantType> plantTypes = pollinatable.getPlantType();
|
||||
|
||||
if (flowerType.equals(FlowerManager.FlowerTypeNether)) {
|
||||
return plantTypes.contains(EnumPlantType.Nether);
|
||||
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
|
||||
return plantTypes.contains(EnumPlantType.Desert);
|
||||
} else {
|
||||
return plantTypes.size() > 1 || !plantTypes.contains(EnumPlantType.Nether);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(World world, IIndividual individual, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (block == Blocks.flower_pot)
|
||||
return growInPot(world, x, y, z);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean growInPot(World world, int x, int y, int z) {
|
||||
world.setBlock(x, y, z, Blocks.flower_pot, 11, Defaults.FLAG_BLOCK_SYNCH);
|
||||
return true;
|
||||
return FlowerManager.flowerRegistry.growFlower(this.flowerType, world, individual, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtil.localize("flowers.jungle");
|
||||
return StringUtil.localize(this.description);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,8 +70,8 @@ public class FlowerProviderJungle implements IFlowerProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return new ItemStack[] { new ItemStack(Blocks.vine), new ItemStack(Blocks.tallgrass, 1, 2) };
|
||||
public List<IFlower> getFlowers() {
|
||||
return FlowerManager.flowerRegistry.getAcceptableFlowers(this.flowerType);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFlowerPot;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public final class FlowerRegistry implements IFlowerRegistry {
|
||||
|
||||
private final ArrayListMultimap<String, IFlower> registeredFlowers;
|
||||
private final ArrayListMultimap<String, IFlowerGrowthRule> growthRules;
|
||||
private final Map<String, TreeMap<Double, IFlower>> chances;
|
||||
|
||||
private boolean hasDeprecatedFlowersImported;
|
||||
|
||||
public FlowerRegistry() {
|
||||
this.registeredFlowers = ArrayListMultimap.create();
|
||||
this.growthRules = ArrayListMultimap.create();
|
||||
this.chances = new HashMap<String, TreeMap<Double, IFlower>>();
|
||||
|
||||
this.hasDeprecatedFlowersImported = false;
|
||||
|
||||
registerVanillaFlowers();
|
||||
registerVanillaGrowthRules();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAcceptableFlower(Block block, String... flowerTypes) {
|
||||
registerFlower(block, OreDictionary.WILDCARD_VALUE, 0.0, flowerTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAcceptableFlower(Block block, int meta, String... flowerTypes) {
|
||||
registerFlower(block, meta, 0.0, flowerTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPlantableFlower(Block block, int meta, double weight, String... flowerTypes) {
|
||||
registerFlower(block, meta, weight, flowerTypes);
|
||||
}
|
||||
|
||||
private void registerFlower(Block block, int meta, double weight, String... flowerTypes) {
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
if (weight <= 0.0) {
|
||||
weight = 0.0;
|
||||
}
|
||||
if (weight >= 1.0) {
|
||||
weight = 1.0;
|
||||
}
|
||||
|
||||
Flower newFlower = new Flower(block, meta, weight);
|
||||
Integer index;
|
||||
|
||||
for (String flowerType : flowerTypes) {
|
||||
List<IFlower> flowers = this.registeredFlowers.get(flowerType);
|
||||
|
||||
index = flowers.indexOf(newFlower);
|
||||
if (index == -1) {
|
||||
flowers.add(newFlower);
|
||||
} else if (flowers.get(index).getWeight() > newFlower.getWeight()) {
|
||||
flowers.get(index).setWeight(newFlower.getWeight());
|
||||
}
|
||||
|
||||
if (this.chances.containsKey(flowerType)) {
|
||||
this.chances.remove(flowerType);
|
||||
}
|
||||
|
||||
Collections.sort(this.registeredFlowers.get(flowerType));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAcceptedFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
internalInitialize();
|
||||
if (!this.registeredFlowers.containsKey(flowerType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
|
||||
if (block.isAir(world, x, y, z) || block.equals(Blocks.bedrock) || block.equals(Blocks.dirt) || block.equals(Blocks.grass)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int meta;
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityFlowerPot) {
|
||||
TileEntityFlowerPot tileFlowerPot = (TileEntityFlowerPot) tile;
|
||||
Item item = tileFlowerPot.getFlowerPotItem();
|
||||
block = Block.getBlockFromItem(item);
|
||||
meta = tileFlowerPot.getFlowerPotData();
|
||||
} else {
|
||||
meta = world.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
Flower flower = new Flower(block, meta, 0);
|
||||
List<IFlower> acceptedFlowers = this.registeredFlowers.get(flowerType);
|
||||
return acceptedFlowers.contains(flower);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
internalInitialize();
|
||||
if (!this.growthRules.containsKey(flowerType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (IFlowerGrowthRule rule : this.growthRules.get(flowerType)) {
|
||||
if (rule.growFlower(this, flowerType, world, individual, x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IFlower> getAcceptableFlowers(String flowerType) {
|
||||
internalInitialize();
|
||||
|
||||
return this.registeredFlowers.get(flowerType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGrowthRule(IFlowerGrowthRule rule, String... flowerTypes) {
|
||||
if (rule == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String flowerType : flowerTypes) {
|
||||
this.growthRules.get(flowerType).add(rule);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFlower getRandomPlantableFlower(String flowerType, Random rand) {
|
||||
TreeMap<Double, IFlower> chancesMap = getChancesMap(flowerType);
|
||||
double maxKey = chancesMap.lastKey() + 1.0;
|
||||
return chancesMap.get(chancesMap.lowerKey(rand.nextDouble() * maxKey));
|
||||
}
|
||||
|
||||
private TreeMap<Double, IFlower> getChancesMap(String flowerType) {
|
||||
if (!this.chances.containsKey(flowerType)) {
|
||||
TreeMap<Double, IFlower> flowerChances = new TreeMap<Double, IFlower>();
|
||||
double count = 0.0;
|
||||
for (IFlower flower : this.registeredFlowers.get(flowerType)) {
|
||||
if (flower.isPlantable()) {
|
||||
flowerChances.put(count, flower);
|
||||
count += flower.getWeight();
|
||||
}
|
||||
}
|
||||
this.chances.put(flowerType, flowerChances);
|
||||
}
|
||||
return this.chances.get(flowerType);
|
||||
}
|
||||
|
||||
/*
|
||||
* Method to support deprecated FlowerManager.plainFlowers
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private void internalInitialize() {
|
||||
if (!hasDeprecatedFlowersImported) {
|
||||
for (ItemStack plainFlower : FlowerManager.plainFlowers) {
|
||||
Block flowerBlock = Block.getBlockFromItem(plainFlower.getItem());
|
||||
int meta = plainFlower.getItemDamage();
|
||||
registerPlantableFlower(flowerBlock, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
}
|
||||
|
||||
hasDeprecatedFlowersImported = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void registerVanillaFlowers() {
|
||||
// Register plantable plants
|
||||
for (int meta = 0; meta <= 8; meta++) {
|
||||
registerPlantableFlower(Blocks.red_flower, meta, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
}
|
||||
|
||||
registerPlantableFlower(Blocks.yellow_flower, 0, 1.0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerPlantableFlower(Blocks.brown_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
|
||||
registerPlantableFlower(Blocks.red_mushroom, 0, 1.0, FlowerManager.FlowerTypeMushrooms);
|
||||
registerPlantableFlower(Blocks.cactus, 0, 1.0, FlowerManager.FlowerTypeCacti);
|
||||
|
||||
// Register acceptable plants
|
||||
registerAcceptableFlower(Blocks.red_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.yellow_flower, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.brown_mushroom, FlowerManager.FlowerTypeMushrooms);
|
||||
registerAcceptableFlower(Blocks.red_mushroom, FlowerManager.FlowerTypeMushrooms);
|
||||
registerAcceptableFlower(Blocks.cactus, FlowerManager.FlowerTypeCacti);
|
||||
|
||||
registerAcceptableFlower(Blocks.dragon_egg, FlowerManager.FlowerTypeEnd);
|
||||
registerAcceptableFlower(Blocks.vine, FlowerManager.FlowerTypeJungle);
|
||||
registerAcceptableFlower(Blocks.tallgrass, FlowerManager.FlowerTypeJungle);
|
||||
registerAcceptableFlower(Blocks.wheat, FlowerManager.FlowerTypeWheat);
|
||||
registerAcceptableFlower(Blocks.pumpkin_stem, FlowerManager.FlowerTypeGourd);
|
||||
registerAcceptableFlower(Blocks.melon_stem, FlowerManager.FlowerTypeGourd);
|
||||
registerAcceptableFlower(Blocks.nether_wart, FlowerManager.FlowerTypeNether);
|
||||
|
||||
registerAcceptableFlower(Blocks.double_plant, 0, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.double_plant, 1, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.double_plant, 4, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerAcceptableFlower(Blocks.double_plant, 5, FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
}
|
||||
|
||||
private void registerVanillaGrowthRules() {
|
||||
registerGrowthRule(new VanillaDirtGrassGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow);
|
||||
registerGrowthRule(new VanillaSnowGrowthRule(), FlowerManager.FlowerTypeSnow);
|
||||
registerGrowthRule(new VanillaFlowerPotGrowthRule(), FlowerManager.FlowerTypeVanilla, FlowerManager.FlowerTypeSnow, FlowerManager.FlowerTypeMushrooms, FlowerManager.FlowerTypeCacti,
|
||||
FlowerManager.FlowerTypeJungle);
|
||||
registerGrowthRule(new VanillaMyceliumGrowthRule(), FlowerManager.FlowerTypeMushrooms);
|
||||
registerGrowthRule(new VanillaDefaultGrowthRule(), FlowerManager.FlowerTypeEnd);
|
||||
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.melon_stem, Blocks.pumpkin_stem), FlowerManager.FlowerTypeGourd);
|
||||
registerGrowthRule(new VanillaFertilizeGrowthRule(Blocks.wheat), FlowerManager.FlowerTypeWheat);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VanillaDefaultGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Defaults;
|
||||
|
||||
public class VanillaDirtGrassGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry flowerRegistry, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
if (ground != Blocks.dirt && ground != Blocks.grass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFlower flower = flowerRegistry.getRandomPlantableFlower(flowerType, world.rand);
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VanillaFertilizeGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
private final List<Block> allowedItems;
|
||||
|
||||
public VanillaFertilizeGrowthRule(Block... allowedItems) {
|
||||
this.allowedItems = Arrays.asList(allowedItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
Block ground = world.getBlock(x, y, z);
|
||||
int groundMeta;
|
||||
for (Block b : this.allowedItems) {
|
||||
if (b == ground) {
|
||||
groundMeta = world.getBlockMetadata(x, y, z);
|
||||
if (groundMeta > 6) {
|
||||
return false;
|
||||
}
|
||||
if (groundMeta < 6) {
|
||||
groundMeta += world.rand.nextInt(2) + 1;
|
||||
} else {
|
||||
groundMeta = 7;
|
||||
}
|
||||
|
||||
return world.setBlockMetadataWithNotify(x, y, z, groundMeta, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFlowerPot;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFlowerPot;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.apiculture.FlowerManager;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
public class VanillaFlowerPotGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (!(tile instanceof TileEntityFlowerPot)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntityFlowerPot flowerPotTile = (TileEntityFlowerPot) tile;
|
||||
if (flowerPotTile.getFlowerPotItem() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(x, y, z);
|
||||
if (!(block instanceof BlockFlowerPot)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockFlowerPot flowerPot = (BlockFlowerPot) block;
|
||||
|
||||
int flower;
|
||||
if (flowerType.equals(FlowerManager.FlowerTypeVanilla) || flowerType.equals(FlowerManager.FlowerTypeSnow)) {
|
||||
flower = world.rand.nextInt(2) + 1;
|
||||
} else if (flowerType.equals(FlowerManager.FlowerTypeJungle)) {
|
||||
flower = 6;
|
||||
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
|
||||
flower = world.rand.nextInt(2) + 9;
|
||||
} else if (flowerType.equals(FlowerManager.FlowerTypeMushrooms)) {
|
||||
flower = world.rand.nextInt(2) + 7;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
TileEntityFlowerPot newTile = (TileEntityFlowerPot) flowerPot.createNewTileEntity(world, flower);
|
||||
|
||||
flowerPotTile.func_145964_a(newTile.getFlowerPotItem(), newTile.getFlowerPotData());
|
||||
flowerPotTile.markDirty();
|
||||
|
||||
if (!world.setBlockMetadataWithNotify(x, y, z, 1, 2)) {
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Defaults;
|
||||
|
||||
public class VanillaMyceliumGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
if (!world.isAirBlock(x, y, z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
if (ground != Blocks.mycelium) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.genetics.IFlower;
|
||||
import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.config.Defaults;
|
||||
|
||||
public class VanillaSnowGrowthRule implements IFlowerGrowthRule {
|
||||
|
||||
@Override
|
||||
public boolean growFlower(IFlowerRegistry fr, String flowerType, World world, IIndividual individual, int x, int y, int z) {
|
||||
if (world.getBlock(x, y, z) != Blocks.snow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block ground = world.getBlock(x, y - 1, z);
|
||||
if (ground != Blocks.dirt && ground != Blocks.grass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IFlower flower = fr.getRandomPlantableFlower(flowerType, world.rand);
|
||||
return world.setBlock(x, y, z, flower.getBlock(), flower.getMeta(), Defaults.FLAG_BLOCK_SYNCH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,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() {
|
||||
@@ -58,17 +60,20 @@ public class BlockBeehives extends BlockContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) {
|
||||
public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) {
|
||||
if (canHarvestBlock(player, world.getBlockMetadata(x, y, z))) {
|
||||
// Handle TE'd beehives
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile instanceof TileSwarm) {
|
||||
TileSwarm swarm = (TileSwarm) tile;
|
||||
if (swarm.containsBees())
|
||||
for (ItemStack beeStack : 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,15 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!Proxies.common.isSimulating(worldObj))
|
||||
updateClientSide();
|
||||
else {
|
||||
if (!isInited) {
|
||||
initialize();
|
||||
isInited = true;
|
||||
}
|
||||
super.updateEntity();
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
updateClientSide();
|
||||
} else {
|
||||
// Periodic validation if needed
|
||||
if (worldObj.getTotalWorldTime() % 200 == 0 && (!isIntegratedIntoStructure() || isMaster()))
|
||||
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
|
||||
validateStructure();
|
||||
}
|
||||
|
||||
updateServerSide();
|
||||
}
|
||||
@@ -99,8 +96,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 +133,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 +157,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 +175,25 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
@Override
|
||||
public ITileStructure getCentralTE() {
|
||||
|
||||
if (!isIntegratedIntoStructure())
|
||||
if (!isIntegratedIntoStructure()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isMaster()) {
|
||||
TileEntity tile = worldObj.getTileEntity(masterX, masterY, masterZ);
|
||||
if (tile instanceof ITileStructure) {
|
||||
ITileStructure master = (ITileStructure) worldObj.getTileEntity(masterX, masterY, masterZ);
|
||||
if (master.isMaster())
|
||||
if (master.isMaster()) {
|
||||
return master;
|
||||
else
|
||||
} else {
|
||||
return null;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,19 +4,21 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.energy.EnergyManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler {
|
||||
|
||||
@@ -32,6 +34,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
this.boundaryUp = boundaryUp;
|
||||
}
|
||||
}
|
||||
|
||||
protected final EnergyManager energyManager;
|
||||
private final ClimateControl climateControl;
|
||||
private int workingTime = 0;
|
||||
@@ -47,17 +50,14 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
this.textureOn = textureOn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player) {
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!this.hasMaster())
|
||||
if (!this.hasMaster()) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean wasInactive = (workingTime == 0);
|
||||
|
||||
@@ -69,8 +69,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 +87,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 (!updateOnInterval(20)) {
|
||||
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,20 +145,23 @@ 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)
|
||||
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
}
|
||||
|
||||
if (getErrorState() == EnumErrorCode.OK)
|
||||
queen.doFX(beekeepingLogic.getEffectData(), this);
|
||||
// Add swarm effects
|
||||
if (updateOnInterval(200)) {
|
||||
ISidedInventory inventory = getStructureInventory();
|
||||
if (inventory != null) {
|
||||
onQueenChange(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
}
|
||||
}
|
||||
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) {
|
||||
if (getErrorState() == EnumErrorCode.OK) {
|
||||
queen.doFX(beekeepingLogic.getEffectData(), this);
|
||||
}
|
||||
|
||||
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(50)) {
|
||||
float f = xCoord + 0.5F;
|
||||
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
|
||||
float f2 = zCoord + 0.5F;
|
||||
@@ -172,17 +179,19 @@ 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);
|
||||
if (PluginApiculture.beeInterface.isMated(queenStack)) {
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) {
|
||||
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(queenStack);
|
||||
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
|
||||
}
|
||||
@@ -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
|
||||
******************************************************************************/
|
||||
@@ -25,6 +25,7 @@ import forestry.core.interfaces.ICrafter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
|
||||
public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListener {
|
||||
@@ -61,29 +62,33 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if(!hasMaster() || !isIntegratedIntoStructure())
|
||||
if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
|
||||
((IAlvearyComponent) getCentralTE()).registerBeeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
if(worldObj.getTotalWorldTime() % 200 != 0)
|
||||
if (!updateOnInterval(200)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!hasMaster() || !isIntegratedIntoStructure())
|
||||
if (!hasMaster() || !isIntegratedIntoStructure()) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IAlvearyComponent)getCentralTE()).registerBeeListener(this);
|
||||
((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 +99,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 +121,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;
|
||||
}
|
||||
@@ -129,9 +136,9 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack takenFromSlot(int slotIndex, boolean consumeRecipe, EntityPlayer player) {
|
||||
public ItemStack takenFromSlot(int slotIndex, EntityPlayer player) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if(slotIndex == SLOT_SIEVE) {
|
||||
if (slotIndex == SLOT_SIEVE) {
|
||||
destroyPollen();
|
||||
return inventory.getStackInSlot(SLOT_SIEVE);
|
||||
} else {
|
||||
@@ -146,18 +153,31 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
}
|
||||
|
||||
/* IBEELISTENER */
|
||||
@Override public void onQueenChange(ItemStack queen) {}
|
||||
@Override public void wearOutEquipment(int amount) {}
|
||||
@Override public void onQueenDeath(IBee queen) {}
|
||||
@Override public void onPostQueenDeath(IBee queen) {}
|
||||
@Override
|
||||
public void onQueenChange(ItemStack queen) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueenDeath(IBee queen) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostQueenDeath(IBee queen) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
|
||||
|
||||
if(isHandled)
|
||||
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
|
||||
******************************************************************************/
|
||||
@@ -13,6 +13,7 @@ package forestry.apiculture.gadgets;
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
|
||||
|
||||
@@ -27,23 +28,26 @@ public class TileAlvearyStabiliser extends TileAlveary implements IBeeModifier {
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if(!hasMaster() || !isIntegratedIntoStructure())
|
||||
if (!hasMaster() || !isIntegratedIntoStructure() || !Proxies.common.isSimulating(worldObj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
|
||||
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
if(worldObj.getTotalWorldTime() % 200 != 0)
|
||||
if (!updateOnInterval(200)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!hasMaster() || !isIntegratedIntoStructure())
|
||||
if (!hasMaster() || !isIntegratedIntoStructure()) {
|
||||
return;
|
||||
}
|
||||
|
||||
((IAlvearyComponent)getCentralTE()).registerBeeModifier(this);
|
||||
((IAlvearyComponent) getCentralTE()).registerBeeModifier(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,8 +59,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 (updateOnInterval(1000)) {
|
||||
trySpawnSwarm();
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
setIsActive(false);
|
||||
}
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 500 != 0)
|
||||
if (!updateOnInterval(500)) {
|
||||
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 (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) {
|
||||
if (PluginApiculture.beeInterface.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) {
|
||||
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN));
|
||||
displayQueen.doFX(logic.getEffectData(), this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -173,29 +175,14 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
logic.update();
|
||||
|
||||
IBee queen = logic.getQueen();
|
||||
if (queen == null)
|
||||
if (queen == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add swarm effects
|
||||
if (worldObj.getTotalWorldTime() % 200 * 10 == 0)
|
||||
if (updateOnInterval(200)) {
|
||||
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);
|
||||
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 50 == 0) {
|
||||
float f = xCoord + 0.5F;
|
||||
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
|
||||
float f2 = zCoord + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F;
|
||||
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f - f3), f1, (f2 + f4), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f3), f1, (f2 + f4), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 - f3), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 + f3), 0F, 0F, 0F);
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
@@ -211,8 +198,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 +210,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 +270,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
|
||||
******************************************************************************/
|
||||
|
||||
Executable → Regular
+11
-7
@@ -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.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 net.minecraft.world.EnumSkyBlock;
|
||||
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
|
||||
public class TileSwarm extends TileEntity {
|
||||
|
||||
public final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
|
||||
@@ -41,16 +42,19 @@ public class TileSwarm extends TileEntity {
|
||||
}
|
||||
|
||||
public TileSwarm setContained(ItemStack[] bees) {
|
||||
for (ItemStack itemstack : bees)
|
||||
InvTools.addStack(contained, itemstack, false, true);
|
||||
for (ItemStack itemstack : bees) {
|
||||
InvTools.addStack(contained, itemstack, true);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean containsBees() {
|
||||
for (int i = 0; i < contained.getSizeInventory(); i++)
|
||||
if (contained.getStackInSlot(i) != null)
|
||||
for (int i = 0; i < contained.getSizeInventory(); i++) {
|
||||
if (contained.getStackInSlot(i) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
@@ -46,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,18 +75,18 @@ 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) {
|
||||
AxisAlignedBB aabb = this.getBounding(genome, housing, 1f);
|
||||
World world = housing.getWorld();
|
||||
@SuppressWarnings("unchecked") // Quiets warnings. Eventually returns a list of entities.
|
||||
List<Entity> entities = (List<Entity>)world.getEntitiesWithinAABB(EntityCow.class, aabb);
|
||||
for (Entity entity : entities) {
|
||||
|
||||
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,24 +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 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 {
|
||||
|
||||
/** Required for creation from map storage */
|
||||
public ApiaristTracker(String s) {
|
||||
this(s, null);
|
||||
}
|
||||
@@ -58,12 +61,15 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
|
||||
|
||||
@Override
|
||||
public void registerPickup(IIndividual individual) {
|
||||
if(!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID))
|
||||
if (!individual.getGenome().getPrimary().getRoot().getUID().equals(BeeHelper.UID)) {
|
||||
return;
|
||||
if(!individual.isPureBred(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());
|
||||
}
|
||||
@@ -102,12 +108,12 @@ public class ApiaristTracker extends BreedingTracker implements IApiaristTracker
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IBreedingTracker getCommonTracker(EntityPlayer player) {
|
||||
return PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, null);
|
||||
protected IBreedingTracker getBreedingTracker(EntityPlayer player) {
|
||||
return PluginApiculture.beeInterface.getBreedingTracker(player.worldObj, player.getGameProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPacketTag() {
|
||||
protected String speciesRootUID() {
|
||||
return BeeHelper.UID;
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+141
-87
@@ -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,6 +45,8 @@ import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.arboriculture.genetics.FakePollinatable;
|
||||
import forestry.arboriculture.genetics.ICheckPollinatable;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.genetics.Chromosome;
|
||||
@@ -97,19 +99,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 +124,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 +152,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 +165,21 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
public IEffectData[] doEffect(IEffectData[] storedData, IBeeHousing housing) {
|
||||
IAlleleBeeEffect effect = genome.getEffect();
|
||||
|
||||
if (effect == null)
|
||||
if (effect == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
storedData[0] = doEffect(effect, storedData[0], housing);
|
||||
|
||||
// Return here if the primary can already not be combined
|
||||
if (!effect.isCombinable())
|
||||
if (!effect.isCombinable()) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
|
||||
if (!secondary.isCombinable())
|
||||
if (!secondary.isCombinable()) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
storedData[1] = doEffect(secondary, storedData[1], housing);
|
||||
|
||||
@@ -183,18 +195,21 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
public IEffectData[] doFX(IEffectData[] storedData, IBeeHousing housing) {
|
||||
IAlleleBeeEffect effect = genome.getEffect();
|
||||
|
||||
if (effect == null)
|
||||
if (effect == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
storedData[0] = doFX(effect, storedData[0], housing);
|
||||
|
||||
// Return here if the primary can already not be combined
|
||||
if (!effect.isCombinable())
|
||||
if (!effect.isCombinable()) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
IAlleleBeeEffect secondary = (IAlleleBeeEffect) genome.getInactiveAllele(EnumBeeChromosome.EFFECT);
|
||||
if (!secondary.isCombinable())
|
||||
if (!secondary.isCombinable()) {
|
||||
return storedData;
|
||||
}
|
||||
|
||||
storedData[1] = doFX(secondary, storedData[1], housing);
|
||||
|
||||
@@ -244,29 +259,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 (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
|
||||
return EnumErrorCode.INVALIDBIOME;
|
||||
}
|
||||
|
||||
return EnumErrorCode.OK;
|
||||
}
|
||||
@@ -279,19 +301,17 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
return !genome.getPrimary().isNocturnal() || genome.getNocturnal();
|
||||
}
|
||||
|
||||
private boolean checkBiomeHazard(BiomeGenBase biome) {
|
||||
if (biome == null)
|
||||
public boolean isSuitableBiome(BiomeGenBase biome) {
|
||||
if (biome == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EnumTemperature temperature = EnumTemperature.getFromBiome(biome);
|
||||
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
|
||||
return AlleleManager.climateHelper.isWithinLimits(temperature, humidity,
|
||||
genome.getPrimary().getTemperature(), genome.getToleranceTemp(),
|
||||
genome.getPrimary().getHumidity(), genome.getToleranceHumid());
|
||||
return isSuitableClimate(temperature, humidity);
|
||||
}
|
||||
|
||||
private boolean checkSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) {
|
||||
|
||||
private boolean isSuitableClimate(EnumTemperature temperature, EnumHumidity humidity) {
|
||||
return AlleleManager.climateHelper.isWithinLimits(temperature, humidity,
|
||||
genome.getPrimary().getTemperature(), genome.getToleranceTemp(),
|
||||
genome.getPrimary().getHumidity(), genome.getToleranceHumid());
|
||||
@@ -326,9 +346,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 (isSuitableBiome(biome)) {
|
||||
suitableBiomes.add(biome.biomeID);
|
||||
}
|
||||
}
|
||||
|
||||
return suitableBiomes;
|
||||
}
|
||||
@@ -336,9 +358,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 (isSuitableBiome(biome)) {
|
||||
suitableBiomes.add(biome);
|
||||
}
|
||||
}
|
||||
|
||||
return suitableBiomes;
|
||||
}
|
||||
@@ -355,34 +379,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 +422,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 +450,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 +474,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 +494,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 +535,14 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
public IBee spawnPrincess(IBeeHousing housing) {
|
||||
|
||||
// We need a mated queen to produce offspring.
|
||||
if (mate == null)
|
||||
if (mate == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fatigued queens do not produce princesses.
|
||||
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing))
|
||||
if (PluginApiculture.beeInterface.getBeekeepingMode(housing.getWorld()).isFatigued(this, housing)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return createOffspring(housing, getGeneration() + 1);
|
||||
}
|
||||
@@ -512,16 +553,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 +574,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,25 +592,22 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
// Check for mutation. Replace one of the parents with the mutation
|
||||
// template if mutation occured.
|
||||
IChromosome[] mutated1 = mutateSpecies(housing, genome, mate);
|
||||
if (mutated1 != null)
|
||||
if (mutated1 != null) {
|
||||
parent1 = mutated1;
|
||||
}
|
||||
IChromosome[] mutated2 = mutateSpecies(housing, mate, genome);
|
||||
if (mutated2 != null)
|
||||
if (mutated2 != null) {
|
||||
parent2 = mutated2;
|
||||
}
|
||||
|
||||
for (int i = 0; i < parent1.length; i++)
|
||||
if (parent1[i] != null && parent2[i] != null)
|
||||
for (int i = 0; i < parent1.length; i++) {
|
||||
if (parent1[i] != null && parent2[i] != null) {
|
||||
chromosomes[i] = Chromosome.inheritChromosome(world.rand, parent1[i], parent2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(world);
|
||||
IBee offspring = new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
|
||||
|
||||
/* Disabling the mutation rate nerf
|
||||
// All mutation and no play makes queen a dull girl.
|
||||
if(mode.isDegenerating(this, offspring, housing))
|
||||
offspring.setIsNatural(false);*/
|
||||
|
||||
return offspring;
|
||||
return new Bee(new BeeGenome(chromosomes), mode.isNaturalOffspring(this), generation);
|
||||
}
|
||||
|
||||
private IChromosome[] mutateSpecies(IBeeHousing housing, IGenome genomeOne, IGenome genomeTwo) {
|
||||
@@ -617,8 +658,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 +675,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 +699,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);
|
||||
@@ -667,17 +712,24 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
Vect randomPos = Vect.getRandomPositionInArea(random, area);
|
||||
Vect posBlock = Vect.add(housingPos, randomPos, offset);
|
||||
|
||||
IPollinatable receiver = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z);
|
||||
if(receiver == null)
|
||||
ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock.x, posBlock.y, posBlock.z);
|
||||
if (checkPollinatable == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, receiver))
|
||||
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, new FakePollinatable(checkPollinatable))) {
|
||||
continue;
|
||||
if (!receiver.canMateWith(pollen))
|
||||
}
|
||||
if (!checkPollinatable.canMateWith(pollen)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
receiver.mateWith(pollen);
|
||||
return true;
|
||||
IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwnerName(), world, posBlock.x, posBlock.y, posBlock.z);
|
||||
|
||||
if (realPollinatable != null) {
|
||||
realPollinatable.mateWith(pollen);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -692,8 +744,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 +758,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());
|
||||
}
|
||||
@@ -221,23 +228,27 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
/**
|
||||
* List of possible mutations on species alleles.
|
||||
*/
|
||||
private static ArrayList<IBeeMutation> beeMutations = new ArrayList<IBeeMutation>();
|
||||
private static final ArrayList<IBeeMutation> beeMutations = new ArrayList<IBeeMutation>();
|
||||
|
||||
@Override
|
||||
public Collection<IBeeMutation> getMutations(boolean shuffle) {
|
||||
if (shuffle)
|
||||
if (shuffle) {
|
||||
Collections.shuffle(beeMutations);
|
||||
}
|
||||
return beeMutations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMutation(IMutation mutation) {
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID()))
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getTemplate()[0].getUID())) {
|
||||
return;
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID()))
|
||||
}
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele0().getUID())) {
|
||||
return;
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID()))
|
||||
}
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(mutation.getAllele1().getUID())) {
|
||||
return;
|
||||
}
|
||||
|
||||
beeMutations.add((IBeeMutation) mutation);
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -292,7 +293,7 @@ public class BeeTemplates {
|
||||
public static IAllele[] getAustereBranchTemplate() {
|
||||
IAllele[] alleles = getDefaultTemplate();
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1;
|
||||
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolTrue;
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersCacti;
|
||||
return alleles;
|
||||
@@ -327,8 +328,8 @@ public class BeeTemplates {
|
||||
// / TROPICAL BRANCH
|
||||
public static IAllele[] getTropicalBranchTemplate() {
|
||||
IAllele[] alleles = getDefaultTemplate();
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceDown1;
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceUp1;
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersJungle;
|
||||
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectMiasmic;
|
||||
return alleles;
|
||||
@@ -400,6 +401,7 @@ public class BeeTemplates {
|
||||
public static IAllele[] getFrozenBranchTemplate() {
|
||||
IAllele[] alleles = getDefaultTemplate();
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceUp1;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersSnow;
|
||||
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectGlacial;
|
||||
return alleles;
|
||||
@@ -571,7 +573,6 @@ public class BeeTemplates {
|
||||
IAllele[] alleles = getDefaultTemplate();
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersMushrooms;
|
||||
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlower;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceBoth1;
|
||||
return alleles;
|
||||
}
|
||||
@@ -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,67 +4,41 @@
|
||||
* 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 forestry.apiculture.items.ItemBiomefinder;
|
||||
import forestry.apiculture.items.ItemBiomefinder.BiomefinderInventory;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.apiculture.items.ItemHabitatLocator.HabitatLocatorInventory;
|
||||
import forestry.core.gui.ContainerItemInventory;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
|
||||
public class ContainerHabitatLocator extends ContainerItemInventory {
|
||||
|
||||
public final BiomefinderInventory inventory;
|
||||
|
||||
public ContainerHabitatLocator(InventoryPlayer inventoryplayer, BiomefinderInventory inventory) {
|
||||
public ContainerHabitatLocator(InventoryPlayer inventoryplayer, HabitatLocatorInventory inventory) {
|
||||
super(inventory, inventoryplayer.player);
|
||||
|
||||
this.inventory = inventory;
|
||||
|
||||
// Energy
|
||||
this.addSlotToContainer(new SlotFiltered(inventory, 2, 152, 8));
|
||||
|
||||
// Bee to analyze
|
||||
this.addSlotToContainer(new SlotFiltered(inventory, 0, 152, 32));
|
||||
// Analyzed bee
|
||||
this.addSlotToContainer(new SlotFiltered(inventory, 1, 152, 75));
|
||||
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++)
|
||||
addSecuredSlot(inventoryplayer, j1, 8 + j1 * 18, 160);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer) {
|
||||
|
||||
if (!Proxies.common.isSimulating(entityplayer.worldObj))
|
||||
return;
|
||||
|
||||
((ItemBiomefinder) ForestryItem.biomeFinder.item()).startBiomeSearch(entityplayer.worldObj, entityplayer, inventory.biomesToSearch);
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory() - 1; i++) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
continue;
|
||||
|
||||
Proxies.common.dropItemPlayer(entityplayer, stack);
|
||||
inventory.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
// Player hotbar
|
||||
for (int j1 = 0; j1 < 9; j1++) {
|
||||
addSecuredSlot(inventoryplayer, j1, 8 + j1 * 18, 160);
|
||||
}
|
||||
|
||||
inventory.onGuiSaved(entityplayer);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,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.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> {
|
||||
public class GuiAlveary extends GuiForestryTitled<ContainerAlveary, TileAlvearyPlain> {
|
||||
|
||||
public GuiAlveary(InventoryPlayer inventory, TileAlvearyPlain tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/alveary.png", new ContainerAlveary(inventory, tile), tile);
|
||||
@@ -29,7 +30,7 @@ public class GuiAlveary extends GuiForestryTitled<TileAlvearyPlain> {
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
TileAlvearyPlain machine = tile;
|
||||
TileAlvearyPlain machine = inventory;
|
||||
drawHealthMeter(guiLeft + 20, guiTop + 37, machine.getHealthScaled(46), Utils.rateTankLevel(machine.getHealthScaled(100)));
|
||||
}
|
||||
|
||||
@@ -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,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.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> {
|
||||
public class GuiAlvearyHygroregulator extends GuiForestryTitled<ContainerAlvearyHygroregulator, TileAlvearyHygroregulator> {
|
||||
|
||||
public GuiAlvearyHygroregulator(InventoryPlayer inventory, TileAlvearyHygroregulator tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/hygroregulator.png", new ContainerAlvearyHygroregulator(inventory, tile), tile);
|
||||
|
||||
@@ -4,22 +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.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> {
|
||||
public class GuiAlvearySieve extends GuiForestry<ContainerAlvearySieve, TileAlvearySieve> {
|
||||
|
||||
public GuiAlvearySieve(InventoryPlayer inventory, TileAlvearySieve tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/sieve.png", new ContainerAlvearySieve(inventory, tile));
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/sieve.png", new ContainerAlvearySieve(inventory, tile), tile);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,21 +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.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> {
|
||||
public class GuiAlvearySwarmer extends GuiForestry<ContainerAlvearySwarmer, TileAlvearySwarmer> {
|
||||
|
||||
public GuiAlvearySwarmer(InventoryPlayer inventory, TileAlvearySwarmer tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/swarmer.png", new ContainerAlvearySwarmer(inventory, tile));
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/swarmer.png", new ContainerAlvearySwarmer(inventory, tile), tile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,21 +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.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> {
|
||||
public class GuiApiary extends GuiForestryTitled<ContainerApiary, TileBeehouse> {
|
||||
|
||||
public GuiApiary(InventoryPlayer inventory, TileApiary tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/apiary.png", new ContainerApiary(inventory, tile, true), tile);
|
||||
@@ -36,7 +37,7 @@ public class GuiApiary extends GuiForestryTitled<TileBeehouse> {
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
|
||||
TileBeehouse machine = tile;
|
||||
TileBeehouse machine = inventory;
|
||||
drawHealthMeter(guiLeft + 20, guiTop + 37, machine.getHealthScaled(46), Utils.rateTankLevel(machine.getHealthScaled(100)));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Loaded 100 of 806 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user