mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-22 13:09:50 +00:00
Upgraded to 1.7.2. List of currently-known issues are in CURRENT_ISSUES.txt file.
This commit is contained in:
1 parent
02655f092e
commit
02659b2816
227 files changed
+1350
-1222
No files matched your search
@@ -0,0 +1,220 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.apiculture.IBeeGenome;
|
||||
import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
|
||||
/**
|
||||
*
|
||||
* Singleton object to simulate enough of a bee house to fire the bee effects. =D
|
||||
*
|
||||
* @author MysteriousAges
|
||||
*
|
||||
*/
|
||||
public class EffectJarHousing implements IBeeHousing
|
||||
{
|
||||
private static EffectJarHousing instance = new EffectJarHousing();
|
||||
|
||||
TileEntityEffectJar jarEntity;
|
||||
|
||||
public static EffectJarHousing getFor(TileEntityEffectJar entity)
|
||||
{
|
||||
instance.jarEntity = entity;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@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 int getXCoord()
|
||||
{
|
||||
return this.jarEntity.xCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getYCoord()
|
||||
{
|
||||
return this.jarEntity.yCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZCoord()
|
||||
{
|
||||
return this.jarEntity.zCoord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSealed()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelfLighted()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSunlightSimulated()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHellish()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueenChange(ItemStack queen) { }
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) { }
|
||||
|
||||
@Override
|
||||
public void onQueenDeath(IBee queen) { }
|
||||
|
||||
@Override
|
||||
public void onPostQueenDeath(IBee queen) { }
|
||||
|
||||
@Override
|
||||
public ItemStack getQueen()
|
||||
{
|
||||
return this.jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDrone()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQueen(ItemStack itemStack)
|
||||
{
|
||||
this.jarEntity.setInventorySlotContents(TileEntityEffectJar.QUEEN_SLOT, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDrone(ItemStack itemstack) { }
|
||||
|
||||
@Override
|
||||
public int getBiomeId()
|
||||
{
|
||||
return this.jarEntity.getWorldObj().getBiomeGenForCoords(getXCoord(), getYCoord()).biomeID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature()
|
||||
{
|
||||
EnumTemperature temp = EnumTemperature.NORMAL;
|
||||
ItemStack stack = this.jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
||||
if (stack != null)
|
||||
{
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(stack);
|
||||
temp = queen.getGenome().getPrimary().getTemperature();
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity()
|
||||
{
|
||||
EnumHumidity humid = EnumHumidity.NORMAL;
|
||||
ItemStack stack = this.jarEntity.getStackInSlot(TileEntityEffectJar.QUEEN_SLOT);
|
||||
if (stack != null)
|
||||
{
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(stack);
|
||||
humid = queen.getGenome().getPrimary().getHumidity();
|
||||
}
|
||||
return humid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return this.jarEntity.getWorldObj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerName()
|
||||
{
|
||||
return this.jarEntity.getOwner();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorState(int state) { }
|
||||
|
||||
@Override
|
||||
public int getErrorOrdinal()
|
||||
{
|
||||
return 1; // EnumErrorCode.OK.ordinal() value.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBreed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addProduct(ItemStack product, boolean all)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPollenRetrieved(IBee queen, IIndividual pollen, boolean isHandled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onEggLaid(IBee queen)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGeneticDecay(IBeeGenome genome, float currentModifier)
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package magicbees.tileentity;
|
||||
|
||||
import magicbees.main.CommonProxy;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.genetics.IEffectData;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
public class TileEntityEffectJar extends TileEntity implements IInventory
|
||||
{
|
||||
public static final String tileEntityName = CommonProxy.DOMAIN + ".effectJar";
|
||||
|
||||
private String ownerName;
|
||||
private EffectJarHousing housingLogic;
|
||||
|
||||
private static final int SLOT_COUNT = 2;
|
||||
public static final int DRONE_SLOT = 0;
|
||||
public static final int QUEEN_SLOT = SLOT_COUNT - 1;
|
||||
|
||||
private ItemStack[] beeSlots;
|
||||
private IEffectData[] effectData = new IEffectData[2];
|
||||
|
||||
private int throttle;
|
||||
public int currentBeeHealth;
|
||||
public int currentBeeColour;
|
||||
|
||||
public TileEntityEffectJar()
|
||||
{
|
||||
super();
|
||||
this.beeSlots = new ItemStack[SLOT_COUNT];
|
||||
}
|
||||
|
||||
public void setOwner(EntityPlayer player)
|
||||
{
|
||||
this.ownerName = player.getCommandSenderName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass)
|
||||
{
|
||||
return pass == 1;
|
||||
}
|
||||
|
||||
public String getOwner()
|
||||
{
|
||||
return this.ownerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
// Last slot reserved for "queen"
|
||||
return this.beeSlots.length - 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
return beeSlots[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (this.beeSlots[QUEEN_SLOT] != null)
|
||||
{
|
||||
IBee queen = magicbees.bees.BeeManager.beeRoot.getMember(this.beeSlots[QUEEN_SLOT]);
|
||||
|
||||
currentBeeHealth = (queen.getHealth() * 100) / queen.getMaxHealth();
|
||||
currentBeeColour = ((IAlleleBeeSpecies)queen.getGenome().getPrimary()).getIconColour(0);
|
||||
|
||||
EffectJarHousing housingLogic = EffectJarHousing.getFor(this);
|
||||
this.effectData = queen.doEffect(this.effectData, housingLogic);
|
||||
if (this.worldObj.getWorldTime() % 5 == 0)
|
||||
{
|
||||
this.effectData = queen.doFX(this.effectData, housingLogic);
|
||||
}
|
||||
|
||||
// run the queen
|
||||
if (throttle > 550)
|
||||
{
|
||||
throttle = 0;
|
||||
queen.age(this.worldObj, 0.26f);
|
||||
|
||||
if (queen.getHealth() == 0)
|
||||
{
|
||||
this.beeSlots[QUEEN_SLOT] = null;
|
||||
currentBeeHealth = 0;
|
||||
currentBeeColour = 0x0ffffff;
|
||||
}
|
||||
else
|
||||
{
|
||||
queen.writeToNBT(this.beeSlots[QUEEN_SLOT].stackTagCompound);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
throttle++;
|
||||
}
|
||||
}
|
||||
else if (this.beeSlots[DRONE_SLOT] != null)
|
||||
{
|
||||
// make a queen
|
||||
ItemStack droneStack = this.beeSlots[DRONE_SLOT];
|
||||
if (magicbees.bees.BeeManager.beeRoot.isDrone(droneStack))
|
||||
{
|
||||
IBee bee = magicbees.bees.BeeManager.beeRoot.getMember(droneStack);
|
||||
if (droneStack.stackSize == 1)
|
||||
{
|
||||
this.beeSlots[DRONE_SLOT] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
droneStack.stackSize--;
|
||||
}
|
||||
|
||||
this.beeSlots[QUEEN_SLOT] = droneStack.copy();
|
||||
this.beeSlots[QUEEN_SLOT].stackSize = 1;
|
||||
|
||||
int current = bee.getHealth();
|
||||
int max = bee.getMaxHealth();
|
||||
currentBeeHealth = (current * 100) / max;
|
||||
currentBeeColour = ((IAlleleBeeSpecies)bee.getGenome().getPrimary()).getIconColour(0);
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int count)
|
||||
{
|
||||
ItemStack value = null;
|
||||
if (this.beeSlots[slot] != null)
|
||||
{
|
||||
value = this.beeSlots[slot].copy();
|
||||
value.stackSize = Math.min(count, this.beeSlots[slot].stackSize);
|
||||
this.beeSlots[slot].stackSize -= value.stackSize;
|
||||
if (this.beeSlots[slot].stackSize == 0)
|
||||
{
|
||||
this.beeSlots[slot] = null;
|
||||
}
|
||||
}
|
||||
markDirty();
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
{
|
||||
ItemStack value = null;
|
||||
if (this.beeSlots[slot] != null)
|
||||
{
|
||||
value = this.beeSlots[slot];
|
||||
this.beeSlots[slot] = null;
|
||||
}
|
||||
markDirty();
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagRoot)
|
||||
{
|
||||
super.readFromNBT(tagRoot);
|
||||
|
||||
NBTTagList nbttaglist = tagRoot.getTagList("Items", Constants.NBT.TAG_COMPOUND);
|
||||
this.beeSlots = new ItemStack[SLOT_COUNT];
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); ++i)
|
||||
{
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
byte b0 = nbttagcompound1.getByte("Slot");
|
||||
|
||||
if (b0 >= 0 && b0 < this.beeSlots.length)
|
||||
{
|
||||
this.beeSlots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
this.currentBeeHealth = tagRoot.getInteger("currentBeeHealth");
|
||||
this.throttle = tagRoot.getInteger("throttle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagRoot)
|
||||
{
|
||||
super.writeToNBT(tagRoot);
|
||||
|
||||
NBTTagList inventory = new NBTTagList();
|
||||
for (int i = 0; i < this.beeSlots.length; ++i)
|
||||
{
|
||||
if (this.beeSlots[i] != null)
|
||||
{
|
||||
NBTTagCompound itemTag = new NBTTagCompound();
|
||||
itemTag.setByte("Slot", (byte)i);
|
||||
this.beeSlots[i].writeToNBT(itemTag);
|
||||
inventory.appendTag(itemTag);
|
||||
}
|
||||
}
|
||||
tagRoot.setTag("Items", inventory);
|
||||
tagRoot.setInteger("currentBeeHealth", this.currentBeeHealth);
|
||||
tagRoot.setInteger("throttle", this.throttle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack itemStack)
|
||||
{
|
||||
this.beeSlots[slot] = itemStack;
|
||||
if (this.beeSlots[slot] != null)
|
||||
{
|
||||
this.beeSlots[slot].stackSize = Math.min(this.beeSlots[slot].stackSize,
|
||||
this.beeSlots[slot].getItem().getItemStackLimit(this.beeSlots[slot]));
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName()
|
||||
{
|
||||
return "container.effectJar";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() { }
|
||||
|
||||
@Override
|
||||
public void closeInventory() { }
|
||||
}
|
||||
Reference in new issue
Block a user