2014-09-16 20:30:20 +02:00
|
|
|
package magicbees.tileentity;
|
|
|
|
|
|
2015-03-21 18:20:45 -07:00
|
|
|
import magicbees.api.bees.IMagicApiaryAuraProvider;
|
2015-03-18 23:53:22 -07:00
|
|
|
import magicbees.bees.BeeManager;
|
2015-01-16 22:59:06 +01:00
|
|
|
import magicbees.main.CommonProxy;
|
2015-03-18 23:53:22 -07:00
|
|
|
import magicbees.main.MagicBees;
|
2015-03-21 18:20:45 -07:00
|
|
|
import magicbees.main.utils.ChunkCoords;
|
2015-03-19 13:51:41 -07:00
|
|
|
import magicbees.main.utils.ItemStackUtils;
|
2015-03-21 18:20:45 -07:00
|
|
|
import magicbees.main.utils.LogHelper;
|
2015-03-21 20:45:36 -07:00
|
|
|
import magicbees.main.utils.net.NetworkEventHandler;
|
2015-01-08 21:48:13 -08:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2015-01-16 22:59:06 +01:00
|
|
|
import net.minecraft.inventory.Container;
|
|
|
|
|
import net.minecraft.inventory.ICrafting;
|
|
|
|
|
import net.minecraft.inventory.ISidedInventory;
|
2015-01-08 21:48:13 -08:00
|
|
|
import net.minecraft.item.ItemStack;
|
2015-01-16 22:59:06 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
import net.minecraft.nbt.NBTTagList;
|
2015-01-08 21:48:13 -08:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2015-03-26 13:57:29 -07:00
|
|
|
import net.minecraft.world.ChunkPosition;
|
2015-01-08 21:48:13 -08:00
|
|
|
import net.minecraft.world.World;
|
2015-01-08 23:42:46 -08:00
|
|
|
import net.minecraft.world.biome.BiomeGenBase;
|
2015-03-26 13:57:29 -07:00
|
|
|
import net.minecraft.world.chunk.Chunk;
|
2015-01-16 22:59:06 +01:00
|
|
|
import net.minecraftforge.common.util.Constants;
|
2015-01-08 23:42:46 -08:00
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
|
|
|
|
|
|
|
import forestry.api.apiculture.IBee;
|
|
|
|
|
import forestry.api.apiculture.IBeeGenome;
|
|
|
|
|
import forestry.api.apiculture.IBeeHousing;
|
|
|
|
|
import forestry.api.apiculture.IBeekeepingLogic;
|
|
|
|
|
import forestry.api.apiculture.IHiveFrame;
|
|
|
|
|
import forestry.api.core.EnumHumidity;
|
|
|
|
|
import forestry.api.core.EnumTemperature;
|
|
|
|
|
import forestry.api.core.ErrorStateRegistry;
|
|
|
|
|
import forestry.api.core.IErrorState;
|
|
|
|
|
import forestry.api.genetics.IIndividual;
|
|
|
|
|
import forestry.core.utils.Utils;
|
|
|
|
|
|
2015-03-21 20:45:36 -07:00
|
|
|
public class TileEntityMagicApiary extends TileEntity implements ISidedInventory, IBeeHousing, ITileEntityFlags {
|
2015-01-16 22:59:06 +01:00
|
|
|
|
2015-03-20 16:52:42 -07:00
|
|
|
public static final String tileEntityName = CommonProxy.DOMAIN + ".magicApiary";
|
2015-03-19 13:51:41 -07:00
|
|
|
private GameProfile ownerProfile;
|
2014-09-16 20:30:20 +02:00
|
|
|
|
2015-01-16 22:59:06 +01:00
|
|
|
// Constants
|
|
|
|
|
private static final int SLOT_QUEEN = 0;
|
|
|
|
|
private static final int SLOT_DRONE = 1;
|
|
|
|
|
private static final int SLOT_FRAME_START = 2;
|
|
|
|
|
private static final int SLOT_FRAME_COUNT = 3;
|
2015-03-19 13:51:41 -07:00
|
|
|
private static final int SLOT_PRODUCTS_START = 5;
|
|
|
|
|
private static final int SLOT_PRODUCTS_COUNT = 7;
|
|
|
|
|
|
2015-03-21 18:20:45 -07:00
|
|
|
private static final int AURAPROVIDER_SEARCH_RADIUS = 6;
|
2015-03-21 21:26:51 -07:00
|
|
|
private static int CHARGE_TIME_MUTATION = 1200;
|
|
|
|
|
private static int CHARGE_TIME_DEATH = 400;
|
|
|
|
|
private static int CHARGE_TIME_PRODUCTION = 300;
|
2015-03-21 18:20:45 -07:00
|
|
|
|
|
|
|
|
private IBeekeepingLogic logic;
|
|
|
|
|
private IMagicApiaryAuraProvider auraProvider;
|
|
|
|
|
private ChunkCoords auraProviderPosition;
|
2015-01-16 22:59:06 +01:00
|
|
|
private BiomeGenBase biome;
|
|
|
|
|
private int displayHealthMax = 0;
|
|
|
|
|
private int displayHealth = 0;
|
|
|
|
|
private boolean init = false;
|
2015-03-19 13:51:41 -07:00
|
|
|
|
2015-03-21 20:45:36 -07:00
|
|
|
private static final int OFFSET_MUTATION = 0;
|
|
|
|
|
private static final int OFFSET_DEATH = 1;
|
|
|
|
|
private static final int OFFSET_PRODUCTION = 2;
|
|
|
|
|
private static final int FLAG_MUTATIONCHARGE = 1 << OFFSET_MUTATION;
|
|
|
|
|
private static final int FLAG_DEATHCHARGE = 1 << OFFSET_DEATH;
|
|
|
|
|
private static final int FLAG_PRODUCTIONCHARGE = 1 << OFFSET_PRODUCTION;
|
|
|
|
|
private long[] chargeTimestamps = new long[3];
|
2015-03-21 18:20:45 -07:00
|
|
|
private int flags;
|
|
|
|
|
|
2015-03-19 13:51:41 -07:00
|
|
|
private IErrorState errorState = ErrorStateRegistry.getErrorState("ok");
|
2015-01-16 22:59:06 +01:00
|
|
|
|
|
|
|
|
private ItemStack[] items;
|
|
|
|
|
|
2015-03-20 16:52:42 -07:00
|
|
|
public TileEntityMagicApiary(){
|
2015-03-21 18:20:45 -07:00
|
|
|
flags = 0;
|
2015-01-16 22:59:06 +01:00
|
|
|
items = new ItemStack[12];
|
2015-03-18 23:53:22 -07:00
|
|
|
logic = BeeManager.beeRoot.createBeekeepingLogic(this);
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-19 13:51:41 -07:00
|
|
|
public void setOwner(EntityPlayer player) {
|
|
|
|
|
this.ownerProfile = player.getGameProfile();
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getQueen() {
|
|
|
|
|
return getStackInSlot(SLOT_QUEEN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getDrone() {
|
|
|
|
|
return getStackInSlot(SLOT_DRONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setQueen(ItemStack itemstack) {
|
|
|
|
|
setInventorySlotContents(SLOT_QUEEN, itemstack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setDrone(ItemStack itemstack) {
|
|
|
|
|
setInventorySlotContents(SLOT_DRONE, itemstack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canBreed() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onQueenChange(ItemStack queenStack) {
|
2015-03-18 23:53:22 -07:00
|
|
|
if (!worldObj.isRemote) {
|
|
|
|
|
MagicBees.object.netHandler.sendInventoryUpdate(this, SLOT_QUEEN, queenStack);
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void wearOutEquipment(int amount) {
|
2015-03-18 23:53:22 -07:00
|
|
|
int wear = Math.round(amount * BeeManager.beeRoot.getBeekeepingMode(worldObj).getWearModifier());
|
2015-01-16 22:59:06 +01:00
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
for (int i = SLOT_FRAME_START; i < SLOT_FRAME_START + SLOT_FRAME_COUNT; i++) {
|
|
|
|
|
if (getStackInSlot(i) == null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
continue;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
|
|
|
|
if (!(getStackInSlot(i).getItem() instanceof IHiveFrame)) {
|
2015-01-16 22:59:06 +01:00
|
|
|
continue;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
setInventorySlotContents(i, ((IHiveFrame) getStackInSlot(i).getItem()).frameUsed(this, getStackInSlot(i),
|
2015-03-18 23:53:22 -07:00
|
|
|
BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)), wear));
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onQueenDeath(IBee queen) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onPostQueenDeath(IBee queen) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onEggLaid(IBee queen) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-19 13:51:41 -07:00
|
|
|
private boolean isItemStackFrame(int i) {
|
|
|
|
|
return getStackInSlot(i) != null && getStackInSlot(i).getItem() instanceof IHiveFrame;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-16 22:59:06 +01:00
|
|
|
@Override
|
|
|
|
|
public float getTerritoryModifier(IBeeGenome genome, float currentModifier) {
|
|
|
|
|
float mod = 1.0f;
|
2015-03-19 13:51:41 -07:00
|
|
|
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
|
|
|
|
if (isItemStackFrame(slotIndex)) {
|
|
|
|
|
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getTerritoryModifier(genome, mod);
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
return mod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getMutationModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
|
|
|
|
float mod = 1.0f;
|
2015-03-19 13:51:41 -07:00
|
|
|
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
|
|
|
|
if (isItemStackFrame(slotIndex)) {
|
|
|
|
|
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getMutationModifier(genome, mate, mod);
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
2015-03-17 23:03:48 -07:00
|
|
|
if (this.isMutationBoosted()) {
|
|
|
|
|
mod = mod * 2f;
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
return mod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getLifespanModifier(IBeeGenome genome, IBeeGenome mate, float currentModifier) {
|
|
|
|
|
float mod = 1.0f;
|
2015-03-19 13:51:41 -07:00
|
|
|
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
|
|
|
|
if (isItemStackFrame(slotIndex)) {
|
|
|
|
|
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getLifespanModifier(genome, mate, mod);
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
2015-03-17 23:03:48 -07:00
|
|
|
if (this.isDeathRateBoosted()) {
|
|
|
|
|
mod = mod / 2f;
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
return mod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getProductionModifier(IBeeGenome genome, float currentModifier) {
|
2015-03-19 13:51:41 -07:00
|
|
|
float mod = 0.9f;
|
|
|
|
|
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++){
|
|
|
|
|
if (isItemStackFrame(slotIndex)) {
|
|
|
|
|
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getProductionModifier(genome, mod);
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
2015-03-21 20:45:36 -07:00
|
|
|
if (this.isProductionBoosted()) {
|
2015-03-17 23:03:48 -07:00
|
|
|
mod = mod * 2f;
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
return mod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getFloweringModifier(IBeeGenome genome, float currentModifier) {
|
|
|
|
|
float mod = 1.0f;
|
2015-03-19 13:51:41 -07:00
|
|
|
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
|
|
|
|
if (isItemStackFrame(slotIndex)) {
|
|
|
|
|
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getFloweringModifier(genome, mod);
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
return mod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public float getGeneticDecay(IBeeGenome genome, float currentModifier) {
|
2015-03-19 13:51:41 -07:00
|
|
|
float mod = 0.8f;
|
|
|
|
|
for (int slotIndex = SLOT_FRAME_START; slotIndex < SLOT_FRAME_START + SLOT_FRAME_COUNT; slotIndex++) {
|
|
|
|
|
if (isItemStackFrame(slotIndex)) {
|
|
|
|
|
mod *= ((IHiveFrame) getStackInSlot(slotIndex).getItem()).getGeneticDecay(genome, mod);
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
return mod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isSealed() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isSelfLighted() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isSunlightSimulated() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isHellish() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public GameProfile getOwnerName() {
|
2015-03-19 13:51:41 -07:00
|
|
|
return this.ownerProfile;
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public World getWorld() {
|
|
|
|
|
return worldObj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getXCoord() {
|
|
|
|
|
return xCoord;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getYCoord() {
|
|
|
|
|
return yCoord;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getZCoord() {
|
|
|
|
|
return zCoord;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getBiomeId() {
|
|
|
|
|
return biome.biomeID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BiomeGenBase getBiome() {
|
|
|
|
|
return biome;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public EnumTemperature getTemperature() {
|
|
|
|
|
return EnumTemperature.getFromValue(getExactTemperature());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public EnumHumidity getHumidity() {
|
|
|
|
|
return EnumHumidity.getFromValue(getExactHumidity());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setErrorState(int state) {
|
2015-03-19 13:51:41 -07:00
|
|
|
this.errorState = ErrorStateRegistry.getErrorState((short) state);
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setErrorState(IErrorState state) {
|
2015-03-19 13:51:41 -07:00
|
|
|
this.errorState = state;
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getErrorOrdinal() {
|
2015-03-19 13:51:41 -07:00
|
|
|
return this.errorState.getID();
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IErrorState getErrorState() {
|
2015-03-19 13:51:41 -07:00
|
|
|
return this.errorState;
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean addProduct(ItemStack product, boolean all) {
|
2015-03-19 13:51:41 -07:00
|
|
|
int countAdded = ItemStackUtils.addItemToInventory(this, product, SLOT_PRODUCTS_START, SLOT_PRODUCTS_COUNT);
|
|
|
|
|
|
|
|
|
|
if (all) {
|
|
|
|
|
return countAdded == product.stackSize;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return countAdded > 0;
|
|
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getSizeInventory() {
|
|
|
|
|
return items.length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getStackInSlot(int i) {
|
|
|
|
|
return items[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack decrStackSize(int i, int j) {
|
|
|
|
|
ItemStack itemStack = getStackInSlot(i);
|
|
|
|
|
|
|
|
|
|
if (itemStack != null) {
|
|
|
|
|
if (itemStack.stackSize <= j) {
|
|
|
|
|
setInventorySlotContents(i, null);
|
|
|
|
|
}else{
|
|
|
|
|
itemStack = itemStack.splitStack(j);
|
|
|
|
|
markDirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return itemStack;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ItemStack getStackInSlotOnClosing(int i) {
|
|
|
|
|
ItemStack item = getStackInSlot(i);
|
|
|
|
|
setInventorySlotContents(i, null);
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
|
|
|
|
items[i] = itemStack;
|
|
|
|
|
|
|
|
|
|
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()){
|
|
|
|
|
itemStack.stackSize = getInventoryStackLimit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
markDirty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getInventoryName() {
|
2015-03-19 13:51:41 -07:00
|
|
|
return tileEntityName;
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean hasCustomInventoryName() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getInventoryStackLimit() {
|
|
|
|
|
return 64;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isUseableByPlayer(EntityPlayer entityPlayer) {
|
|
|
|
|
return entityPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) <= 64;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void openInventory() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void closeInventory() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int[] getAccessibleSlotsFromSide(int side) {
|
|
|
|
|
return new int[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
|
2015-03-18 23:53:22 -07:00
|
|
|
if(slot == SLOT_QUEEN && BeeManager.beeRoot.isMember(itemStack)
|
|
|
|
|
&& !BeeManager.beeRoot.isDrone(itemStack)) {
|
2015-01-16 22:59:06 +01:00
|
|
|
return true;
|
2015-03-15 01:06:14 -07:00
|
|
|
}
|
2015-03-18 23:53:22 -07:00
|
|
|
else if (slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack)) {
|
2015-03-15 01:06:14 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
2015-03-18 23:53:22 -07:00
|
|
|
return slot == SLOT_DRONE && BeeManager.beeRoot.isDrone(itemStack);
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
|
|
|
|
|
switch (slot){
|
|
|
|
|
case SLOT_QUEEN:
|
|
|
|
|
case SLOT_DRONE:
|
|
|
|
|
case SLOT_FRAME_START:
|
|
|
|
|
case SLOT_FRAME_START + 1:
|
|
|
|
|
case SLOT_FRAME_START + 2:
|
|
|
|
|
return false;
|
|
|
|
|
default:
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
private int getHealthDisplay() {
|
|
|
|
|
if (getStackInSlot(SLOT_QUEEN) == null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
return 0;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
|
2015-03-18 23:53:22 -07:00
|
|
|
if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) {
|
|
|
|
|
return BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)).getHealth();
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-03-18 23:53:22 -07:00
|
|
|
else if (!BeeManager.beeRoot.isDrone(getStackInSlot(SLOT_QUEEN))) {
|
2015-01-16 22:59:06 +01:00
|
|
|
return displayHealth;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
|
|
|
|
else {
|
2015-01-16 22:59:06 +01:00
|
|
|
return 0;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
private int getMaxHealthDisplay() {
|
|
|
|
|
if (getStackInSlot(SLOT_QUEEN) == null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
return 0;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-03-18 23:53:22 -07:00
|
|
|
if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) {
|
|
|
|
|
return BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN)).getMaxHealth();
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-03-18 23:53:22 -07:00
|
|
|
else if (!BeeManager.beeRoot.isDrone(getStackInSlot(SLOT_QUEEN))) {
|
2015-01-16 22:59:06 +01:00
|
|
|
return displayHealthMax;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
|
|
|
|
else {
|
2015-01-16 22:59:06 +01:00
|
|
|
return 0;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
public int getHealthScaled(int i) {
|
|
|
|
|
if (getMaxHealthDisplay() == 0) {
|
2015-01-16 22:59:06 +01:00
|
|
|
return 0;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
|
|
|
|
|
return (getHealthDisplay() * i) / getMaxHealthDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getTemperatureScaled(int i) {
|
|
|
|
|
return Math.round(i * (getExactTemperature() / 2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getHumidityScaled(int i) {
|
|
|
|
|
return Math.round(i * getExactHumidity());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Saving and loading */
|
|
|
|
|
@Override
|
2015-03-17 23:03:48 -07:00
|
|
|
public void writeToNBT(NBTTagCompound compound) {
|
2015-01-16 22:59:06 +01:00
|
|
|
super.writeToNBT(compound);
|
|
|
|
|
|
|
|
|
|
NBTTagList items = new NBTTagList();
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
for (int i = 0; i < getSizeInventory(); i++) {
|
2015-01-16 22:59:06 +01:00
|
|
|
ItemStack itemStack = getStackInSlot(i);
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
if (itemStack != null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
NBTTagCompound item = new NBTTagCompound();
|
|
|
|
|
item.setByte("Slot", (byte)i);
|
|
|
|
|
itemStack.writeToNBT(item);
|
|
|
|
|
items.appendTag(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-21 18:20:45 -07:00
|
|
|
compound.setTag("Items", items);
|
2015-01-16 22:59:06 +01:00
|
|
|
|
|
|
|
|
compound.setInteger("BiomeId", biome.biomeID);
|
2015-03-17 23:03:48 -07:00
|
|
|
if (logic != null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
logic.writeToNBT(compound);
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
|
2015-03-21 18:20:45 -07:00
|
|
|
ChunkCoords.writeToNBT(this.auraProviderPosition, compound);
|
|
|
|
|
|
|
|
|
|
compound.setInteger("flags", this.flags);
|
2015-03-21 20:45:36 -07:00
|
|
|
compound.setLong("timestamp0", chargeTimestamps[0]);
|
|
|
|
|
compound.setLong("timestamp1", chargeTimestamps[1]);
|
|
|
|
|
compound.setLong("timestamp2", chargeTimestamps[2]);
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-03-17 23:03:48 -07:00
|
|
|
public void readFromNBT(NBTTagCompound compound) {
|
2015-01-16 22:59:06 +01:00
|
|
|
super.readFromNBT(compound);
|
|
|
|
|
|
|
|
|
|
NBTTagList items = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
for (int i = 0; i < items.tagCount(); i++) {
|
2015-01-16 22:59:06 +01:00
|
|
|
NBTTagCompound item = (NBTTagCompound)items.getCompoundTagAt(i);
|
|
|
|
|
int slot = item.getByte("Slot");
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
if (slot >= 0 && slot < getSizeInventory()) {
|
2015-01-16 22:59:06 +01:00
|
|
|
setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(item));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int biomeId = compound.getInteger("BiomeId");
|
|
|
|
|
biome = BiomeGenBase.getBiome(biomeId);
|
|
|
|
|
logic.readFromNBT(compound);
|
2015-03-21 18:20:45 -07:00
|
|
|
|
|
|
|
|
this.auraProviderPosition = ChunkCoords.readFromNBT(compound);
|
|
|
|
|
this.flags = compound.getInteger("flags");
|
2015-03-21 20:45:36 -07:00
|
|
|
this.chargeTimestamps[0] = compound.getLong("timestamp0");
|
|
|
|
|
this.chargeTimestamps[1] = compound.getLong("timestamp1");
|
|
|
|
|
this.chargeTimestamps[2] = compound.getLong("timestamp2");
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
public float getExactTemperature() {
|
2015-01-16 22:59:06 +01:00
|
|
|
return biome.temperature;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
public float getExactHumidity() {
|
2015-01-16 22:59:06 +01:00
|
|
|
return biome.rainfall;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-03-17 23:03:48 -07:00
|
|
|
public void updateEntity() {
|
|
|
|
|
if (init == false) {
|
2015-01-16 22:59:06 +01:00
|
|
|
init = true;
|
|
|
|
|
updateBiome();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-18 23:53:22 -07:00
|
|
|
if (worldObj.isRemote) {
|
2015-03-19 13:51:41 -07:00
|
|
|
updateClientSide();
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
|
|
|
|
else {
|
2015-03-19 13:51:41 -07:00
|
|
|
updateServerSide();
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
public void updateBiome() {
|
|
|
|
|
if (worldObj != null) {
|
|
|
|
|
if (biome == null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, yCoord);
|
2015-03-17 23:03:48 -07:00
|
|
|
if (biome != null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
this.biome = biome;
|
|
|
|
|
setErrorState(ErrorStateRegistry.getErrorState("OK"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
public void updateClientSide() {
|
2015-03-18 23:53:22 -07:00
|
|
|
if (BeeManager.beeRoot.isMated(getStackInSlot(SLOT_QUEEN))) {
|
|
|
|
|
if (getErrorState() == ErrorStateRegistry.getErrorState("OK") && worldObj.getTotalWorldTime() % 10 == 0) {
|
|
|
|
|
IBee displayQueen = BeeManager.beeRoot.getMember(getStackInSlot(SLOT_QUEEN));
|
2015-01-16 22:59:06 +01:00
|
|
|
displayQueen.doFX(logic.getEffectData(), this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
public void updateServerSide() {
|
2015-03-21 20:45:36 -07:00
|
|
|
if (this.auraProvider == null) {
|
2015-03-21 18:20:45 -07:00
|
|
|
findAuraProvider();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
updateAuraProvider();
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-16 22:59:06 +01:00
|
|
|
logic.update();
|
|
|
|
|
|
|
|
|
|
IBee queen = logic.getQueen();
|
2015-03-17 23:03:48 -07:00
|
|
|
if (queen == null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
return;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
|
2015-03-18 23:53:22 -07:00
|
|
|
if (worldObj.getTotalWorldTime() % 5 == 0) {
|
2015-01-16 22:59:06 +01:00
|
|
|
onQueenChange(getStackInSlot(SLOT_QUEEN));
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-17 23:03:48 -07:00
|
|
|
public void getGUINetworkData(int i, int j) {
|
|
|
|
|
if (logic == null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
return;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
|
|
|
|
|
switch(i) {
|
|
|
|
|
case 0:
|
|
|
|
|
displayHealth = j;
|
|
|
|
|
break;
|
|
|
|
|
case 1: displayHealthMax = j;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
2015-03-17 23:03:48 -07:00
|
|
|
if (logic == null) {
|
2015-01-16 22:59:06 +01:00
|
|
|
return;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-01-16 22:59:06 +01:00
|
|
|
|
|
|
|
|
iCrafting.sendProgressBarUpdate(container, 0, logic.getBreedingTime());
|
|
|
|
|
iCrafting.sendProgressBarUpdate(container, 1, logic.getTotalBreedingTime());
|
|
|
|
|
}
|
2015-03-17 23:03:48 -07:00
|
|
|
|
2015-03-21 20:45:36 -07:00
|
|
|
public boolean isProductionBoosted() {
|
|
|
|
|
return (flags & FLAG_PRODUCTIONCHARGE) == FLAG_PRODUCTIONCHARGE;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isDeathRateBoosted() {
|
2015-03-21 20:45:36 -07:00
|
|
|
return (flags & FLAG_DEATHCHARGE) == FLAG_DEATHCHARGE;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isMutationBoosted() {
|
2015-03-21 20:45:36 -07:00
|
|
|
return (flags & FLAG_MUTATIONCHARGE) == FLAG_MUTATIONCHARGE;
|
2015-03-17 23:03:48 -07:00
|
|
|
}
|
2015-03-21 18:20:45 -07:00
|
|
|
|
|
|
|
|
private void updateAuraProvider() {
|
2015-03-21 21:26:51 -07:00
|
|
|
if (worldObj.getTotalWorldTime() % 15 == 0 && locationHasAuraProvider(auraProviderPosition)) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-21 20:45:36 -07:00
|
|
|
int oldFlags = flags;
|
|
|
|
|
if (!isMutationBoosted()) {
|
|
|
|
|
if (this.auraProvider.getMutationCharge()) {
|
|
|
|
|
flags |= FLAG_MUTATIONCHARGE;
|
|
|
|
|
chargeTimestamps[OFFSET_MUTATION] = worldObj.getTotalWorldTime();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (chargeTimestamps[OFFSET_MUTATION] + CHARGE_TIME_MUTATION <= worldObj.getTotalWorldTime()) {
|
|
|
|
|
if (!this.auraProvider.getMutationCharge()) {
|
|
|
|
|
flags = flags & ~FLAG_MUTATIONCHARGE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isDeathRateBoosted()) {
|
|
|
|
|
if (this.auraProvider.getDeathRateCharge()) {
|
|
|
|
|
flags |= FLAG_DEATHCHARGE;
|
|
|
|
|
chargeTimestamps[OFFSET_DEATH] = worldObj.getTotalWorldTime();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (chargeTimestamps[OFFSET_DEATH] + CHARGE_TIME_DEATH <= worldObj.getTotalWorldTime()) {
|
|
|
|
|
if (!this.auraProvider.getDeathRateCharge()) {
|
|
|
|
|
flags = flags & ~FLAG_DEATHCHARGE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isProductionBoosted()) {
|
|
|
|
|
if (this.auraProvider.getProductionCharge()) {
|
|
|
|
|
flags |= FLAG_PRODUCTIONCHARGE;
|
|
|
|
|
chargeTimestamps[OFFSET_PRODUCTION] = worldObj.getTotalWorldTime();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (chargeTimestamps[OFFSET_PRODUCTION] + CHARGE_TIME_PRODUCTION <= worldObj.getTotalWorldTime()) {
|
|
|
|
|
if (!this.auraProvider.getProductionCharge()) {
|
|
|
|
|
flags = flags & ~FLAG_PRODUCTIONCHARGE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-21 18:20:45 -07:00
|
|
|
|
2015-03-21 20:45:36 -07:00
|
|
|
if (oldFlags != flags) {
|
|
|
|
|
NetworkEventHandler.getInstance().sendFlagsUpdate(this, new int[] {flags});
|
|
|
|
|
}
|
2015-03-21 18:20:45 -07:00
|
|
|
}
|
2015-03-21 21:26:51 -07:00
|
|
|
|
2015-03-26 13:57:29 -07:00
|
|
|
private static int MAX_BLOCKS_SEARCH_PER_CHECK = (AURAPROVIDER_SEARCH_RADIUS * 2 + 1) * 12;
|
2015-03-21 18:20:45 -07:00
|
|
|
private void findAuraProvider() {
|
|
|
|
|
if (worldObj.getTotalWorldTime() % 10 != 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.auraProviderPosition == null) {
|
|
|
|
|
this.auraProviderPosition = new ChunkCoords(0,
|
|
|
|
|
xCoord - AURAPROVIDER_SEARCH_RADIUS,
|
|
|
|
|
(yCoord - AURAPROVIDER_SEARCH_RADIUS >= 0) ? yCoord - AURAPROVIDER_SEARCH_RADIUS : 0,
|
|
|
|
|
zCoord - AURAPROVIDER_SEARCH_RADIUS);
|
|
|
|
|
LogHelper.info("Apiary starting search");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// Will end up here after loading from save with a valid auraProvider.
|
2015-03-21 21:26:51 -07:00
|
|
|
if (locationHasAuraProvider(auraProviderPosition)) {
|
2015-03-21 20:45:36 -07:00
|
|
|
IMagicApiaryAuraProvider provider = (IMagicApiaryAuraProvider)(worldObj.getTileEntity(auraProviderPosition.x,
|
2015-03-21 18:20:45 -07:00
|
|
|
auraProviderPosition.y,
|
|
|
|
|
auraProviderPosition.x));
|
2015-03-21 20:45:36 -07:00
|
|
|
if (provider == null) {
|
|
|
|
|
// ... well, it WAS here...
|
|
|
|
|
this.auraProviderPosition = null;
|
|
|
|
|
}
|
2015-03-21 18:20:45 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int blocksCounted = 0;
|
|
|
|
|
int x = auraProviderPosition.x;
|
|
|
|
|
int y = auraProviderPosition.y;
|
|
|
|
|
int z = auraProviderPosition.z;
|
|
|
|
|
while ((y < yCoord + AURAPROVIDER_SEARCH_RADIUS) && blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) {
|
|
|
|
|
while ((z < zCoord + AURAPROVIDER_SEARCH_RADIUS) && blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) {
|
|
|
|
|
while ((x < xCoord + AURAPROVIDER_SEARCH_RADIUS) && blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) {
|
|
|
|
|
if (locationHasAuraProvider(x, y, z)) {
|
|
|
|
|
LogHelper.info("Apiary found aura provider!");
|
|
|
|
|
this.auraProvider = (IMagicApiaryAuraProvider)(worldObj.getTileEntity(x, y, z));
|
|
|
|
|
saveAuraProviderPosition(x, y, z);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++blocksCounted;
|
|
|
|
|
++x;
|
|
|
|
|
}
|
|
|
|
|
if (blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) {
|
|
|
|
|
++z;
|
|
|
|
|
x = xCoord - AURAPROVIDER_SEARCH_RADIUS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (blocksCounted < MAX_BLOCKS_SEARCH_PER_CHECK) {
|
|
|
|
|
++y;
|
|
|
|
|
z = zCoord - AURAPROVIDER_SEARCH_RADIUS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LogHelper.info("Apiary suspending search");
|
|
|
|
|
|
|
|
|
|
if (auraProvider == null) {
|
|
|
|
|
saveAuraProviderPosition(x, y, z);
|
|
|
|
|
|
|
|
|
|
if (auraProviderPosition.y >= yCoord + AURAPROVIDER_SEARCH_RADIUS) {
|
|
|
|
|
LogHelper.info("Apiary finished scanning blocks; did not find aura provider.");
|
|
|
|
|
this.auraProviderPosition = null;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveAuraProviderPosition(int x, int y, int z) {
|
|
|
|
|
auraProviderPosition = new ChunkCoords(auraProviderPosition.dimension, x, y, z);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-21 21:26:51 -07:00
|
|
|
private boolean locationHasAuraProvider(ChunkCoords coords) {
|
|
|
|
|
return locationHasAuraProvider(coords.x, coords.y, coords.z);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-21 18:20:45 -07:00
|
|
|
private boolean locationHasAuraProvider(int x, int y, int z) {
|
2015-03-26 13:57:29 -07:00
|
|
|
Chunk chunk = worldObj.getChunkFromBlockCoords(x, z);
|
|
|
|
|
x %= 16;
|
|
|
|
|
z %= 16;
|
|
|
|
|
if (x < 0) {
|
|
|
|
|
x += 16;
|
|
|
|
|
}
|
|
|
|
|
if (z < 0) {
|
|
|
|
|
z += 16;
|
|
|
|
|
}
|
|
|
|
|
ChunkPosition cPos = new ChunkPosition(x, y, z);
|
|
|
|
|
TileEntity entity = (TileEntity)chunk.chunkTileEntityMap.get(cPos);
|
2015-03-21 18:20:45 -07:00
|
|
|
if (entity != null && entity instanceof IMagicApiaryAuraProvider) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-03-21 20:45:36 -07:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setFlags(int[] flagArray) {
|
|
|
|
|
if (flagArray.length == 1) {
|
|
|
|
|
this.flags = flagArray[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-16 20:30:20 +02:00
|
|
|
}
|