mirror of
https://github.com/GTNewHorizons/MagicBees.git
synced 2026-11-13 00:37:51 +00:00
Adding Beegonia subtile.
This commit is contained in:
1 parent
a7076ce817
commit
55840ac08e
6 files changed
+218
-4
No files matched your search
@@ -33,6 +33,7 @@ import magicbees.item.types.WaxType;
|
||||
import magicbees.main.utils.LocalizationManager;
|
||||
import magicbees.main.utils.LogHelper;
|
||||
import magicbees.main.utils.VersionInfo;
|
||||
import magicbees.main.utils.compat.BotaniaHelper;
|
||||
import magicbees.main.utils.compat.ThaumcraftHelper;
|
||||
import magicbees.storage.BackpackDefinition;
|
||||
import magicbees.tileentity.TileEntityEffectJar;
|
||||
@@ -339,6 +340,7 @@ public class Config
|
||||
|
||||
p = configuration.get("modules", "Botania", true);
|
||||
botaniaActive = p.getBoolean();
|
||||
BotaniaHelper.doBotaniaModuleConfigs(configuration);
|
||||
}
|
||||
|
||||
private void doGeneralConfigs() {
|
||||
|
||||
@@ -3,10 +3,21 @@ package magicbees.main.utils.compat;
|
||||
import magicbees.main.Config;
|
||||
import magicbees.main.utils.BlockInterface;
|
||||
import magicbees.main.utils.ItemInterface;
|
||||
import magicbees.main.utils.compat.botania.BotaniaSignature;
|
||||
import magicbees.main.utils.compat.botania.SubTileBeegonia;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BotaniaHelper {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static IIcon subtileIcons[];
|
||||
|
||||
public enum ManaResource {
|
||||
MANASTEEL,
|
||||
MANAPEARL,
|
||||
@@ -31,6 +42,8 @@ public class BotaniaHelper {
|
||||
private static boolean isBotaniaActive = false;
|
||||
public static final String Name = "Botania";
|
||||
|
||||
public static double beegoniaManaMultiplier;
|
||||
|
||||
public static boolean isActive() {
|
||||
return isBotaniaActive;
|
||||
}
|
||||
@@ -45,10 +58,17 @@ public class BotaniaHelper {
|
||||
if (isActive()) {
|
||||
getBlocks();
|
||||
getItems();
|
||||
|
||||
registerSubtiles();
|
||||
}
|
||||
}
|
||||
|
||||
public static void postInit() {
|
||||
if (isActive()) {
|
||||
BotaniaAPI.registerSubTile(SubTileBeegonia.NAME, SubTileBeegonia.class);
|
||||
BotaniaAPI.registerSubTileSignature(SubTileBeegonia.class, new BotaniaSignature(SubTileBeegonia.NAME));
|
||||
BotaniaAPI.addSubTileToCreativeMenu(SubTileBeegonia.NAME);
|
||||
}
|
||||
}
|
||||
|
||||
public static void getBlocks() {
|
||||
@@ -59,4 +79,17 @@ public class BotaniaHelper {
|
||||
public static void getItems() {
|
||||
Config.botManaResource = ItemInterface.getItem(Name, "manaResource");
|
||||
}
|
||||
|
||||
private static void registerSubtiles() {
|
||||
BotaniaAPI.registerSubTile(SubTileBeegonia.NAME, SubTileBeegonia.class);
|
||||
}
|
||||
|
||||
public static void doBotaniaModuleConfigs(Configuration configuration) {
|
||||
Property p;
|
||||
String section = "botaniaPlugin";
|
||||
|
||||
p = configuration.get(section, "beegoniaManaMultiplier", 1);
|
||||
p.comment = "Multiplyer for the Beegonia's mana generation. Default: 1.0 (Affects duration, not throughput)";
|
||||
beegoniaManaMultiplier = p.getDouble();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package magicbees.main.utils.compat.botania;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import vazkii.botania.api.subtile.signature.SubTileSignature;
|
||||
|
||||
public class BotaniaSignature extends SubTileSignature {
|
||||
|
||||
private String name;
|
||||
IIcon icon;
|
||||
|
||||
public BotaniaSignature(String subtileName) {
|
||||
this.name = subtileName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconForStack(ItemStack stack) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register) {
|
||||
icon = register.registerIcon("magicbees:" + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForStack(ItemStack stack) {
|
||||
return "tile.botania:flower." + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedLoreTextForStack(ItemStack stack) {
|
||||
return "tile.botania:flower." + name + ".lore";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package magicbees.main.utils.compat.botania;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import magicbees.bees.BeeManager;
|
||||
import magicbees.main.utils.compat.BotaniaHelper;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.subtile.SubTileGenerating;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.api.apiculture.IAlleleBeeSpecies;
|
||||
import forestry.api.apiculture.IBee;
|
||||
|
||||
public class SubTileBeegonia extends SubTileGenerating {
|
||||
|
||||
public static final String NAME = "beegonia";
|
||||
|
||||
private static final int DRONE_BURN_TIME_BASE = 100;
|
||||
private static final int ITEM_STACK_AGE_THRESHOLD = 60;
|
||||
private static final int RANGE = 3;
|
||||
|
||||
private int burnTimeLeft = 0;
|
||||
|
||||
private void searchForDroneStack() {
|
||||
if (!supertile.getWorldObj().isRemote && mana < getMaxMana()) {
|
||||
boolean needsSync = false;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityItem> items = supertile.getWorldObj().getEntitiesWithinAABB(EntityItem.class,
|
||||
AxisAlignedBB.getBoundingBox(supertile.xCoord - RANGE, supertile.yCoord - RANGE, supertile.zCoord - RANGE,
|
||||
supertile.xCoord + RANGE + 1, supertile.yCoord + RANGE + 1, supertile.zCoord + RANGE + 1));
|
||||
for (EntityItem item : items) {
|
||||
if (item.age >= ITEM_STACK_AGE_THRESHOLD && !item.isDead) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if (BeeManager.beeRoot.isDrone(stack)) {
|
||||
IBee bee = BeeManager.beeRoot.getMember(stack);
|
||||
|
||||
if (stack.stackSize > 0) {
|
||||
stack.stackSize--;
|
||||
burnTimeLeft = (int)(DRONE_BURN_TIME_BASE * getSpeciesScaledComplexity(bee.getGenome().getPrimary()) * BotaniaHelper.beegoniaManaMultiplier);
|
||||
needsSync = true;
|
||||
|
||||
supertile.getWorldObj().playSoundEffect(supertile.xCoord, supertile.yCoord, supertile.zCoord, "botania:endoflame", 0.2F, 1F);
|
||||
}
|
||||
|
||||
if (stack.stackSize <= 0) {
|
||||
item.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needsSync) {
|
||||
sync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getSpeciesScaledComplexity(IAlleleBeeSpecies species) {
|
||||
if (species == null) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
int halfComplexity = species.getComplexity() / 2;
|
||||
return (halfComplexity >= 1) ? halfComplexity : 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
if (linkedCollector != null) {
|
||||
if (burnTimeLeft > 0) {
|
||||
burnTimeLeft--;
|
||||
}
|
||||
else {
|
||||
searchForDroneStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromPacketNBT(NBTTagCompound cmp) {
|
||||
super.readFromPacketNBT(cmp);
|
||||
|
||||
burnTimeLeft = cmp.getInteger("burnTimeLeft");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacketNBT(NBTTagCompound cmp) {
|
||||
super.writeToPacketNBT(cmp);
|
||||
|
||||
cmp.setInteger("burnTimeLeft", burnTimeLeft);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxMana() {
|
||||
return 600;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValueForPassiveGeneration() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canGeneratePassively() {
|
||||
return burnTimeLeft > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDelayBetweenPassiveGeneration() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassiveFlower() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0xFFFF96;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon() {
|
||||
return BotaniaAPI.getSignatureForName(NAME).getIconForStack(null);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user