mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 17:44:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d690a38fa2 | ||
|
|
46eb29cf28 | ||
|
|
fb01d3ffaa | ||
|
|
e676a73a7c |
No files matched your search
+2
-2
@@ -4,8 +4,8 @@ mcp_mappings=snapshot_20160525
|
||||
|
||||
tesla_version=1.9.4-1.1.0.24
|
||||
jei_version=3.7.3.221
|
||||
ic2_version=2.5.5-ex19
|
||||
ic2_version=2.6.5-ex110
|
||||
|
||||
version_major=5
|
||||
version_minor=1
|
||||
version_patch=8
|
||||
version_patch=9
|
||||
@@ -5,6 +5,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.apiculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@@ -32,6 +34,7 @@ public interface IBeeHousing extends IHousing, IErrorLogicSource {
|
||||
*/
|
||||
Iterable<IBeeListener> getBeeListeners();
|
||||
|
||||
@Nonnull
|
||||
IBeeHousingInventory getBeeInventory();
|
||||
|
||||
IBeekeepingLogic getBeekeepingLogic();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.apiculture;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -233,7 +234,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
if (beeType == EnumBeeType.PRINCESS) {
|
||||
tickBreed();
|
||||
} else if (beeType == EnumBeeType.QUEEN) {
|
||||
queenWorkTick(queen);
|
||||
queenWorkTick(queen, queenStack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +247,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
}
|
||||
}
|
||||
|
||||
private void queenWorkTick(IBee queen) {
|
||||
private void queenWorkTick(@Nullable IBee queen, @Nonnull ItemStack queenStack) {
|
||||
if (queen == null) {
|
||||
beeProgress = 0;
|
||||
beeProgressMax = 0;
|
||||
@@ -272,7 +273,8 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
// Write the changed queen back into the item stack.
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
queen.writeToNBT(nbttagcompound);
|
||||
housing.getBeeInventory().getQueen().setTagCompound(nbttagcompound);
|
||||
queenStack.setTagCompound(nbttagcompound);
|
||||
housing.getBeeInventory().setQueen(queenStack);
|
||||
}
|
||||
|
||||
beeProgress = queen.getHealth();
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.entities;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -36,8 +37,11 @@ import forestry.core.config.Config;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
|
||||
public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implements IApiary {
|
||||
@Nonnull
|
||||
private static final IBeeModifier beeModifier = new ApiaryBeeModifier();
|
||||
@Nonnull
|
||||
private final IBeeListener beeListener = new ApiaryBeeListener(this);
|
||||
@Nonnull
|
||||
private final InventoryApiary inventory = new InventoryApiary(getAccessHandler());
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -64,6 +68,7 @@ public class EntityMinecartApiary extends EntityMinecartBeeHousingBase implement
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return inventory;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.entities;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -72,6 +73,7 @@ public class EntityMinecartBeehouse extends EntityMinecartBeeHousingBase {
|
||||
return Collections.singleton(beeListener);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return beeInventory;
|
||||
|
||||
@@ -53,6 +53,7 @@ import forestry.core.utils.Translator;
|
||||
|
||||
public class AlvearyController extends RectangularMultiblockControllerBase implements IAlvearyControllerInternal, IClimateControlled {
|
||||
|
||||
@Nonnull
|
||||
private final InventoryBeeHousing inventory;
|
||||
private final IBeekeepingLogic beekeepingLogic;
|
||||
|
||||
@@ -77,6 +78,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
this.beeModifiers.add(new AlvearyBeeModifier());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return inventory;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -45,6 +46,7 @@ public class FakeAlvearyController extends FakeMultiblockController implements I
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return FakeBeeHousingInventory.instance;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@@ -99,6 +100,7 @@ public abstract class TileAlveary extends MultiblockTileEntityForestry<Multibloc
|
||||
return getMultiblockLogic().getController().getBeeListeners();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return getMultiblockLogic().getController().getBeeInventory();
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package forestry.apiculture.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.apiculture.IBeeHousingInventory;
|
||||
|
||||
public class FakeBeeHousingInventory implements IBeeHousingInventory {
|
||||
@Nonnull
|
||||
public static final FakeBeeHousingInventory instance = new FakeBeeHousingInventory();
|
||||
|
||||
private FakeBeeHousingInventory() {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -30,8 +31,11 @@ import forestry.apiculture.inventory.IApiaryInventory;
|
||||
import forestry.apiculture.inventory.InventoryApiary;
|
||||
|
||||
public class TileApiary extends TileBeeHousingBase implements IApiary {
|
||||
@Nonnull
|
||||
private final IBeeModifier beeModifier = new ApiaryBeeModifier();
|
||||
@Nonnull
|
||||
private final IBeeListener beeListener = new ApiaryBeeListener(this);
|
||||
@Nonnull
|
||||
private final InventoryApiary inventory = new InventoryApiary(getAccessHandler());
|
||||
|
||||
public TileApiary() {
|
||||
@@ -39,6 +43,7 @@ public class TileApiary extends TileBeeHousingBase implements IApiary {
|
||||
setInternalInventory(inventory);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return inventory;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -24,9 +25,12 @@ import forestry.apiculture.gui.ContainerBeeHousing;
|
||||
import forestry.apiculture.gui.GuiBeeHousing;
|
||||
|
||||
public class TileBeeHouse extends TileBeeHousingBase {
|
||||
@Nonnull
|
||||
private static final IBeeModifier beeModifier = new BeehouseBeeModifier();
|
||||
|
||||
@Nonnull
|
||||
private final IBeeListener beeListener;
|
||||
@Nonnull
|
||||
private final InventoryBeeHousing beeInventory;
|
||||
|
||||
public TileBeeHouse() {
|
||||
@@ -38,6 +42,7 @@ public class TileBeeHouse extends TileBeeHousingBase {
|
||||
setInternalInventory(beeInventory);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return beeInventory;
|
||||
|
||||
@@ -293,6 +293,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBeeHousingInventory getBeeInventory() {
|
||||
return inventory;
|
||||
|
||||
@@ -101,7 +101,6 @@ public class BlockArbDoor extends BlockDoor implements IWoodTyped, IItemModelReg
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state) {
|
||||
return new ItemStack(getItem());
|
||||
}
|
||||
|
||||
@@ -192,8 +192,7 @@ public class BlockFarm extends BlockStructure {
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return blockState.getValue(META) == EnumFarmBlockType.CONTROL;
|
||||
return state.getValue(META) == EnumFarmBlockType.CONTROL;
|
||||
}
|
||||
|
||||
public ItemStack get(EnumFarmBlockType type, int amount) {
|
||||
|
||||
@@ -483,11 +483,6 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
continue;
|
||||
}
|
||||
|
||||
// Allow listeners to cancel this cycle.
|
||||
if (isCycleCanceledByListeners(logic, farmSide, farmListeners)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Always try to collect windfall.
|
||||
if (collectWindfall(logic)) {
|
||||
farmWorkStatus.didWork = true;
|
||||
@@ -504,7 +499,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
harvestProvider = logic;
|
||||
}
|
||||
} else if (stage == Stage.CULTIVATE) {
|
||||
farmWorkStatus = cultivateTargets(farmWorkStatus, farmTargets, logic);
|
||||
farmWorkStatus = cultivateTargets(farmWorkStatus, farmTargets, logic, farmSide);
|
||||
}
|
||||
|
||||
if (farmWorkStatus.didWork) {
|
||||
@@ -622,31 +617,37 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
private static class FarmWorkStatus {
|
||||
public boolean didWork = false;
|
||||
public boolean hasFarmland = false;
|
||||
public boolean hasFertilizer = false;
|
||||
public boolean hasLiquid = false;
|
||||
public boolean hasFertilizer = true;
|
||||
public boolean hasLiquid = true;
|
||||
}
|
||||
|
||||
private FarmWorkStatus cultivateTargets(FarmWorkStatus farmWorkStatus, List<FarmTarget> farmTargets, IFarmLogic logic) {
|
||||
float hydrationModifier = hydrationManager.getHydrationModifier();
|
||||
|
||||
final int fertilizerConsumption = logic.getFertilizerConsumption();
|
||||
int liquidConsumption = logic.getWaterConsumption(hydrationModifier);
|
||||
FluidStack liquid = new FluidStack(FluidRegistry.WATER, liquidConsumption);
|
||||
|
||||
private FarmWorkStatus cultivateTargets(FarmWorkStatus farmWorkStatus, List<FarmTarget> farmTargets, IFarmLogic logic, FarmDirection farmSide) {
|
||||
boolean hasFarmland = false;
|
||||
if (farmTargets != null) {
|
||||
for (FarmTarget target : farmTargets) {
|
||||
if (target.getExtent() <= 0) {
|
||||
break;
|
||||
} else {
|
||||
if (target.getExtent() > 0) {
|
||||
hasFarmland = true;
|
||||
farmWorkStatus.hasFarmland = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasFarmland && !isCycleCanceledByListeners(logic, farmSide, farmListeners)) {
|
||||
final float hydrationModifier = hydrationManager.getHydrationModifier();
|
||||
final int fertilizerConsumption = logic.getFertilizerConsumption();
|
||||
final int liquidConsumption = logic.getWaterConsumption(hydrationModifier);
|
||||
final FluidStack liquid = new FluidStack(FluidRegistry.WATER, liquidConsumption);
|
||||
|
||||
for (FarmTarget target : farmTargets) {
|
||||
// Check fertilizer and water
|
||||
if (!fertilizerManager.hasFertilizer(fertilizerConsumption)) {
|
||||
farmWorkStatus.hasFertilizer = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (liquid.amount > 0 && !hasLiquid(liquid)) {
|
||||
farmWorkStatus.hasLiquid = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -660,9 +661,6 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
}
|
||||
}
|
||||
|
||||
farmWorkStatus.hasLiquid = liquid.amount <= 0 || hasLiquid(liquid);
|
||||
farmWorkStatus.hasFertilizer = fertilizerManager.hasFertilizer(fertilizerConsumption);
|
||||
|
||||
return farmWorkStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.tiles;
|
||||
|
||||
import forestry.farming.blocks.BlockFarm;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -42,15 +44,11 @@ public class TileFarmControl extends TileFarm implements IFarmComponent.Listener
|
||||
|
||||
@Override
|
||||
public boolean cancelTask(IFarmLogic logic, FarmDirection direction) {
|
||||
return hasRedstoneSignal(direction.getFacing()) || hasRedstoneSignal(EnumFacing.UP) || hasRedstoneSignal(EnumFacing.DOWN);
|
||||
}
|
||||
|
||||
private boolean hasRedstoneSignal(EnumFacing direction) {
|
||||
BlockPos side = tile.getPos().offset(direction);
|
||||
EnumFacing dir = direction.getOpposite();
|
||||
World world = tile.getWorld();
|
||||
|
||||
return world.getRedstonePower(side, dir) > 0 || world.getStrongPower(side, dir) > 0;
|
||||
BlockPos pos = tile.getPos();
|
||||
EnumFacing facing = direction.getFacing();
|
||||
World world = tile.getWorldObj();
|
||||
IBlockState blockState = world.getBlockState(pos.offset(facing));
|
||||
return !(blockState.getBlock() instanceof BlockFarm) && world.getRedstonePower(pos, facing) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user