2013-05-23 21:07:28 -07:00
|
|
|
package magicbees.tileentity;
|
2013-04-02 20:02:09 -07:00
|
|
|
|
2015-10-01 21:47:53 -07:00
|
|
|
import com.google.common.collect.ImmutableSet;
|
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
|
|
import forestry.api.apiculture.DefaultBeeListener;
|
2013-04-02 20:02:09 -07:00
|
|
|
import forestry.api.apiculture.IBeeGenome;
|
|
|
|
|
import forestry.api.apiculture.IBeeHousing;
|
2015-10-01 21:47:53 -07:00
|
|
|
import forestry.api.apiculture.IBeeHousingInventory;
|
|
|
|
|
import forestry.api.apiculture.IBeeListener;
|
|
|
|
|
import forestry.api.apiculture.IBeeModifier;
|
|
|
|
|
import forestry.api.apiculture.IBeekeepingLogic;
|
2013-04-02 20:02:09 -07:00
|
|
|
import forestry.api.core.EnumHumidity;
|
|
|
|
|
import forestry.api.core.EnumTemperature;
|
2015-10-01 21:47:53 -07:00
|
|
|
import forestry.api.core.IErrorLogic;
|
2015-01-11 01:51:48 -08:00
|
|
|
import forestry.api.core.IErrorState;
|
2022-10-12 21:09:45 +02:00
|
|
|
import java.io.DataInputStream;
|
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
|
import java.io.IOException;
|
2015-10-01 21:47:53 -07:00
|
|
|
import magicbees.bees.BeeManager;
|
2022-10-12 21:09:45 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.util.ChunkCoordinates;
|
|
|
|
|
import net.minecraft.util.Vec3;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import net.minecraft.world.biome.BiomeGenBase;
|
2013-04-02 20:02:09 -07:00
|
|
|
|
2013-05-06 00:24:06 -07:00
|
|
|
/**
|
2015-10-01 21:47:53 -07:00
|
|
|
* Simulates enough of a bee house to fire the bee effects. =D
|
2013-05-06 00:24:06 -07:00
|
|
|
*
|
2015-10-01 21:47:53 -07:00
|
|
|
* @author MysteriousAges, mezz
|
2013-05-06 00:24:06 -07:00
|
|
|
*/
|
2015-10-01 21:47:53 -07:00
|
|
|
public class EffectJarHousing implements IBeeHousing {
|
2015-01-08 21:48:13 -08:00
|
|
|
|
2022-10-12 21:09:45 +02:00
|
|
|
private static final IErrorLogic errorLogic = new JarErrorLogic();
|
|
|
|
|
private static final Iterable<IBeeListener> beeListeners = ImmutableSet.<IBeeListener>of(new DefaultBeeListener());
|
|
|
|
|
private static final Iterable<IBeeModifier> beeModifiers = ImmutableSet.<IBeeModifier>of(new JarHousingModifier());
|
|
|
|
|
|
|
|
|
|
private final IBeekeepingLogic beekeepingLogic;
|
|
|
|
|
private final TileEntityEffectJar jarEntity;
|
|
|
|
|
private final BiomeGenBase biome;
|
|
|
|
|
private final IBeeHousingInventory inventory;
|
|
|
|
|
|
|
|
|
|
public EffectJarHousing(TileEntityEffectJar entity) {
|
|
|
|
|
this.jarEntity = entity;
|
|
|
|
|
this.biome = entity.getWorldObj().getBiomeGenForCoords(entity.xCoord, entity.zCoord);
|
|
|
|
|
this.inventory = new JarBeeHousingInventory(entity);
|
|
|
|
|
this.beekeepingLogic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ChunkCoordinates getCoordinates() {
|
|
|
|
|
return new ChunkCoordinates(jarEntity.xCoord, jarEntity.yCoord, jarEntity.zCoord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BiomeGenBase getBiome() {
|
|
|
|
|
return biome;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public EnumTemperature getTemperature() {
|
|
|
|
|
return EnumTemperature.getFromBiome(biome, jarEntity.xCoord, jarEntity.yCoord, jarEntity.zCoord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public EnumHumidity getHumidity() {
|
|
|
|
|
return EnumHumidity.getFromValue(biome.rainfall);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getBlockLightValue() {
|
|
|
|
|
return jarEntity.getWorldObj().getBlockLightValue(jarEntity.xCoord, jarEntity.yCoord + 1, jarEntity.zCoord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canBlockSeeTheSky() {
|
|
|
|
|
return jarEntity.getWorldObj().canBlockSeeTheSky(jarEntity.xCoord, jarEntity.yCoord + 1, jarEntity.zCoord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public World getWorld() {
|
|
|
|
|
return jarEntity.getWorldObj();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public GameProfile getOwner() {
|
|
|
|
|
return jarEntity.getOwner();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Vec3 getBeeFXCoordinates() {
|
|
|
|
|
return Vec3.createVectorHelper(jarEntity.xCoord + 0.5f, jarEntity.yCoord + 0.5f, jarEntity.zCoord + 0.5f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IErrorLogic getErrorLogic() {
|
|
|
|
|
return errorLogic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IBeeHousingInventory getBeeInventory() {
|
|
|
|
|
return inventory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IBeekeepingLogic getBeekeepingLogic() {
|
|
|
|
|
return beekeepingLogic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Iterable<IBeeModifier> getBeeModifiers() {
|
|
|
|
|
return beeModifiers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Iterable<IBeeListener> getBeeListeners() {
|
|
|
|
|
return beeListeners;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class JarBeeHousingInventory implements IBeeHousingInventory {
|
|
|
|
|
private final TileEntityEffectJar jarEntity;
|
|
|
|
|
|
|
|
|
|
public JarBeeHousingInventory(TileEntityEffectJar jarEntity) {
|
|
|
|
|
this.jarEntity = jarEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getQueen() {
|
|
|
|
|
return jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getDrone() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setQueen(ItemStack itemStack) {
|
|
|
|
|
jarEntity.setInventorySlotContents(TileEntityEffectJar.QUEEN_SLOT, itemStack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setDrone(ItemStack itemstack) {}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean addProduct(ItemStack product, boolean all) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class JarErrorLogic implements IErrorLogic {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean setCondition(boolean condition, IErrorState errorState) {
|
|
|
|
|
return condition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean contains(IErrorState state) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean hasErrors() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void clearErrors() {}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void writeData(DataOutputStream data) throws IOException {}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void readData(DataInputStream data) throws IOException {}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ImmutableSet<IErrorState> getErrorStates() {
|
|
|
|
|
return ImmutableSet.of();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class JarHousingModifier implements IBeeModifier {
|
|
|
|
|
@Override
|
|
|
|
|
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
|
|
|
|
return 0.9f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
|
|
|
|
return 0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
|
|
|
|
return 0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
|
|
|
|
return 0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
|
|
|
|
return 0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
|
|
|
|
return 0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isSealed() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isSelfLighted() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isSunlightSimulated() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isHellish() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-02 20:02:09 -07:00
|
|
|
}
|