Compare commits

...
Author SHA1 Message Date
Nirek-K 06b1f9fabf Allow Biogas Engine fuel tank to be drained externally.
(cherry picked from commit 81d2c1971c)
2015-09-26 19:51:33 -07:00
Nirek-K b00f92ab76 Fix #847 TradeStation not outputting items to automation (also fix insertion filtering)
(cherry picked from commit 9478ffb7c1)
2015-09-26 14:45:04 -07:00
mezz 83a41d41d3 Bump version to 3.6.8 2015-09-24 01:47:11 -07:00
Nirek-K a47fab4579 Make plantball value slightly less terrible (equal to 9 wheat, so 'slightly' better to combine wheat, still worse for things like saplings)
(cherry picked from commit 31bd1e82fd)
2015-09-24 01:46:48 -07:00
Nirek-K 07389fe1dc Fix #829 IC2 plantballs not working in fermenter
(cherry picked from commit b56a299f63)
2015-09-24 01:46:42 -07:00
mezz b276c5bb38 Fix #750 Worktable not working properly with GT Tools
(cherry picked from commit 37dd0efee2)
2015-09-24 01:09:19 -07:00
mezz b630540a26 Fix #834 Fix machine fluid handling for IFluidContainerItem
(cherry picked from commit f49bcfd020)
2015-09-22 23:20:04 -07:00
mezz 340ba2dc7c Fix #680 and Fix #750 worktable handling of tools and ItemCraftedEvent
Cleanup some derped refactoring

(cherry picked from commit 9f1b1cc474)
2015-09-12 16:59:59 -07:00
mezz 3e6c8407ff Bump version 2015-09-09 23:16:33 -07:00
mezz 87908d2a35 Merge pull request #818 from bdew/3.6-fixes
Fixes for 3.6.x - BeekeepingLogic overwriting queens with old data + OreDict use in Squeezer recipes
2015-09-09 23:13:21 -07:00
bdew a137cf8f12 Fixed BeekeepingLogic overwriting queen with old data 2015-09-09 13:38:26 +03:00
bdew 70f710231d Changed squeezer recipes to prioritize specific recipes over OD and fixed accepting items 2015-09-09 11:45:27 +03:00
mezz 7a68e04053 Fix #813 Found Chromosome with invalid Alleles 2015-09-08 13:45:16 -07:00
mezz 3c37a81617 Fix #816 Exception during loading Alveary Heater 2015-09-08 13:32:55 -07:00
mezz a9cc367623 Fix crash from missing Agrarian bee allele from older worlds 2015-07-13 20:51:45 -07:00
mezz 7757790b84 Bump version to 3.6.3 2015-06-30 20:51:04 -07:00
mezz bcdbec5b89 Fix #742 Hopper doesn't fill last spot of Carpenter inventory 2015-06-28 15:02:06 -07:00
mezz 3fcb927201 Fix issue with BeekeepingLogic cached canWork 2015-06-28 15:01:24 -07:00
mezz b374f0b23c Bump version to 3.6.2 2015-06-28 15:01:05 -07:00
mezz e9c4c416f5 Fix #739 Trade station crashes when loaded without name set 2015-06-27 21:16:48 -07:00
mezz 1b7d64a7b5 Fix #738 plain leaf blocks accept fertilizer and fruit pods do not grow 2015-06-26 22:31:37 -07:00
mezz 7b05cfd2f7 Bump version to 3.6.1 2015-06-26 22:31:37 -07:00
mezz 66fc9fbc9f Fix bees to pollinate vanilla trees again 2015-06-24 22:26:17 -07:00
mezz aa1ecd8c13 Fix #732 letter sizes 2015-06-24 21:18:36 -07:00
mezz c3453981c3 Fix #730 Crash with corrupted forestry leaves from MFR harvester 2015-06-20 20:38:19 -07:00
mezz 870eaf8725 Bump BC recipes compatible version range.
BuildcraftAPI|recipes got a breaking update in 7.0, but it only
breaks integration tables
2015-06-20 16:17:54 -07:00
mezz 2d07fea3ad Fix Analyzer block's display for trees and butterflies 2015-06-20 01:45:54 -07:00
mezz 95be941803 Fix #729 Leaves name doesn't show properly 2015-06-19 20:38:32 -07:00
mezz be16bf4491 Merge branch 'dev' into 3.6.0 2015-06-19 00:34:41 -07:00
mezz ce6aa27f44 Merge branch 'dev'
Conflicts:
	application.properties
	src/main/java/forestry/Forestry.java
	src/main/java/forestry/core/fluids/TankManager.java
	src/main/java/forestry/core/genetics/Allele.java
	src/main/java/forestry/factory/gadgets/MachineBottler.java
	src/main/java/forestry/factory/gadgets/MachineStill.java
	src/main/java/forestry/factory/gui/ContainerBottler.java
	src/main/java/forestry/plugins/PluginApiculture.java
	src/main/java/forestry/plugins/PluginCore.java
	src/main/java/forestry/plugins/PluginManager.java
	src/main/java/forestry/storage/items/ItemNaturalistBackpack.java
2015-05-21 00:48:20 -07:00
mezz bf179c91d9 Bump patch version to 3.5.6 2015-05-09 17:55:08 -07:00
Nirek-K 5fc1b10298 Add meta checking to flower weight adjustment
(cherry picked from commit 49deb75278)
2015-05-09 17:54:44 -07:00
Nirek-K 23b8f8b892 #Fix 646 Move plantables registration to not be smashed by acceptable.
(cherry picked from commit c705486472)
2015-05-09 17:52:54 -07:00
Nirek-K 1598946632 Fix #650 Fix logic errors in bee planting
(cherry picked from commit d29f4c0b79)
2015-05-09 17:52:34 -07:00
mezz aad6dbaa3f Bump patch version to 3.5.5 2015-05-09 17:41:13 -07:00
mezz ca6cc89015 Fix #652 Bottler liquid dupe bug on server
(cherry picked from commit d5296fbc60)
2015-05-09 17:39:52 -07:00
Nirek-K 7a22f1d939 Fix #644 Make Clockwork engine recipe OreDictionary aware. 2015-05-09 00:15:28 -07:00
mezz feda84fbc6 bump patch version 2015-04-18 13:13:39 -07:00
mezz f7b36e11d1 Fix compatibility with Forge 10.13.3.x fluid changes 2015-04-18 13:08:25 -07:00
mezz cfbab6b988 Fix #597 Crash from Butterfly Genome.getActiveAllele 2015-04-06 21:20:03 -07:00
mezz 3978a068d1 Bump minor patch version 2015-04-05 21:15:14 -07:00
mezz 9d2d0af432 Fix #594 Crash in Natura plugin
(cherry picked from commit 689adab411)
2015-04-05 21:14:56 -07:00
mezz d451309170 bump patch version to 3.5.1 2015-04-05 20:28:27 -07:00
mezz c82dd0fbfb Fix #592 Some Crates are missing a recipe 2015-04-05 20:22:21 -07:00
mezz 803911e10a Fix #588 crash on crate registry with disabled storage module and natura
(cherry picked from commit 536254af42)
2015-04-05 20:20:40 -07:00
Nirek-K 29eedf9011 Fix #588 Bulletproof null checks for Natura Plugin
(cherry picked from commit 3f6f12f7cc)
2015-04-05 20:15:05 -07:00
mezz 882848a00f Revert "Close #441 Add Underground Biomes Constructs integration"
This reverts commit b3b1a6a415.

Conflicts:
	lang
	src/main/java/forestry/Forestry.java
	src/main/java/forestry/plugins/PluginManager.java

(cherry picked from commit 1ca041a29f)

Conflicts:
	src/main/java/forestry/plugins/PluginManager.java
2015-04-04 19:44:15 -07:00
mezz 4d253e1dd6 Merge branch 'dev' into release_3.5
Conflicts:
	src/main/java/forestry/apiculture/worldgen/HiveGenHelper.java
2015-03-26 23:02:38 -07:00
mezz 4d7988ee0f Merge branch 'dev' into release_3.4
Conflicts:
	application.properties
	src/main/java/forestry/apiculture/gadgets/TileSwarm.java
	src/main/java/forestry/apiculture/genetics/Bee.java
	src/main/java/forestry/arboriculture/gadgets/ForestryBlockLeaves.java
	src/main/java/forestry/core/config/Config.java
	src/main/java/forestry/core/gui/widgets/ReservoirWidget.java
	src/main/java/forestry/core/utils/BlockUtil.java
	src/main/java/forestry/energy/EnergyManager.java
	src/main/java/forestry/factory/gadgets/MachineCarpenter.java
	src/main/java/forestry/mail/gui/GuiCatalogue.java
	src/main/java/forestry/plugins/PluginArboriculture.java
2015-02-16 15:00:16 -08:00
CovertJaguar fcad67a1c2 Update lang 2015-01-29 14:45:38 -08:00
mezz 1bd3b61df9 Fix #480 Increase hive spawn rate 25%, add config option for spawn rate
(cherry picked from commit 56dfae034d)

Conflicts:
	src/main/java/forestry/apiculture/worldgen/HiveDecorator.java
2015-01-29 00:11:35 -08:00
mezz 060ca1eb80 Fix #479 Try to make sure hives are always glowing
(cherry picked from commit 636201ce5a)
2015-01-29 00:09:47 -08:00
mezz 98a2d9c65e Fix bee biome temperature check for nether biomes
(cherry picked from commit c3f37a379a)
2015-01-25 22:26:39 -08:00
mezz eb010094ca Fix crash from missing block when a plugin mod is uninstalled
(cherry picked from commit 5a7bd9f57a)
2015-01-25 22:25:36 -08:00
mezz e6cbced8a2 #457 Add config option for village generation (forgot lumberjack) 2015-01-24 00:25:50 -08:00
mezz d300078227 Close #457 Add config option for village generation
(cherry picked from commit dab217eab0)
2015-01-24 00:21:56 -08:00
mezz 65c7f0242c Fix #470 Engines don't output to other mods' machines
(cherry picked from commit dffa845851)
2015-01-23 23:27:46 -08:00
mezz c4140ef9c3 Fix #472 Crash with Thaumic Tinkerer Ichorium Axe
(cherry picked from commit 1aefd5863e)
2015-01-23 23:26:54 -08:00
mezz 389e5e01e7 Fix #467 Carpenter automation
(cherry picked from commit c6dae0318c)
2015-01-23 22:34:21 -08:00
mezz a55b2645b7 Fix #465 crash after closing catalogue and opening another item gui
(cherry picked from commit dc1449855e)
2015-01-23 22:33:46 -08:00
mezz 9a36381ce0 Fix possible reservoir crash from thermionic fabricator
(cherry picked from commit 195c8fc524)
2015-01-23 22:32:37 -08:00
CovertJaguar 2565eea5ba Set version to 3.4 2015-01-17 20:44:55 -08:00
CovertJaguar 13ae9ece47 Fix submodule issues 2015-01-17 20:36:25 -08:00
CovertJaguar d3e87b1aaf Merge branch 'dev' into release_3.4
Conflicts:
	application.properties
	src/main/java/forestry/apiculture/gadgets/TileAlvearyHygroregulator.java
	src/main/java/forestry/apiculture/gadgets/TileAlvearyPlain.java
	src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java
	src/main/java/forestry/apiculture/worldgen/HiveDecorator.java
	src/main/java/forestry/apiculture/worldgen/HiveForest.java
	src/main/java/forestry/apiculture/worldgen/HiveGen.java
	src/main/java/forestry/apiculture/worldgen/HiveGenHelper.java
	src/main/java/forestry/apiculture/worldgen/HiveMeadows.java
	src/main/java/forestry/apiculture/worldgen/HiveSnow.java
	src/main/java/forestry/apiculture/worldgen/HiveSwamp.java
	src/main/java/forestry/apiculture/worldgen/HiveSwarmer.java
	src/main/java/forestry/core/gui/ContainerForestry.java
	src/main/java/forestry/core/utils/RecipeUtil.java
	src/main/java/forestry/factory/gadgets/TileWorktable.java
	src/main/java/forestry/factory/gui/ContainerFabricator.java
	src/main/java/forestry/factory/gui/ContainerWorktable.java
	src/main/java/forestry/factory/recipes/RecipeMemory.java
2015-01-17 20:33:15 -08:00
CovertJaguar 990d4990db Fix lang 2014-12-14 21:39:45 -08:00
mezz ce232e808e Fix Alveary Swarmer and Swarm Hive
(cherry picked from commit 2577ee9c930cdc91bdf3d207cbeaaebbe1141257)

Conflicts:
	src/main/java/forestry/apiculture/gadgets/TileAlvearySwarmer.java
2014-12-09 01:08:14 -08:00
mezz 31574a9c6e Cleanup
(cherry picked from commit 4f95ceab29)
2014-12-09 01:03:05 -08:00
mezz cd9a4110ee Refactor out worktable canCraftRecipe logic to RecipeUtil 2014-12-08 20:26:51 -08:00
mezz 6b35ff2ba1 Improve null safety of memorized recipe isValid check
(cherry picked from commit 23ffb78ab3)
2014-12-07 16:25:01 -08:00
mezz 5133e721cc Add blacklist to worktable memory, blacklist non-empty maps
(cherry picked from commit 2cb1959421)
2014-12-07 16:18:23 -08:00
mezz 09ced92f5b Support left click drag on Worktable
(cherry picked from commit 029604222c)
2014-12-07 16:18:17 -08:00
mezz 12477a7711 Fix crash when crafting with a Map on a Worktable 2014-12-07 16:17:21 -08:00
mezz b7dc4d9144 Fix #359 Crafting with a worktable does not trigger achievements.
(cherry picked from commit c010977a0b)
2014-12-07 16:16:24 -08:00
mezz da48d317ff Fix #362 Missing Analyzer Crafting recipe
(cherry picked from commit 7ffb9d5c1d)
2014-12-07 15:32:02 -08:00
mezz 5bfb11e952 Fix #353 Alveary heater/fan energy consumption, animation
(cherry picked from commit 475d99eae8)
2014-12-07 15:30:30 -08:00
mezz 4dffb9f352 Fix biome error in Alveary
(cherry picked from commit d0244ece32)
2014-12-07 15:30:20 -08:00
mezz beadb47539 Fix #356 Worktable using the wrong wood with Shift-use all
(cherry picked from commit 0105f36668)
2014-12-07 15:30:08 -08:00
mezz 6301d3c193 Fix #357 Forestry stained glass not silk touchable
(cherry picked from commit ab3ba0c4db)
2014-12-07 15:30:02 -08:00
mezz 883863e047 Safety check for IC2 Plugin. #351
(cherry picked from commit 38009bb32a)
2014-12-07 15:29:42 -08:00
mezz 2c14f02151 Fix #352 Backpack deletion/duplication bug
(cherry picked from commit d827a0f132)
2014-12-07 15:29:07 -08:00
CovertJaguar 00771b1a42 Bump version 2014-11-30 17:22:40 -08:00
CovertJaguar 46ec2f2740 Merge branch 'dev' into release_3.3 2014-11-30 17:21:03 -08:00
mezz ac653d46c1 Fix #326 decorative leaves should not pollinate 2014-11-15 04:15:20 -08:00
mezz 63d9935d01 Minor code cleanup 2014-11-15 04:15:14 -08:00
mezz ba695b977d Fix #325 Centrifuge dupe bug 2014-11-15 04:13:46 -08:00
CovertJaguar 6b1dfb1596 Set submodules 2014-11-15 04:12:44 -08:00
CovertJaguar fff02be71d Bump version to 3.2 2014-11-08 21:40:45 -08:00
CovertJaguar 0e5b9e4957 Merge branch 'dev' into release_3.2
Conflicts:
	src/main/resources/assets/forestry/textures/blocks/storage/apatite.png
	src/main/resources/assets/forestry/textures/blocks/storage/bronze.png
	src/main/resources/assets/forestry/textures/blocks/storage/copper.png
	src/main/resources/assets/forestry/textures/blocks/storage/tin.png
2014-11-08 21:39:26 -08:00
MysteriousAges 3415030fbf Revert "Storage block textures - Apatite, Bronze, Copper, Tin."
This reverts commit c8fd93873a.
2014-10-24 20:18:30 -07:00
60 changed files with 691 additions and 620 deletions

No files matched your search

+1 -1
View File
@@ -2,4 +2,4 @@ mcversion=1.7.10
forgeversion=10.13.3.1370-1.7.10
version_major=3
version_minor=6
version_patch=0
version_patch=8
+5 -1
View File
@@ -70,6 +70,10 @@ repositories {
name = "ic2"
url = "http://maven.ic2.player.to/"
}
ivy {
name "BuildCraft"
artifactPattern "http://www.mod-buildcraft.com/releases/BuildCraft/[revision]/[module]-[revision]-[classifier].[ext]"
}
}
configurations {
@@ -79,7 +83,7 @@ configurations {
dependencies {
api 'net.industrial-craft:industrialcraft-2:2.2.713-experimental:api'
api 'com.mod-buildcraft:buildcraft:6.4.10:dev'
api name: "buildcraft", version: "6.4.10", classifier: "dev"
}
processResources {
@@ -10,6 +10,7 @@
******************************************************************************/
package forestry.apiculture;
import java.util.Collections;
import java.util.Set;
import java.util.Stack;
@@ -36,7 +37,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
private static final int MAX_POLLINATION_ATTEMPTS = 20;
private static final int totalBreedingTime = Defaults.APIARY_BREEDING_TIME;
private static final int ticksPerCheckCanWork = 10;
private static final int ticksPerCheckQueenCanWork = 10;
private final IBeeHousing housing;
private final boolean housingSupportsMultipleErrorStates;
@@ -45,6 +46,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
private int breedingTime;
private int queenWorkCycleThrottle;
private IEffectData effectData[] = new IEffectData[2];
private ItemStack queenStack;
private IBee queen;
private IIndividual pollen;
private int attemptedPollinations = 0;
@@ -53,8 +55,8 @@ public class BeekeepingLogic implements IBeekeepingLogic {
// Cached flowers check
private boolean hasFlowersCached = false;
private int hasFlowersCooldown = 0;
private boolean canWorkCached = false;
private int canWorkCooldown = 0;
private Set<IErrorState> queenCanWorkCached = Collections.emptySet();
private int queenCanWorkCooldown = 0;
public BeekeepingLogic(IBeeHousing housing) {
this.housing = housing;
@@ -128,16 +130,6 @@ public class BeekeepingLogic implements IBeekeepingLogic {
@Override
public boolean canWork() {
if (canWorkCooldown > 0) {
canWorkCooldown--;
} else {
canWorkCached = checkCanWork();
canWorkCooldown = ticksPerCheckCanWork;
}
return canWorkCached;
}
private boolean checkCanWork() {
if (housingSupportsMultipleErrorStates) {
Set<IErrorState> errorStates = housing.getErrorStates();
for (IErrorState errorState : errorStates) {
@@ -183,7 +175,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
if (hasFlowersCooldown <= 0) {
hasFlowersCached = queen.hasFlower(housing);
hasFlowersCooldown = PluginApiculture.ticksPerBeeWorkCycle / ticksPerCheckCanWork;
hasFlowersCooldown = PluginApiculture.ticksPerBeeWorkCycle;
// check more often if we haven't found flowers
if (!hasFlowersCached) {
@@ -318,7 +310,12 @@ public class BeekeepingLogic implements IBeekeepingLogic {
ItemStack queenStack = housing.getQueen();
if (queenStack == null || !ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
if (!ItemStack.areItemStacksEqual(this.queenStack, queenStack)) {
this.queen = BeeManager.beeRoot.getMember(queenStack);
this.queenStack = queenStack;
}
if (queenStack == null || !ForestryItem.beeQueenGE.isItemEqual(queenStack)) {
housingErrorState = EnumErrorCode.NOQUEEN;
hasQueen = false;
queen = null;
@@ -367,30 +364,46 @@ public class BeekeepingLogic implements IBeekeepingLogic {
}
private boolean queenCanWork() {
if (queen == null) {
return false;
if (queenCanWorkCooldown > 0) {
queenCanWorkCooldown--;
} else {
if (queen == null) {
return false;
}
queenCanWorkCached = checkQueenCanWork();
queenCanWorkCooldown = ticksPerCheckQueenCanWork;
}
if (housingSupportsMultipleErrorStates) {
try {
Set<IErrorState> errorStates = queen.getCanWork(housing);
Set<IErrorState> errorStates = queenCanWorkCached;
if (errorStates.size() > 0) {
if (housingSupportsMultipleErrorStates) {
for (IErrorState errorState : errorStates) {
housing.setErrorCondition(true, errorState);
}
return (errorStates.size() == 0);
} catch (Throwable ignored) {
// queen might not support getCanWork(housing)
} else {
IErrorState state = errorStates.iterator().next();
housing.setErrorState(state);
}
return false;
} else {
return true;
}
}
private Set<IErrorState> checkQueenCanWork() {
try {
return queen.getCanWork(housing);
} catch (Throwable ignored) {
// queen might not support getCanWork
}
IErrorState state = queen.canWork(housing);
if (state != EnumErrorCode.OK) {
housing.setErrorState(state);
return false;
return Collections.singleton(state);
}
return true;
return Collections.emptySet();
}
// / BREEDING
@@ -141,10 +141,12 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
this.active = active;
if (worldObj.isRemote) {
worldObj.func_147479_m(xCoord, yCoord, zCoord);
} else {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
if (worldObj != null) {
if (worldObj.isRemote) {
worldObj.func_147479_m(xCoord, yCoord, zCoord);
} else {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
}
@@ -155,7 +155,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
}
this.active = active;
if (!worldObj.isRemote) {
if (worldObj != null && !worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
@@ -229,7 +229,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory,
this.active = active;
if (!worldObj.isRemote) {
if (worldObj != null && !worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
@@ -456,7 +456,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised,
}
this.active = active;
if (!worldObj.isRemote) {
if (worldObj != null && !worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
View File
File mode changed.
View File
File mode changed.
@@ -77,6 +77,10 @@ public class BeeGenome extends Genome implements IBeeGenome {
// NBT RETRIEVAL
public static IAlleleBeeSpecies getSpecies(ItemStack itemStack) {
if (!BeeManager.beeRoot.isMember(itemStack)) {
return null;
}
IAlleleSpecies species = getSpeciesDirectly(itemStack);
if (species instanceof IAlleleBeeSpecies) {
return (IAlleleBeeSpecies) species;
View File
File mode changed.
@@ -1,29 +1,29 @@
/*******************************************************************************
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
******************************************************************************/
package forestry.apiculture.worldgen;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
import forestry.api.apiculture.hives.IHiveGen;
public abstract class HiveGen implements IHiveGen {
@Override
public boolean canReplace(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
Material material = block.getMaterial();
return (material.isReplaceable() && !material.isLiquid()) ||
material == Material.air ||
material == Material.plants;
}
}
/*******************************************************************************
* 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 net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.world.World;
import forestry.api.apiculture.hives.IHiveGen;
public abstract class HiveGen implements IHiveGen {
@Override
public boolean canReplace(World world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
Material material = block.getMaterial();
return (material.isReplaceable() && !material.isLiquid()) ||
material == Material.air ||
material == Material.plants;
}
}
@@ -1,31 +1,31 @@
/*******************************************************************************
* 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 net.minecraft.block.Block;
import forestry.api.apiculture.hives.IHiveGen;
import forestry.api.apiculture.hives.IHiveGenHelper;
public class HiveGenHelper implements IHiveGenHelper {
private static final IHiveGen treeGen = new HiveGenTree();
@Override
public IHiveGen ground(Block... validGroundBlocks) {
return new HiveGenGround(validGroundBlocks);
}
@Override
public IHiveGen tree() {
return treeGen;
}
}
/*******************************************************************************
* 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 net.minecraft.block.Block;
import forestry.api.apiculture.hives.IHiveGen;
import forestry.api.apiculture.hives.IHiveGenHelper;
public class HiveGenHelper implements IHiveGenHelper {
private static final IHiveGen treeGen = new HiveGenTree();
@Override
public IHiveGen ground(Block... validGroundBlocks) {
return new HiveGenGround(validGroundBlocks);
}
@Override
public IHiveGen tree() {
return treeGen;
}
}
@@ -1,48 +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 net.minecraft.tileentity.TileEntity;
import net.minecraftforge.event.entity.player.BonemealEvent;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import forestry.api.genetics.IFruitBearer;
import forestry.arboriculture.gadgets.TileFruitPod;
import forestry.core.proxy.Proxies;
public class EventHandlerArboriculture {
@SubscribeEvent
public void handleBonemeal(BonemealEvent event) {
if (!Proxies.common.isSimulating(event.world)) {
return;
}
TileEntity tile = event.world.getTileEntity(event.x, event.y, event.z);
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);
}
}
}
}
@@ -139,4 +139,30 @@ public class BlockFruitPod extends BlockCocoa {
return PluginArboriculture.modelIdPods;
}
/* IGrowable */
@Override
// canFertilize
public boolean func_149851_a(World world, int x, int y, int z, boolean isClient) {
TileFruitPod podTile = getPodTile(world, x, y, z);
if (podTile != null) {
return podTile.canMature();
}
return false;
}
@Override
// shouldFertilize
public boolean func_149852_a(World world, Random random, int x, int y, int z) {
return true;
}
@Override
// fertilize
public void func_149853_b(World world, Random random, int x, int y, int z) {
TileFruitPod podTile = getPodTile(world, x, y, z);
if (podTile != null) {
podTile.mature();
}
}
}
@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Random;
import net.minecraft.block.BlockNewLeaf;
import net.minecraft.block.IGrowable;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
@@ -49,7 +50,7 @@ import forestry.core.utils.StackUtils;
import forestry.plugins.PluginArboriculture;
import forestry.plugins.PluginLepidopterology;
public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProvider {
public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProvider, IGrowable {
public ForestryBlockLeaves() {
this.setCreativeTab(Tabs.tabArboriculture);
@@ -328,4 +329,30 @@ public class ForestryBlockLeaves extends BlockNewLeaf implements ITileEntityProv
return super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
}
/* IGrowable */
@Override
// canFertilize
public boolean func_149851_a(World world, int x, int y, int z, boolean isClient) {
TileLeaves leafTile = getLeafTile(world, x, y, z);
if (leafTile != null) {
return leafTile.hasFruit() && leafTile.getRipeness() < 1.0f;
}
return false;
}
@Override
// shouldFertilize
public boolean func_149852_a(World world, Random random, int x, int y, int z) {
return true;
}
@Override
// fertilize
public void func_149853_b(World world, Random random, int x, int y, int z) {
TileLeaves leafTile = getLeafTile(world, x, y, z);
if (leafTile != null) {
leafTile.addRipeness(1.0f);
}
}
}
@@ -138,6 +138,14 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
Proxies.net.sendNetworkPacket(new PacketRipeningUpdate(this));
}
public void fromRipeningPacket(int newMaturity) {
if (newMaturity == maturity) {
return;
}
maturity = (short) newMaturity;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
/* IFRUITBEARER */
@Override
public boolean hasFruit() {
@@ -328,7 +328,11 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
}
public String getUnlocalizedName() {
return getTree().getGenome().getPrimary().getUnlocalizedName();
ITree tree = getTree();
if (tree == null) {
return "for.leaves.corrupted";
}
return tree.getGenome().getPrimary().getUnlocalizedName();
}
/* NETWORK */
@@ -417,8 +421,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
}
}
public void fromRipeningPacket(PacketRipeningUpdate packet) {
int newColourFruits = packet.getValue();
public void fromRipeningPacket(int newColourFruits) {
if (newColourFruits == colourFruits) {
return;
}
@@ -46,6 +46,10 @@ public class TreeGenome extends Genome implements ITreeGenome {
// NBT RETRIEVAL
public static IAlleleTreeSpecies getSpecies(ItemStack itemStack) {
if (!PluginArboriculture.treeInterface.isMember(itemStack)) {
return null;
}
IAlleleSpecies species = getSpeciesDirectly(itemStack);
if (species instanceof IAlleleTreeSpecies) {
return (IAlleleTreeSpecies) species;
@@ -3,6 +3,7 @@ package forestry.arboriculture.items;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import forestry.arboriculture.gadgets.TileLeaves;
@@ -35,7 +36,7 @@ public class ItemLeavesBlock extends ItemForestryBlock {
}
String grammar = StringUtil.localize("trees.grammar.leaves");
String localizedName = StringUtil.localize(unlocalizedName);
String localizedName = StatCollector.translateToLocal(unlocalizedName);
return grammar.replaceAll("%SPECIES", localizedName).replaceAll("%TYPE", type);
}
@@ -13,13 +13,10 @@ package forestry.arboriculture.network;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import forestry.arboriculture.gadgets.TileLeaves;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.IPacketHandler;
import forestry.core.network.PacketId;
import forestry.core.proxy.Proxies;
public class PacketHandlerArboriculture implements IPacketHandler {
@@ -28,8 +25,7 @@ public class PacketHandlerArboriculture implements IPacketHandler {
switch (packetID) {
case RIPENING_UPDATE: {
PacketRipeningUpdate packet = new PacketRipeningUpdate(data);
onRipeningUpdate(packet);
PacketRipeningUpdate.onPacketData(data);
return true;
}
}
@@ -37,10 +33,4 @@ public class PacketHandlerArboriculture implements IPacketHandler {
return false;
}
private static void onRipeningUpdate(PacketRipeningUpdate packet) {
TileEntity tile = packet.getTarget(Proxies.common.getRenderWorld());
if (tile instanceof TileLeaves) {
((TileLeaves) tile).fromRipeningPacket(packet);
}
}
}
@@ -12,17 +12,24 @@ package forestry.arboriculture.network;
import java.io.IOException;
import net.minecraft.tileentity.TileEntity;
import forestry.arboriculture.gadgets.TileFruitPod;
import forestry.arboriculture.gadgets.TileLeaves;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketId;
import forestry.core.proxy.Proxies;
public class PacketRipeningUpdate extends PacketCoordinates {
private int value;
public static void onPacketData(DataInputStreamForestry data) throws IOException {
new PacketRipeningUpdate(data);
}
public PacketRipeningUpdate(DataInputStreamForestry data) throws IOException {
super(data);
}
@@ -40,13 +47,20 @@ public class PacketRipeningUpdate extends PacketCoordinates {
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeInt(value);
data.writeVarInt(value);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
value = data.readInt();
value = data.readVarInt();
TileEntity tile = getTarget(Proxies.common.getRenderWorld());
if (tile instanceof TileLeaves) {
((TileLeaves) tile).fromRipeningPacket(value);
} else if (tile instanceof TileFruitPod) {
((TileFruitPod) tile).fromRipeningPacket(value);
}
}
public int getValue() {
+1 -1
View File
@@ -113,7 +113,7 @@ public class Config {
public static float getBeehivesRate() {
return generateBeehivesRate;
}
public static boolean isExUtilEnderLilyEnabled() {
return ExUtilEnderLily;
}
@@ -29,7 +29,7 @@ import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler;
import forestry.core.fluids.tanks.StandardTank;
import forestry.core.config.Defaults;
import forestry.core.inventory.InvTools;
import forestry.core.utils.StackUtils;
@@ -103,36 +103,6 @@ public final class FluidHelper {
return false;
}
public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot) {
processContainers(tank, inv, inputSlot, outputSlot, tank.getFluidType(), true, true);
}
public static void processContainers(StandardTank tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) {
TankManager tankManger = new TankManager();
tankManger.add(tank);
processContainers(tankManger, inv, inputSlot, outputSlot, fluidToFill, processFilled, processEmpty);
}
public static void processContainers(TankManager tank, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
processContainers(tank, inv, inputSlot, outputSlot, fluidToFill, true, true);
}
public static void processContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill, boolean processFilled, boolean processEmpty) {
ItemStack input = inv.getStackInSlot(inputSlot);
if (input == null) {
return;
}
if (processFilled && drainContainers(fluidHandler, inv, inputSlot, outputSlot)) {
return;
}
if (processEmpty && fluidToFill != null) {
fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill);
}
}
public static boolean fillContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, Fluid fluidToFill) {
return fillContainers(fluidHandler, inv, inputSlot, outputSlot, fluidToFill, true);
}
@@ -161,10 +131,10 @@ public final class FluidHelper {
}
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int slot) {
return drainContainers(fluidHandler, inv, slot, slot);
return drainContainers(fluidHandler, inv, slot, slot, Defaults.BUCKET_VOLUME);
}
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot) {
public static boolean drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, int maxAmount) {
ItemStack input = inv.getStackInSlot(inputSlot);
ItemStack output = inv.getStackInSlot(outputSlot);
@@ -176,36 +146,39 @@ public final class FluidHelper {
if (fluidInContainer == null) {
return false;
}
if (fluidInContainer.amount > maxAmount) {
fluidInContainer.amount = maxAmount;
}
int used = fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, false);
if (used < fluidInContainer.amount) {
ItemStack drainedItem = getDrainedContainer(input, used);
if (ItemStack.areItemStacksEqual(input, drainedItem)) {
return false;
}
ItemStack emptyItem = getEmptyContainer(input);
if (output != null && emptyItem != null) {
if (output != null && drainedItem != null) {
if (outputSlot == inputSlot) {
if (input.stackSize > 1) {
return false;
}
} else if (!StackUtils.isIdenticalItem(output, emptyItem)) {
} else if (!StackUtils.isIdenticalItem(output, drainedItem)) {
return false;
} else if (output.stackSize + emptyItem.stackSize > output.getMaxStackSize()) {
} else if (output.stackSize + drainedItem.stackSize > output.getMaxStackSize()) {
return false;
}
}
fluidHandler.fill(ForgeDirection.UNKNOWN, fluidInContainer, true);
if (emptyItem != null) {
if (drainedItem != null) {
if (outputSlot == inputSlot) {
inv.setInventorySlotContents(outputSlot, emptyItem);
inv.setInventorySlotContents(outputSlot, drainedItem);
return true;
}
if (output == null) {
inv.setInventorySlotContents(outputSlot, emptyItem);
inv.setInventorySlotContents(outputSlot, drainedItem);
} else {
output.stackSize++;
}
@@ -269,15 +242,6 @@ public final class FluidHelper {
return false;
}
public static ItemStack getEmptyContainer(ItemStack container) {
Item item = container.getItem();
if (item == null) {
return null;
}
return item.getContainerItem(container);
}
public static ItemStack getDrainedContainer(ItemStack container, int drainAmount) {
if (container == null) {
return null;
@@ -288,15 +252,20 @@ public final class FluidHelper {
}
Item item = container.getItem();
if (item instanceof IFluidContainerItem) {
if (item == null) {
return null;
} else if (item instanceof IFluidContainerItem) {
ItemStack drained = container.copy();
drained.stackSize = 1;
IFluidContainerItem containerItem = (IFluidContainerItem) item;
containerItem.drain(drained, drainAmount, true);
return drained;
} else {
if (drainAmount < Defaults.BUCKET_VOLUME) {
return container;
}
return item.getContainerItem(container);
}
return getEmptyContainer(container);
}
public static ItemStack getFilledContainer(Fluid fluid, ItemStack empty) {
@@ -172,7 +172,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection, IAct
}
this.active = active;
if (!worldObj.isRemote) {
if (worldObj != null && !worldObj.isRemote) {
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
}
}
@@ -27,11 +27,9 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import forestry.api.apiculture.BeeManager;
import forestry.api.core.ForestryAPI;
import forestry.api.core.IErrorState;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IIndividual;
import forestry.core.EnumErrorCode;
import forestry.core.config.Defaults;
@@ -39,6 +37,7 @@ import forestry.core.fluids.FluidHelper;
import forestry.core.fluids.Fluids;
import forestry.core.fluids.TankManager;
import forestry.core.fluids.tanks.FilteredTank;
import forestry.core.interfaces.IItemStackDisplay;
import forestry.core.interfaces.ILiquidTankContainer;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.TileInventoryAdapter;
@@ -48,10 +47,12 @@ import forestry.core.inventory.wrappers.InventoryMapper;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.GuiId;
import forestry.core.network.PacketItemStackDisplay;
import forestry.core.proxy.Proxies;
import forestry.core.utils.GeneticsUtil;
import forestry.core.utils.GuiUtil;
public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankContainer {
public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiquidTankContainer, IItemStackDisplay {
/* CONSTANTS */
public static final int TIME_TO_ANALYZE = 125;
@@ -148,7 +149,8 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
if (added) {
setInventorySlotContents(SLOT_ANALYZE, null);
setNeedsNetworkUpdate();
PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay());
Proxies.net.sendNetworkPacket(packet);
}
setErrorCondition(!added, EnumErrorCode.NOSPACE);
@@ -183,7 +185,8 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
}
setInventorySlotContents(SLOT_ANALYZE, inputStack);
slot.setStackInSlot(null);
setNeedsNetworkUpdate();
PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay());
Proxies.net.sendNetworkPacket(packet);
return true;
}
@@ -202,39 +205,19 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
ItemStack displayStack = getIndividualOnDisplay();
if (displayStack == null) {
data.writeBoolean(false);
} else {
data.writeBoolean(true);
IIndividual displayIndividual = AlleleManager.alleleRegistry.getIndividual(displayStack);
int type = BeeManager.beeRoot.getType(displayStack).ordinal();
data.writeUTF(displayIndividual.getIdent());
data.writeShort(type);
data.writeShort(displayStack.stackSize);
}
data.writeItemStack(displayStack);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
individualOnDisplayClient = data.readItemStack();
}
ItemStack newIndividualOnDisplay = null;
if (data.readBoolean()) {
String individualUID = data.readUTF();
int type = data.readShort();
int stackSize = data.readShort();
IAllele[] template = BeeManager.beeRoot.getTemplate(individualUID);
IIndividual individual = BeeManager.beeRoot.templateAsIndividual(template);
newIndividualOnDisplay = BeeManager.beeRoot.getMemberStack(individual, type);
newIndividualOnDisplay.stackSize = stackSize;
}
if (!ItemStack.areItemStacksEqual(newIndividualOnDisplay, individualOnDisplayClient)) {
individualOnDisplayClient = newIndividualOnDisplay;
@Override
public void handleItemStackForDisplay(ItemStack itemStack) {
if (!ItemStack.areItemStacksEqual(itemStack, individualOnDisplayClient)) {
individualOnDisplayClient = itemStack;
worldObj.func_147479_m(xCoord, yCoord, zCoord);
}
}
@@ -24,6 +24,10 @@ public class ContainerTile<T extends TileForestry> extends ContainerForestry {
protected final T tile;
public ContainerTile(T tileForestry) {
this.tile = tileForestry;
}
public ContainerTile(T tileForestry, InventoryPlayer playerInventory, int xInv, int yInv) {
this.tile = tileForestry;
@@ -17,22 +17,17 @@ import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.FMLCommonHandler;
import forestry.core.interfaces.ICrafter;
import forestry.core.interfaces.ICrafterWorktable;
public class SlotCrafter extends SlotCrafting {
private final ICrafter crafter;
private final IInventory craftMatrix;
private final ICrafterWorktable crafter;
public SlotCrafter(EntityPlayer player, IInventory craftMatrix, ICrafter crafter, int slot, int xPos, int yPos) {
public SlotCrafter(EntityPlayer player, IInventory craftMatrix, ICrafterWorktable crafter, int slot, int xPos, int yPos) {
super(player, craftMatrix, craftMatrix, slot, xPos, yPos);
this.crafter = crafter;
this.craftMatrix = craftMatrix;
}
@Override
public boolean isItemValid(ItemStack par1ItemStack) {
return false;
this.crafter = crafter;
}
@Override
@@ -51,18 +46,23 @@ public class SlotCrafter extends SlotCrafting {
@Override
public ItemStack getStack() {
return this.crafter.getResult();
return crafter.getResult();
}
@Override
public boolean getHasStack() {
return this.getStack() != null && crafter.canTakeStack(getSlotIndex());
return getStack() != null && crafter.canTakeStack(getSlotIndex());
}
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack itemStack) {
if (!crafter.onCraftingStart(player)) {
return;
}
FMLCommonHandler.instance().firePlayerCraftingEvent(player, itemStack, craftMatrix);
this.onCrafting(itemStack, itemStack.stackSize); // handles crafting achievements, maps, and statistics
crafter.takenFromSlot(getSlotIndex(), player);
this.onCrafting(itemStack); // handles crafting achievements, maps, and statistics
crafter.onCraftingComplete(player);
}
}
View File
File mode changed.
@@ -0,0 +1,14 @@
package forestry.core.interfaces;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public interface ICrafterWorktable {
ItemStack getResult();
boolean canTakeStack(int slotIndex);
boolean onCraftingStart(EntityPlayer player);
void onCraftingComplete(EntityPlayer player);
}
+27 -13
View File
@@ -927,33 +927,46 @@ public abstract class InvTools {
* If the inventory doesn't have all the required items, returns false without removing anything.
* If stowContainer is true, items with containers will have their container stowed.
*/
public static boolean removeSets(IInventory inventory, int count, ItemStack[] set, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) {
public static boolean removeSets(IInventory inventory, int count, ItemStack[] set, EntityPlayer player, boolean stowContainer, boolean oreDictionary) {
return removeSets(inventory, count, set, 0, inventory.getSizeInventory(), player, stowContainer, oreDictionary, false) != null;
}
ItemStack[] condensedSet = StackUtils.condenseStacks(set, -1, false);
public static boolean removeSets(IInventory inventory, int count, ItemStack[] set, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary) {
return removeSets(inventory, count, set, firstSlotIndex, slotCount, player, stowContainer, oreDictionary, false) != null;
}
public static ItemStack[] removeSets(IInventory inventory, int count, ItemStack[] set, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) {
ItemStack[] removed = new ItemStack[set.length];
ItemStack[] stock = getStacks(inventory, firstSlotIndex, slotCount);
if (StackUtils.containsSets(condensedSet, stock, oreDictionary, craftingTools) < count) {
return false;
if (StackUtils.containsSets(set, stock, oreDictionary, craftingTools) < count) {
return null;
}
for (ItemStack stackToRemove : condensedSet) {
for (int i = 0; i < set.length; i++) {
if (set[i] == null) {
continue;
}
ItemStack stackToRemove = set[i].copy();
stackToRemove.stackSize *= count;
// try to remove the exact stack first
removeStack(inventory, stackToRemove, firstSlotIndex, slotCount, player, stowContainer, false, false);
// remove crafting equivalents next
if (stackToRemove.stackSize > 0) {
removeStack(inventory, stackToRemove, firstSlotIndex, slotCount, player, stowContainer, oreDictionary, craftingTools);
ItemStack removedStack = removeStack(inventory, stackToRemove, firstSlotIndex, slotCount, player, stowContainer, false, false);
if (removedStack == null) {
// remove crafting equivalents next
removedStack = removeStack(inventory, stackToRemove, firstSlotIndex, slotCount, player, stowContainer, oreDictionary, craftingTools);
}
removed[i] = removedStack;
}
return true;
return removed;
}
/**
* Private Helper for removeSetsFromInventory. Assumes removal is possible.
*/
private static void removeStack(IInventory inventory, ItemStack stackToRemove, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) {
private static ItemStack removeStack(IInventory inventory, ItemStack stackToRemove, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) {
for (int j = firstSlotIndex; j < firstSlotIndex + slotCount; j++) {
ItemStack stackInSlot = inventory.getStackInSlot(j);
if (stackInSlot == null) {
@@ -972,9 +985,10 @@ public abstract class InvTools {
}
if (stackToRemove.stackSize == 0) {
return;
return removed;
}
}
return null;
}
/* CONTAINS */
@@ -61,11 +61,11 @@ public class PacketHandler {
@SubscribeEvent
public void onPacket(ClientCustomPacketEvent event) {
onPacketData(event.packet, null);
onPacketData(event.packet, Proxies.common.getPlayer());
}
/** Returns true if the packet has been handled */
private static boolean onPacketData(FMLProxyPacket fmlPacket, EntityPlayerMP player) {
private static boolean onPacketData(FMLProxyPacket fmlPacket, EntityPlayer player) {
InputStream is = new ByteBufInputStream(fmlPacket.payload());
DataInputStreamForestry data = new DataInputStreamForestry(is);
@@ -107,7 +107,7 @@ public class PacketHandler {
case PIPETTE_CLICK: {
PacketSlotClick packet = new PacketSlotClick(data);
onPipetteClick(packet, player);
onPipetteClick(packet, (EntityPlayerMP) player);
return true;
}
case SOLDERING_IRON_CLICK: {
@@ -42,7 +42,7 @@ public class BlockUtil {
if (!(tile instanceof IEnergyReceiver)) {
return false;
}
IEnergyReceiver receptor = (IEnergyReceiver) tile;
return receptor.canConnectEnergy(side);
}
@@ -41,23 +41,23 @@ import forestry.plugins.PluginArboriculture;
public class GeneticsUtil {
private static Set<Material> ersatzSpecimenMaterials;
private static Set<Block> ersatzSpecimenBlocks;
private static Set<Material> getErsatzSpecimenMaterials() {
if (ersatzSpecimenMaterials == null) {
ersatzSpecimenMaterials = new HashSet<Material>();
private static Set<Block> getErsatzBlocks() {
if (ersatzSpecimenBlocks == null) {
ersatzSpecimenBlocks = new HashSet<Block>();
for (ItemStack ersatzSpecimen : AlleleManager.ersatzSpecimen.keySet()) {
Block ersatzBlock = StackUtils.getBlock(ersatzSpecimen);
if (ersatzBlock != null) {
ersatzSpecimenMaterials.add(ersatzBlock.getMaterial());
ersatzSpecimenBlocks.add(ersatzBlock);
}
}
}
return ersatzSpecimenMaterials;
return ersatzSpecimenBlocks;
}
private static boolean isErsatzMaterial(Block block) {
return block != null && getErsatzSpecimenMaterials().contains(block.getMaterial());
private static boolean isErsatzBlock(Block block) {
return block != null && getErsatzBlocks().contains(block);
}
public static boolean hasNaturalistEye(EntityPlayer player) {
@@ -127,7 +127,7 @@ public class GeneticsUtil {
public static ITree getErsatzPollen(World world, final int x, final int y, final int z) {
Block block = world.getBlock(x, y, z);
if (!isErsatzMaterial(block)) {
if (!isErsatzBlock(block)) {
return null;
}
+30 -112
View File
@@ -116,54 +116,6 @@ public class StackUtils {
}
return added;
}
public static int addToInventory(ItemStack itemstack, IInventory inventory, boolean doAdd, int slot1, int count) {
int added = 0;
for (int i = slot1; i < slot1 + count; i++) {
ItemStack inventoryStack = inventory.getStackInSlot(i);
// Grab those free slots
if (inventoryStack == null) {
if (doAdd) {
inventory.setInventorySlotContents(i, itemstack.copy());
}
return itemstack.stackSize;
}
// Already full
if (inventoryStack.stackSize >= inventoryStack.getMaxStackSize()) {
continue;
}
// Not same type
if (!inventoryStack.isItemEqual(itemstack)) {
continue;
}
int space = inventoryStack.getMaxStackSize() - inventoryStack.stackSize;
// Enough space to add all
if (space > itemstack.stackSize - added) {
if (doAdd) {
inventoryStack.stackSize += itemstack.stackSize;
}
return itemstack.stackSize;
// Only part can be added
} else {
if (doAdd) {
inventoryStack.stackSize = inventoryStack.getMaxStackSize();
}
added += space;
}
}
return added;
}
/**
@@ -189,18 +141,6 @@ public class StackUtils {
temp.stackSize = 0;
}
public static boolean freeSpaceInStack(ItemStack stack, int maxSize) {
if (stack == null) {
return true;
}
if (stack.stackSize >= maxSize) {
return false;
}
return true;
}
/**
* Creates a split stack of the specified amount, preserving NBT data,
* without decreasing the source stack.
@@ -215,14 +155,7 @@ public class StackUtils {
}
public static ItemStack[] condenseStacks(ItemStack[] stacks) {
return condenseStacks(stacks, -1, false);
}
/**
* @param maxCountedPerStack The maximum stacksize counted in a single stack. -1 for unlimited.
*/
public static ItemStack[] condenseStacks(ItemStack[] stacks, int maxCountedPerStack, boolean craftingEquivalency) {
ArrayList<ItemStack> condensed = new ArrayList<ItemStack>();
List<ItemStack> condensed = new ArrayList<ItemStack>();
for (ItemStack stack : stacks) {
if (stack == null) {
@@ -234,17 +167,14 @@ public class StackUtils {
boolean matched = false;
for (ItemStack cached : condensed) {
if ((cached.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(cached, stack)) || (craftingEquivalency && isCraftingEquivalent(cached, stack, true, false))) {
cached.stackSize += maxCountedPerStack > 0 && stack.stackSize > maxCountedPerStack ? maxCountedPerStack : stack.stackSize;
if ((cached.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(cached, stack))) {
cached.stackSize += stack.stackSize;
matched = true;
}
}
if (!matched) {
ItemStack cached = stack.copy();
if (maxCountedPerStack > 0) {
cached.stackSize = maxCountedPerStack;
}
condensed.add(cached);
}
@@ -273,34 +203,31 @@ public class StackUtils {
* Counts how many full sets are contained in the passed stock
*/
public static int containsSets(ItemStack[] set, ItemStack[] stock, boolean oreDictionary, boolean craftingTools) {
int count = 0;
int totalSets = 0;
ItemStack[] condensedRequired = StackUtils.condenseStacks(set, -1, oreDictionary);
ItemStack[] condensedOffered = StackUtils.condenseStacks(stock, -1, oreDictionary);
ItemStack[] condensedRequired = StackUtils.condenseStacks(set);
ItemStack[] condensedOffered = StackUtils.condenseStacks(stock);
for (ItemStack req : condensedRequired) {
boolean matched = false;
int reqCount = 0;
for (ItemStack offer : condensedOffered) {
if (isCraftingEquivalent(req, offer, oreDictionary, craftingTools)) {
int stackCount = (int) Math.floor(offer.stackSize / req.stackSize);
matched |= (stackCount > 0);
if (count == 0) {
count = stackCount;
} else if (count > stackCount) {
count = stackCount;
}
reqCount = Math.max(reqCount, stackCount);
}
}
if (!matched) {
if (reqCount == 0) {
return 0;
} else if (totalSets == 0) {
totalSets = reqCount;
} else if (totalSets > reqCount) {
totalSets = reqCount;
}
}
return count;
return totalSets;
}
/**
@@ -341,6 +268,10 @@ public class StackUtils {
return false;
}
if (craftingTools && isCraftingTool(base) && base.getItem() == comparison.getItem()) {
return true;
}
if (base.hasTagCompound() && !base.stackTagCompound.hasNoTags()) {
if (!ItemStack.areItemStacksEqual(base, comparison)) {
return false;
@@ -367,21 +298,22 @@ public class StackUtils {
}
}
if (craftingTools) {
return isThisCraftingTool(base, comparison);
}
return false;
}
public static boolean isCraftingTool(ItemStack itemstack) {
return itemstack.getItem().hasContainerItem(itemstack)
&& itemstack.getItem().isDamageable()
&& !itemstack.getItem().doesContainerItemLeaveCraftingGrid(itemstack);
}
Item item = itemstack.getItem();
if (item == null) {
return false;
}
public static boolean isThisCraftingTool(ItemStack phantom, ItemStack actual) {
return isCraftingTool(phantom) && phantom.getItem() == actual.getItem();
if (item.hasContainerItem(itemstack)) {
if (item.isDamageable() || itemstack.hasTagCompound()) {
return !item.doesContainerItemLeaveCraftingGrid(itemstack);
}
}
return false;
}
public static void stowContainerItem(ItemStack itemstack, IInventory stowing, int slotIndex, EntityPlayer player) {
@@ -439,20 +371,6 @@ public class StackUtils {
return created;
}
public static ItemStack consumeItem(ItemStack stack) {
if (stack.stackSize == 1) {
if (stack.getItem().hasContainerItem(stack)) {
return stack.getItem().getContainerItem(stack);
} else {
return null;
}
} else {
stack.splitStack(1);
return stack;
}
}
public static Block getBlock(ItemStack stack) {
Item item = stack.getItem();
@@ -68,7 +68,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank
setInternalInventory(new EngineBronzeInventoryAdapter(this));
fuelTank = new FilteredTank(Defaults.ENGINE_TANK_CAPACITY, FuelManager.bronzeEngineFuel.keySet());
fuelTank.tankMode = StandardTank.TankMode.INPUT;
fuelTank.tankMode = StandardTank.TankMode.DEFAULT;
heatingTank = new FilteredTank(Defaults.ENGINE_TANK_CAPACITY, FluidRegistry.LAVA);
heatingTank.tankMode = StandardTank.TankMode.INPUT;
this.tankManager = new TankManager(fuelTank, heatingTank);
View File
File mode changed.
+2 -2
View File
@@ -98,7 +98,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
craftPreviewInventory = new InventoryCraftResult();
setInternalInventory(new CarpenterInventoryAdapter(this));
InvTools.configureSided(getInternalInventory(), Defaults.FACINGS, SLOT_BOX, 20);
InvTools.configureSided(getInternalInventory(), Defaults.FACINGS, SLOT_BOX, 21);
tankManager = new TankManager(resourceTank);
}
@@ -297,7 +297,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
private boolean removeSets(int count, ItemStack[] set) {
EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwner());
return InvTools.removeSets(getInternalInventory(), count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true);
return InvTools.removeSets(getInternalInventory(), count, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true);
}
private boolean tryAddPending() {
@@ -439,7 +439,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
private boolean removeFromInventory(ItemStack[] set, EntityPlayer player, boolean doRemove) {
IInventoryAdapter inventory = getInternalInventory();
if (doRemove) {
return InvTools.removeSets(inventory, 1, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true);
return InvTools.removeSets(inventory, 1, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true);
} else {
ItemStack[] stock = InvTools.getStacks(inventory, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
return StackUtils.containsSets(set, stock) >= 1;
+13 -5
View File
@@ -76,8 +76,8 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
this.chance = chance;
}
public boolean matches(ItemStack[] res) {
return StackUtils.containsSets(resources, res, true, true) > 0;
public boolean matches(ItemStack[] res, boolean oreDict) {
return StackUtils.containsSets(resources, res, oreDict, true) > 0;
}
}
@@ -104,8 +104,16 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
}
public static Recipe findMatchingRecipe(ItemStack[] items) {
// First try to match a specific recipe (without OD)
for (Recipe recipe : recipes) {
if (recipe.matches(items)) {
if (recipe.matches(items, false)) {
return recipe;
}
}
// If that fails - try again with oredict support enabled
for (Recipe recipe : recipes) {
if (recipe.matches(items, true)) {
return recipe;
}
}
@@ -118,7 +126,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
return true;
}
for (ItemStack recipeInput : recipeInputs) {
if (StackUtils.isCraftingEquivalent(recipeInput, itemStack)) {
if (StackUtils.isCraftingEquivalent(recipeInput, itemStack, true, true)) {
return true;
}
}
@@ -283,7 +291,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
private boolean removeResources(ItemStack[] stacks) {
EntityPlayer player = Proxies.common.getPlayer(worldObj, getOwner());
return InvTools.removeSets(getInternalInventory(), 1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true, true);
return InvTools.removeSets(getInternalInventory(), 1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true);
}
@Override
View File
File mode changed.
@@ -19,12 +19,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import forestry.api.core.ForestryAPI;
import forestry.core.gadgets.TileBase;
import forestry.core.interfaces.ICrafter;
import forestry.core.interfaces.ICrafterWorktable;
import forestry.core.inventory.InvTools;
import forestry.core.inventory.InventoryAdapter;
import forestry.core.inventory.TileInventoryAdapter;
import forestry.core.inventory.wrappers.InventoryMapper;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.GuiId;
@@ -33,7 +36,7 @@ import forestry.core.utils.GuiUtil;
import forestry.core.utils.RecipeUtil;
import forestry.factory.recipes.RecipeMemory;
public class TileWorktable extends TileBase implements ICrafter {
public class TileWorktable extends TileBase implements ICrafterWorktable {
/* CONSTANTS */
public final static int SLOT_CRAFTING_1 = 0;
@@ -161,11 +164,6 @@ public class TileWorktable extends TileBase implements ICrafter {
return RecipeUtil.canCraftRecipe(worldObj, recipeItems, recipeOutput, inventory);
}
private boolean removeResources(EntityPlayer player) {
ItemStack[] set = InvTools.getStacks(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
return InvTools.removeSets(getInternalInventory(), 1, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, true, true, true);
}
@Override
public boolean canTakeStack(int slotIndex) {
if (slotIndex == SLOT_CRAFTING_RESULT) {
@@ -175,17 +173,47 @@ public class TileWorktable extends TileBase implements ICrafter {
}
@Override
public ItemStack takenFromSlot(int slotIndex, EntityPlayer player) {
if (!removeResources(player)) {
return null;
public boolean onCraftingStart(EntityPlayer player) {
ItemStack[] set = InvTools.getStacks(currentRecipe.getMatrix(), SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
ItemStack[] removed = InvTools.removeSets(this, 1, set, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, player, false, true, true);
for (int i = 0; i < removed.length; i++) {
craftingInventory.setInventorySlotContents(i, removed[i]);
}
return removed != null;
}
@Override
public void onCraftingComplete(EntityPlayer player) {
IInventory craftingInventory = getCraftingInventory();
for (int i = 0; i < craftingInventory.getSizeInventory(); ++i) {
ItemStack itemStack = craftingInventory.getStackInSlot(i);
if (itemStack == null) {
continue;
}
if (!itemStack.getItem().hasContainerItem(itemStack)) {
continue;
}
ItemStack container = itemStack.getItem().getContainerItem(itemStack);
if (container != null && container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) {
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container));
continue;
}
if (!InvTools.tryAddStack(this, container, true)) {
player.dropPlayerItemWithRandomChoice(container, false);
}
}
if (Proxies.common.isSimulating(worldObj)) {
memorized.memorizeRecipe(worldObj, currentRecipe, currentCrafting);
}
updateCraftResult();
return currentRecipe.getRecipeOutput(worldObj).copy();
}
@Override
@@ -203,8 +231,8 @@ public class TileWorktable extends TileBase implements ICrafter {
/**
* @return Inaccessible crafting inventory for the craft grid.
*/
public InventoryAdapter getCraftingInventory() {
return craftingInventory;
public IInventory getCraftingInventory() {
return new InventoryMapper(craftingInventory, SLOT_CRAFTING_1, SLOT_CRAFTING_COUNT);
}
private static class WorktableInventoryAdapter extends TileInventoryAdapter<TileWorktable> {
View File
File mode changed.
@@ -36,115 +36,7 @@ import forestry.core.utils.PlainInventory;
public class RecipeMemory implements INBTTagable, IStreamable {
public static final class Recipe implements INBTTagable, IStreamable {
private InventoryAdapter matrix;
private long lastUsed;
private boolean locked;
private ItemStack cachedRecipeOutput;
public Recipe() {
}
public Recipe(InventoryCrafting crafting) {
this.matrix = new InventoryAdapter(new PlainInventory(crafting));
}
public Recipe(NBTTagCompound nbttagcompound) {
readFromNBT(nbttagcompound);
}
public void updateLastUse(long lastUsed) {
this.lastUsed = lastUsed;
}
public void toggleLock() {
locked = !locked;
}
public InventoryAdapter getMatrix() {
return matrix;
}
public ItemStack getRecipeOutput(World world) {
if (cachedRecipeOutput == null) {
InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3);
for (int i = 0; i < crafting.getSizeInventory(); i++) {
crafting.setInventorySlotContents(i, matrix.getStackInSlot(i));
}
cachedRecipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, world);
}
return cachedRecipeOutput;
}
public long getLastUsed() {
return this.lastUsed;
}
public boolean isLocked() {
return this.locked;
}
public boolean hasSameOutput(InventoryCrafting crafting, World world) {
ItemStack recipeOutput = getRecipeOutput(world);
if (recipeOutput == null) {
return false;
}
ItemStack matchingRecipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, world);
return ItemStack.areItemStacksEqual(recipeOutput, matchingRecipeOutput);
}
@Override
public final void readFromNBT(NBTTagCompound nbttagcompound) {
matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3));
matrix.readFromNBT(nbttagcompound);
sanitizeMatrix();
lastUsed = nbttagcompound.getLong("LastUsed");
locked = nbttagcompound.getBoolean("Locked");
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
sanitizeMatrix();
matrix.writeToNBT(nbttagcompound);
nbttagcompound.setLong("LastUsed", lastUsed);
nbttagcompound.setBoolean("Locked", locked);
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
sanitizeMatrix();
matrix.writeData(data);
data.writeLong(lastUsed);
data.writeBoolean(locked);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3));
matrix.readData(data);
sanitizeMatrix();
lastUsed = data.readLong();
locked = data.readBoolean();
}
/**
* This is a nasty hack to hide a bug where the recipe stacks somehow
* get the stackSize set to -1. Which makes the recipe no longer work,
* ever. I've seen the bug, even inspected the NBT data of an afflicted
* worktable, but can't duplicate it, and can't trace it. -CovertJaguar
*/
private void sanitizeMatrix() {
for (int slot = 0; slot < matrix.getSizeInventory(); slot++) {
ItemStack stack = matrix.getStackInSlot(slot);
if (stack != null) {
stack.stackSize = 1;
}
}
}
}
public static final int capacity = 9;
private static final Container DUMMY_CONTAINER = new ContainerDummy();
private static final List<Class<? extends Item>> memoryBlacklist = new ArrayList<Class<? extends Item>>();
@@ -155,7 +47,6 @@ public class RecipeMemory implements INBTTagable, IStreamable {
private LinkedList<Recipe> recipes = new LinkedList<Recipe>();
private long lastUpdate;
public final int capacity = 9;
private static boolean isValid(World world, Recipe recipe) {
if (recipe == null) {
@@ -310,4 +201,116 @@ public class RecipeMemory implements INBTTagable, IStreamable {
List<Recipe> newRecipes = data.readStreamables(Recipe.class);
recipes.addAll(newRecipes);
}
public static final class Recipe implements INBTTagable, IStreamable {
private InventoryAdapter matrix;
private long lastUsed;
private boolean locked;
private ItemStack cachedRecipeOutput;
public Recipe() {
// required for serialization
}
public Recipe(InventoryCrafting crafting) {
this.matrix = new InventoryAdapter(new PlainInventory(crafting));
}
public Recipe(NBTTagCompound nbttagcompound) {
readFromNBT(nbttagcompound);
}
public void updateLastUse(long lastUsed) {
this.lastUsed = lastUsed;
}
public void toggleLock() {
locked = !locked;
}
public InventoryAdapter getMatrix() {
return matrix;
}
public ItemStack getRecipeOutput(World world) {
if (cachedRecipeOutput == null) {
InventoryCrafting crafting = new InventoryCrafting(DUMMY_CONTAINER, 3, 3);
for (int i = 0; i < crafting.getSizeInventory(); i++) {
crafting.setInventorySlotContents(i, matrix.getStackInSlot(i));
}
cachedRecipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, world);
}
return cachedRecipeOutput;
}
public long getLastUsed() {
return this.lastUsed;
}
public boolean isLocked() {
return this.locked;
}
public boolean hasSameOutput(InventoryCrafting crafting, World world) {
ItemStack recipeOutput = getRecipeOutput(world);
if (recipeOutput == null) {
return false;
}
ItemStack matchingRecipeOutput = CraftingManager.getInstance().findMatchingRecipe(crafting, world);
return ItemStack.areItemStacksEqual(recipeOutput, matchingRecipeOutput);
}
@Override
public final void readFromNBT(NBTTagCompound nbttagcompound) {
matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3));
matrix.readFromNBT(nbttagcompound);
sanitizeMatrix();
lastUsed = nbttagcompound.getLong("LastUsed");
locked = nbttagcompound.getBoolean("Locked");
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
sanitizeMatrix();
matrix.writeToNBT(nbttagcompound);
nbttagcompound.setLong("LastUsed", lastUsed);
nbttagcompound.setBoolean("Locked", locked);
}
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
sanitizeMatrix();
matrix.writeData(data);
data.writeLong(lastUsed);
data.writeBoolean(locked);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
matrix = new InventoryAdapter(new InventoryCrafting(DUMMY_CONTAINER, 3, 3));
matrix.readData(data);
sanitizeMatrix();
lastUsed = data.readLong();
locked = data.readBoolean();
}
/**
* This is a nasty hack to hide a bug where the recipe stacks somehow
* get the stackSize set to -1. Which makes the recipe no longer work,
* ever. I've seen the bug, even inspected the NBT data of an afflicted
* worktable, but can't duplicate it, and can't trace it. -CovertJaguar
*/
private void sanitizeMatrix() {
for (int slot = 0; slot < matrix.getSizeInventory(); slot++) {
ItemStack stack = matrix.getStackInSlot(slot);
if (stack != null) {
stack.stackSize = 1;
}
}
}
}
}
@@ -43,6 +43,10 @@ public class ButterflyGenome extends Genome implements IButterflyGenome {
// NBT RETRIEVAL
public static IAlleleButterflySpecies getSpecies(ItemStack itemStack) {
if (!PluginLepidopterology.butterflyInterface.isMember(itemStack)) {
return null;
}
IAlleleSpecies species = getSpeciesDirectly(itemStack);
if (species instanceof IAlleleButterflySpecies) {
return (IAlleleButterflySpecies) species;
@@ -76,7 +76,7 @@ public class GuiHandlerMail extends GuiHandlerBase {
case TraderGUI:
return new GuiTrader(player.inventory, getTileForestry(world, x, y, z, player, MachineTrader.class));
case TraderNameGUI:
return new GuiTradeName(player.inventory, getTileForestry(world, x, y, z, player, MachineTrader.class));
return new GuiTradeName(getTileForestry(world, x, y, z, player, MachineTrader.class));
default:
return null;
@@ -122,7 +122,7 @@ public class GuiHandlerMail extends GuiHandlerBase {
case TraderGUI:
return new ContainerTrader(player.inventory, getTileForestry(world, x, y, z, player, MachineTrader.class));
case TraderNameGUI:
return new ContainerTradeName(player.inventory, getTileForestry(world, x, y, z, player, MachineTrader.class));
return new ContainerTradeName(getTileForestry(world, x, y, z, player, MachineTrader.class));
default:
return null;
@@ -14,19 +14,21 @@ import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.IPacketHandler;
import forestry.core.network.PacketId;
import forestry.core.network.PacketString;
import forestry.core.proxy.Proxies;
import forestry.mail.gadgets.MachineTrader;
import forestry.mail.gui.ContainerCatalogue;
import forestry.mail.gui.ContainerLetter;
import forestry.mail.gui.ContainerTradeName;
import forestry.mail.gui.GuiMailboxInfo;
import forestry.mail.network.PacketLetterInfo;
import forestry.mail.network.PacketPOBoxInfo;
import forestry.mail.network.PacketRequestLetterInfo;
import forestry.mail.network.PacketTraderAddress;
public class PacketHandlerMail implements IPacketHandler {
@@ -55,8 +57,8 @@ public class PacketHandlerMail implements IPacketHandler {
return true;
}
case TRADING_ADDRESS_SET: {
PacketString packet = new PacketString(data);
onAddressSet(player, packet);
PacketTraderAddress packet = new PacketTraderAddress(data);
handleTradeAddressSet(player, packet);
return true;
}
case POBOX_INFO_REQUEST: {
@@ -83,12 +85,15 @@ public class PacketHandlerMail implements IPacketHandler {
GuiMailboxInfo.instance.setPOBoxInfo(packet.poboxInfo);
}
private static void onAddressSet(EntityPlayer player, PacketString packet) {
if (!(player.openContainer instanceof ContainerTradeName)) {
private static void handleTradeAddressSet(EntityPlayer player, PacketTraderAddress packet) {
TileEntity tile = packet.getTarget(player.worldObj);
if (!(tile instanceof MachineTrader)) {
return;
}
((ContainerTradeName) player.openContainer).handleSetAddress(packet);
String addressName = packet.getAddressName();
((MachineTrader) tile).handleSetAddress(addressName);
}
private static void onLetterText(EntityPlayer player, PacketString packet) {
@@ -58,6 +58,9 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
for (int i = SLOT_STAMPS_1; i < SLOT_STAMPS_1 + SLOT_STAMPS_COUNT; i++) {
slots.add(i);
}
for (int i = SLOT_RECEIVE_BUFFER; i < SLOT_RECEIVE_BUFFER + SLOT_RECEIVE_BUFFER_COUNT; i++) {
slots.add(i);
}
for (int i = SLOT_SEND_BUFFER; i < SLOT_SEND_BUFFER + SLOT_SEND_BUFFER_COUNT; i++) {
slots.add(i);
}
@@ -95,6 +98,10 @@ public class TradeStation extends WorldSavedData implements ITradeStation, IInve
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return canSlotAccept(i, itemstack);
}
}
// / CONSTANTS
@@ -36,9 +36,11 @@ import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.GuiId;
import forestry.core.proxy.Proxies;
import forestry.core.utils.EnumAccess;
import forestry.core.utils.StackUtils;
import forestry.mail.MailAddress;
import forestry.mail.TradeStation;
import forestry.mail.network.PacketTraderAddress;
import forestry.mail.triggers.MailTriggers;
import buildcraft.api.statements.ITriggerExternal;
@@ -94,14 +96,23 @@ public class MachineTrader extends TileBase {
@Override
public void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeUTF(address.getName());
String name = null;
if (address != null) {
name = address.getName();
}
if (name == null) {
name = "";
}
data.writeUTF(name);
}
@Override
public void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
String address = data.readUTF();
this.address = PostManager.postRegistry.getMailAddress(address);
if (address.length() > 0) {
this.address = PostManager.postRegistry.getMailAddress(address);
}
}
/* UPDATING */
@@ -240,6 +251,22 @@ public class MachineTrader extends TileBase {
return address;
}
public void handleSetAddress(String addressName) {
IMailAddress address = PostManager.postRegistry.getMailAddress(addressName);
setAddress(address);
if (!worldObj.isRemote) {
IMailAddress newAddress = getAddress();
if (newAddress != null) {
String newAddressName = newAddress.getName();
if (newAddressName != null && newAddressName.equals(addressName)) {
PacketTraderAddress packetResponse = new PacketTraderAddress(this, addressName);
Proxies.net.sendNetworkPacket(packetResponse);
}
}
}
}
public void setAddress(IMailAddress address) {
if (address == null) {
throw new NullPointerException("address must not be null");
@@ -260,6 +287,8 @@ public class MachineTrader extends TileBase {
this.address = address;
PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwner(), address);
}
} else {
this.address = address;
}
}
@@ -273,6 +302,15 @@ public class MachineTrader extends TileBase {
return (TradeStation) PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwner(), address);
}
@Override
public EnumAccess getAccess() {
if (isLinked()) {
return super.getAccess();
} else {
return EnumAccess.PRIVATE;
}
}
/* ITRIGGERPROVIDER */
@Optional.Method(modid = "BuildCraftAPI|statements")
@Override
@@ -10,52 +10,33 @@
******************************************************************************/
package forestry.mail.gui;
import org.apache.commons.lang3.StringUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import forestry.api.mail.IMailAddress;
import forestry.api.mail.PostManager;
import forestry.core.network.PacketId;
import forestry.core.network.PacketString;
import forestry.core.proxy.Proxies;
import forestry.core.gui.ContainerTile;
import forestry.mail.gadgets.MachineTrader;
public class ContainerTradeName extends Container {
public class ContainerTradeName extends ContainerTile<MachineTrader> {
protected final MachineTrader machine;
public ContainerTradeName(InventoryPlayer player, MachineTrader tile) {
machine = tile;
public ContainerTradeName(MachineTrader tile) {
super(tile);
}
public IMailAddress getAddress() {
return machine.getAddress();
}
public void setAddress(String addressName) {
if (StringUtils.isBlank(addressName)) {
return;
}
PacketString packet = new PacketString(PacketId.TRADING_ADDRESS_SET, addressName);
Proxies.net.sendToServer(packet);
IMailAddress address = PostManager.postRegistry.getMailAddress(addressName);
machine.setAddress(address);
}
public void handleSetAddress(PacketString packet) {
String addressName = packet.getString();
IMailAddress address = PostManager.postRegistry.getMailAddress(addressName);
machine.setAddress(address);
return tile.getAddress();
}
@Override
public boolean canInteractWith(EntityPlayer entityPlayer) {
return machine.isOwner(entityPlayer);
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (tile.isLinked()) {
for (Object crafter : crafters) {
if (crafter instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) crafter;
tile.openGui(player, tile);
}
}
}
}
}
View File
File mode changed.
@@ -13,23 +13,22 @@ package forestry.mail.gui;
import org.apache.commons.lang3.StringUtils;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Keyboard;
import forestry.core.config.Defaults;
import forestry.core.gui.GuiForestry;
import forestry.core.proxy.Proxies;
import forestry.core.utils.StringUtil;
import forestry.mail.gadgets.MachineTrader;
import forestry.mail.network.PacketTraderAddress;
public class GuiTradeName extends GuiForestry<ContainerTradeName, MachineTrader> {
private GuiTextField addressNameField;
private boolean addressNameFocus;
public GuiTradeName(InventoryPlayer inventoryplayer, MachineTrader tile) {
super(Defaults.TEXTURE_PATH_GUI + "/tradername.png", new ContainerTradeName(inventoryplayer, tile), tile);
public GuiTradeName(MachineTrader tile) {
super(Defaults.TEXTURE_PATH_GUI + "/tradername.png", new ContainerTradeName(tile), tile);
this.xSize = 176;
this.ySize = 90;
}
@@ -51,8 +50,7 @@ public class GuiTradeName extends GuiForestry<ContainerTradeName, MachineTrader>
// Set focus or enter text into address
if (addressNameField.isFocused()) {
if (eventKey == Keyboard.KEY_RETURN) {
addressNameFocus = true;
addressNameField.setFocused(false);
setAddress();
} else {
addressNameField.textboxKeyTyped(eventCharacter, eventKey);
}
@@ -70,36 +68,24 @@ public class GuiTradeName extends GuiForestry<ContainerTradeName, MachineTrader>
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
// Close gui screen if we linked up.
if (container.machine.isLinked()) {
this.mc.thePlayer.closeScreen();
this.mc.setIngameFocus();
}
// Check for focus changes
if (addressNameFocus && !addressNameField.isFocused()) {
this.setAddress();
}
addressNameFocus = addressNameField.isFocused();
super.drawGuiContainerBackgroundLayer(var1, var2, var3);
String prompt = StringUtil.localize("gui.mail.nametrader");
fontRendererObj.drawString(prompt, guiLeft + this.getCenteredOffset(prompt), guiTop + 16, fontColor.get("gui.mail.text"));
addressNameField.drawTextBox();
}
@Override
public void onGuiClosed() {
setAddress();
super.onGuiClosed();
setAddress();
}
private void setAddress() {
String address = addressNameField.getText();
if (StringUtils.isNotBlank(address)) {
container.setAddress(address);
PacketTraderAddress packet = new PacketTraderAddress(inventory, address);
Proxies.net.sendToServer(packet);
}
}
@@ -111,12 +111,20 @@ public class ItemLetter extends ItemInventoried {
public static LetterState getState(int meta) {
int ordinal = meta & 0x0f;
return LetterState.values()[ordinal];
LetterState[] values = LetterState.values();
if (ordinal >= values.length) {
ordinal = 0;
}
return values[ordinal];
}
public static LetterSize getSize(int meta) {
int ordinal = meta >> 4;
return LetterSize.values()[ordinal];
LetterSize[] values = LetterSize.values();
if (ordinal >= values.length) {
ordinal = 0;
}
return values[ordinal];
}
public static LetterSize getSize(ILetter letter) {
@@ -167,23 +175,24 @@ public class ItemLetter extends ItemInventoried {
switch (state) {
case OPENED:
if (letter.countAttachments() <= 0) {
int meta = encodeMeta(LetterState.EMPTIED, size);
parent.setItemDamage(meta);
state = LetterState.EMPTIED;
}
break;
case FRESH:
case STAMPED:
if (letter.isMailable() && letter.isPostPaid()) {
int meta = encodeMeta(LetterState.STAMPED, size);
parent.setItemDamage(meta);
state = LetterState.STAMPED;
} else {
int meta = encodeMeta(LetterState.FRESH, size);
parent.setItemDamage(meta);
state = LetterState.FRESH;
}
size = getSize(letter);
break;
case EMPTIED:
}
int meta = encodeMeta(state, size);
parent.setItemDamage(meta);
letter.writeToNBT(parent.getTagCompound());
}
@@ -0,0 +1,51 @@
/*******************************************************************************
* 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.mail.network;
import java.io.IOException;
import forestry.core.network.DataInputStreamForestry;
import forestry.core.network.DataOutputStreamForestry;
import forestry.core.network.PacketCoordinates;
import forestry.core.network.PacketId;
import forestry.mail.gadgets.MachineTrader;
public class PacketTraderAddress extends PacketCoordinates {
private String addressName;
public PacketTraderAddress(DataInputStreamForestry data) throws IOException {
super(data);
}
public PacketTraderAddress(MachineTrader tile, String addressName) {
super(PacketId.TRADING_ADDRESS_SET, tile);
this.addressName = addressName;
}
@Override
protected void writeData(DataOutputStreamForestry data) throws IOException {
super.writeData(data);
data.writeUTF(addressName);
}
@Override
protected void readData(DataInputStreamForestry data) throws IOException {
super.readData(data);
addressName = data.readUTF();
}
public String getAddressName() {
return addressName;
}
}
@@ -297,6 +297,8 @@ public class PluginApiculture extends ForestryPlugin {
createAlleles();
BeeDefinition.initBees();
AlleleManager.alleleRegistry.registerDeprecatedAlleleReplacement("forestry.speciesArgrarian", BeeDefinition.AGRARIAN.getGenome().getPrimary());
// Hives
createHives();
registerBeehiveDrops();
@@ -23,7 +23,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.oredict.OreDictionary;
import cpw.mods.fml.common.IFuelHandler;
@@ -48,7 +47,6 @@ import forestry.api.genetics.IFruitFamily;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.ICrateRegistry;
import forestry.api.storage.StorageManager;
import forestry.arboriculture.EventHandlerArboriculture;
import forestry.arboriculture.FruitProviderNone;
import forestry.arboriculture.FruitProviderPod;
import forestry.arboriculture.FruitProviderPod.EnumPodType;
@@ -338,8 +336,6 @@ public class PluginArboriculture extends ForestryPlugin {
GameRegistry.registerTileEntity(TileFruitPod.class, "forestry.Pods");
definitionChest.register();
MinecraftForge.EVENT_BUS.register(new EventHandlerArboriculture());
if (Config.enableVillager) {
VillagerRegistry.instance().registerVillagerId(Defaults.ID_VILLAGER_LUMBERJACK);
Proxies.render.registerVillagerSkin(Defaults.ID_VILLAGER_LUMBERJACK, Defaults.TEXTURE_SKIN_LUMBERJACK);
@@ -23,7 +23,7 @@ public class PluginBuildCraftRecipes extends ForestryPlugin {
@Override
public boolean isAvailable() {
return Proxies.common.isAPILoaded("buildcraft.api.recipes", "[2.0, 3.0)");
return Proxies.common.isAPILoaded("buildcraft.api.recipes", "[2.0, 4.0)");
}
@Override
@@ -275,11 +275,11 @@ public class PluginIC2 extends ForestryPlugin {
}
}
if (plantBall != null && compressedPlantBall != null) {
RecipeUtil.injectLeveledRecipe(plantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 4, Fluids.BIOMASS);
RecipeUtil.injectLeveledRecipe(compressedPlantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 5, Fluids.BIOMASS);
} else {
Proxies.log.fine("No IC2 plantballs found.");
if (plantBall != null) {
RecipeUtil.injectLeveledRecipe(plantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS);
}
if (compressedPlantBall != null) {
RecipeUtil.injectLeveledRecipe(compressedPlantBall, GameMode.getGameMode().getIntegerSetting("fermenter.yield.wheat") * 9, Fluids.BIOMASS);
}
if (resin != null) {
@@ -97,6 +97,10 @@ public class PluginManager {
PLANTMEGAPACK(new PluginPlantMegaPack()),
WITCHERY(new PluginWitchery());
static {
ForestryAPI.enabledPlugins = new HashSet<String>();
}
private final ForestryPlugin instance;
private final boolean canBeDisabled;
@@ -220,7 +224,6 @@ public class PluginManager {
unloadedModules.removeAll(toLoad);
loadedModules.addAll(toLoad);
ForestryAPI.enabledPlugins = new HashSet<String>();
for (Module m : loadedModules) {
ForestryAPI.enabledPlugins.add(m.toString());
}
View File
File mode changed.