mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-14 17:14:46 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
990d4990db | ||
|
|
ce232e808e | ||
|
|
31574a9c6e | ||
|
|
cd9a4110ee | ||
|
|
6b35ff2ba1 | ||
|
|
5133e721cc | ||
|
|
09ced92f5b | ||
|
|
12477a7711 | ||
|
|
b7dc4d9144 | ||
|
|
da48d317ff | ||
|
|
5bfb11e952 | ||
|
|
4dffb9f352 | ||
|
|
beadb47539 | ||
|
|
6301d3c193 | ||
|
|
883863e047 | ||
|
|
2c14f02151 | ||
|
|
00771b1a42 | ||
|
|
46ec2f2740 | ||
|
|
3d765067cf | ||
|
|
9da092e6d4 | ||
|
|
0b5a5bc34d | ||
|
|
c17a6af267 | ||
|
|
3884fecf77 | ||
|
|
05a7ac6d93 | ||
|
|
7f5108f26c | ||
|
|
be82dd318b | ||
|
|
ce2930b1ab | ||
|
|
cc187d6b8b | ||
|
|
1d2c4e438d | ||
|
|
be0a62b831 | ||
|
|
8b37aa86ff | ||
|
|
9d70a1b0ec | ||
|
|
6ea4ab4491 | ||
|
|
10a5ba3eb8 | ||
|
|
8ce7e49d5f | ||
|
|
34c1956cc1 | ||
|
|
cfbde3eb83 | ||
|
|
328b9e8356 | ||
|
|
878fe51866 | ||
|
|
efe1236326 | ||
|
|
abe0563550 | ||
|
|
14b34e0b01 | ||
|
|
dba8b5448a | ||
|
|
91206dce35 | ||
|
|
6cdafc05de | ||
|
|
00924ccd68 | ||
|
|
e251d28893 | ||
|
|
0ec13d6966 | ||
|
|
07ba130dc6 | ||
|
|
6927c4d5fb | ||
|
|
e2144b140b | ||
|
|
aab26dca3e | ||
|
|
bb5f2b0977 | ||
|
|
eca3be2e63 | ||
|
|
feef3b8a63 | ||
|
|
6e33a55bcb | ||
|
|
53f512d7aa | ||
|
|
b6ba59f9f9 | ||
|
|
ae3f75e22a | ||
|
|
9dd73935d7 | ||
|
|
b69897ff3d | ||
|
|
4da4a7cf56 | ||
|
|
9ddb43e388 | ||
|
|
ead6b2c9b9 | ||
|
|
25a88df47c | ||
|
|
968ad8189e | ||
|
|
aba03f6364 | ||
|
|
70e8654adb | ||
|
|
8fe22130d3 | ||
|
|
79c7ae435c | ||
|
|
6a3d92e825 | ||
|
|
c2acb36c44 | ||
|
|
4609ebc754 | ||
|
|
aea3c55192 | ||
|
|
e7ae15c81d | ||
|
|
4a390fe967 | ||
|
|
2132c4457d | ||
|
|
267905ef3f | ||
|
|
e528609212 | ||
|
|
6fb07b9d40 |
No files matched your search
@@ -12,6 +12,7 @@
|
||||
!/CLA.txt
|
||||
!/CONTRIBUTING.md
|
||||
!/LICENSE.txt
|
||||
!/license-header.txt
|
||||
!/README.md
|
||||
!/application.properties
|
||||
!/build.gradle
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Forestry
|
||||
====================================
|
||||
|
||||
|
||||
### What is it?
|
||||
|
||||
Forestry is a modification for the game Minecraft and known primarily for its farms and bees.
|
||||
|
||||
+1
-1
Submodule api updated: 4f7ca82190...2bb45e18be.
@@ -1,6 +1,6 @@
|
||||
mcversion=1.7.10
|
||||
forgeversion=10.13.0.1207
|
||||
version_major=3
|
||||
version_minor=2
|
||||
version_minor=3
|
||||
version_patch=0
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ configurations {
|
||||
|
||||
dependencies {
|
||||
compile 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api'
|
||||
apis 'com.mod-buildcraft:buildcraft:6.1.5:dev'
|
||||
apis 'com.mod-buildcraft:buildcraft:6.2.1:dev'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
+1
-1
Submodule lang updated: 8ca6c91070...3c34adcc54.
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
*******************************************************************************
|
||||
*/
|
||||
@@ -12,7 +12,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
*/
|
||||
public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
|
||||
|
||||
protected EnergyStorage storage = new EnergyStorage(32000);
|
||||
protected final EnergyStorage storage = new EnergyStorage(32000);
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
@@ -52,10 +52,10 @@ import net.minecraft.item.Item;
|
||||
name = "Forestry",
|
||||
version = Version.VERSION,
|
||||
dependencies = "required-after:Forge@[10.13.0.1207,);"
|
||||
+ "after:Buildcraft|Core;"
|
||||
+ "after:Buildcraft|Core@[6.1.7,);"
|
||||
+ "after:ExtrabiomesXL;"
|
||||
+ "after:BiomesOPlenty;"
|
||||
+ "after:IC2")
|
||||
+ "after:IC2@[2.0.140,)")
|
||||
//, certificateFingerprint = Version.FINGERPRINT)
|
||||
public class Forestry {
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -32,11 +32,11 @@ import forestry.plugins.PluginApiculture;
|
||||
public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
|
||||
private static final int MAX_POLLINATION_ATTEMPTS = 20;
|
||||
IBeeHousing housing;
|
||||
private final IBeeHousing housing;
|
||||
// Breeding
|
||||
private int breedingTime;
|
||||
private final int totalBreedingTime = Defaults.APIARY_BREEDING_TIME;
|
||||
private int throttle;
|
||||
private int queenWorkCycleThrottle;
|
||||
private IEffectData effectData[] = new IEffectData[2];
|
||||
private IBee queen;
|
||||
private IIndividual pollen;
|
||||
@@ -51,7 +51,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
breedingTime = nbttagcompound.getInteger("BreedingTime");
|
||||
throttle = nbttagcompound.getInteger("Throttle");
|
||||
queenWorkCycleThrottle = nbttagcompound.getInteger("Throttle");
|
||||
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Offspring", 10);
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
@@ -63,7 +63,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("BreedingTime", breedingTime);
|
||||
nbttagcompound.setInteger("Throttle", throttle);
|
||||
nbttagcompound.setInteger("Throttle", queenWorkCycleThrottle);
|
||||
|
||||
Stack<ItemStack> spawnCopy = new Stack<ItemStack>();
|
||||
spawnCopy.addAll(spawn);
|
||||
@@ -107,116 +107,185 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
resetQueen(null);
|
||||
this.queen = null;
|
||||
|
||||
// Still something to spawn, try it
|
||||
while (!spawn.isEmpty()) {
|
||||
ItemStack next = spawn.peek();
|
||||
if (housing.addProduct(next, true)) {
|
||||
spawn.pop();
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
} else
|
||||
housing.setErrorState(EnumErrorCode.NOSPACE.ordinal());
|
||||
if (!addPendingProducts()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tryBreedingPrincess() || !hasHealthyQueen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!queenCanWork()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// No queen? And no princess?
|
||||
if (housing.getQueen() == null) {
|
||||
housing.setErrorState(EnumErrorCode.NOQUEEN.ordinal());
|
||||
return;
|
||||
}
|
||||
|
||||
// Princess available? Try to breed!
|
||||
if (ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
|
||||
if (ForestryItem.beeDroneGE.isItemEqual(housing.getDrone()))
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
else
|
||||
housing.setErrorState(EnumErrorCode.NODRONE.ordinal());
|
||||
tickBreed();
|
||||
return;
|
||||
}
|
||||
|
||||
// Can't continue if an item of the wrong type is in the queen slot.
|
||||
if (!ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
|
||||
housing.setErrorState(EnumErrorCode.NOQUEEN.ordinal());
|
||||
return;
|
||||
}
|
||||
|
||||
IBee queen = PluginApiculture.beeInterface.getMember(housing.getQueen());
|
||||
// Kill dying queens
|
||||
if (!queen.isAlive()) {
|
||||
killQueen(queen);
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
return;
|
||||
}
|
||||
|
||||
resetQueen(queen);
|
||||
|
||||
// Not while raining, at night or without light
|
||||
EnumErrorCode state = EnumErrorCode.values()[queen.isWorking(housing)];
|
||||
if (state != EnumErrorCode.OK) {
|
||||
housing.setErrorState(state.ordinal());
|
||||
return;
|
||||
} else if (housing.getErrorOrdinal() != EnumErrorCode.NOFLOWER.ordinal())
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
queenWorkTick();
|
||||
}
|
||||
|
||||
private void queenWorkTick() {
|
||||
// Effects only fire when queen can work.
|
||||
effectData = queen.doEffect(effectData, housing);
|
||||
|
||||
// We have a queen, work!
|
||||
throttle++;
|
||||
|
||||
if (throttle >= PluginApiculture.beeCycleTicks)
|
||||
throttle = 0;
|
||||
else
|
||||
return;
|
||||
|
||||
// Need a flower
|
||||
if (!queen.hasFlower(housing)) {
|
||||
housing.setErrorState(EnumErrorCode.NOFLOWER.ordinal());
|
||||
return;
|
||||
} else
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
// Work cycles are throttled, rather than occurring every game tick.
|
||||
queenWorkCycleThrottle++;
|
||||
if (queenWorkCycleThrottle >= PluginApiculture.ticksPerBeeWorkCycle) {
|
||||
queenWorkCycleThrottle = 0;
|
||||
|
||||
// Need a flower
|
||||
if (queen.hasFlower(housing)) {
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
doQueenWorkCycle();
|
||||
} else {
|
||||
housing.setErrorState(EnumErrorCode.NOFLOWER.ordinal());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doQueenWorkCycle() {
|
||||
doProduction();
|
||||
queen.plantFlowerRandom(housing);
|
||||
doPollination();
|
||||
// Age the queen
|
||||
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
|
||||
updateQueenItemNBT();
|
||||
}
|
||||
|
||||
private void doProduction() {
|
||||
// Produce and add stacks
|
||||
ItemStack[] products = queen.produceStacks(housing);
|
||||
housing.wearOutEquipment(1);
|
||||
for (ItemStack stack : products) {
|
||||
housing.addProduct(stack, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Plant a flower
|
||||
queen.plantFlowerRandom(housing);
|
||||
private void doPollination() {
|
||||
// Get pollen if none available yet
|
||||
if (pollen == null) {
|
||||
pollen = queen.retrievePollen(housing);
|
||||
attemptedPollinations = 0;
|
||||
if (pollen != null) {
|
||||
if (housing.onPollenRetrieved(queen, pollen, false))
|
||||
if (housing.onPollenRetrieved(queen, pollen, false)) {
|
||||
pollen = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pollen != null) {
|
||||
attemptedPollinations++;
|
||||
if (queen.pollinateRandom(housing, pollen)
|
||||
|| attemptedPollinations >= MAX_POLLINATION_ATTEMPTS) {
|
||||
if (queen.pollinateRandom(housing, pollen) || attemptedPollinations >= MAX_POLLINATION_ATTEMPTS) {
|
||||
pollen = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Age the queen
|
||||
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
|
||||
|
||||
private void updateQueenItemNBT() {
|
||||
// Write the changed queen back into the item stack.
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
queen.writeToNBT(nbttagcompound);
|
||||
housing.getQueen().setTagCompound(nbttagcompound);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
private void resetQueen(IBee bee) {
|
||||
this.queen = bee;
|
||||
private boolean addPendingProducts() {
|
||||
EnumErrorCode housingErrorState = null;
|
||||
|
||||
while (!spawn.isEmpty()) {
|
||||
ItemStack next = spawn.peek();
|
||||
if (housing.addProduct(next, true)) {
|
||||
spawn.pop();
|
||||
housingErrorState = EnumErrorCode.OK;
|
||||
} else {
|
||||
housingErrorState = EnumErrorCode.NOSPACE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (housingErrorState != null) {
|
||||
try {
|
||||
housing.setErrorState(housingErrorState);
|
||||
} catch (Error e) {
|
||||
housing.setErrorState(housingErrorState.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
return housingErrorState != EnumErrorCode.NOSPACE;
|
||||
}
|
||||
|
||||
private boolean hasHealthyQueen() {
|
||||
boolean hasQueen = true;
|
||||
EnumErrorCode housingErrorState = null;
|
||||
|
||||
if (housing.getQueen() == null || !ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
|
||||
housingErrorState = EnumErrorCode.NOQUEEN;
|
||||
hasQueen = false;
|
||||
} else {
|
||||
IBee queen = PluginApiculture.beeInterface.getMember(housing.getQueen());
|
||||
// Kill dying queens
|
||||
if (!queen.isAlive()) {
|
||||
killQueen(queen);
|
||||
housingErrorState = EnumErrorCode.OK;
|
||||
hasQueen = false;
|
||||
} else {
|
||||
this.queen = queen;
|
||||
}
|
||||
}
|
||||
if (housingErrorState != null) {
|
||||
try {
|
||||
housing.setErrorState(housingErrorState);
|
||||
} catch (Error e) {
|
||||
housing.setErrorState(housingErrorState.ordinal());
|
||||
}
|
||||
}
|
||||
return hasQueen;
|
||||
}
|
||||
|
||||
private boolean tryBreedingPrincess() {
|
||||
boolean isBreedingPrincess = false;
|
||||
|
||||
// Princess available? Try to breed!
|
||||
if (ForestryItem.beePrincessGE.isItemEqual(housing.getQueen())) {
|
||||
if (ForestryItem.beeDroneGE.isItemEqual(housing.getDrone())) {
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
} else {
|
||||
housing.setErrorState(EnumErrorCode.NODRONE.ordinal());
|
||||
}
|
||||
tickBreed();
|
||||
isBreedingPrincess = true;
|
||||
}
|
||||
|
||||
return isBreedingPrincess;
|
||||
}
|
||||
|
||||
private boolean queenCanWork() {
|
||||
try {
|
||||
boolean canWork = true;
|
||||
// Not while raining, at night or without light
|
||||
EnumErrorCode state = queen.canWork(housing);
|
||||
if (state != EnumErrorCode.OK) {
|
||||
housing.setErrorState(state);
|
||||
canWork = false;
|
||||
} else if (housing.getErrorState() != EnumErrorCode.NOFLOWER) {
|
||||
housing.setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
return canWork;
|
||||
} catch (Error e) {
|
||||
return queenCanWorkDeprecated();
|
||||
}
|
||||
}
|
||||
|
||||
// fallback for outdated APIs
|
||||
private boolean queenCanWorkDeprecated() {
|
||||
boolean canWork = true;
|
||||
// Not while raining, at night or without light
|
||||
EnumErrorCode state = EnumErrorCode.values()[queen.isWorking(housing)];
|
||||
if (state != EnumErrorCode.OK) {
|
||||
housing.setErrorState(state.ordinal());
|
||||
canWork = false;
|
||||
} else if (housing.getErrorOrdinal() != EnumErrorCode.NOFLOWER.ordinal()) {
|
||||
housing.setErrorState(EnumErrorCode.OK.ordinal());
|
||||
}
|
||||
return canWork;
|
||||
}
|
||||
|
||||
// / BREEDING
|
||||
|
||||
@@ -1,255 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IApiaristTracker;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.Version;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.CommandMC;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class CommandBeekeepingMode extends CommandMC {
|
||||
|
||||
String[] modeStrings;
|
||||
|
||||
public CommandBeekeepingMode() {
|
||||
modeStrings = new String[PluginApiculture.beeInterface.getBeekeepingModes().size()];
|
||||
for (int i = 0; i < PluginApiculture.beeInterface.getBeekeepingModes().size(); i++)
|
||||
modeStrings[i] = PluginApiculture.beeInterface.getBeekeepingModes().get(i).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object arg0) {
|
||||
return this.getCommandName().compareTo(((ICommand) arg0).getCommandName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "beekeeping";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender var1) {
|
||||
return "/" + this.getCommandName() + " help";
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List getCommandAliases() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] arguments) {
|
||||
|
||||
if (arguments.length <= 0)
|
||||
throw new WrongUsageException(StringUtil.localizeAndFormat("chat.help", this.getCommandUsage(sender)));
|
||||
|
||||
if (arguments[0].matches("list"))
|
||||
listModes(sender, arguments);
|
||||
else if (arguments[0].matches("info"))
|
||||
listModeInfo(sender, arguments);
|
||||
else if (arguments[0].matches("set")) {
|
||||
if (arguments.length <= 1)
|
||||
throw new WrongUsageException("/" + this.getCommandName() + " set [<world-#>] <mode-name>");
|
||||
|
||||
World world = getWorld(sender, arguments);
|
||||
String desired = arguments[arguments.length - 1];
|
||||
|
||||
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired);
|
||||
if (mode == null)
|
||||
throw new CommandException(StringUtil.localize("chat.bees.command.beekeeping.error"), desired);
|
||||
|
||||
PluginApiculture.beeInterface.setBeekeepingMode(world, mode.getName());
|
||||
func_152373_a(sender, this, StringUtil.localize("chat.bees.command.beekeeping.set"), mode.getName());
|
||||
|
||||
} else if (arguments[0].matches("save")) {
|
||||
if (arguments.length <= 1)
|
||||
throw new WrongUsageException("/" + this.getCommandName() + " save <player-name>");
|
||||
|
||||
saveStatistics(sender, arguments);
|
||||
} else if (arguments[0].matches("help")) {
|
||||
sendChatMessage(sender, StringUtil.localizeAndFormat("chat.bees.command.help.0", this.getCommandName()));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.1"));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.2"));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.3"));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.4"));
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.help.5"));
|
||||
}
|
||||
}
|
||||
|
||||
private void saveStatistics(ICommandSender sender, String[] arguments) {
|
||||
|
||||
String newLine = System.getProperty("line.separator");
|
||||
World world = getWorld(sender, arguments);
|
||||
|
||||
String player = arguments[1];
|
||||
Collection<String> statistics = new ArrayList<String>();
|
||||
|
||||
statistics.add(String.format("Beekeeping statistics for %s on %s:", player, DateFormat.getInstance().format(new Date())));
|
||||
statistics.add("");
|
||||
statistics.add("MODE: " + PluginApiculture.beeInterface.getBeekeepingMode(world).getName());
|
||||
statistics.add("");
|
||||
|
||||
GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(player);
|
||||
IApiaristTracker tracker = PluginApiculture.beeInterface.getBreedingTracker(world, profile);
|
||||
if (tracker == null)
|
||||
statistics.add("No statistics found.");
|
||||
else {
|
||||
statistics.add("BRED:");
|
||||
statistics.add("-----");
|
||||
statistics.add("");
|
||||
|
||||
statistics.add("Queens:\t\t" + tracker.getQueenCount());
|
||||
statistics.add("Princesses:\t" + tracker.getPrincessCount());
|
||||
statistics.add("Drones:\t\t" + tracker.getDroneCount());
|
||||
statistics.add("");
|
||||
|
||||
Collection<IAlleleBeeSpecies> species = new ArrayList<IAlleleBeeSpecies>();
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
|
||||
if (allele instanceof IAlleleBeeSpecies)
|
||||
species.add((IAlleleBeeSpecies) allele);
|
||||
|
||||
statistics.add(String.format("SPECIES (%s):", species.size()));
|
||||
statistics.add("-------------");
|
||||
statistics.add("");
|
||||
|
||||
for (IAlleleBeeSpecies allele : species)
|
||||
statistics.add(generateSpeciesListEntry(allele, tracker));
|
||||
}
|
||||
|
||||
File file = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/stats/" + player + ".log");
|
||||
try {
|
||||
|
||||
if (file.getParentFile() != null)
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
if (!file.exists() && !file.createNewFile()) {
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.stats.error1"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.canWrite()) {
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.stats.error2"));
|
||||
return;
|
||||
}
|
||||
|
||||
FileOutputStream fileout = new FileOutputStream(file);
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileout, "UTF-8"));
|
||||
|
||||
writer.write("# " + Defaults.MOD + newLine + "# " + Version.getVersion() + newLine);
|
||||
|
||||
for (String line : statistics)
|
||||
writer.write(line + newLine);
|
||||
|
||||
writer.close();
|
||||
|
||||
} catch (Exception ex) {
|
||||
sendChatMessage(sender, StringUtil.localize("chat.bees.command.stats.error3"));
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
sendChatMessage(sender, StringUtil.localizeAndFormat("chat.bees.command.stats.saved", player));
|
||||
}
|
||||
|
||||
private String generateSpeciesListEntry(IAlleleBeeSpecies species, IApiaristTracker tracker) {
|
||||
String discovered = "[ ]";
|
||||
if (tracker.isDiscovered(species))
|
||||
discovered = "[ X ]";
|
||||
String blacklisted = "[ ]";
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(species.getUID()))
|
||||
blacklisted = "[ BL ]";
|
||||
String notcounted = "[ ]";
|
||||
if (!species.isCounted())
|
||||
notcounted = "[ NC ]";
|
||||
|
||||
return String.format("%s %s %s\t%-40s %-20s %-20s", discovered, blacklisted, notcounted, species.getUID(), species.getName(), species.getAuthority());
|
||||
}
|
||||
|
||||
private void listModes(ICommandSender sender, String[] arguments) {
|
||||
World world = getWorld(sender, arguments);
|
||||
|
||||
String message = StringUtil.localize("chat.bees.command.mode.current");
|
||||
message = message.replaceAll("%MODE", PluginApiculture.beeInterface.getBeekeepingMode(world).getName());
|
||||
message = message.replaceAll("%WORLD", String.valueOf(world.getWorldInfo().getSaveVersion()));
|
||||
sendChatMessage(sender, message);
|
||||
|
||||
String help = "";
|
||||
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes()) {
|
||||
if (!help.isEmpty())
|
||||
help += ", ";
|
||||
help += mode.getName();
|
||||
}
|
||||
sendChatMessage(sender, StringUtil.localizeAndFormat("chat.bees.command.mode.help", help));
|
||||
return;
|
||||
}
|
||||
|
||||
private void listModeInfo(ICommandSender sender, String[] arguments) {
|
||||
if (arguments.length <= 1)
|
||||
throw new WrongUsageException("/" + this.getCommandName() + " info <mode-name>");
|
||||
|
||||
IBeekeepingMode found = null;
|
||||
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes())
|
||||
if (mode.getName().equalsIgnoreCase(arguments[1])) {
|
||||
found = mode;
|
||||
break;
|
||||
}
|
||||
|
||||
if (found == null)
|
||||
throw new CommandException("No beekeeping mode called '%s' is available.", arguments[1]);
|
||||
|
||||
sendChatMessage(sender, "\u00A7aMode: " + found.getName());
|
||||
for (String desc : found.getDescription())
|
||||
sendChatMessage(sender, StringUtil.localize(desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCommandSenderUseCommand(ICommandSender sender) {
|
||||
if (sender instanceof EntityPlayer)
|
||||
return Proxies.common.isOp((EntityPlayer) sender);
|
||||
else
|
||||
return sender.canCommandSenderUseCommand(4, getCommandName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] incomplete) {
|
||||
return getListOfStringsMatchingLastWord(incomplete, modeStrings);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.core.utils.CommandMC;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class CommandGiveBee extends CommandMC {
|
||||
|
||||
EnumBeeType type;
|
||||
|
||||
public CommandGiveBee(EnumBeeType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "give" + type.toString().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender par1ICommandSender) {
|
||||
return "/" + getCommandName() + " <player-name> <species-name>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] arguments) {
|
||||
if (arguments.length >= 2) {
|
||||
EntityPlayer player = getPlayer(sender, arguments[0]);
|
||||
|
||||
String parameter = arguments[1];
|
||||
|
||||
IAlleleBeeSpecies species = null;
|
||||
|
||||
search: for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
|
||||
|
||||
if (!uid.equals(parameter))
|
||||
continue;
|
||||
|
||||
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
|
||||
species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid);
|
||||
break search;
|
||||
}
|
||||
}
|
||||
|
||||
search: if (species == null)
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
|
||||
if (allele instanceof IAlleleBeeSpecies)
|
||||
if (((IAlleleBeeSpecies) allele).getName().equals(parameter)) {
|
||||
species = (IAlleleBeeSpecies) allele;
|
||||
break search;
|
||||
}
|
||||
|
||||
if (species == null)
|
||||
throw new SpeciesNotFoundException(parameter);
|
||||
|
||||
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
|
||||
|
||||
if (template == null)
|
||||
throw new TemplateNotFoundException(species);
|
||||
|
||||
IBeeGenome genome = PluginApiculture.beeInterface.templateAsGenome(template);
|
||||
|
||||
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, genome);
|
||||
|
||||
if(this.type == EnumBeeType.QUEEN)
|
||||
bee.mate(bee);
|
||||
|
||||
ItemStack beestack = PluginApiculture.beeInterface.getMemberStack(bee, type.ordinal());
|
||||
player.dropPlayerItemWithRandomChoice(beestack, true);
|
||||
func_152373_a(sender, this, "Player %s was given a %s bee.", player.getCommandSenderName(), ((IAlleleSpecies) template[0]).getName());
|
||||
} else
|
||||
throw new WrongUsageException("/" + getCommandName() + " <player-name> <species-name>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the strings available in this command to the given list of tab completion options.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List addTabCompletionOptions(ICommandSender sender, String[] parameters) {
|
||||
if (parameters.length == 1)
|
||||
return getListOfStringsMatchingLastWord(parameters, this.getPlayers());
|
||||
else if (parameters.length == 2)
|
||||
return getListOfStringsMatchingLastWord(parameters, this.getSpecies());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String[] getSpecies() {
|
||||
List<String> species = new ArrayList<String>();
|
||||
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
|
||||
if (allele instanceof IAlleleBeeSpecies)
|
||||
species.add(((IAlleleSpecies) allele).getName());
|
||||
|
||||
return species.toArray(new String[] {});
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class FlowerProviderVanilla implements IFlowerProvider {
|
||||
|
||||
@Override
|
||||
public ItemStack[] getItemStacks() {
|
||||
return FlowerManager.plainFlowers.toArray(new ItemStack[0]);
|
||||
return FlowerManager.plainFlowers.toArray(new ItemStack[FlowerManager.plainFlowers.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class VillageHandlerApiculture implements IVillageCreationHandler, IVilla
|
||||
|
||||
@Override
|
||||
public StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int size) {
|
||||
return new StructureVillagePieces.PieceWeight(ComponentVillageBeeHouse.class, 15, MathHelper.getRandomIntegerInRange(random, 0 + size, 1 + size));
|
||||
return new StructureVillagePieces.PieceWeight(ComponentVillageBeeHouse.class, 15, MathHelper.getRandomIntegerInRange(random, size, 1 + size));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import forestry.core.commands.SubCommand;
|
||||
|
||||
public class CommandBeekeeping extends SubCommand {
|
||||
|
||||
public CommandBeekeeping() {
|
||||
super("beekeeping");
|
||||
addAlias("bee");
|
||||
addChildCommand(new CommandBeekeepingMode());
|
||||
addChildCommand(new CommandBeekeepingSave());
|
||||
addChildCommand(new CommandBeekeepingGiveBee());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.apiculture.SpeciesNotFoundException;
|
||||
import forestry.apiculture.TemplateNotFoundException;
|
||||
import forestry.core.commands.CommandHelpers;
|
||||
import forestry.core.commands.SubCommand;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBeekeepingGiveBee extends SubCommand {
|
||||
|
||||
private final String beeTypeHelpString;
|
||||
private final String[] beeTypeArr;
|
||||
|
||||
public CommandBeekeepingGiveBee() {
|
||||
super("give");
|
||||
setPermLevel(PermLevel.ADMIN);
|
||||
|
||||
List<String> beeTypeStrings = new ArrayList<String>();
|
||||
for (EnumBeeType type : EnumBeeType.values()) {
|
||||
if (type == EnumBeeType.NONE)
|
||||
continue;
|
||||
beeTypeStrings.add(type.getName());
|
||||
}
|
||||
|
||||
beeTypeArr = beeTypeStrings.toArray(new String[beeTypeStrings.size()]);
|
||||
|
||||
StringBuilder beeTypeHelp = new StringBuilder();
|
||||
String separator = ", ";
|
||||
|
||||
Iterator<String> iter = beeTypeStrings.iterator();
|
||||
while (iter.hasNext()) {
|
||||
beeTypeHelp.append(iter.next());
|
||||
if (iter.hasNext())
|
||||
beeTypeHelp.append(separator);
|
||||
}
|
||||
beeTypeHelpString = beeTypeHelp.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSubCommand(ICommandSender sender, String[] arguments) {
|
||||
if (arguments.length < 3) {
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
EnumBeeType beeType = getBeeType(arguments[0]);
|
||||
if (beeType == EnumBeeType.NONE) {
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = CommandHelpers.getPlayer(sender, arguments[1]);
|
||||
|
||||
String parameter = arguments[2];
|
||||
|
||||
IAlleleBeeSpecies species = null;
|
||||
|
||||
for (String uid : AlleleManager.alleleRegistry.getRegisteredAlleles().keySet()) {
|
||||
|
||||
if (!uid.equals(parameter))
|
||||
continue;
|
||||
|
||||
if (AlleleManager.alleleRegistry.getAllele(uid) instanceof IAlleleBeeSpecies) {
|
||||
species = (IAlleleBeeSpecies) AlleleManager.alleleRegistry.getAllele(uid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (species == null) {
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values()) {
|
||||
if (allele instanceof IAlleleBeeSpecies && allele.getName().equals(parameter)) {
|
||||
species = (IAlleleBeeSpecies) allele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (species == null)
|
||||
throw new SpeciesNotFoundException(parameter);
|
||||
|
||||
IAllele[] template = PluginApiculture.beeInterface.getTemplate(species.getUID());
|
||||
|
||||
if (template == null)
|
||||
throw new TemplateNotFoundException(species);
|
||||
|
||||
IBeeGenome genome = PluginApiculture.beeInterface.templateAsGenome(template);
|
||||
|
||||
IBee bee = PluginApiculture.beeInterface.getBee(player.worldObj, genome);
|
||||
|
||||
if(beeType == EnumBeeType.QUEEN)
|
||||
bee.mate(bee);
|
||||
|
||||
ItemStack beeStack = PluginApiculture.beeInterface.getMemberStack(bee, beeType.ordinal());
|
||||
player.dropPlayerItemWithRandomChoice(beeStack, true);
|
||||
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.give.given", player.getCommandSenderName(), template[0].getName(), beeType.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> addTabCompletionOptions(ICommandSender sender, String[] parameters) {
|
||||
if (parameters.length == 1) {
|
||||
List<String> tabCompletion = CommandHelpers.getListOfStringsMatchingLastWord(parameters, beeTypeArr);
|
||||
tabCompletion.add("help");
|
||||
return tabCompletion;
|
||||
} else if (parameters.length == 2) {
|
||||
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers());
|
||||
} else if (parameters.length == 3) {
|
||||
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, getSpecies());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] getSpecies() {
|
||||
List<String> species = new ArrayList<String>();
|
||||
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
|
||||
if (allele instanceof IAlleleBeeSpecies)
|
||||
species.add(allele.getName());
|
||||
|
||||
return species.toArray(new String[species.size()]);
|
||||
}
|
||||
|
||||
EnumBeeType getBeeType(String beeTypeName) {
|
||||
for (EnumBeeType beeType : EnumBeeType.values()) {
|
||||
if (beeType.getName().equalsIgnoreCase(beeTypeName))
|
||||
return beeType;
|
||||
}
|
||||
return EnumBeeType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHelp(ICommandSender sender) {
|
||||
super.printHelp(sender);
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.give.available", beeTypeHelpString);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import forestry.core.commands.SubCommand;
|
||||
|
||||
public class CommandBeekeepingMode extends SubCommand {
|
||||
|
||||
public CommandBeekeepingMode() {
|
||||
super("mode");
|
||||
addChildCommand(new CommandBeekeepingModeInfo());
|
||||
addChildCommand(new CommandBeekeepingModeSet());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.core.commands.CommandHelpers;
|
||||
import forestry.core.commands.SubCommand;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBeekeepingModeInfo extends SubCommand {
|
||||
|
||||
private final String[] modeStringArr;
|
||||
private final String helpString;
|
||||
|
||||
public CommandBeekeepingModeInfo() {
|
||||
super("info");
|
||||
|
||||
List<String> modeStrings = new ArrayList<String>();
|
||||
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes())
|
||||
modeStrings.add(mode.getName());
|
||||
|
||||
modeStringArr = modeStrings.toArray(new String[modeStrings.size()]);
|
||||
|
||||
StringBuilder help = new StringBuilder();
|
||||
String separator = ", ";
|
||||
|
||||
Iterator<String> iter = modeStrings.iterator();
|
||||
while (iter.hasNext()) {
|
||||
help.append(iter.next());
|
||||
if (iter.hasNext())
|
||||
help.append(separator);
|
||||
}
|
||||
helpString = help.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSubCommand(ICommandSender sender, String[] args) {
|
||||
if (args.length <= 0) {
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String modeName = args[0];
|
||||
|
||||
IBeekeepingMode found = findModeWithName(modeName);
|
||||
if (found == null) {
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.info.error", modeName);
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
ChatStyle green = new ChatStyle();
|
||||
green.setColor(EnumChatFormatting.GREEN);
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, green, found.getName());
|
||||
|
||||
for (String desc : found.getDescription())
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for." + desc);
|
||||
}
|
||||
|
||||
private IBeekeepingMode findModeWithName(String name) {
|
||||
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes()) {
|
||||
if (mode.getName().equalsIgnoreCase(name))
|
||||
return mode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHelp(ICommandSender sender) {
|
||||
super.printHelp(sender);
|
||||
|
||||
World world = CommandHelpers.getWorld(sender, this);
|
||||
|
||||
String modeName = PluginApiculture.beeInterface.getBeekeepingMode(world).getName();
|
||||
String worldName = String.valueOf(world.getWorldInfo().getSaveVersion());
|
||||
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.info.current", modeName, worldName);
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.info.available", helpString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> addTabCompletionOptions(ICommandSender sender, String[] incomplete) {
|
||||
return CommandHelpers.getListOfStringsMatchingLastWord(incomplete, modeStringArr);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.core.commands.CommandHelpers;
|
||||
import forestry.core.commands.SubCommand;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBeekeepingModeSet extends SubCommand {
|
||||
private final String[] modeStringArr;
|
||||
|
||||
public CommandBeekeepingModeSet() {
|
||||
super("set");
|
||||
setPermLevel(PermLevel.ADMIN);
|
||||
int modeStringCount = PluginApiculture.beeInterface.getBeekeepingModes().size();
|
||||
List<String> modeStrings = new ArrayList<String>(modeStringCount);
|
||||
for (IBeekeepingMode mode : PluginApiculture.beeInterface.getBeekeepingModes())
|
||||
modeStrings.add(mode.getName());
|
||||
|
||||
modeStringArr = modeStrings.toArray(new String[modeStringCount]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSubCommand(ICommandSender sender, String[] args) {
|
||||
if (args.length == 0 || args.length > 2) {
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
World world;
|
||||
if (args.length == 2)
|
||||
world = CommandHelpers.getWorld(sender, this, args, 0);
|
||||
else
|
||||
world = CommandHelpers.getWorld(sender, this);
|
||||
|
||||
String desired = args[args.length - 1];
|
||||
|
||||
IBeekeepingMode mode = PluginApiculture.beeInterface.getBeekeepingMode(desired);
|
||||
if (mode == null) {
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.set.error", desired);
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
PluginApiculture.beeInterface.setBeekeepingMode(world, mode.getName());
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.mode.set.success", mode.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> addTabCompletionOptions(ICommandSender sender, String[] incomplete) {
|
||||
return CommandHelpers.getListOfStringsMatchingLastWord(incomplete, modeStringArr);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.commands;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IApiaristTracker;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.core.commands.CommandHelpers;
|
||||
import forestry.core.commands.SubCommand;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.Version;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class CommandBeekeepingSave extends SubCommand {
|
||||
|
||||
private final String discoveredSymbol;
|
||||
private final String blacklistedSymbol;
|
||||
private final String notCountedSymbol;
|
||||
|
||||
public CommandBeekeepingSave() {
|
||||
super("save");
|
||||
discoveredSymbol = StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.discovered.symbol");
|
||||
blacklistedSymbol = StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.blacklisted.symbol");
|
||||
notCountedSymbol = StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.notCounted.symbol");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> addTabCompletionOptions(ICommandSender sender, String[] parameters) {
|
||||
return CommandHelpers.getListOfStringsMatchingLastWord(parameters, CommandHelpers.getPlayers());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processSubCommand(ICommandSender sender, String[] args) {
|
||||
if (args.length != 1) {
|
||||
printHelp(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String newLine = System.getProperty("line.separator");
|
||||
World world = CommandHelpers.getWorld(sender, this);
|
||||
|
||||
String player = args[0];
|
||||
Collection<String> statistics = new ArrayList<String>();
|
||||
|
||||
String date = DateFormat.getInstance().format(new Date());
|
||||
statistics.add(StatCollector.translateToLocalFormatted("for.chat.command.forestry.beekeeping.save.stats", player, date));
|
||||
statistics.add("");
|
||||
String modeName = PluginApiculture.beeInterface.getBeekeepingMode(world).getName();
|
||||
statistics.add(StatCollector.translateToLocalFormatted("for.chat.command.forestry.beekeeping.save.mode", modeName));
|
||||
statistics.add("");
|
||||
|
||||
GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a(player);
|
||||
IApiaristTracker tracker = PluginApiculture.beeInterface.getBreedingTracker(world, profile);
|
||||
if (tracker == null)
|
||||
statistics.add(StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.error4"));
|
||||
else {
|
||||
String discoveredLine = StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.discovered") + ":";
|
||||
statistics.add(discoveredLine);
|
||||
statistics.add(line(discoveredLine.length()));
|
||||
|
||||
String queen = StatCollector.translateToLocal("for.bees.grammar.queen.type");
|
||||
String princess = StatCollector.translateToLocal("for.bees.grammar.princess.type");
|
||||
String drone = StatCollector.translateToLocal("for.bees.grammar.drone.type");
|
||||
statistics.add(queen + ":\t\t" + tracker.getQueenCount());
|
||||
statistics.add(princess + ":\t" + tracker.getPrincessCount());
|
||||
statistics.add(drone + ":\t\t" + tracker.getDroneCount());
|
||||
statistics.add("");
|
||||
|
||||
Collection<IAlleleBeeSpecies> species = new ArrayList<IAlleleBeeSpecies>();
|
||||
for (IAllele allele : AlleleManager.alleleRegistry.getRegisteredAlleles().values())
|
||||
if (allele instanceof IAlleleBeeSpecies)
|
||||
species.add((IAlleleBeeSpecies) allele);
|
||||
|
||||
String speciesCount = StatCollector.translateToLocal("for.gui.speciescount");
|
||||
String speciesCountLine = String.format("%s (%s):", speciesCount, species.size());
|
||||
statistics.add(speciesCountLine);
|
||||
statistics.add(line(speciesCountLine.length()));
|
||||
|
||||
statistics.add(discoveredSymbol + ": " + StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.discovered"));
|
||||
statistics.add(blacklistedSymbol + ": " + StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.blacklisted"));
|
||||
statistics.add(notCountedSymbol + ": " + StatCollector.translateToLocal("for.chat.command.forestry.beekeeping.save.key.notCounted"));
|
||||
statistics.add("");
|
||||
|
||||
String header = generateSpeciesListHeader();
|
||||
statistics.add(header);
|
||||
|
||||
statistics.add(line(header.length()));
|
||||
statistics.add("");
|
||||
|
||||
for (IAlleleBeeSpecies allele : species)
|
||||
statistics.add(generateSpeciesListEntry(allele, tracker));
|
||||
}
|
||||
|
||||
File file = new File(Proxies.common.getForestryRoot(), "config/" + Defaults.MOD.toLowerCase(Locale.ENGLISH) + "/stats/" + player + ".log");
|
||||
try {
|
||||
File folder = file.getParentFile();
|
||||
if (folder != null && !folder.exists()) {
|
||||
boolean success = file.getParentFile().mkdirs();
|
||||
if (!success) {
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.error1");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.exists() && !file.createNewFile()) {
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.error1");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!file.canWrite()) {
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.error2");
|
||||
return;
|
||||
}
|
||||
|
||||
FileOutputStream fileout = new FileOutputStream(file);
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fileout, "UTF-8"));
|
||||
|
||||
writer.write("# " + Defaults.MOD + newLine + "# " + Version.getVersion() + newLine);
|
||||
|
||||
for (String line : statistics)
|
||||
writer.write(line + newLine);
|
||||
|
||||
writer.close();
|
||||
|
||||
}
|
||||
catch (IOException ex) {
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.error3");
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
CommandHelpers.sendLocalizedChatMessage(sender, "for.chat.command.forestry.beekeeping.save.saved", player);
|
||||
}
|
||||
|
||||
private String line(int length) {
|
||||
StringBuilder line = new StringBuilder();
|
||||
for (int i = 0; i < length; i++)
|
||||
line.append("-");
|
||||
|
||||
return line.toString();
|
||||
}
|
||||
|
||||
private String generateSpeciesListHeader() {
|
||||
String authority = StatCollector.translateToLocal("for.gui.alyzer.authority");
|
||||
String species = StatCollector.translateToLocal("for.gui.species");
|
||||
return speciesListEntry(discoveredSymbol, blacklistedSymbol, notCountedSymbol, "UID", species, authority);
|
||||
}
|
||||
|
||||
private String generateSpeciesListEntry(IAlleleBeeSpecies species, IApiaristTracker tracker) {
|
||||
String discovered = "";
|
||||
if (tracker.isDiscovered(species))
|
||||
discovered = discoveredSymbol;
|
||||
|
||||
String blacklisted = "";
|
||||
if (AlleleManager.alleleRegistry.isBlacklisted(species.getUID()))
|
||||
blacklisted = blacklistedSymbol;
|
||||
|
||||
String notCounted = "";
|
||||
if (!species.isCounted())
|
||||
notCounted = notCountedSymbol;
|
||||
|
||||
return speciesListEntry(discovered, blacklisted, notCounted, species.getUID(), species.getName(), species.getAuthority());
|
||||
}
|
||||
|
||||
private String speciesListEntry(String discovered, String blacklisted, String notCounted, String UID, String speciesName, String authority) {
|
||||
return String.format("[ %-2s ] [ %-2s ] [ %-2s ]\t%-40s %-20s %-20s", discovered, blacklisted, notCounted, UID, speciesName, authority);
|
||||
}
|
||||
}
|
||||
@@ -105,13 +105,13 @@ public class BlockAlveary extends BlockStructure {
|
||||
public static final int BOTTOM = 2;
|
||||
public static final int LEFT = 3;
|
||||
public static final int RIGHT = 4;
|
||||
public static final int TX_55_SWOF = 5;
|
||||
public static final int TX_56_SWON = 6;
|
||||
public static final int TX_57_HTOF = 7;
|
||||
public static final int TX_58_HTON = 8;
|
||||
public static final int TX_71_FNOF = 9;
|
||||
public static final int TX_72_FNON = 10;
|
||||
public static final int TX_73_VLVE = 11;
|
||||
public static final int ALVEARY_SWARMER_OFF = 5;
|
||||
public static final int ALVEARY_SWARMER_ON = 6;
|
||||
public static final int ALVEARY_HEATER_OFF = 7;
|
||||
public static final int ALVEARY_HEATER_ON = 8;
|
||||
public static final int ALVEARY_FAN_OFF = 9;
|
||||
public static final int ALVEARY_FAN_ON = 10;
|
||||
public static final int ALVEARY_HYGRO = 11;
|
||||
public static final int STABILISER = 12;
|
||||
public static final int SIEVE = 13;
|
||||
|
||||
@@ -152,13 +152,13 @@ public class BlockAlveary extends BlockStructure {
|
||||
case 1:
|
||||
return icons[ENTRANCE];
|
||||
case TileAlvearySwarmer.BLOCK_META:
|
||||
return icons[TX_55_SWOF];
|
||||
return icons[ALVEARY_SWARMER_OFF];
|
||||
case TileAlvearyFan.BLOCK_META:
|
||||
return icons[TX_71_FNOF];
|
||||
return icons[ALVEARY_FAN_OFF];
|
||||
case TileAlvearyHeater.BLOCK_META:
|
||||
return icons[TX_57_HTOF];
|
||||
return icons[ALVEARY_HEATER_OFF];
|
||||
case TileAlvearyHygroregulator.BLOCK_META:
|
||||
return icons[TX_73_VLVE];
|
||||
return icons[ALVEARY_HYGRO];
|
||||
case TileAlvearyStabiliser.BLOCK_META:
|
||||
return icons[STABILISER];
|
||||
case TileAlvearySieve.BLOCK_META:
|
||||
|
||||
@@ -10,10 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.apiculture.IHiveDrop;
|
||||
import forestry.api.apiculture.hives.HiveManager;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.MaterialBeehive;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
@@ -26,16 +31,9 @@ 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.BeeManager;
|
||||
import forestry.api.apiculture.IHiveDrop;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.MaterialBeehive;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockBeehives extends BlockContainer {
|
||||
|
||||
@@ -84,7 +82,7 @@ public class BlockBeehives extends BlockContainer {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ArrayList<IHiveDrop> dropList = BeeManager.hiveDrops[metadata - 1];
|
||||
List<IHiveDrop> dropList = getDropsForHive(metadata);
|
||||
|
||||
Collections.shuffle(dropList);
|
||||
// Grab a princess
|
||||
@@ -123,6 +121,26 @@ public class BlockBeehives extends BlockContainer {
|
||||
return meta;
|
||||
}
|
||||
|
||||
private List<IHiveDrop> getDropsForHive(int meta) {
|
||||
String hiveName = getHiveNameForMeta(meta);
|
||||
if (hiveName == null)
|
||||
return Collections.emptyList();
|
||||
return HiveManager.get(hiveName).getDrops();
|
||||
}
|
||||
|
||||
private String getHiveNameForMeta(int meta) {
|
||||
switch (meta) {
|
||||
case 1: return HiveManager.forest;
|
||||
case 2: return HiveManager.meadows;
|
||||
case 3: return HiveManager.desert;
|
||||
case 4: return HiveManager.jungle;
|
||||
case 5: return HiveManager.end;
|
||||
case 6: return HiveManager.snow;
|
||||
case 7: return HiveManager.swamp;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
@@ -155,7 +173,7 @@ 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) {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class StructureLogicAlveary extends StructureLogic {
|
||||
slabBlocks.add(ForestryBlock.slabs1.block());
|
||||
slabBlocks.add(ForestryBlock.slabs2.block());
|
||||
slabBlocks.add(ForestryBlock.slabs3.block());
|
||||
if (ForestryBlock.slabs4 != null)
|
||||
if (ForestryBlock.slabs4.block() != null)
|
||||
slabBlocks.add(ForestryBlock.slabs4.block());
|
||||
}
|
||||
|
||||
|
||||
@@ -11,28 +11,36 @@
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.core.IStructureLogic;
|
||||
import forestry.api.core.ITileStructure;
|
||||
import forestry.apiculture.trigger.ApicultureTriggers;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.triggers.ForestryTrigger;
|
||||
import forestry.core.utils.TileInventoryAdapter;
|
||||
import forestry.core.utils.Utils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public abstract class TileAlveary extends TileForestry implements IAlvearyComponent {
|
||||
|
||||
private final IStructureLogic structureLogic;
|
||||
private boolean isMaster;
|
||||
protected int masterX, masterZ;
|
||||
protected int masterY = -99;
|
||||
|
||||
protected TileInventoryAdapter inventory;
|
||||
protected final int componentBlockMeta;
|
||||
|
||||
@@ -123,11 +131,6 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
}
|
||||
|
||||
/* ITILESTRUCTURE */
|
||||
IStructureLogic structureLogic;
|
||||
|
||||
private boolean isMaster;
|
||||
protected int masterX, masterZ;
|
||||
protected int masterY = -99;
|
||||
|
||||
@Override
|
||||
public String getTypeUID() {
|
||||
@@ -245,12 +248,13 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
public void removeBeeListener(IBeeListener event) {
|
||||
}
|
||||
|
||||
// / ITRIGGERPROVIDER
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public LinkedList<ITriggerExternal> getCustomTriggers() {
|
||||
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
|
||||
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
|
||||
res.add(ForestryTrigger.missingQueen);
|
||||
res.add(ForestryTrigger.missingDrone);
|
||||
res.add(ApicultureTriggers.missingQueen);
|
||||
res.add(ApicultureTriggers.missingDrone);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,17 +32,16 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
this.boundaryUp = boundaryUp;
|
||||
}
|
||||
}
|
||||
protected EnergyManager energyManager;
|
||||
ClimateControl climateControl;
|
||||
private int transferTime = 0;
|
||||
private int animationDelay = 0;
|
||||
protected final EnergyManager energyManager;
|
||||
private final ClimateControl climateControl;
|
||||
private int workingTime = 0;
|
||||
private final int textureOff;
|
||||
private final int textureOn;
|
||||
|
||||
public TileAlvearyClimatiser(ClimateControl control, int textureOff, int textureOn, int componentBlockMeta) {
|
||||
super(componentBlockMeta);
|
||||
this.climateControl = control;
|
||||
energyManager = new EnergyManager(1000, 250, 2000);
|
||||
energyManager = new EnergyManager(1000, 50, 2000);
|
||||
energyManager.setReceiveOnly();
|
||||
this.textureOff = textureOff;
|
||||
this.textureOn = textureOn;
|
||||
@@ -60,28 +59,22 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
if (!this.hasMaster())
|
||||
return;
|
||||
|
||||
if (energyManager.consumeEnergyToDoWork()) {
|
||||
boolean wasInactive = (workingTime == 0);
|
||||
|
||||
transferTime = energyManager.getEnergyPerWork();
|
||||
|
||||
if (animationDelay <= 0) {
|
||||
animationDelay = 100;
|
||||
sendNetworkUpdate();
|
||||
} else
|
||||
animationDelay = 100;
|
||||
if (workingTime < 20 && energyManager.consumeEnergyToDoWork()) {
|
||||
// consume 10 RF per tick of work
|
||||
workingTime += energyManager.getEnergyPerWork() / 10;
|
||||
}
|
||||
|
||||
if (transferTime > 0) {
|
||||
transferTime--;
|
||||
if (workingTime > 0) {
|
||||
workingTime--;
|
||||
IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE();
|
||||
if (component != null)
|
||||
component.addTemperatureChange(climateControl.changePerTransfer, climateControl.boundaryDown, climateControl.boundaryUp);
|
||||
}
|
||||
|
||||
if (animationDelay > 0) {
|
||||
animationDelay--;
|
||||
if (animationDelay <= 0)
|
||||
sendNetworkUpdate();
|
||||
if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +86,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
/* TEXTURES */
|
||||
@Override
|
||||
public int getIcon(int side, int metadata) {
|
||||
if (animationDelay > 0)
|
||||
if (workingTime > 0)
|
||||
return textureOn;
|
||||
else
|
||||
return textureOff;
|
||||
@@ -104,23 +97,23 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
energyManager.readFromNBT(nbttagcompound);
|
||||
transferTime = nbttagcompound.getInteger("Heating");
|
||||
workingTime = nbttagcompound.getInteger("Heating");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
energyManager.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setInteger("Heating", transferTime);
|
||||
nbttagcompound.setInteger("Heating", workingTime);
|
||||
}
|
||||
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void fromPacketPayload(PacketPayload payload) {
|
||||
short delay = payload.shortPayload[0];
|
||||
if (animationDelay != delay) {
|
||||
animationDelay = delay;
|
||||
short workingTime = payload.shortPayload[0];
|
||||
if (this.workingTime != workingTime) {
|
||||
this.workingTime = workingTime;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
@@ -128,7 +121,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
@Override
|
||||
public PacketPayload getPacketPayload() {
|
||||
PacketPayload payload = new PacketPayload(0, 1);
|
||||
payload.shortPayload[0] = (short) animationDelay;
|
||||
payload.shortPayload[0] = (short) workingTime;
|
||||
return payload;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ public class TileAlvearyFan extends TileAlvearyClimatiser {
|
||||
public static final int BLOCK_META = 3;
|
||||
|
||||
public TileAlvearyFan() {
|
||||
super(new ClimateControl(-0.01f, 0.05f, 2.5f), BlockAlveary.TX_71_FNOF, BlockAlveary.TX_72_FNON, BLOCK_META);
|
||||
super(new ClimateControl(-0.01f, 0.05f, 2.5f), BlockAlveary.ALVEARY_FAN_OFF, BlockAlveary.ALVEARY_FAN_ON, BLOCK_META);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,14 +12,11 @@ package forestry.apiculture.gadgets;
|
||||
|
||||
public class TileAlvearyHeater extends TileAlvearyClimatiser {
|
||||
|
||||
public static final int TEXTURE_OFF = 57;
|
||||
public static final int TEXTURE_ON = 58;
|
||||
|
||||
/* CONSTANTS */
|
||||
public static final int BLOCK_META = 4;
|
||||
|
||||
public TileAlvearyHeater() {
|
||||
super(new ClimateControl(0.01f, 0.0f, 2.5f), BlockAlveary.TX_57_HTOF, BlockAlveary.TX_58_HTON, BLOCK_META);
|
||||
super(new ClimateControl(0.01f, 0.0f, 2.5f), BlockAlveary.ALVEARY_HEATER_OFF, BlockAlveary.ALVEARY_HEATER_ON, BLOCK_META);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,9 +59,9 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
private final HygroregulatorRecipe[] recipes;
|
||||
|
||||
/* MEMBERS */
|
||||
InventoryAdapter canInventory = new InventoryAdapter(1, "CanInv");
|
||||
private final InventoryAdapter canInventory = new InventoryAdapter(1, "CanInv");
|
||||
private final TankManager tankManager;
|
||||
private FilteredTank liquidTank;
|
||||
private final FilteredTank liquidTank;
|
||||
|
||||
private HygroregulatorRecipe currentRecipe;
|
||||
private int transferTime;
|
||||
@@ -187,7 +187,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
/* TEXTURES */
|
||||
@Override
|
||||
public int getIcon(int side, int metadata) {
|
||||
return BlockAlveary.TX_73_VLVE;
|
||||
return BlockAlveary.ALVEARY_HYGRO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,30 +10,22 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.*;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
import forestry.api.core.ITileStructure;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.gui.ContainerAlveary;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
@@ -45,7 +37,20 @@ import forestry.core.network.PacketInventoryStack;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.TileInventoryAdapter;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, ISpecialInventory, IBeeHousing, IClimatised, IHintSource {
|
||||
|
||||
@@ -58,9 +63,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
// / MEMBERS
|
||||
protected IBeekeepingLogic beekeepingLogic;
|
||||
protected int biomeId;
|
||||
protected float temperature;
|
||||
protected float humidity;
|
||||
protected BiomeGenBase biome;
|
||||
protected float tempChange = 0.0f;
|
||||
protected float humidChange = 0.0f;
|
||||
private int displayHealthMax = 0;
|
||||
@@ -78,6 +81,17 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
player.openGui(ForestryAPI.instance, GuiId.AlvearyGUI.ordinal(), worldObj, masterX, masterY, masterZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
setBiomeInformation();
|
||||
}
|
||||
|
||||
private void setBiomeInformation() {
|
||||
this.biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
@@ -111,11 +125,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
@Override
|
||||
public void initialize() {
|
||||
super.initialize();
|
||||
BiomeGenBase biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
|
||||
this.biomeId = biome.biomeID;
|
||||
this.temperature = biome.temperature;
|
||||
this.humidity = biome.rainfall;
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
setBiomeInformation();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -167,13 +177,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
return;
|
||||
|
||||
// / Multiplayer FX
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 == 0) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void equalizeTemperature() {
|
||||
@@ -280,11 +289,13 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
|
||||
float temperature = biome.temperature;
|
||||
tempChange = Math.min(boundaryUp - temperature, Math.max(boundaryDown - temperature, tempChange + change));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
|
||||
float humidity = biome.rainfall;
|
||||
humidChange = Math.min(boundaryUp - humidity, Math.max(boundaryDown - humidity, humidChange + change));
|
||||
}
|
||||
|
||||
@@ -326,12 +337,17 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public int getBiomeId() {
|
||||
return this.biomeId;
|
||||
return biome.biomeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
if (EnumTemperature.isBiomeHellish(biomeId) && tempChange >= 0)
|
||||
if (BiomeHelper.isBiomeHellish(biome) && tempChange >= 0)
|
||||
return EnumTemperature.HELLISH;
|
||||
|
||||
return EnumTemperature.getFromValue(getExactTemperature());
|
||||
@@ -754,27 +770,22 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
/* SMP GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
displayHealth = j;
|
||||
break;
|
||||
case 1:
|
||||
displayHealthMax = j;
|
||||
break;
|
||||
case 2:
|
||||
this.temperature = (float) j / 100;
|
||||
break;
|
||||
case 3:
|
||||
this.humidity = (float) j / 100;
|
||||
break;
|
||||
case 4:
|
||||
this.tempChange = (float) j / 100;
|
||||
break;
|
||||
case 5:
|
||||
this.humidChange = (float) j / 100;
|
||||
break;
|
||||
case 6:
|
||||
this.biomeId = j;
|
||||
break;
|
||||
case 0:
|
||||
displayHealth = j;
|
||||
break;
|
||||
case 1:
|
||||
displayHealthMax = j;
|
||||
break;
|
||||
case 4:
|
||||
this.tempChange = (float) j / 100;
|
||||
break;
|
||||
case 5:
|
||||
this.humidChange = (float) j / 100;
|
||||
break;
|
||||
case 6: {
|
||||
this.biome = BiomeGenBase.getBiome(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -785,11 +796,9 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
iCrafting.sendProgressBarUpdate(container, 0, beekeepingLogic.getBreedingTime());
|
||||
iCrafting.sendProgressBarUpdate(container, 1, beekeepingLogic.getTotalBreedingTime());
|
||||
iCrafting.sendProgressBarUpdate(container, 2, Math.round(temperature * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 3, Math.round(humidity * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 4, Math.round(tempChange * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 5, Math.round(humidChange * 100));
|
||||
iCrafting.sendProgressBarUpdate(container, 6, biomeId);
|
||||
iCrafting.sendProgressBarUpdate(container, 6, biome.biomeID);
|
||||
}
|
||||
|
||||
/* IERRORSOURCE */
|
||||
@@ -812,12 +821,12 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IS
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return this.temperature + this.tempChange;
|
||||
return biome.temperature + this.tempChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return this.humidity + this.humidChange;
|
||||
return biome.rainfall + this.humidChange;
|
||||
}
|
||||
|
||||
/* IHINTSOURCE */
|
||||
|
||||
@@ -34,7 +34,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
public static final int SLOTS_POLLEN_COUNT = 4;
|
||||
public static final int SLOT_SIEVE = 4;
|
||||
|
||||
InventoryAdapter inventory = new InventoryAdapter(5, "Items", 1);
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(5, "Items", 1);
|
||||
|
||||
public TileAlvearySieve() {
|
||||
super(BLOCK_META);
|
||||
|
||||
@@ -10,17 +10,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
@@ -28,12 +17,23 @@ import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
import forestry.apiculture.worldgen.WorldGenHive;
|
||||
import forestry.apiculture.worldgen.WorldGenHiveSwamer;
|
||||
import forestry.apiculture.worldgen.HiveDecorator;
|
||||
import forestry.apiculture.worldgen.HiveSwarmer;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.TileInventoryAdapter;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Stack;
|
||||
|
||||
public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory {
|
||||
|
||||
@@ -42,6 +42,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
|
||||
|
||||
TileInventoryAdapter swarmerInventory;
|
||||
private final Stack<ItemStack> pendingSpawns = new Stack<ItemStack>();
|
||||
private boolean isActive;
|
||||
|
||||
public TileAlvearySwarmer() {
|
||||
super(BLOCK_META);
|
||||
@@ -64,86 +65,103 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 100 != 0)
|
||||
if (pendingSpawns.size() > 0)
|
||||
if (pendingSpawns.size() > 0) {
|
||||
setIsActive(true);
|
||||
if (worldObj.getTotalWorldTime() % 1000 == 0)
|
||||
trySpawnSwarm();
|
||||
} else {
|
||||
setIsActive(false);
|
||||
}
|
||||
|
||||
if (worldObj.getTotalWorldTime() % 500 != 0)
|
||||
return;
|
||||
|
||||
if (!this.hasMaster())
|
||||
ItemStack princessStack = getPrincessStack();
|
||||
if (princessStack == null)
|
||||
return;
|
||||
|
||||
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
|
||||
if (!(master instanceof IBeeHousing))
|
||||
int chance = consumeInducerAndGetChance();
|
||||
if (chance == 0)
|
||||
return;
|
||||
|
||||
IBeeHousing housing = (IBeeHousing) master;
|
||||
ItemStack queenstack = housing.getQueen();
|
||||
if (queenstack == null)
|
||||
return;
|
||||
if (!PluginApiculture.beeInterface.isMated(queenstack))
|
||||
return;
|
||||
|
||||
// Calculate chance
|
||||
int slot = getInducerSlot();
|
||||
if (slot < 0)
|
||||
return;
|
||||
int chance = getChanceFor(swarmerInventory.getStackInSlot(slot));
|
||||
|
||||
// Remove resource
|
||||
swarmerInventory.decrStackSize(slot, 1);
|
||||
|
||||
// Try to spawn princess
|
||||
if (worldObj.rand.nextInt(1000) >= chance)
|
||||
return;
|
||||
|
||||
// Queue swarm spawn
|
||||
IBee spawn = PluginApiculture.beeInterface.getMember(queenstack);
|
||||
spawn.setIsNatural(false);
|
||||
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(spawn, EnumBeeType.PRINCESS.ordinal()));
|
||||
|
||||
IBee princess = PluginApiculture.beeInterface.getMember(princessStack);
|
||||
princess.setIsNatural(false);
|
||||
pendingSpawns.push(PluginApiculture.beeInterface.getMemberStack(princess, EnumBeeType.PRINCESS.ordinal()));
|
||||
}
|
||||
|
||||
private int getChanceFor(ItemStack stack) {
|
||||
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(stack))
|
||||
return entry.getValue();
|
||||
private ItemStack getPrincessStack() {
|
||||
if (!this.hasMaster())
|
||||
return null;
|
||||
|
||||
IAlvearyComponent master = (IAlvearyComponent) this.getCentralTE();
|
||||
if (!(master instanceof IBeeHousing))
|
||||
return null;
|
||||
|
||||
IBeeHousing housing = (IBeeHousing) master;
|
||||
ItemStack princessStack = housing.getQueen();
|
||||
if (princessStack == null || !PluginApiculture.beeInterface.isMated(princessStack))
|
||||
return null;
|
||||
|
||||
return princessStack;
|
||||
}
|
||||
|
||||
private int consumeInducerAndGetChance() {
|
||||
if (swarmerInventory == null)
|
||||
return 0;
|
||||
|
||||
for (int i = 0; i < swarmerInventory.getSizeInventory(); i++) {
|
||||
ItemStack stack = swarmerInventory.getStackInSlot(i);
|
||||
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
|
||||
if (StackUtils.isIdenticalItem(entry.getKey(), stack)) {
|
||||
swarmerInventory.decrStackSize(i, 1);
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int getInducerSlot() {
|
||||
for (int i = 0; i < swarmerInventory.getSizeInventory(); i++) {
|
||||
if (swarmerInventory.getStackInSlot(i) == null)
|
||||
continue;
|
||||
for (Entry<ItemStack, Integer> entry : BeeManager.inducers.entrySet()) {
|
||||
if (entry.getKey().isItemEqual(swarmerInventory.getStackInSlot(i)))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void trySpawnSwarm() {
|
||||
|
||||
ItemStack toSpawn = pendingSpawns.peek();
|
||||
WorldGenHive generator = new WorldGenHiveSwamer(new ItemStack[] { toSpawn });
|
||||
HiveSwarmer hive = new HiveSwarmer(128, toSpawn);
|
||||
|
||||
int i = 0;
|
||||
while (i < 10) {
|
||||
i++;
|
||||
int spawnX = xCoord + worldObj.rand.nextInt(40 * 2) - 40;
|
||||
int spawnY = yCoord + worldObj.rand.nextInt(40);
|
||||
int spawnZ = zCoord + worldObj.rand.nextInt(40 * 2) - 40;
|
||||
if (generator.generate(worldObj, worldObj.rand, spawnX, spawnY, spawnZ)) {
|
||||
pendingSpawns.pop();
|
||||
break;
|
||||
}
|
||||
int chunkX = (xCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
|
||||
int chunkZ = (zCoord + worldObj.rand.nextInt(40 * 2) - 40) / 16;
|
||||
|
||||
if (HiveDecorator.instance().genHive(worldObj, worldObj.rand, chunkX, chunkZ, hive)) {
|
||||
pendingSpawns.pop();
|
||||
}
|
||||
}
|
||||
|
||||
private void setIsActive(boolean isActive) {
|
||||
if (this.isActive != isActive) {
|
||||
this.isActive = isActive;
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public void fromPacketPayload(PacketPayload payload) {
|
||||
boolean isActive = payload.shortPayload[0] > 0;
|
||||
if (this.isActive != isActive) {
|
||||
this.isActive = isActive;
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketPayload getPacketPayload() {
|
||||
PacketPayload payload = new PacketPayload(0, 1);
|
||||
payload.shortPayload[0] = (short) (isActive ? 1 : 0);
|
||||
return payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,10 +175,10 @@ public class TileAlvearySwarmer extends TileAlveary implements ISpecialInventory
|
||||
if(side == 0 || side == 1)
|
||||
return BlockAlveary.BOTTOM;
|
||||
|
||||
if (pendingSpawns.size() > 0)
|
||||
return BlockAlveary.TX_56_SWON;
|
||||
if (isActive)
|
||||
return BlockAlveary.ALVEARY_SWARMER_ON;
|
||||
else
|
||||
return BlockAlveary.TX_55_SWOF;
|
||||
return BlockAlveary.ALVEARY_SWARMER_OFF;
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
|
||||
@@ -11,17 +11,21 @@
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.apiculture.trigger.ApicultureTriggers;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.triggers.ForestryTrigger;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
@@ -342,12 +346,13 @@ public class TileApiary extends TileBeehouse implements ISidedInventory {
|
||||
// }
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
@Override
|
||||
public LinkedList<ITriggerExternal> getCustomTriggers() {
|
||||
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
|
||||
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
|
||||
res.add(ForestryTrigger.missingQueen);
|
||||
res.add(ForestryTrigger.missingDrone);
|
||||
res.add(PluginApiculture.triggerNoFrames);
|
||||
res.add(ApicultureTriggers.missingQueen);
|
||||
res.add(ApicultureTriggers.missingDrone);
|
||||
res.add(ApicultureTriggers.noFrames);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -11,23 +11,15 @@
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.gadgets.TileBase;
|
||||
@@ -40,6 +32,13 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.InventoryAdapter;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginApiculture;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@@ -47,19 +46,18 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public static final int SLOT_QUEEN = 0;
|
||||
public static final int SLOT_DRONE = 1;
|
||||
public static final int SLOT_INVENTORY_1 = 2;
|
||||
protected static int SLOT_PRODUCT_1 = 2;
|
||||
protected static int SLOT_PRODUCT_COUNT = 7;
|
||||
public static final int SLOT_PRODUCT_1 = 2;
|
||||
public static final int SLOT_PRODUCT_COUNT = 7;
|
||||
public static final int SLOT_FRAMES_1 = 9;
|
||||
public static final int SLOT_FRAMES_2 = 10;
|
||||
public static final int SLOT_FRAMES_3 = 11;
|
||||
public static final int SLOT_INVENTORY_COUNT = 7;
|
||||
public static final int SLOT_FRAMES_COUNT = 3;
|
||||
|
||||
// Inventory
|
||||
protected InventoryAdapter inventory = new InventoryAdapter(12, "Items");
|
||||
protected final InventoryAdapter inventory = new InventoryAdapter(12, "Items");
|
||||
private final IBeekeepingLogic logic;
|
||||
private int biomeId = -1;
|
||||
private float temperature;
|
||||
private float humidity;
|
||||
private BiomeGenBase biome;
|
||||
private int displayHealthMax = 0;
|
||||
private int displayHealth = 0;
|
||||
|
||||
@@ -78,9 +76,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setFloat("Temp", temperature);
|
||||
nbttagcompound.setFloat("Humidity", humidity);
|
||||
nbttagcompound.setInteger("BiomeId", biomeId);
|
||||
nbttagcompound.setInteger("BiomeId", biome.biomeID);
|
||||
|
||||
inventory.writeToNBT(nbttagcompound);
|
||||
if (logic != null)
|
||||
@@ -91,9 +87,8 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
temperature = nbttagcompound.getFloat("Temp");
|
||||
humidity = nbttagcompound.getFloat("Humidity");
|
||||
biomeId = nbttagcompound.getInteger("BiomeId");
|
||||
int biomeId = nbttagcompound.getInteger("BiomeId");
|
||||
biome = BiomeGenBase.getBiome(biomeId);
|
||||
|
||||
inventory.readFromNBT(nbttagcompound);
|
||||
logic.readFromNBT(nbttagcompound);
|
||||
@@ -119,24 +114,22 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
if (EnumTemperature.isBiomeHellish(biomeId))
|
||||
return EnumTemperature.HELLISH;
|
||||
return EnumTemperature.getFromValue(temperature);
|
||||
return EnumTemperature.getFromValue(getExactTemperature());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(humidity);
|
||||
return EnumHumidity.getFromValue(getExactHumidity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return this.temperature;
|
||||
return biome.temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return this.humidity;
|
||||
return biome.rainfall;
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@@ -144,12 +137,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public void updateClientSide() {
|
||||
|
||||
// / Multiplayer FX
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN)))
|
||||
if (PluginApiculture.beeInterface.isMated(inventory.getStackInSlot(SLOT_QUEEN))) {
|
||||
if (getErrorState() == EnumErrorCode.OK && worldObj.getTotalWorldTime() % 2 % 2 == 0) {
|
||||
IBee displayQueen = PluginApiculture.beeInterface.getMember(inventory.getStackInSlot(SLOT_QUEEN));
|
||||
displayQueen.doFX(logic.getEffectData(), this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -244,20 +237,18 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
}
|
||||
|
||||
public int getTemperatureScaled(int i) {
|
||||
return Math.round(i * (temperature / 2));
|
||||
return Math.round(i * (getExactTemperature() / 2));
|
||||
}
|
||||
|
||||
public int getHumidityScaled(int i) {
|
||||
return Math.round(i * humidity);
|
||||
return Math.round(i * getExactHumidity());
|
||||
}
|
||||
|
||||
public void updateBiome() {
|
||||
if (worldObj != null) {
|
||||
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
if (biome != null) {
|
||||
this.biomeId = biome.biomeID;
|
||||
this.temperature = biome.temperature;
|
||||
this.humidity = biome.rainfall;
|
||||
this.biome = biome;
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
}
|
||||
@@ -320,7 +311,12 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
@Override
|
||||
public int getBiomeId() {
|
||||
return this.biomeId;
|
||||
return biome.biomeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,7 @@ import forestry.core.utils.InventoryAdapter;
|
||||
|
||||
public class TileSwarm extends TileEntity {
|
||||
|
||||
public InventoryAdapter contained = new InventoryAdapter(2, "Contained");
|
||||
public final InventoryAdapter contained = new InventoryAdapter(2, "Contained");
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
|
||||
@@ -62,7 +62,7 @@ public class AIAvoidPlayers extends EntityAIBase {
|
||||
return false;
|
||||
|
||||
pathing = pathNavigator.getPathToXYZ(randomTarget.xCoord, randomTarget.yCoord, randomTarget.zCoord);
|
||||
return pathing == null ? false : pathing.isDestinationSame(randomTarget);
|
||||
return pathing != null && pathing.isDestinationSame(randomTarget);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,20 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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 com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.apiculture.EnumBeeChromosome;
|
||||
import forestry.api.apiculture.EnumBeeType;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
@@ -40,6 +29,15 @@ import forestry.core.config.Defaults;
|
||||
import forestry.core.genetics.AlleleSpecies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies, IIconProvider {
|
||||
|
||||
@@ -148,8 +146,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
@Override
|
||||
public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
|
||||
ArrayList<ItemStack> bounty = new ArrayList<ItemStack>();
|
||||
for(ItemStack stack : super.getResearchBounty(world, researcher, individual, bountyLevel))
|
||||
bounty.add(stack);
|
||||
Collections.addAll(bounty, super.getResearchBounty(world, researcher, individual, bountyLevel));
|
||||
|
||||
if(bountyLevel > 10) {
|
||||
for(ItemStack stack : specialty.keySet()) {
|
||||
@@ -159,7 +156,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
for(ItemStack stack : products.keySet()) {
|
||||
bounty.add(StackUtils.copyWithRandomSize(stack, (int)((float)bountyLevel / 2), world.rand));
|
||||
}
|
||||
return bounty.toArray(StackUtils.EMPTY_STACK_ARRAY);
|
||||
return bounty.toArray(new ItemStack[bounty.size()]);
|
||||
}
|
||||
|
||||
/* OTHER */
|
||||
@@ -211,7 +208,7 @@ public class AlleleBeeSpecies extends AlleleSpecies implements IAlleleBeeSpecies
|
||||
if(EnumBeeType.values()[i] == EnumBeeType.NONE)
|
||||
continue;
|
||||
|
||||
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");;
|
||||
icons[i][0] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".outline");
|
||||
icons[i][1] = (EnumBeeType.values()[i] != EnumBeeType.LARVAE) ? body1
|
||||
: TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body");
|
||||
icons[i][2] = TextureManager.getInstance().registerTex(register, "bees/" + iconType + "/" + EnumBeeType.values()[i].toString().toLowerCase(Locale.ENGLISH) + ".body2");
|
||||
|
||||
@@ -25,7 +25,7 @@ import forestry.core.utils.DamageSourceForestry;
|
||||
|
||||
public class AlleleEffectAggressive extends AlleleEffectThrottled {
|
||||
|
||||
public static DamageSource damageSourceBeeAggressive = new DamageSourceForestry("bee.aggressive");
|
||||
public static final DamageSource damageSourceBeeAggressive = new DamageSourceForestry("bee.aggressive");
|
||||
|
||||
public AlleleEffectAggressive(String uid) {
|
||||
super(uid, "aggressive", true, 40, false, false);
|
||||
|
||||
@@ -25,9 +25,9 @@ import forestry.core.genetics.EffectData;
|
||||
public class AlleleEffectCreeper extends AlleleEffectThrottled {
|
||||
|
||||
private final int explosionChance = 50;
|
||||
byte defaultForce = 12;
|
||||
byte indexExplosionTimer = 1;
|
||||
byte indexExplosionForce = 2;
|
||||
private final byte defaultForce = 12;
|
||||
private final byte indexExplosionTimer = 1;
|
||||
private final byte indexExplosionForce = 2;
|
||||
|
||||
public AlleleEffectCreeper(String uid) {
|
||||
super(uid, "creeper", true, 20, false, true);
|
||||
|
||||
@@ -25,8 +25,8 @@ import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class AlleleEffectIgnition extends AlleleEffectThrottled {
|
||||
|
||||
int ignitionChance = 50;
|
||||
int fireDuration = 500;
|
||||
private final int ignitionChance = 50;
|
||||
private final int fireDuration = 500;
|
||||
|
||||
public AlleleEffectIgnition(String uid) {
|
||||
super(uid, "ignition", false, 20, false, true);
|
||||
|
||||
@@ -24,7 +24,7 @@ import forestry.core.utils.DamageSourceForestry;
|
||||
|
||||
public class AlleleEffectMisanthrope extends AlleleEffectThrottled {
|
||||
|
||||
public static DamageSource damageSourceBeeEnd = new DamageSourceForestry("bee.end");
|
||||
public static final DamageSource damageSourceBeeEnd = new DamageSourceForestry("bee.end");
|
||||
|
||||
public AlleleEffectMisanthrope(String uid) {
|
||||
super(uid, "misanthrope", true, 20, false, false);
|
||||
|
||||
@@ -32,7 +32,7 @@ import forestry.core.utils.Vect;
|
||||
|
||||
public class AlleleEffectRadioactive extends AlleleEffectThrottled {
|
||||
|
||||
public static DamageSource damageSourceBeeRadioactive = new DamageSourceForestry("bee.radioactive");
|
||||
public static final DamageSource damageSourceBeeRadioactive = new DamageSourceForestry("bee.radioactive");
|
||||
|
||||
public AlleleEffectRadioactive(String uid) {
|
||||
super(uid, "radioactive", true, 40, false, true);
|
||||
|
||||
@@ -16,7 +16,7 @@ import forestry.api.apiculture.IAlleleBeeEffect;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.core.genetics.Allele;
|
||||
import forestry.core.genetics.EffectData;
|
||||
import forestry.core.utils.Vect;
|
||||
|
||||
@@ -16,7 +16,7 @@ import forestry.core.genetics.Allele;
|
||||
|
||||
public class AlleleFlowers extends Allele implements IAlleleFlowers {
|
||||
|
||||
IFlowerProvider provider;
|
||||
private final IFlowerProvider provider;
|
||||
|
||||
public AlleleFlowers(String uid, IFlowerProvider provider) {
|
||||
this(uid, provider, false);
|
||||
|
||||
@@ -19,6 +19,8 @@ import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.apiculture.IBeeMutation;
|
||||
import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -30,7 +32,6 @@ import forestry.api.genetics.IFlowerProvider;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.genetics.Chromosome;
|
||||
import forestry.core.genetics.GenericRatings;
|
||||
@@ -46,7 +47,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -69,12 +69,6 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
this.isIrregularMating = mate.isNatural() != this.isNatural;
|
||||
}
|
||||
|
||||
public Bee(IBeeGenome genome, IBee mate) {
|
||||
this(genome);
|
||||
this.mate = mate.getGenome();
|
||||
this.isIrregularMating = mate.isNatural() != this.isNatural;
|
||||
}
|
||||
|
||||
public Bee(World world, IBeeGenome genome) {
|
||||
this(world, genome, true, 0);
|
||||
}
|
||||
@@ -203,38 +197,44 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
@Override
|
||||
public int isWorking(IBeeHousing housing) {
|
||||
return canWork(housing).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumErrorCode canWork(IBeeHousing housing) {
|
||||
|
||||
World world = housing.getWorld();
|
||||
// / Rain needs tolerant flyers
|
||||
if (world.isRaining() && !genome.getTolerantFlyer() && housing.getHumidity() != EnumHumidity.ARID && !housing.isSealed())
|
||||
return EnumErrorCode.ISRAINING.ordinal();
|
||||
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(housing.getBiomeId()) && !housing.isSealed()) {
|
||||
return EnumErrorCode.ISRAINING;
|
||||
}
|
||||
|
||||
// / Night or darkness requires nocturnal species
|
||||
if(world.isDaytime()) {
|
||||
if(!canWorkDuringDay())
|
||||
return EnumErrorCode.NOTNIGHT.ordinal();
|
||||
return EnumErrorCode.NOTNIGHT;
|
||||
} else if (!canWorkAtNight() && !housing.isSelfLighted())
|
||||
return EnumErrorCode.NOTDAY.ordinal();
|
||||
return EnumErrorCode.NOTDAY;
|
||||
|
||||
if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) {
|
||||
if(!canWorkDuringDay())
|
||||
return EnumErrorCode.NOTGLOOMY.ordinal();
|
||||
return EnumErrorCode.NOTGLOOMY;
|
||||
} else if(!canWorkAtNight() && !housing.isSelfLighted())
|
||||
return EnumErrorCode.NOTLUCID.ordinal();
|
||||
return EnumErrorCode.NOTLUCID;
|
||||
|
||||
// / No sky, except if in hell
|
||||
BiomeGenBase biome = BiomeGenBase.getBiome(housing.getBiomeId());
|
||||
if(biome == null)
|
||||
return EnumErrorCode.NOSKY.ordinal();
|
||||
if (!BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.NETHER) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
|
||||
return EnumErrorCode.NOSKY;
|
||||
if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
|
||||
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated())
|
||||
return EnumErrorCode.NOSKY.ordinal();
|
||||
return EnumErrorCode.NOSKY;
|
||||
|
||||
// / And finally climate check
|
||||
if (!checkSuitableClimate(housing.getTemperature(), housing.getHumidity()))
|
||||
return EnumErrorCode.INVALIDBIOME.ordinal();
|
||||
return EnumErrorCode.INVALIDBIOME;
|
||||
|
||||
return EnumErrorCode.OK.ordinal();
|
||||
return EnumErrorCode.OK;
|
||||
}
|
||||
|
||||
private boolean canWorkAtNight() {
|
||||
@@ -329,6 +329,16 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
return suitableBiomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<BiomeGenBase> getSuitableBiomes() {
|
||||
ArrayList<BiomeGenBase> suitableBiomes = new ArrayList<BiomeGenBase>();
|
||||
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray())
|
||||
if (checkBiomeHazard(biome))
|
||||
suitableBiomes.add(biome);
|
||||
|
||||
return suitableBiomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTooltip(List<String> list) {
|
||||
|
||||
@@ -398,12 +408,13 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
}
|
||||
|
||||
return products.toArray(new ItemStack[0]);
|
||||
return products.toArray(new ItemStack[products.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getSpecialtyList() {
|
||||
return genome.getPrimary().getSpecialty().keySet().toArray(new ItemStack[0]);
|
||||
Set<ItemStack> specialties = genome.getPrimary().getSpecialty().keySet();
|
||||
return specialties.toArray(new ItemStack[specialties.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -444,7 +455,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
|
||||
// We are done if the we are not jubilant.
|
||||
if (!primary.isJubilant(genome, housing) || !secondary.isJubilant(genome, housing))
|
||||
return products.toArray(StackUtils.EMPTY_STACK_ARRAY);
|
||||
return products.toArray(new ItemStack[products.size()]);
|
||||
|
||||
// / Specialty products
|
||||
for (Map.Entry<ItemStack, Integer> entry : primary.getSpecialty().entrySet())
|
||||
@@ -452,7 +463,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
products.add(entry.getKey().copy());
|
||||
|
||||
return genome.getFlowerProvider().affectProducts(housing.getWorld(), this, housing.getXCoord(), housing.getYCoord(), housing.getZCoord(),
|
||||
products.toArray(StackUtils.EMPTY_STACK_ARRAY));
|
||||
products.toArray(new ItemStack[products.size()]));
|
||||
}
|
||||
|
||||
/* REPRODUCTION */
|
||||
@@ -496,7 +507,7 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
|
||||
if (bees.size() > 0)
|
||||
return bees.toArray(new IBee[0]);
|
||||
return bees.toArray(new IBee[bees.size()]);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
}
|
||||
|
||||
/* TEMPLATES */
|
||||
public static ArrayList<IBee> beeTemplates = new ArrayList<IBee>();
|
||||
public static final ArrayList<IBee> beeTemplates = new ArrayList<IBee>();
|
||||
|
||||
@Override
|
||||
public ArrayList<IBee> getIndividualTemplates() {
|
||||
@@ -248,7 +248,7 @@ public class BeeHelper extends SpeciesRoot implements IBeeRoot {
|
||||
}
|
||||
|
||||
/* BREEDING MODES */
|
||||
ArrayList<IBeekeepingMode> beekeepingModes = new ArrayList<IBeekeepingMode>();
|
||||
final ArrayList<IBeekeepingMode> beekeepingModes = new ArrayList<IBeekeepingMode>();
|
||||
public static IBeekeepingMode activeBeekeepingMode;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,8 @@ import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.core.genetics.Allele;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class BeeTemplates {
|
||||
|
||||
// / MUTATIONS
|
||||
@@ -98,24 +100,27 @@ public class BeeTemplates {
|
||||
public static IMutation vengefulB;
|
||||
public static IMutation avengingA;
|
||||
|
||||
public static IAllele[] defaultTemplate;
|
||||
|
||||
public static IAllele[] getDefaultTemplate() {
|
||||
IAllele[] alleles = new IAllele[EnumBeeChromosome.values().length];
|
||||
if (defaultTemplate == null) {
|
||||
defaultTemplate = new IAllele[EnumBeeChromosome.values().length];
|
||||
|
||||
alleles[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesForest;
|
||||
alleles[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
|
||||
alleles[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShorter;
|
||||
alleles[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityNormal;
|
||||
alleles[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceNone;
|
||||
alleles[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolFalse;
|
||||
alleles[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceNone;
|
||||
alleles[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolFalse;
|
||||
alleles[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolFalse;
|
||||
alleles[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersVanilla;
|
||||
alleles[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlowest;
|
||||
alleles[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryDefault;
|
||||
alleles[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectNone;
|
||||
|
||||
return alleles;
|
||||
defaultTemplate[EnumBeeChromosome.SPECIES.ordinal()] = Allele.speciesForest;
|
||||
defaultTemplate[EnumBeeChromosome.SPEED.ordinal()] = Allele.speedSlowest;
|
||||
defaultTemplate[EnumBeeChromosome.LIFESPAN.ordinal()] = Allele.lifespanShorter;
|
||||
defaultTemplate[EnumBeeChromosome.FERTILITY.ordinal()] = Allele.fertilityNormal;
|
||||
defaultTemplate[EnumBeeChromosome.TEMPERATURE_TOLERANCE.ordinal()] = Allele.toleranceNone;
|
||||
defaultTemplate[EnumBeeChromosome.NOCTURNAL.ordinal()] = Allele.boolFalse;
|
||||
defaultTemplate[EnumBeeChromosome.HUMIDITY_TOLERANCE.ordinal()] = Allele.toleranceNone;
|
||||
defaultTemplate[EnumBeeChromosome.TOLERANT_FLYER.ordinal()] = Allele.boolFalse;
|
||||
defaultTemplate[EnumBeeChromosome.CAVE_DWELLING.ordinal()] = Allele.boolFalse;
|
||||
defaultTemplate[EnumBeeChromosome.FLOWER_PROVIDER.ordinal()] = Allele.flowersVanilla;
|
||||
defaultTemplate[EnumBeeChromosome.FLOWERING.ordinal()] = Allele.floweringSlowest;
|
||||
defaultTemplate[EnumBeeChromosome.TERRITORY.ordinal()] = Allele.territoryDefault;
|
||||
defaultTemplate[EnumBeeChromosome.EFFECT.ordinal()] = Allele.effectNone;
|
||||
}
|
||||
return Arrays.copyOf(defaultTemplate, defaultTemplate.length);
|
||||
}
|
||||
|
||||
// / COMMON BRANCH
|
||||
|
||||
@@ -23,11 +23,11 @@ import forestry.api.apiculture.IBeekeepingMode;
|
||||
|
||||
public class BeekeepingMode implements IBeekeepingMode {
|
||||
|
||||
public static IBeekeepingMode easy = new BeekeepingMode("EASY", 2.0f, 1.0f, 1.0f, false, false);
|
||||
public static IBeekeepingMode normal = new BeekeepingMode("NORMAL", 1.0f, 1.0f, 1.0f, false, true);
|
||||
public static IBeekeepingMode hard = new BeekeepingMode("HARD", 0.75f, 1.5f, 1.0f, false, true);
|
||||
public static IBeekeepingMode hardcore = new BeekeepingMode("HARDCORE", 0.5f, 5.0f, 0.8f, true, true);
|
||||
public static IBeekeepingMode insane = new BeekeepingMode("INSANE", 0.2f, 10.0f, 0.6f, true, true);
|
||||
public static final IBeekeepingMode easy = new BeekeepingMode("EASY", 2.0f, 1.0f, 1.0f, false, false);
|
||||
public static final IBeekeepingMode normal = new BeekeepingMode("NORMAL", 1.0f, 1.0f, 1.0f, false, true);
|
||||
public static final IBeekeepingMode hard = new BeekeepingMode("HARD", 0.75f, 1.5f, 1.0f, false, true);
|
||||
public static final IBeekeepingMode hardcore = new BeekeepingMode("HARDCORE", 0.5f, 5.0f, 0.8f, true, true);
|
||||
public static final IBeekeepingMode insane = new BeekeepingMode("INSANE", 0.2f, 10.0f, 0.6f, true, true);
|
||||
|
||||
final Random rand;
|
||||
final String name;
|
||||
|
||||
@@ -10,30 +10,29 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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 net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class HiveDrop implements IHiveDrop {
|
||||
|
||||
private IAllele[] template;
|
||||
private ArrayList<ItemStack> additional = new ArrayList<ItemStack>();
|
||||
private int chance;
|
||||
private final IAllele[] template;
|
||||
private final ArrayList<ItemStack> additional = new ArrayList<ItemStack>();
|
||||
private final int chance;
|
||||
private float ignobleShare = 0.0f;
|
||||
|
||||
public HiveDrop(IAllele[] template, ItemStack[] bonus, int chance) {
|
||||
this.template = template;
|
||||
this.chance = chance;
|
||||
|
||||
for (ItemStack stack : bonus)
|
||||
this.additional.add(stack);
|
||||
Collections.addAll(this.additional, bonus);
|
||||
}
|
||||
|
||||
public HiveDrop setIgnobleShare(float share) {
|
||||
@@ -42,22 +41,22 @@ public class HiveDrop implements IHiveDrop {
|
||||
}
|
||||
|
||||
private IBee createBee(World world) {
|
||||
IBee bee = PluginApiculture.beeInterface.getBee(world, PluginApiculture.beeInterface.templateAsGenome(template));
|
||||
if(world.rand.nextFloat() < ignobleShare)
|
||||
bee.setIsNatural(false);
|
||||
return bee;
|
||||
return PluginApiculture.beeInterface.getBee(world, PluginApiculture.beeInterface.templateAsGenome(template));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPrincess(World world, int x, int y, int z, int fortune) {
|
||||
return PluginApiculture.beeInterface.getMemberStack(createBee(world), EnumBeeType.PRINCESS.ordinal());
|
||||
IBee bee = createBee(world);
|
||||
if(world.rand.nextFloat() < ignobleShare)
|
||||
bee.setIsNatural(false);
|
||||
|
||||
return PluginApiculture.beeInterface.getMemberStack(bee, EnumBeeType.PRINCESS.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrones(World world, int x, int y, int z, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
ret.add(PluginApiculture.beeInterface.getMemberStack(createBee(world),
|
||||
EnumBeeType.DRONE.ordinal()));
|
||||
ret.add(PluginApiculture.beeInterface.getMemberStack(createBee(world), EnumBeeType.DRONE.ordinal()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ import forestry.core.utils.Vect;
|
||||
|
||||
public class MutationEMC extends MutationReqRes {
|
||||
|
||||
int emcRequired = 0;
|
||||
Class<?> condenserClass;
|
||||
Field emcField;
|
||||
private final int emcRequired;
|
||||
private final Class<?> condenserClass;
|
||||
private final Field emcField;
|
||||
|
||||
public MutationEMC(IAllele allele0, IAllele allele1, IAllele[] template, int chance, ItemStack blockRequired, Class<?> condenserClass, Field emcField,
|
||||
int emcRequired) {
|
||||
|
||||
@@ -19,12 +19,12 @@ import forestry.api.genetics.IGenome;
|
||||
public class MutationTimeLimited extends BeeMutation {
|
||||
|
||||
/**
|
||||
* Fed up with Date and Calendar and their shinenigans
|
||||
* Fed up with Date and Calendar and their shenanigans
|
||||
*/
|
||||
public static class DayMonth {
|
||||
|
||||
public int day;
|
||||
public int month;
|
||||
public final int day;
|
||||
public final int month;
|
||||
|
||||
public DayMonth() {
|
||||
this.day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
|
||||
@@ -93,8 +93,9 @@ public class MutationTimeLimited extends BeeMutation {
|
||||
return day + "." + month;
|
||||
}
|
||||
}
|
||||
DayMonth start;
|
||||
DayMonth end;
|
||||
|
||||
private final DayMonth start;
|
||||
private final DayMonth end;
|
||||
|
||||
public MutationTimeLimited(IAllele allele0, IAllele allele1, IAllele[] template, int chance, DayMonth start) {
|
||||
this(allele0, allele1, template, chance, start, null);
|
||||
@@ -113,7 +114,7 @@ public class MutationTimeLimited extends BeeMutation {
|
||||
if (chance == 0)
|
||||
return 0;
|
||||
|
||||
if (start == null && end == null)
|
||||
if (start == null)
|
||||
return chance;
|
||||
|
||||
DayMonth now = new DayMonth();
|
||||
|
||||
@@ -22,7 +22,7 @@ import forestry.core.gui.slots.SlotCustom;
|
||||
|
||||
public class ContainerAlveary extends ContainerForestry {
|
||||
|
||||
private TileAlvearyPlain tile;
|
||||
private final TileAlvearyPlain tile;
|
||||
|
||||
public ContainerAlveary(InventoryPlayer player, TileAlvearyPlain tile) {
|
||||
super(tile);
|
||||
@@ -31,10 +31,10 @@ public class ContainerAlveary extends ContainerForestry {
|
||||
tile.sendNetworkUpdate();
|
||||
|
||||
// Queen/Princess
|
||||
this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39, new Object[] { ForestryItem.beePrincessGE, ForestryItem.beeQueenGE }));
|
||||
this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_QUEEN, 29, 39, ForestryItem.beePrincessGE, ForestryItem.beeQueenGE));
|
||||
|
||||
// Drone
|
||||
this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65, new Object[] { ForestryItem.beeDroneGE }));
|
||||
this.addSlot(new SlotCustom(tile, TileAlvearyPlain.SLOT_DRONE, 29, 65, ForestryItem.beeDroneGE));
|
||||
|
||||
// Product Inventory
|
||||
this.addSlot(new SlotClosed(tile, 2, 116, 52));
|
||||
@@ -62,8 +62,8 @@ public class ContainerAlveary extends ContainerForestry {
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < crafters.size(); i++)
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
for (Object crafter : crafters)
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafter);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,17 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import forestry.apiculture.gadgets.TileAlvearyHygroregulator;
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.slots.SlotLiquidContainer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class ContainerAlvearyHygroregulator extends ContainerLiquidTanks {
|
||||
|
||||
TileAlvearyHygroregulator tile;
|
||||
private final TileAlvearyHygroregulator tile;
|
||||
|
||||
public ContainerAlvearyHygroregulator(IInventory inventory, TileAlvearyHygroregulator tile) {
|
||||
super(inventory, tile);
|
||||
|
||||
@@ -22,7 +22,7 @@ import forestry.core.gui.slots.SlotCustom;
|
||||
|
||||
public class ContainerAlvearySieve extends ContainerForestry {
|
||||
|
||||
TileAlvearySieve tile;
|
||||
private final TileAlvearySieve tile;
|
||||
|
||||
public ContainerAlvearySieve(InventoryPlayer player, TileAlvearySieve tile) {
|
||||
super(tile.getInternalInventory());
|
||||
@@ -30,10 +30,10 @@ public class ContainerAlvearySieve extends ContainerForestry {
|
||||
this.tile = tile;
|
||||
IInventory inventory = tile.getInternalInventory();
|
||||
|
||||
addSlot(new SlotCustom(inventory, 0, 94, 52, new Object[0]).setCrafter(tile));
|
||||
addSlot(new SlotCustom(inventory, 1, 115, 39, new Object[0]).setCrafter(tile));
|
||||
addSlot(new SlotCustom(inventory, 2, 73, 39, new Object[0]).setCrafter(tile));
|
||||
addSlot(new SlotCustom(inventory, 3, 94, 26, new Object[0]).setCrafter(tile));
|
||||
addSlot(new SlotCustom(inventory, 0, 94, 52).setCrafter(tile));
|
||||
addSlot(new SlotCustom(inventory, 1, 115, 39).setCrafter(tile));
|
||||
addSlot(new SlotCustom(inventory, 2, 73, 39).setCrafter(tile));
|
||||
addSlot(new SlotCustom(inventory, 3, 94, 26).setCrafter(tile));
|
||||
|
||||
addSlot(new SlotCustom(inventory, TileAlvearySieve.SLOT_SIEVE, 43, 39, ForestryItem.craftingMaterial.getItemStack(1, 3)).setCrafter(tile));
|
||||
|
||||
|
||||
@@ -10,13 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.apiculture.gadgets.TileAlvearySwarmer;
|
||||
import forestry.core.gui.ContainerForestry;
|
||||
import forestry.core.gui.slots.SlotCustom;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ContainerAlvearySwarmer extends ContainerForestry {
|
||||
|
||||
@@ -39,6 +41,7 @@ public class ContainerAlvearySwarmer extends ContainerForestry {
|
||||
}
|
||||
|
||||
private Object[] getInducerItems() {
|
||||
return BeeManager.inducers.keySet().toArray(new Object[0]);
|
||||
Set<ItemStack> inducers = BeeManager.inducers.keySet();
|
||||
return inducers.toArray(new Object[inducers.size()]);
|
||||
}
|
||||
}
|
||||
@@ -77,8 +77,8 @@ public class ContainerApiary extends ContainerForestry {
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < crafters.size(); i++) {
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafters.get(i));
|
||||
for (Object crafter : crafters) {
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import forestry.core.proxy.Proxies;
|
||||
|
||||
public class ContainerHabitatLocator extends ContainerItemInventory {
|
||||
|
||||
public BiomefinderInventory inventory;
|
||||
public final BiomefinderInventory inventory;
|
||||
|
||||
public ContainerHabitatLocator(InventoryPlayer inventoryplayer, BiomefinderInventory inventory) {
|
||||
super(inventory, inventoryplayer.player);
|
||||
@@ -32,12 +32,12 @@ public class ContainerHabitatLocator extends ContainerItemInventory {
|
||||
this.inventory = inventory;
|
||||
|
||||
// Energy
|
||||
this.addSlot(new SlotCustom(inventory, 2, 152, 8, new Object[] { ForestryItem.honeydew, ForestryItem.honeyDrop }));
|
||||
this.addSlot(new SlotCustom(inventory, 2, 152, 8, ForestryItem.honeydew, ForestryItem.honeyDrop));
|
||||
|
||||
// Bee to analyze
|
||||
this.addSlot(new SlotCustom(inventory, 0, 152, 32, new Object[] { ItemBeeGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, 0, 152, 32, ItemBeeGE.class));
|
||||
// Analyzed bee
|
||||
this.addSlot(new SlotCustom(inventory, 1, 152, 75, new Object[] { ItemBeeGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, 1, 152, 75, ItemBeeGE.class));
|
||||
|
||||
// Player inventory
|
||||
for (int i1 = 0; i1 < 3; i1++)
|
||||
|
||||
@@ -28,17 +28,17 @@ import forestry.core.proxy.Proxies;
|
||||
|
||||
public class ContainerImprinter extends ContainerForestry implements IGuiSelectable {
|
||||
|
||||
public ImprinterInventory inventory;
|
||||
private boolean isNetSynched = false;
|
||||
public final ImprinterInventory inventory;
|
||||
private boolean isNetSynced = false;
|
||||
|
||||
public ContainerImprinter(InventoryPlayer inventoryplayer, ImprinterInventory inventory) {
|
||||
super(inventory);
|
||||
|
||||
this.inventory = inventory;
|
||||
// Input
|
||||
this.addSlot(new SlotCustom(inventory, 0, 152, 12, new Object[] { ItemBeeGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, 0, 152, 12, ItemBeeGE.class));
|
||||
// Output
|
||||
this.addSlot(new SlotCustom(inventory, 1, 152, 72, new Object[] { ItemBeeGE.class }));
|
||||
this.addSlot(new SlotCustom(inventory, 1, 152, 72, ItemBeeGE.class));
|
||||
|
||||
// Player inventory
|
||||
for (int i1 = 0; i1 < 3; i1++)
|
||||
@@ -84,7 +84,7 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta
|
||||
private void sendSelectionChange(PacketPayload payload) {
|
||||
PacketUpdate packet = new PacketUpdate(PacketIds.GUI_SELECTION_CHANGE, payload);
|
||||
Proxies.net.sendToServer(packet);
|
||||
isNetSynched = false;
|
||||
isNetSynced = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,8 +94,8 @@ public class ContainerImprinter extends ContainerForestry implements IGuiSelecta
|
||||
}
|
||||
|
||||
public void updateContainer(World world) {
|
||||
if (!isNetSynched && !Proxies.common.isSimulating(world)) {
|
||||
isNetSynched = true;
|
||||
if (!isNetSynced && !Proxies.common.isSimulating(world)) {
|
||||
isNetSynced = true;
|
||||
Proxies.net.sendToServer(new PacketUpdate(PacketIds.IMPRINT_SELECTION_GET));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class GuiBeealyzer extends GuiAlyzer {
|
||||
.getArea().toString(), bee, EnumBeeChromosome.TERRITORY);
|
||||
|
||||
drawRow(StringUtil.localize("gui.effect"), bee.getGenome().getEffect().getName(),
|
||||
((IAlleleBeeEffect) bee.getGenome().getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal())).getName(), bee,
|
||||
bee.getGenome().getInactiveAllele(EnumBeeChromosome.EFFECT.ordinal()).getName(), bee,
|
||||
EnumBeeChromosome.EFFECT);
|
||||
|
||||
newLine();
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.List;
|
||||
|
||||
public class ItemBeeGE extends ItemGE {
|
||||
|
||||
EnumBeeType type;
|
||||
private final EnumBeeType type;
|
||||
|
||||
public ItemBeeGE(EnumBeeType type) {
|
||||
super();
|
||||
@@ -141,7 +141,7 @@ public class ItemBeeGE extends ItemGE {
|
||||
public int getColourFromSpecies(IAlleleSpecies species, int renderPass) {
|
||||
|
||||
if (species != null && species instanceof IAlleleBeeSpecies)
|
||||
return ((IAlleleBeeSpecies) species).getIconColour(renderPass);
|
||||
return species.getIconColour(renderPass);
|
||||
else
|
||||
return 0xffffff;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import net.minecraft.world.World;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
|
||||
@@ -30,7 +30,7 @@ import forestry.api.apiculture.IBee;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.render.TextureBiomefinder;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
|
||||
@@ -27,9 +27,9 @@ public class ItemHoneycomb extends ItemForestryMultiPass {
|
||||
|
||||
private static class CombInfo {
|
||||
|
||||
public String name;
|
||||
public int primaryColor;
|
||||
public int secondaryColor;
|
||||
public final String name;
|
||||
public final int primaryColor;
|
||||
public final int secondaryColor;
|
||||
public boolean isSecret = false;
|
||||
|
||||
public CombInfo(String name, int primaryColor, int secondaryColor) {
|
||||
@@ -43,7 +43,8 @@ public class ItemHoneycomb extends ItemForestryMultiPass {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public CombInfo[] combs = new CombInfo[]{new CombInfo("honey", 0xe8d56a, 0xffa12b), // 0
|
||||
public final CombInfo[] combs = new CombInfo[]{
|
||||
new CombInfo("honey", 0xe8d56a, 0xffa12b), // 0
|
||||
new CombInfo("cocoa", 0x674016, 0xffb62b).setIsSecret(), // 1
|
||||
new CombInfo("simmering", 0x981919, 0xffb62b), // 2
|
||||
new CombInfo("stringy", 0xc8be67, 0xbda93e), // 3
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ItemImprinter extends ItemForestry {
|
||||
private int primaryIndex = 0;
|
||||
private int secondaryIndex = 0;
|
||||
|
||||
EntityPlayer player;
|
||||
private final EntityPlayer player;
|
||||
|
||||
public ImprinterInventory(EntityPlayer player) {
|
||||
this.player = player;
|
||||
|
||||
@@ -22,18 +22,18 @@ import forestry.api.apiculture.EnumBeeType;
|
||||
public class ModelBee extends ModelBase {
|
||||
|
||||
//fields
|
||||
ModelRenderer snout;
|
||||
ModelRenderer torsoWing;
|
||||
ModelRenderer rump;
|
||||
ModelRenderer tail;
|
||||
ModelRenderer tailEnd;
|
||||
ModelRenderer bridge;
|
||||
ModelRenderer eyeRight;
|
||||
ModelRenderer eyeLeft;
|
||||
ModelRenderer wingLeft;
|
||||
ModelRenderer wingRight;
|
||||
ModelRenderer crownQueen;
|
||||
ModelRenderer crownPrincess;
|
||||
private final ModelRenderer snout;
|
||||
private final ModelRenderer torsoWing;
|
||||
private final ModelRenderer rump;
|
||||
private final ModelRenderer tail;
|
||||
private final ModelRenderer tailEnd;
|
||||
private final ModelRenderer bridge;
|
||||
private final ModelRenderer eyeRight;
|
||||
private final ModelRenderer eyeLeft;
|
||||
private final ModelRenderer wingLeft;
|
||||
private final ModelRenderer wingRight;
|
||||
private final ModelRenderer crownQueen;
|
||||
private final ModelRenderer crownPrincess;
|
||||
|
||||
EnumBeeType type = EnumBeeType.DRONE;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import forestry.apiculture.entities.EntityBee;
|
||||
|
||||
public class RenderBee extends RenderLiving {
|
||||
|
||||
ModelBee beeModel;
|
||||
private final ModelBee beeModel;
|
||||
|
||||
public RenderBee() {
|
||||
super(new ModelBee(), 0.15f);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class TextureBiomefinder extends TextureAtlasSprite {
|
||||
if (minecraft.theWorld != null && minecraft.thePlayer != null)
|
||||
updateCompass(minecraft.theWorld, minecraft.thePlayer.posX, minecraft.thePlayer.posZ, minecraft.thePlayer.rotationYaw, false, true);
|
||||
else
|
||||
updateCompass((World)null, 0.0d, 0.0d, 0.0d, true, true);
|
||||
updateCompass(null, 0.0d, 0.0d, 0.0d, true, true);
|
||||
}
|
||||
|
||||
public void updateCompass(World world, double playerX, double playerZ, double playerYaw, boolean par8, boolean hasSpin) {
|
||||
|
||||
@@ -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.trigger;
|
||||
|
||||
import forestry.core.triggers.Trigger;
|
||||
|
||||
public class ApicultureTriggers {
|
||||
public static Trigger noFrames;
|
||||
public static Trigger missingQueen;
|
||||
public static Trigger missingDrone;
|
||||
|
||||
public static void initialize() {
|
||||
noFrames = new TriggerNoFrames();
|
||||
|
||||
missingQueen = new TriggerMissingQueen();
|
||||
missingDrone = new TriggerMissingDrone();
|
||||
}
|
||||
}
|
||||
Executable → Regular
+3
-2
@@ -8,12 +8,13 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.triggers;
|
||||
package forestry.apiculture.trigger;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.triggers.Trigger;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
Executable → Regular
+3
-2
@@ -8,12 +8,13 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.triggers;
|
||||
package forestry.apiculture.trigger;
|
||||
|
||||
import buildcraft.api.statements.IStatementContainer;
|
||||
import buildcraft.api.statements.IStatementParameter;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.triggers.Trigger;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -32,11 +32,11 @@ public class TriggerNoFrames extends Trigger {
|
||||
if (!(tile instanceof TileApiary))
|
||||
return false;
|
||||
|
||||
for (int i = TileApiary.SLOT_FRAMES_1; i < TileApiary.SLOT_FRAMES_1 + TileApiary.SLOT_FRAMES_COUNT; i++)
|
||||
if (((TileApiary) tile).getStackInSlot(i) == null)
|
||||
continue;
|
||||
else
|
||||
for (int i = TileApiary.SLOT_FRAMES_1; i < TileApiary.SLOT_FRAMES_1 + TileApiary.SLOT_FRAMES_COUNT; i++) {
|
||||
if (((TileApiary) tile).getStackInSlot(i) != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import forestry.plugins.PluginApiculture;
|
||||
|
||||
public class ComponentVillageBeeHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
protected ItemStack[] buildingBlocks = new ItemStack[]{ForestryBlock.planks1.getItemStack(1, 15), new ItemStack(Blocks.log, 1, 0),};
|
||||
protected final ItemStack[] buildingBlocks = new ItemStack[]{ForestryBlock.planks1.getItemStack(1, 15), new ItemStack(Blocks.log, 1, 0),};
|
||||
protected int averageGroundLevel = -1;
|
||||
protected boolean isInDesert = false;
|
||||
protected boolean hasChest = false;
|
||||
|
||||
@@ -52,34 +52,39 @@ public class HiveDecorator {
|
||||
if (!TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, EVENT_TYPE)) {
|
||||
return;
|
||||
}
|
||||
decorateHives(event.world, event.rand, event.chunkX * 16, event.chunkZ * 16);
|
||||
decorateHives(event.world, event.rand, event.chunkX, event.chunkZ);
|
||||
}
|
||||
|
||||
private void decorateHives(World world, Random rand, int worldX, int worldZ) {
|
||||
private void decorateHives(World world, Random rand, int chunkX, int chunkZ) {
|
||||
for (IHive hive : HiveManager.getHives())
|
||||
if (Config.generateBeehivesDebug)
|
||||
genHiveDebug(world, worldX, worldZ, hive);
|
||||
genHiveDebug(world, chunkX, chunkZ, hive);
|
||||
else
|
||||
genHive(world, rand, worldX, worldZ, hive);
|
||||
genHive(world, rand, chunkX, chunkZ, hive);
|
||||
}
|
||||
|
||||
private void genHive(World world, Random rand, int worldX, int worldZ, IHive hive) {
|
||||
public boolean genHive(World world, Random rand, int chunkX, int chunkZ, IHive hive) {
|
||||
if (hive.genChance() < rand.nextFloat() * 128.0f)
|
||||
return;
|
||||
return false;
|
||||
|
||||
int worldX = chunkX * 16;
|
||||
int worldZ = chunkZ * 16;
|
||||
|
||||
BiomeGenBase biome = world.getBiomeGenForCoords(worldX, worldZ);
|
||||
EnumHumidity humidity = EnumHumidity.getFromValue(biome.rainfall);
|
||||
|
||||
if (!hive.isGoodBiome(biome) || !hive.isGoodHumidity(humidity))
|
||||
return;
|
||||
return false;
|
||||
|
||||
for (int tries = 0; tries < 4; tries ++) {
|
||||
int x = worldX + rand.nextInt(16);
|
||||
int z = worldZ + rand.nextInt(16);
|
||||
|
||||
if (tryGenHive(world, x, z, hive))
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void genHiveDebug(World world, int worldX, int worldZ, IHive hive) {
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
package forestry.apiculture.worldgen;
|
||||
|
||||
import forestry.api.apiculture.hives.HiveGround;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@@ -14,7 +14,6 @@ import forestry.api.apiculture.hives.HiveTree;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class HiveForest extends HiveTree {
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import forestry.api.apiculture.hives.HiveTree;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class HiveJungle extends HiveTree {
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class HiveMeadows extends HiveGround {
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.apiculture.worldgen;
|
||||
|
||||
import forestry.api.apiculture.hives.HiveGround;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
@@ -23,6 +24,11 @@ public class HiveParched extends HiveGround {
|
||||
super(ForestryBlock.beehives.block(), 3, genChance, Blocks.sand, Blocks.sandstone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGoodBiome(BiomeGenBase biome) {
|
||||
return !BiomeHelper.canRainOrSnow(biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGoodHumidity(EnumHumidity humidity) {
|
||||
return humidity == EnumHumidity.ARID;
|
||||
|
||||
@@ -11,12 +11,10 @@
|
||||
package forestry.apiculture.worldgen;
|
||||
|
||||
import forestry.api.apiculture.hives.HiveGround;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class HiveSnow extends HiveGround {
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class HiveSwamp extends HiveGround {
|
||||
|
||||
|
||||
Executable → Regular
+11
-23
@@ -4,46 +4,34 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import forestry.api.apiculture.hives.HiveGround;
|
||||
import forestry.apiculture.gadgets.TileSwarm;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.apiculture.gadgets.TileSwarm;
|
||||
public class HiveSwarmer extends HiveGround {
|
||||
|
||||
/**
|
||||
*
|
||||
* @author CovertJaguar <http://www.railcraft.info/>
|
||||
*/
|
||||
public class WorldGenHiveSwamer extends WorldGenHive {
|
||||
private final ItemStack[] bees;
|
||||
|
||||
private ItemStack[] bees;
|
||||
|
||||
public WorldGenHiveSwamer(ItemStack[] bees) {
|
||||
public HiveSwarmer(float genChance, ItemStack... bees) {
|
||||
super(ForestryBlock.beehives.block(), 8, genChance, Blocks.dirt, Blocks.grass);
|
||||
this.bees = bees;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generate(World world, Random random, int x, int y, int z) {
|
||||
if (world.blockExists(x, y, z) && world.isAirBlock(x, y, z) && (!world.isAirBlock(x, y - 1, z) || !world.isAirBlock(x, y + 1, z))) {
|
||||
setHive(world, x, y, z, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postGen(World world, int x, int y, int z, int meta) {
|
||||
public void postGen(World world, int x, int y, int z) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileSwarm)
|
||||
((TileSwarm) tile).setContained(bees);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +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.worldgen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
|
||||
public abstract class WorldGenHive extends WorldGenerator {
|
||||
|
||||
@Override
|
||||
public abstract boolean generate(World world, Random random, int x, int y, int z);
|
||||
|
||||
protected void setHive(World world, int x, int y, int z, int meta) {
|
||||
boolean placed = world.setBlock(x, y, z, ForestryBlock.beehives.block(), meta, Defaults.FLAG_BLOCK_SYNCH);
|
||||
if (!placed)
|
||||
return;
|
||||
|
||||
if (!ForestryBlock.beehives.isBlockEqual(world, x, y, z))
|
||||
return;
|
||||
|
||||
ForestryBlock.beehives.block().onBlockAdded(world, x, y, z);
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
|
||||
postGen(world, x, y, z, meta);
|
||||
}
|
||||
|
||||
protected void postGen(World world, int x, int y, int z, int meta) {
|
||||
ForestryBlock.beehives.block().onBlockPlaced(world, x, y, z, 0, 0.0f, 0.0f, 0.0f, meta);
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ import forestry.plugins.PluginArboriculture;
|
||||
|
||||
public class CommandTreekeepingMode extends CommandMC {
|
||||
|
||||
String[] modeStrings;
|
||||
private final String[] modeStrings;
|
||||
|
||||
public CommandTreekeepingMode() {
|
||||
modeStrings = new String[PluginArboriculture.treeInterface.getTreekeepingModes().size()];
|
||||
@@ -209,7 +209,6 @@ public class CommandTreekeepingMode extends CommandMC {
|
||||
help += mode.getName();
|
||||
}
|
||||
sendChatMessage(sender, "Available modes: " + help);
|
||||
return;
|
||||
}
|
||||
|
||||
private void listModeInfo(ICommandSender sender, String[] arguments) {
|
||||
|
||||
@@ -10,17 +10,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
|
||||
import forestry.api.genetics.IFruitBearer;
|
||||
import forestry.arboriculture.gadgets.TileFruitPod;
|
||||
import forestry.arboriculture.gadgets.TileSapling;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
|
||||
public class EventHandlerArboriculture {
|
||||
|
||||
@@ -35,17 +32,17 @@ public class EventHandlerArboriculture {
|
||||
int result = ((TileSapling) tile).tryGrow(true);
|
||||
if (result == 1 || result == 2)
|
||||
event.setResult(Result.ALLOW);
|
||||
} else if(tile instanceof TileFruitPod) {
|
||||
if(((TileFruitPod)tile).canMature()) {
|
||||
((TileFruitPod)tile).mature();
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
} else if (tile instanceof IFruitBearer) {
|
||||
IFruitBearer bearer = (IFruitBearer) tile;
|
||||
if (bearer.getRipeness() <= 1.0f) {
|
||||
bearer.addRipeness(1.0f);
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
} else if(tile instanceof TileFruitPod) {
|
||||
if(((TileFruitPod)tile).canMature()) {
|
||||
((TileFruitPod)tile).mature();
|
||||
event.setResult(Result.ALLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,17 +10,17 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Simple fruit provider which drops from any leaf block according to yield and either marks all leave blocks as fruit leaves or none.
|
||||
@@ -55,12 +55,13 @@ public class FruitProviderRandom extends FruitProviderNone {
|
||||
if (world.rand.nextFloat() <= genome.getYield() * modeYieldMod * entry.getValue())
|
||||
product.add(entry.getKey().copy());
|
||||
|
||||
return product.toArray(new ItemStack[0]);
|
||||
return product.toArray(new ItemStack[product.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getProducts() {
|
||||
return products.keySet().toArray(new ItemStack[0]);
|
||||
Set<ItemStack> products = this.products.keySet();
|
||||
return products.toArray(new ItemStack[products.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,17 +10,17 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.genetics.IFruitFamily;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class FruitProviderRipening extends FruitProviderNone {
|
||||
|
||||
@@ -73,12 +73,13 @@ public class FruitProviderRipening extends FruitProviderNone {
|
||||
if (world.rand.nextFloat() <= genome.getYield() * entry.getValue() * modeYieldMod * 5.0f * stage)
|
||||
product.add(entry.getKey().copy());
|
||||
|
||||
return product.toArray(new ItemStack[0]);
|
||||
return product.toArray(new ItemStack[product.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getProducts() {
|
||||
return products.keySet().toArray(new ItemStack[0]);
|
||||
Set<ItemStack> products = this.products.keySet();
|
||||
return products.toArray(new ItemStack[products.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,7 @@ public class PacketHandlerArboriculture implements IPacketHandler {
|
||||
|
||||
private void onLeafUpdate(PacketLeafUpdate packet) {
|
||||
|
||||
TileEntity tile = ((ILocatedPacket) packet).getTarget(Proxies.common.getRenderWorld());
|
||||
TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld());
|
||||
if (tile instanceof TileLeaves)
|
||||
((TileLeaves) tile).fromPacket(packet);
|
||||
|
||||
|
||||
@@ -1,37 +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.arboriculture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.world.IWorldGenInterface;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
|
||||
public class WorldGenHelper implements IWorldGenInterface {
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Override
|
||||
public Class<? extends WorldGenerator>[] getTreeGenerators(String ident) {
|
||||
|
||||
ArrayList<Class<? extends WorldGenerator>> generators = new ArrayList<Class<? extends WorldGenerator>>();
|
||||
for (IIndividual tree : PluginArboriculture.treeInterface.getIndividualTemplates())
|
||||
if (tree.getIdent().equals(ident))
|
||||
for (Class<? extends WorldGenerator> generator : ((ITree)tree).getGenome().getPrimary().getGeneratorClasses())
|
||||
generators.add(generator);
|
||||
|
||||
return generators.toArray(new Class[0]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,8 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.gadgets;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.WoodType;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -22,16 +26,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.arboriculture.IWoodTyped;
|
||||
import forestry.arboriculture.WoodType;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockArbFence extends BlockFence implements IWoodTyped {
|
||||
|
||||
@@ -72,7 +69,7 @@ public class BlockArbFence extends BlockFence implements IWoodTyped {
|
||||
public boolean canConnectFenceTo(IBlockAccess world, int x, int y, int z) {
|
||||
if (!isFence(world, x, y, z)) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block != null && block.getMaterial().isOpaque() && block.renderAsNormalBlock() ? block.getMaterial() != Material.gourd : false;
|
||||
return block != null && block.getMaterial().isOpaque() && block.renderAsNormalBlock() && block.getMaterial() != Material.gourd;
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockFireproofLog extends BlockLog implements IWoodFireproof {
|
||||
|
||||
public static Material fireproofWood = new Material(MapColor.woodColor);
|
||||
private static final Material fireproofWood = new Material(MapColor.woodColor);
|
||||
|
||||
public BlockFireproofLog(LogCat cat) {
|
||||
super(cat, fireproofWood);
|
||||
|
||||
@@ -19,7 +19,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockFireproofPlanks extends BlockPlanks implements IWoodFireproof {
|
||||
|
||||
public static Material fireproofWood = new Material(MapColor.woodColor);
|
||||
private static final Material fireproofWood = new Material(MapColor.woodColor);
|
||||
|
||||
public BlockFireproofPlanks(PlankCat cat) {
|
||||
super(cat, fireproofWood);
|
||||
|
||||
@@ -10,10 +10,20 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.IToolGrafter;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.IToolScoop;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.EnumFlutterType;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import forestry.plugins.PluginLepidopterology;
|
||||
import net.minecraft.block.BlockNewLeaf;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -28,24 +38,12 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.IToolGrafter;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.IToolScoop;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.EnumFlutterType;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import forestry.plugins.PluginLepidopterology;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProvider {
|
||||
|
||||
@@ -149,8 +147,7 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv
|
||||
|
||||
// Add fruits
|
||||
if (tile.hasFruit())
|
||||
for (ItemStack stack : tile.getTree().produceStacks(world, x, y, z, tile.getRipeningTime()))
|
||||
prod.add(stack);
|
||||
Collections.addAll(prod, tile.getTree().produceStacks(world, x, y, z, tile.getRipeningTime()));
|
||||
|
||||
return prod;
|
||||
}
|
||||
|
||||
@@ -10,28 +10,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import forestry.api.arboriculture.IAlleleFruit;
|
||||
import forestry.api.arboriculture.IFruitProvider;
|
||||
import forestry.api.arboriculture.ILeafTickHandler;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
@@ -50,6 +36,20 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.plugins.PluginArboriculture;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class TileLeaves extends TileTreeContainer implements IPollinatable, IFruitBearer, IButterflyNursery {
|
||||
|
||||
@@ -69,17 +69,14 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
private int maturationTime;
|
||||
private int encumbrance;
|
||||
|
||||
private int biomeId = -1;
|
||||
private BiomeGenBase biome;
|
||||
|
||||
private IEffectData effectData[] = new IEffectData[2];
|
||||
|
||||
private void updateBiome() {
|
||||
if(worldObj == null)
|
||||
return;
|
||||
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
if (biome != null) {
|
||||
this.biomeId = biome.biomeID;
|
||||
}
|
||||
biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@@ -119,7 +116,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
|
||||
@Override
|
||||
public void onBlockTick() {
|
||||
if(biomeId < 0)
|
||||
if(biome == null)
|
||||
updateBiome();
|
||||
|
||||
if (isDecorative || getTree() == null)
|
||||
@@ -127,7 +124,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
|
||||
boolean isDestroyed = isDestroyed();
|
||||
for(ILeafTickHandler tickHandler : getTree().getGenome().getPrimary().getRoot().getLeafTickHandlers())
|
||||
if(tickHandler.onRandomLeafTick(getTree(), worldObj, biomeId, xCoord, yCoord, zCoord, isDestroyed))
|
||||
if(tickHandler.onRandomLeafTick(getTree(), worldObj, biome.biomeID, xCoord, yCoord, zCoord, isDestroyed))
|
||||
return;
|
||||
|
||||
if(isDestroyed)
|
||||
@@ -149,7 +146,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
if(caterpillar != null)
|
||||
matureCaterpillar();
|
||||
|
||||
effectData = getTree().doEffect(effectData, worldObj, biomeId, xCoord, yCoord, zCoord);
|
||||
effectData = getTree().doEffect(effectData, worldObj, biome.biomeID, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -393,7 +390,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
|
||||
boolean wasDestroyed = isDestroyed();
|
||||
encumbrance += caterpillar.getGenome().getMetabolism();
|
||||
wasDestroyed = !wasDestroyed && isDestroyed() ? true : false;
|
||||
wasDestroyed = !wasDestroyed && isDestroyed();
|
||||
|
||||
if(maturationTime >= (float)caterpillar.getGenome().getLifespan() / (caterpillar.getGenome().getFertility()*2)
|
||||
&& caterpillar.canTakeFlight(worldObj, xCoord, yCoord, zCoord)) {
|
||||
@@ -424,7 +421,12 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
|
||||
@Override
|
||||
public int getBiomeId() {
|
||||
return 0;
|
||||
return biome.biomeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiome() {
|
||||
return biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -438,7 +440,18 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
|
||||
@Override public void setErrorState(int state) {}
|
||||
|
||||
@Override
|
||||
public void setErrorState(EnumErrorCode state) {
|
||||
}
|
||||
|
||||
@Override public int getErrorOrdinal() { return 0; }
|
||||
|
||||
@Override
|
||||
public EnumErrorCode getErrorState() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all) {
|
||||
return false;
|
||||
|
||||
@@ -10,14 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.gadgets;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.arboriculture.genetics.Tree;
|
||||
import forestry.core.interfaces.IOwnable;
|
||||
@@ -27,6 +20,12 @@ import forestry.core.network.PacketIds;
|
||||
import forestry.core.network.PacketTileNBT;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.EnumAccess;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
* This is the base TE class for any block that needs to contain tree genome information.
|
||||
@@ -156,10 +155,7 @@ public abstract class TileTreeContainer extends TileEntity implements INetworked
|
||||
|
||||
@Override
|
||||
public boolean isOwner(EntityPlayer player) {
|
||||
if (owner != null)
|
||||
return owner.equals(player.getGameProfile());
|
||||
else
|
||||
return false;
|
||||
return PlayerUtil.isSameGameProfile(owner, player.getGameProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ import forestry.core.genetics.Allele;
|
||||
|
||||
public class AlleleFruit extends Allele implements IAlleleFruit {
|
||||
|
||||
private IFruitProvider provider;
|
||||
private final IFruitProvider provider;
|
||||
|
||||
public AlleleFruit(String uid, IFruitProvider provider) {
|
||||
this(uid, provider, false);
|
||||
|
||||
@@ -16,7 +16,7 @@ import forestry.core.genetics.Allele;
|
||||
|
||||
public class AlleleGrowth extends Allele implements IAlleleGrowth {
|
||||
|
||||
IGrowthProvider provider;
|
||||
private final IGrowthProvider provider;
|
||||
|
||||
public AlleleGrowth(String uid, IGrowthProvider provider) {
|
||||
this(uid, provider, false);
|
||||
|
||||
@@ -21,7 +21,7 @@ import forestry.core.utils.Vect;
|
||||
|
||||
public class AlleleLeafEffectNone extends Allele implements IAlleleLeafEffect {
|
||||
|
||||
int[] DEFAULT_EFFECT_AREA = new int[] { 12, 12, 12 };
|
||||
private static final int[] DEFAULT_EFFECT_AREA = new int[] { 12, 12, 12 };
|
||||
|
||||
public AlleleLeafEffectNone(String uid) {
|
||||
super(uid, true);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
}
|
||||
}
|
||||
|
||||
private static HashMap<String, LeafType> leafTypes = new HashMap<String, LeafType>();
|
||||
private static final HashMap<String, LeafType> leafTypes = new HashMap<String, LeafType>();
|
||||
static {
|
||||
leafTypes.put("deciduous", new LeafType("deciduous", (short) 10, (short) 11, (short) 12));
|
||||
leafTypes.put("conifers", new LeafType("conifers", (short) 15, (short) 16, (short) 17));
|
||||
@@ -83,16 +83,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
private EnumPlantType nativeType = EnumPlantType.Plains;
|
||||
private final ArrayList<IFruitFamily> fruits = new ArrayList<IFruitFamily>();
|
||||
|
||||
private ItemStack wood;
|
||||
|
||||
public AlleleTreeSpecies(String uid, boolean isDominant, String name, IClassification branch, String binomial, int primaryColor, int secondaryColor) {
|
||||
super(uid, isDominant, name, branch, binomial);
|
||||
|
||||
this.root = (ITreeRoot)AlleleManager.alleleRegistry.getSpeciesRoot(TreeHelper.UID);
|
||||
this.primaryColour = primaryColor;
|
||||
//this.secondaryColour = secondaryColor;
|
||||
leafType = leafTypes.get("deciduous");
|
||||
}
|
||||
private final ItemStack wood;
|
||||
|
||||
public AlleleTreeSpecies(String uid, boolean isDominant, String name, IClassification branch, String binomial, int primaryColor,
|
||||
Class<? extends WorldGenArboriculture> generator, ItemStack wood) {
|
||||
@@ -184,7 +175,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
@SuppressWarnings("rawtypes")
|
||||
public WorldGenerator getGenerator(ITree tree, World world, int x, int y, int z) {
|
||||
try {
|
||||
return generatorClass.getConstructor(new Class[] { ITreeGenData.class }).newInstance(new Object[] { tree });
|
||||
return generatorClass.getConstructor(new Class[] { ITreeGenData.class }).newInstance(tree);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("Failed to instantiate generator of class " + generatorClass.getName());
|
||||
}
|
||||
@@ -235,7 +226,7 @@ public class AlleleTreeSpecies extends AlleleSpecies implements IAlleleTreeSpeci
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon icon;
|
||||
private IIcon icon;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -311,7 +311,7 @@ public class Tree extends Individual implements ITree, ITreeGenData, IPlantable
|
||||
else
|
||||
prod.add(createOffspring(world, x, y, z));
|
||||
|
||||
return prod.toArray(new ITree[0]);
|
||||
return prod.toArray(new ITree[prod.size()]);
|
||||
}
|
||||
|
||||
private ITree createOffspring(World world, int x, int y, int z) {
|
||||
|
||||
@@ -60,16 +60,20 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
|
||||
|
||||
public static final String UID = "rootTrees";
|
||||
public static int treeSpeciesCount = -1;
|
||||
public static ITreekeepingMode activeTreekeepingMode;
|
||||
public static final ArrayList<ITree> treeTemplates = new ArrayList<ITree>();
|
||||
|
||||
private final ArrayList<ITreekeepingMode> treekeepingModes = new ArrayList<ITreekeepingMode>();
|
||||
|
||||
public TreeHelper() {
|
||||
setResearchSuitability(new ItemStack(Blocks.sapling, 1, Defaults.WILDCARD), 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUID() {
|
||||
return UID;
|
||||
}
|
||||
|
||||
public TreeHelper() {
|
||||
setResearchSuitability(new ItemStack(Blocks.sapling, 1, Defaults.WILDCARD), 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends IIndividual> getMemberClass() {
|
||||
return ITree.class;
|
||||
@@ -290,8 +294,6 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
|
||||
}
|
||||
|
||||
/* BREEDING MODES */
|
||||
ArrayList<ITreekeepingMode> treekeepingModes = new ArrayList<ITreekeepingMode>();
|
||||
public static ITreekeepingMode activeTreekeepingMode;
|
||||
|
||||
@Override
|
||||
public ArrayList<ITreekeepingMode> getTreekeepingModes() {
|
||||
@@ -337,7 +339,6 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
|
||||
}
|
||||
|
||||
/* TEMPLATES */
|
||||
public static ArrayList<ITree> treeTemplates = new ArrayList<ITree>();
|
||||
|
||||
@Override
|
||||
public ArrayList<ITree> getIndividualTemplates() {
|
||||
@@ -356,7 +357,7 @@ public class TreeHelper extends SpeciesRoot implements ITreeRoot {
|
||||
}
|
||||
|
||||
/* MUTATIONS */
|
||||
private static ArrayList<ITreeMutation> treeMutations = new ArrayList<ITreeMutation>();
|
||||
private static final ArrayList<ITreeMutation> treeMutations = new ArrayList<ITreeMutation>();
|
||||
|
||||
@Override
|
||||
public ArrayList<ITreeMutation> getMutations(boolean shuffle) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import forestry.plugins.PluginArboriculture;
|
||||
|
||||
public class TreeMutation extends Mutation implements ITreeMutation {
|
||||
|
||||
private ITreeRoot root;
|
||||
private final ITreeRoot root;
|
||||
|
||||
public TreeMutation(IAllele allele0, IAllele allele1, IAllele[] template, int chance) {
|
||||
super(allele0, allele1, template, chance);
|
||||
|
||||
Loaded 100 of 365 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user