mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 09:34:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d690a38fa2 | ||
|
|
46eb29cf28 | ||
|
|
fb01d3ffaa | ||
|
|
e676a73a7c | ||
|
|
6e348dbc5d | ||
|
|
39114ec429 | ||
|
|
3b82fe3bd0 | ||
|
|
2667334252 | ||
|
|
be39e2c3c3 | ||
|
|
40eece7d77 | ||
|
|
4fcc785e85 | ||
|
|
11e4097bd8 | ||
|
|
f8c37da06d | ||
|
|
09756f21fd | ||
|
|
a06c4bd1dc | ||
|
|
bb477f0dfb | ||
|
|
0b86b3df8f | ||
|
|
edd5357008 |
No files matched your search
@@ -55,6 +55,9 @@ sourceSets {
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url 'http://maven.epoxide.xyz'
|
||||
}
|
||||
maven {
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
@@ -65,6 +68,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile "net.darkhax.tesla:Tesla:${tesla_version}"
|
||||
deobfCompile "mezz.jei:jei_${mcversion}:${jei_version}:api"
|
||||
runtime "mezz.jei:jei_${mcversion}:${jei_version}"
|
||||
deobfCompile "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
|
||||
|
||||
+6
-5
@@ -1,10 +1,11 @@
|
||||
mcversion=1.10
|
||||
forgeversion=12.18.0.1989-1.10.0
|
||||
mcversion=1.10.2
|
||||
forgeversion=12.18.0.2005-1.10.0
|
||||
mcp_mappings=snapshot_20160525
|
||||
|
||||
jei_version=3.7.0.+
|
||||
ic2_version=2.5.5-ex19
|
||||
tesla_version=1.9.4-1.1.0.24
|
||||
jei_version=3.7.3.221
|
||||
ic2_version=2.6.5-ex110
|
||||
|
||||
version_major=5
|
||||
version_minor=1
|
||||
version_patch=4
|
||||
version_patch=9
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
#Tue Jun 21 15:23:47 PDT 2016
|
||||
#Mon Sep 14 12:28:28 PDT 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
|
||||
+1
-1
Submodule lang updated: 6fc3c7ef64...2d88011e4a.
@@ -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();
|
||||
|
||||
@@ -7,17 +7,15 @@ package forestry.api.apiculture;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public interface IBeeRoot extends ISpeciesRoot {
|
||||
|
||||
/**
|
||||
@@ -100,7 +98,7 @@ public interface IBeeRoot extends ISpeciesRoot {
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
Collection<IBeeMutation> getMutations(boolean shuffle);
|
||||
List<IBeeMutation> getMutations(boolean shuffle);
|
||||
|
||||
/* GAME MODE */
|
||||
void resetBeekeepingMode();
|
||||
|
||||
@@ -8,18 +8,17 @@ package forestry.api.arboriculture;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public interface ITreeRoot extends ISpeciesRoot {
|
||||
|
||||
@Override
|
||||
@@ -82,7 +81,7 @@ public interface ITreeRoot extends ISpeciesRoot {
|
||||
boolean setFruitBlock(World world, IAlleleFruit allele, float sappiness, BlockPos pos);
|
||||
|
||||
/* GAME MODE */
|
||||
ArrayList<ITreekeepingMode> getTreekeepingModes();
|
||||
List<ITreekeepingMode> getTreekeepingModes();
|
||||
|
||||
ITreekeepingMode getTreekeepingMode(World world);
|
||||
|
||||
@@ -98,6 +97,5 @@ public interface ITreeRoot extends ISpeciesRoot {
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
Collection<ITreeMutation> getMutations(boolean shuffle);
|
||||
|
||||
List<ITreeMutation> getMutations(boolean shuffle);
|
||||
}
|
||||
@@ -138,13 +138,13 @@ public interface ISpeciesRoot {
|
||||
/**
|
||||
* @return All registered mutations.
|
||||
*/
|
||||
Collection<? extends IMutation> getMutations(boolean shuffle);
|
||||
List<? extends IMutation> getMutations(boolean shuffle);
|
||||
|
||||
/**
|
||||
* @param other Allele to match mutations against.
|
||||
* @return All registered mutations the given allele is part of.
|
||||
*/
|
||||
Collection<? extends IMutation> getCombinations(IAllele other);
|
||||
List<? extends IMutation> getCombinations(IAllele other);
|
||||
|
||||
/**
|
||||
* @since Forestry 3.7
|
||||
|
||||
@@ -7,18 +7,16 @@ package forestry.api.lepidopterology;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
public interface IButterflyRoot extends ISpeciesRoot {
|
||||
|
||||
@Override
|
||||
@@ -67,7 +65,7 @@ public interface IButterflyRoot extends ISpeciesRoot {
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
Collection<IButterflyMutation> getMutations(boolean shuffle);
|
||||
List<IButterflyMutation> getMutations(boolean shuffle);
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -12,8 +12,8 @@ package forestry.apiculture.genetics;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -249,10 +249,10 @@ public class BeeRoot extends SpeciesRoot implements IBeeRoot {
|
||||
/**
|
||||
* List of possible mutations on species alleles.
|
||||
*/
|
||||
private static final ArrayList<IBeeMutation> beeMutations = new ArrayList<>();
|
||||
private static final List<IBeeMutation> beeMutations = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public Collection<IBeeMutation> getMutations(boolean shuffle) {
|
||||
public List<IBeeMutation> getMutations(boolean shuffle) {
|
||||
if (shuffle) {
|
||||
Collections.shuffle(beeMutations);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class ItemHiveFrame extends ItemForestry implements IHiveFrame {
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
beeModifier.addInformation(stack, playerIn, tooltip, advanced);
|
||||
if (!stack.isItemDamaged()) {
|
||||
tooltip.add(Translator.translateToLocalFormatted("item.for.frame.durability", stack.getMaxDamage()));
|
||||
tooltip.add(Translator.translateToLocalFormatted("item.for.durability", stack.getMaxDamage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.apiculture.multiblock;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -23,6 +24,7 @@ import forestry.core.tiles.IActivatable;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyReceiver, IActivatable, IAlvearyComponent.Climatiser {
|
||||
|
||||
@@ -143,4 +145,18 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
return energyManager.canConnectEnergy(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return energyManager.hasCapability(capability) || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
T energyCapability = energyManager.getCapability(capability);
|
||||
if (energyCapability != null) {
|
||||
return energyCapability;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -34,6 +34,7 @@ import forestry.api.genetics.ISaplingTranslator;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.api.storage.ICrateRegistry;
|
||||
import forestry.api.storage.StorageManager;
|
||||
import forestry.arboriculture.blocks.BlockForestryLeaves;
|
||||
import forestry.arboriculture.blocks.BlockPile;
|
||||
import forestry.arboriculture.blocks.BlockRegistryArboriculture;
|
||||
import forestry.arboriculture.blocks.log.BlockArbLog;
|
||||
@@ -49,6 +50,7 @@ import forestry.arboriculture.genetics.alleles.AlleleFruit;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleGrowth;
|
||||
import forestry.arboriculture.genetics.alleles.AlleleLeafEffect;
|
||||
import forestry.arboriculture.items.ItemCharcoal;
|
||||
import forestry.arboriculture.items.ItemGrafter;
|
||||
import forestry.arboriculture.items.ItemRegistryArboriculture;
|
||||
import forestry.arboriculture.models.TextureLeaves;
|
||||
import forestry.arboriculture.network.PacketRegistryArboriculture;
|
||||
@@ -79,12 +81,16 @@ import net.minecraft.block.BlockNewLeaf;
|
||||
import net.minecraft.block.BlockOldLeaf;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.common.IFuelHandler;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
@@ -546,4 +552,31 @@ public class PluginArboriculture extends BlankForestryPlugin {
|
||||
alleleFruit.getProvider().registerSprites();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onHarvestDropsEvent(BlockEvent.HarvestDropsEvent event) {
|
||||
IBlockState state = event.getState();
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof BlockLeaves && !(block instanceof BlockForestryLeaves)) {
|
||||
EntityPlayer player = event.getHarvester();
|
||||
if (player != null) {
|
||||
ItemStack harvestingTool = player.getHeldItemMainhand();
|
||||
if (harvestingTool != null && harvestingTool.getItem() instanceof ItemGrafter) {
|
||||
if (event.getDrops().isEmpty()) {
|
||||
World world = event.getWorld();
|
||||
Item itemDropped = block.getItemDropped(state, world.rand, 3);
|
||||
if (itemDropped != null) {
|
||||
event.getDrops().add(new ItemStack(itemDropped, 1, block.damageDropped(state)));
|
||||
}
|
||||
}
|
||||
|
||||
harvestingTool.damageItem(1, player);
|
||||
if (harvestingTool.stackSize <= 0) {
|
||||
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, harvestingTool, EnumHand.MAIN_HAND);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -16,6 +16,29 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.IToolGrafter;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IToolScoop;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
import forestry.api.lepidopterology.EnumFlutterType;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.arboriculture.LeafDecayHelper;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.IGrowable;
|
||||
@@ -40,9 +63,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.property.ExtendedBlockState;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
@@ -50,29 +70,6 @@ import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.IToolGrafter;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IToolScoop;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.ButterflyManager;
|
||||
import forestry.api.lepidopterology.EnumFlutterType;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.arboriculture.LeafDecayHelper;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.genetics.TreeDefinition;
|
||||
import forestry.arboriculture.tiles.TileLeaves;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class BlockForestryLeaves extends BlockLeaves implements ITileEntityProvider, IGrowable, IItemModelRegister, IColoredBlock {
|
||||
|
||||
public BlockForestryLeaves() {
|
||||
@@ -137,17 +134,16 @@ public class BlockForestryLeaves extends BlockLeaves implements ITileEntityProvi
|
||||
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getActiveItemStack());
|
||||
float saplingModifier = 1.0f;
|
||||
|
||||
if (!world.isRemote) {
|
||||
ItemStack held = player.inventory.getCurrentItem();
|
||||
if (held != null && held.getItem() instanceof IToolGrafter) {
|
||||
saplingModifier = ((IToolGrafter) held.getItem()).getSaplingModifier(held, world, player, pos);
|
||||
held.damageItem(1, player);
|
||||
if (held.stackSize <= 0) {
|
||||
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, held, EnumHand.MAIN_HAND);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, null);
|
||||
}
|
||||
ItemStack held = player.inventory.getCurrentItem();
|
||||
if (held != null && held.getItem() instanceof IToolGrafter) {
|
||||
saplingModifier = ((IToolGrafter) held.getItem()).getSaplingModifier(held, world, player, pos);
|
||||
held.damageItem(1, player);
|
||||
if (held.stackSize <= 0) {
|
||||
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, held, EnumHand.MAIN_HAND);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, null);
|
||||
}
|
||||
}
|
||||
|
||||
GameProfile playerProfile = player.getGameProfile();
|
||||
List<ItemStack> leafDrops = getLeafDrop(world, playerProfile, pos, saplingModifier, fortune);
|
||||
drops.set(leafDrops);
|
||||
|
||||
@@ -13,17 +13,16 @@ package forestry.arboriculture.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.arboriculture.ITreekeepingMode;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.core.commands.ICommandModeHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TreeModeHelper implements ICommandModeHelper {
|
||||
|
||||
@Override
|
||||
public String[] getModeNames() {
|
||||
ArrayList<ITreekeepingMode> treekeepingModes = TreeManager.treeRoot.getTreekeepingModes();
|
||||
List<ITreekeepingMode> treekeepingModes = TreeManager.treeRoot.getTreekeepingModes();
|
||||
int modeStringCount = treekeepingModes.size();
|
||||
List<String> modeStrings = new ArrayList<>(modeStringCount);
|
||||
for (ITreekeepingMode mode : treekeepingModes) {
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -34,6 +37,14 @@ public class ItemGrafter extends ItemForestryTool implements IToolGrafter {
|
||||
setEfficiencyOnProperMaterial(4.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
if (!stack.isItemDamaged()) {
|
||||
tooltip.add(Translator.translateToLocalFormatted("item.for.uses", stack.getMaxDamage() + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(IBlockState state, ItemStack stack) {
|
||||
Block block = state.getBlock();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ItemRegistryArboriculture extends ItemRegistry {
|
||||
registerOreDict(OreDictUtil.CHARCOAL, new ItemStack(charcoal, 1, OreDictionary.WILDCARD_VALUE));
|
||||
registerOreDict(OreDictUtil.CHARCOAL, new ItemStack(Items.COAL, 1, 1));
|
||||
|
||||
grafter = registerItem(new ItemGrafter(4), "grafter");
|
||||
grafter = registerItem(new ItemGrafter(9), "grafter");
|
||||
grafterProven = registerItem(new ItemGrafter(149), "grafterProven");
|
||||
}
|
||||
}
|
||||
@@ -104,8 +104,10 @@ public abstract class EntityMinecartForestry extends EntityMinecart implements I
|
||||
@Override
|
||||
public void killMinecart(DamageSource damageSource) {
|
||||
super.killMinecart(damageSource);
|
||||
Block block = getDisplayTile().getBlock();
|
||||
entityDropItem(new ItemStack(block, 1, block.getMetaFromState(getDisplayTile())), 0.0F);
|
||||
if (this.worldObj.getGameRules().getBoolean("doEntityDrops")) {
|
||||
Block block = getDisplayTile().getBlock();
|
||||
entityDropItem(new ItemStack(block), 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
// fix cart contents rendering as black in the End dimension
|
||||
|
||||
@@ -20,14 +20,13 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IChromosome;
|
||||
import forestry.api.genetics.IChromosomeType;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class SpeciesRoot implements ISpeciesRoot {
|
||||
|
||||
@@ -82,8 +81,8 @@ public abstract class SpeciesRoot implements ISpeciesRoot {
|
||||
|
||||
/* MUTATIONS */
|
||||
@Override
|
||||
public Collection<? extends IMutation> getCombinations(IAllele other) {
|
||||
ArrayList<IMutation> combinations = new ArrayList<>();
|
||||
public List<IMutation> getCombinations(IAllele other) {
|
||||
List<IMutation> combinations = new ArrayList<>();
|
||||
for (IMutation mutation : getMutations(false)) {
|
||||
if (mutation.isPartner(other)) {
|
||||
combinations.add(mutation);
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
package forestry.core.genetics.alleles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -20,6 +21,7 @@ import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IAlleleSpeciesBuilder;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IMutation;
|
||||
@@ -111,20 +113,30 @@ public abstract class AlleleSpecies extends Allele implements IAlleleSpeciesBuil
|
||||
|
||||
@Override
|
||||
public ItemStack[] getResearchBounty(World world, GameProfile researcher, IIndividual individual, int bountyLevel) {
|
||||
ItemStack research = null;
|
||||
if (world.rand.nextFloat() < (float) 10 / bountyLevel) {
|
||||
Collection<? extends IMutation> combinations = getRoot().getCombinations(this);
|
||||
if (!combinations.isEmpty()) {
|
||||
IMutation[] candidates = combinations.toArray(new IMutation[combinations.size()]);
|
||||
research = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, candidates[world.rand.nextInt(candidates.length)]);
|
||||
if (world.rand.nextFloat() < bountyLevel / 16.0f) {
|
||||
List<? extends IMutation> allMutations = getRoot().getCombinations(this);
|
||||
if (!allMutations.isEmpty()) {
|
||||
List<IMutation> unresearchedMutations = new ArrayList<>();
|
||||
IBreedingTracker tracker = individual.getGenome().getSpeciesRoot().getBreedingTracker(world, researcher);
|
||||
for (IMutation mutation : allMutations) {
|
||||
if (!tracker.isResearched(mutation)) {
|
||||
unresearchedMutations.add(mutation);
|
||||
}
|
||||
}
|
||||
|
||||
IMutation chosenMutation;
|
||||
if (!unresearchedMutations.isEmpty()) {
|
||||
chosenMutation = unresearchedMutations.get(world.rand.nextInt(unresearchedMutations.size()));
|
||||
} else {
|
||||
chosenMutation = allMutations.get(world.rand.nextInt(allMutations.size()));
|
||||
}
|
||||
|
||||
ItemStack researchNote = AlleleManager.alleleRegistry.getMutationNoteStack(researcher, chosenMutation);
|
||||
return new ItemStack[]{researchNote};
|
||||
}
|
||||
}
|
||||
|
||||
if (research != null) {
|
||||
return new ItemStack[]{research};
|
||||
} else {
|
||||
return ItemStackUtil.EMPTY_STACK_ARRAY;
|
||||
}
|
||||
return ItemStackUtil.EMPTY_STACK_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,16 +23,11 @@ import forestry.core.tiles.EscritoireGame;
|
||||
import forestry.core.tiles.TileEscritoire;
|
||||
|
||||
public class ContainerEscritoire extends ContainerTile<TileEscritoire> implements IGuiSelectable {
|
||||
|
||||
private final EntityPlayer player;
|
||||
|
||||
private long lastUpdate;
|
||||
|
||||
public ContainerEscritoire(EntityPlayer player, TileEscritoire tile) {
|
||||
super(tile, player.inventory, 34, 153);
|
||||
|
||||
this.player = player;
|
||||
|
||||
// Analyze slot
|
||||
addSlotToContainer(new SlotFiltered(this.tile, InventoryEscritoire.SLOT_ANALYZE, 97, 67).setPickupWatcher(this.tile).setStackLimit(1));
|
||||
|
||||
@@ -54,7 +49,7 @@ public class ContainerEscritoire extends ContainerTile<TileEscritoire> implement
|
||||
long gameLastUpdate = tile.getGame().getLastUpdate();
|
||||
if (lastUpdate != gameLastUpdate) {
|
||||
lastUpdate = gameLastUpdate;
|
||||
Proxies.net.sendToPlayer(new PacketGuiUpdate(tile), player);
|
||||
sendPacketToListeners(new PacketGuiUpdate(tile));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
import forestry.api.genetics.IGenome;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
@@ -292,17 +293,9 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
HashMap<IMutation, IAllele> combinations = new HashMap<>();
|
||||
|
||||
ISpeciesRoot speciesRoot = individual.getGenome().getSpeciesRoot();
|
||||
|
||||
for (IMutation mutation : speciesRoot.getCombinations(individual.getGenome().getPrimary())) {
|
||||
combinations.put(mutation, individual.getGenome().getPrimary());
|
||||
}
|
||||
|
||||
for (IMutation mutation : speciesRoot.getCombinations(individual.getGenome().getSecondary())) {
|
||||
combinations.put(mutation, individual.getGenome().getSecondary());
|
||||
}
|
||||
IGenome genome = individual.getGenome();
|
||||
ISpeciesRoot speciesRoot = genome.getSpeciesRoot();
|
||||
IAlleleSpecies species = genome.getPrimary();
|
||||
|
||||
int columnWidth = 50;
|
||||
int x = 0;
|
||||
@@ -310,17 +303,16 @@ public class GuiAlyzer extends GuiForestry<ContainerAlyzer, IInventory> {
|
||||
EntityPlayer player = Proxies.common.getPlayer();
|
||||
IBreedingTracker breedingTracker = speciesRoot.getBreedingTracker(player.worldObj, player.getGameProfile());
|
||||
|
||||
for (Map.Entry<IMutation, IAllele> mutation : combinations.entrySet()) {
|
||||
|
||||
if (breedingTracker.isDiscovered(mutation.getKey())) {
|
||||
drawMutationInfo(mutation.getKey(), mutation.getValue(), COLUMN_0 + x, breedingTracker);
|
||||
for (IMutation mutation : speciesRoot.getCombinations(species)) {
|
||||
if (breedingTracker.isDiscovered(mutation)) {
|
||||
drawMutationInfo(mutation, species, COLUMN_0 + x, breedingTracker);
|
||||
} else {
|
||||
// Do not display secret undiscovered mutations.
|
||||
if (mutation.getKey().isSecret()) {
|
||||
if (mutation.isSecret()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
drawUnknownMutation(mutation.getKey(), COLUMN_0 + x, breedingTracker);
|
||||
drawUnknownMutation(mutation, COLUMN_0 + x, breedingTracker);
|
||||
}
|
||||
|
||||
x += columnWidth;
|
||||
|
||||
@@ -91,6 +91,7 @@ public class GameTokenWidget extends Widget {
|
||||
|
||||
@Override
|
||||
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
|
||||
game.choose(index);
|
||||
Proxies.net.sendToServer(new PacketGuiSelectRequest(index, 0));
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import forestry.api.genetics.IAllele;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -72,10 +73,10 @@ public class EscritoireGameBoard implements INbtWritable, IStreamable {
|
||||
tokenCount = getTokenCount(genome);
|
||||
|
||||
for (int i = 0; i < tokenCount / 2; i++) {
|
||||
IIndividual token = root.templateAsIndividual(root.getRandomTemplate(rand));
|
||||
ItemStack pair = root.getMemberStack(token, root.getIconType());
|
||||
gameTokens.add(new EscritoireGameToken(pair));
|
||||
gameTokens.add(new EscritoireGameToken(pair));
|
||||
IAllele[] randomTemplate = root.getRandomTemplate(rand);
|
||||
String speciesUid = randomTemplate[root.getSpeciesChromosomeType().ordinal()].getUID();
|
||||
gameTokens.add(new EscritoireGameToken(speciesUid));
|
||||
gameTokens.add(new EscritoireGameToken(speciesUid));
|
||||
}
|
||||
Collections.shuffle(gameTokens);
|
||||
return true;
|
||||
|
||||
@@ -14,17 +14,19 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.core.INbtWritable;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.utils.ColourUtil;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
|
||||
@@ -41,6 +43,8 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
private static final String[] OVERLAY_FAILED = new String[]{"errors/errored"};
|
||||
private static final String[] OVERLAY_SELECTED = new String[]{"errors/unknown"};
|
||||
|
||||
@Nullable
|
||||
private IIndividual tokenIndividual;
|
||||
@Nullable
|
||||
private ItemStack tokenStack;
|
||||
@Nonnull
|
||||
@@ -51,8 +55,8 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
// required for IStreamable serialization
|
||||
}
|
||||
|
||||
public EscritoireGameToken(@Nullable ItemStack tokenStack) {
|
||||
this.tokenStack = tokenStack;
|
||||
public EscritoireGameToken(@Nullable String speciesUid) {
|
||||
setTokenSpecies(speciesUid);
|
||||
}
|
||||
|
||||
public EscritoireGameToken(@Nonnull NBTTagCompound nbttagcompound) {
|
||||
@@ -61,8 +65,29 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
state = State.values()[stateOrdinal];
|
||||
}
|
||||
|
||||
// legacy
|
||||
if (nbttagcompound.hasKey("tokenStack")) {
|
||||
tokenStack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("tokenStack"));
|
||||
ISpeciesRoot speciesRoot = AlleleManager.alleleRegistry.getSpeciesRoot(tokenStack);
|
||||
tokenIndividual = speciesRoot.getMember(tokenStack);
|
||||
}
|
||||
|
||||
if (nbttagcompound.hasKey("tokenSpecies")) {
|
||||
String speciesUid = nbttagcompound.getString("tokenSpecies");
|
||||
setTokenSpecies(speciesUid);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTokenSpecies(String speciesUid) {
|
||||
IAllele allele = AlleleManager.alleleRegistry.getAllele(speciesUid);
|
||||
if (allele instanceof IAlleleSpecies) {
|
||||
IAlleleSpecies species = (IAlleleSpecies) allele;
|
||||
ISpeciesRoot root = species.getRoot();
|
||||
IAllele[] template = root.getTemplate(speciesUid);
|
||||
if (template != null) {
|
||||
this.tokenIndividual = root.templateAsIndividual(template);
|
||||
this.tokenStack = root.getMemberStack(this.tokenIndividual, root.getIconType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,12 +133,11 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
}
|
||||
|
||||
public int getTokenColour() {
|
||||
if (tokenStack == null || !isVisible()) {
|
||||
if (tokenIndividual == null || !isVisible()) {
|
||||
return 0xffffff;
|
||||
}
|
||||
|
||||
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(tokenStack);
|
||||
int iconColor = individual.getGenome().getPrimary().getSpriteColour(0);
|
||||
int iconColor = tokenIndividual.getGenome().getPrimary().getSpriteColour(0);
|
||||
|
||||
if (state == State.MATCHED) {
|
||||
return ColourUtil.multiplyRGBComponents(iconColor, 0.7f);
|
||||
@@ -146,10 +170,8 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("state", state.ordinal());
|
||||
|
||||
if (tokenStack != null) {
|
||||
NBTTagCompound stackcompound = new NBTTagCompound();
|
||||
tokenStack.writeToNBT(stackcompound);
|
||||
nbttagcompound.setTag("tokenStack", stackcompound);
|
||||
if (tokenIndividual != null) {
|
||||
nbttagcompound.setString("tokenSpecies", tokenIndividual.getGenome().getPrimary().getUID());
|
||||
}
|
||||
return nbttagcompound;
|
||||
}
|
||||
@@ -158,12 +180,20 @@ public class EscritoireGameToken implements INbtWritable, IStreamable {
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeEnum(state, State.VALUES);
|
||||
data.writeItemStack(tokenStack);
|
||||
if (tokenIndividual != null) {
|
||||
data.writeBoolean(true);
|
||||
data.writeUTF(tokenIndividual.getGenome().getPrimary().getUID());
|
||||
} else {
|
||||
data.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
state = data.readEnum(State.VALUES);
|
||||
tokenStack = data.readItemStack();
|
||||
if (data.readBoolean()) {
|
||||
String speciesUid = data.readUTF();
|
||||
setTokenSpecies(speciesUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.core.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -251,22 +252,17 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.core.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -33,6 +34,7 @@ import forestry.core.utils.BlockUtil;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
public abstract class TileEngine extends TileBase implements IEnergyConnection, IActivatable {
|
||||
private static final int CANT_SEND_ENERGY_TIME = 20;
|
||||
@@ -294,4 +296,19 @@ public abstract class TileEngine extends TileBase implements IEnergyConnection,
|
||||
public EnergyManager getEnergyManager() {
|
||||
return energyManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return energyManager.hasCapability(capability) || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
T energyCapability = energyManager.getCapability(capability);
|
||||
if (energyCapability != null) {
|
||||
return energyCapability;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
@@ -352,8 +352,9 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && inventory != null){
|
||||
SidedInvWrapper sidedInvWrapper = new SidedInvWrapper(inventory, facing);
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(sidedInvWrapper);
|
||||
@@ -362,8 +363,8 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && inventory != null){
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && inventory != null){
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.core.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -27,6 +28,7 @@ import forestry.core.render.TankRenderInfo;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
//@Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles")
|
||||
public abstract class TilePowered extends TileBase implements IRenderableTile, IEnergyReceiver, IPowerHandler, ISpeedUpgradable, IStreamableGui {
|
||||
@@ -218,4 +220,19 @@ public abstract class TilePowered extends TileBase implements IRenderableTile, I
|
||||
public boolean canConnectEnergy(EnumFacing from) {
|
||||
return energyManager.canConnectEnergy(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return energyManager.hasCapability(capability) || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
T energyCapability = energyManager.getCapability(capability);
|
||||
if (energyCapability != null) {
|
||||
return energyCapability;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import cofh.api.energy.IEnergyReceiver;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileEngine;
|
||||
import forestry.energy.EnergyManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
@@ -51,12 +52,19 @@ public abstract class BlockUtil {
|
||||
}
|
||||
|
||||
public static boolean isEnergyReceiverOrEngine(EnumFacing side, TileEntity tile) {
|
||||
if (!(tile instanceof IEnergyReceiver) && !(tile instanceof TileEngine)) {
|
||||
return false;
|
||||
}
|
||||
if (tile != null) {
|
||||
if (EnergyManager.TESLA_CONSUMER != null) {
|
||||
if (tile.hasCapability(EnergyManager.TESLA_CONSUMER, side)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
IEnergyConnection receptor = (IEnergyConnection) tile;
|
||||
return receptor.canConnectEnergy(side);
|
||||
if (tile instanceof IEnergyReceiver || (tile instanceof TileEngine)) {
|
||||
IEnergyConnection receptor = (IEnergyConnection) tile;
|
||||
return receptor.canConnectEnergy(side);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean tryPlantCocoaPod(World world, BlockPos pos) {
|
||||
|
||||
@@ -2,6 +2,9 @@ package forestry.energy;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
import net.darkhax.tesla.api.ITeslaProducer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -13,11 +16,25 @@ import forestry.core.network.IStreamable;
|
||||
import forestry.core.tiles.TileEngine;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "net.darkhax.tesla.api.ITeslaConsumer", modid = "Tesla"),
|
||||
@Optional.Interface(iface = "net.darkhax.tesla.api.ITeslaProducer", modid = "Tesla"),
|
||||
@Optional.Interface(iface = "net.darkhax.tesla.api.ITeslaHolder", modid = "Tesla")
|
||||
})
|
||||
public class EnergyManager implements IEnergyReceiver, ITeslaConsumer, ITeslaProducer, ITeslaHolder, IEnergyProvider, IStreamable {
|
||||
@CapabilityInject(ITeslaConsumer.class)
|
||||
public static Capability<ITeslaConsumer> TESLA_CONSUMER = null;
|
||||
@CapabilityInject(ITeslaProducer.class)
|
||||
public static Capability<ITeslaProducer> TESLA_PRODUCER = null;
|
||||
@CapabilityInject(ITeslaHolder.class)
|
||||
public static Capability<ITeslaHolder> TESLA_HOLDER = null;
|
||||
|
||||
public class EnergyManager implements IEnergyReceiver, IEnergyProvider, IStreamable {
|
||||
private enum EnergyTransferMode {
|
||||
EXTRACT, RECEIVE, BOTH
|
||||
}
|
||||
@@ -63,7 +80,6 @@ public class EnergyManager implements IEnergyReceiver, IEnergyProvider, IStreama
|
||||
|
||||
/* NBT */
|
||||
public EnergyManager readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
NBTTagCompound energyManagerNBT = nbt.getCompoundTag("EnergyManager");
|
||||
NBTTagCompound energyStorageNBT = energyManagerNBT.getCompoundTag("EnergyStorage");
|
||||
energyStorage.readFromNBT(energyStorageNBT);
|
||||
@@ -72,7 +88,6 @@ public class EnergyManager implements IEnergyReceiver, IEnergyProvider, IStreama
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
NBTTagCompound energyStorageNBT = new NBTTagCompound();
|
||||
energyStorage.writeToNBT(energyStorageNBT);
|
||||
|
||||
@@ -188,16 +203,18 @@ public class EnergyManager implements IEnergyReceiver, IEnergyProvider, IStreama
|
||||
*/
|
||||
public int sendEnergy(EnumFacing orientation, TileEntity tile, int amount, boolean simulate) {
|
||||
int sent = 0;
|
||||
if (BlockUtil.isEnergyReceiverOrEngine(orientation.getOpposite(), tile)) {
|
||||
if (tile != null) {
|
||||
int extractable = energyStorage.extractEnergy(amount, true);
|
||||
if (extractable > 0) {
|
||||
|
||||
if (tile instanceof IEnergyReceiver) {
|
||||
EnumFacing side = orientation.getOpposite();
|
||||
if (TESLA_CONSUMER != null && tile.hasCapability(TESLA_CONSUMER, side)) {
|
||||
sent = sendEnergyTesla(tile, side, extractable, simulate);
|
||||
} else if (tile instanceof IEnergyReceiver) {
|
||||
IEnergyReceiver receptor = (IEnergyReceiver) tile;
|
||||
sent = receptor.receiveEnergy(orientation.getOpposite(), extractable, simulate);
|
||||
} else if (tile instanceof TileEngine) {
|
||||
sent = receptor.receiveEnergy(side, extractable, simulate);
|
||||
} else if (tile instanceof TileEngine) { // engine chaining
|
||||
TileEngine receptor = (TileEngine) tile;
|
||||
sent = receptor.getEnergyManager().receiveEnergy(orientation.getOpposite(), extractable, simulate);
|
||||
sent = receptor.getEnergyManager().receiveEnergy(side, extractable, simulate);
|
||||
}
|
||||
|
||||
energyStorage.extractEnergy(sent, simulate);
|
||||
@@ -219,4 +236,62 @@ public class EnergyManager implements IEnergyReceiver, IEnergyProvider, IStreama
|
||||
public void generateEnergy(int amount) {
|
||||
energyStorage.modifyEnergyStored(amount);
|
||||
}
|
||||
|
||||
public boolean hasCapability(Capability<?> capability) {
|
||||
if (capability == TESLA_PRODUCER && canExtract()) {
|
||||
return true;
|
||||
} else if (capability == TESLA_CONSUMER && canReceive()) {
|
||||
return true;
|
||||
} else if (capability == TESLA_HOLDER) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public <T> T getCapability(Capability<T> capability) {
|
||||
if (capability == TESLA_PRODUCER && canExtract()) {
|
||||
return TESLA_PRODUCER.cast(this);
|
||||
} else if (capability == TESLA_CONSUMER && canReceive()) {
|
||||
return TESLA_CONSUMER.cast(this);
|
||||
} else if (capability == TESLA_HOLDER) {
|
||||
return TESLA_HOLDER.cast(this);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Tesla")
|
||||
public static int sendEnergyTesla(TileEntity tile, EnumFacing side, int amount, boolean simulate) {
|
||||
ITeslaConsumer consumer = tile.getCapability(TESLA_CONSUMER, side);
|
||||
return (int) consumer.givePower(amount, simulate);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Tesla")
|
||||
@Override
|
||||
public long givePower(long power, boolean simulated) {
|
||||
if (!canReceive()) {
|
||||
return 0;
|
||||
}
|
||||
return energyStorage.receiveEnergy(power, simulated);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Tesla")
|
||||
@Override
|
||||
public long takePower(long power, boolean simulated) {
|
||||
if (!canExtract()) {
|
||||
return 0;
|
||||
}
|
||||
return energyStorage.extractEnergy(power, simulated);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Tesla")
|
||||
@Override
|
||||
public long getStoredPower() {
|
||||
return energyStorage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Tesla")
|
||||
@Override
|
||||
public long getCapacity() {
|
||||
return energyStorage.getMaxEnergyStored();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package forestry.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class EnergyStorage {
|
||||
|
||||
protected int energy;
|
||||
protected int capacity;
|
||||
protected int maxReceive;
|
||||
protected int maxExtract;
|
||||
|
||||
public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
|
||||
this.capacity = capacity;
|
||||
this.maxReceive = maxReceive;
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public EnergyStorage readFromNBT(NBTTagCompound nbt) {
|
||||
this.energy = nbt.getInteger("Energy");
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
if (energy < 0) {
|
||||
energy = 0;
|
||||
}
|
||||
nbt.setInteger("Energy", energy);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public EnergyStorage setCapacity(int capacity) {
|
||||
this.capacity = capacity;
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public EnergyStorage setMaxTransfer(int maxTransfer) {
|
||||
|
||||
setMaxReceive(maxTransfer);
|
||||
setMaxExtract(maxTransfer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EnergyStorage setMaxReceive(int maxReceive) {
|
||||
|
||||
this.maxReceive = maxReceive;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EnergyStorage setMaxExtract(int maxExtract) {
|
||||
this.maxExtract = maxExtract;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getMaxReceive() {
|
||||
return maxReceive;
|
||||
}
|
||||
|
||||
public int getMaxExtract() {
|
||||
return maxExtract;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow for server to client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers
|
||||
* are guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void setEnergyStored(int energy) {
|
||||
if (energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (energy < 0) {
|
||||
this.energy = 0;
|
||||
} else {
|
||||
this.energy = energy;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this
|
||||
* externally, as not all IEnergyHandlers are guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void modifyEnergyStored(int energy) {
|
||||
this.energy += energy;
|
||||
|
||||
if (this.energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* IEnergyStorage */
|
||||
public int receiveEnergy(long maxReceive, boolean simulate) {
|
||||
int energyReceived = (int) Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
public int extractEnergy(long maxExtract, boolean simulate) {
|
||||
int energyExtracted = (int) Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
}
|
||||
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
public int getEnergyStored() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
public int getMaxEnergyStored() {
|
||||
return capacity;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,10 @@
|
||||
package forestry.energy.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.energy.EnergyManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
@@ -293,22 +295,17 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.energy.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -215,15 +216,16 @@ public class TileEuGenerator extends TileBase implements ISidedInventory, ILiqui
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.factory.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -167,22 +168,17 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
|
||||
@@ -250,22 +250,17 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.factory.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -320,22 +321,17 @@ public class TileFabricator extends TilePowered implements ISlotPickupWatcher, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.factory.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -324,21 +325,16 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.factory.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -520,21 +521,16 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.factory.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -161,22 +162,17 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.factory.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -257,22 +258,17 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.factory.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -187,22 +188,17 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return true;
|
||||
}
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (super.hasCapability(capability, facing)) {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tankManager);
|
||||
}
|
||||
return null;
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package forestry.farming.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -21,6 +22,7 @@ import forestry.energy.EnergyManager;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
public class TileFarmGearbox extends TileFarm implements IEnergyReceiver, IEnergyHandler, IFarmComponent.Active {
|
||||
|
||||
@@ -117,4 +119,18 @@ public class TileFarmGearbox extends TileFarm implements IEnergyReceiver, IEnerg
|
||||
return energyManager.canConnectEnergy(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return energyManager.hasCapability(capability) || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
T energyCapability = energyManager.getCapability(capability);
|
||||
if (energyCapability != null) {
|
||||
return energyCapability;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,16 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.tiles;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
public class TileGreenhouseGearbox extends TileGreenhouse implements IEnergyReceiver, IEnergyHandler {
|
||||
|
||||
@@ -59,4 +63,25 @@ public class TileGreenhouseGearbox extends TileGreenhouse implements IEnergyRece
|
||||
return getMultiblockLogic().getController().getEnergyManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
EnergyManager energyManager = getEnergyManager();
|
||||
if (energyManager != null && energyManager.hasCapability(capability)) {
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
EnergyManager energyManager = getEnergyManager();
|
||||
if (energyManager != null) {
|
||||
T energyCapability = energyManager.getCapability(capability);
|
||||
if (energyCapability != null) {
|
||||
return energyCapability;
|
||||
}
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ package forestry.lepidopterology.genetics;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -264,7 +264,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
|
||||
}
|
||||
|
||||
/* MUTATIONS */
|
||||
private static final ArrayList<IButterflyMutation> butterflyMutations = new ArrayList<>();
|
||||
private static final List<IButterflyMutation> butterflyMutations = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void registerMutation(IMutation mutation) {
|
||||
@@ -282,7 +282,7 @@ public class ButterflyRoot extends SpeciesRoot implements IButterflyRoot {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IButterflyMutation> getMutations(boolean shuffle) {
|
||||
public List<IButterflyMutation> getMutations(boolean shuffle) {
|
||||
if (shuffle) {
|
||||
Collections.shuffle(butterflyMutations);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 199 B After Width: | Height: | Size: 202 B |
Reference in new issue
Block a user