add setting to config-> disable butterflies spawn (#44)

* bs

* add setting to config-> disable butterflies spawn
+ default disable is false

* changed name DISABLE_BUTTERFLY to disableButterfly

* changed Boolean to boolean
(for disableButterfly)
This commit is contained in:
Quetz4l authored and GitHub committed 2023-03-20 21:48:43 +01:00
1 parent 7e60669620
commit ca9ebbc0ed
5 files changed
+311 -20

No files matched your search

@@ -31,6 +31,7 @@ import forestry.mail.gui.GuiMailboxInfo;
public class Config {
public static boolean disableButterfly;
public static final String CATEGORY_COMMON = "common";
public static final String CATEGORY_FLUIDS = "fluids";
@@ -146,6 +147,8 @@ public class Config {
configCommon = new LocalizedConfiguration(configFileCommon, "1.2.0");
disableButterfly = configCommon.getBooleanLocalized("mobs", "disable.butterfly", false);
gameMode = configCommon
.getStringLocalized("difficulty", "game.mode", "EASY", new String[] { "OP, EASY, NORMAL, HARD" });
@@ -14,6 +14,7 @@ import forestry.api.arboriculture.ILeafTickHandler;
import forestry.api.arboriculture.ITree;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.IButterfly;
import forestry.core.config.Config;
import forestry.core.utils.Log;
import forestry.lepidopterology.entities.EntityButterfly;
import forestry.plugins.PluginLepidopterology;
@@ -22,6 +23,9 @@ public class ButterflySpawner implements ILeafTickHandler {
@Override
public boolean onRandomLeafTick(ITree tree, World world, int x, int y, int z, boolean isDestroyed) {
if (Config.disableButterfly) {
return false;
}
if (world.rand.nextFloat() >= tree.getGenome().getSappiness() * tree.getGenome().getYield()) {
return false;
@@ -48,6 +48,7 @@ import forestry.api.lepidopterology.IButterflyGenome;
import forestry.api.lepidopterology.IButterflyRoot;
import forestry.api.lepidopterology.IEntityButterfly;
import forestry.api.lepidopterology.ILepidopteristTracker;
import forestry.core.config.Config;
import forestry.core.utils.ItemStackUtil;
import forestry.lepidopterology.genetics.Butterfly;
@@ -369,6 +370,9 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
@Override
protected boolean canDespawn() {
if (Config.disableButterfly) {
this.setDead();
}
return ticksExisted > MAX_LIFESPAN;
}
@@ -21,6 +21,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import com.mojang.realmsclient.gui.ChatFormatting;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import forestry.api.core.Tabs;
@@ -87,6 +89,12 @@ public class ItemButterflyGE extends ItemGE {
return butterfly.getDisplayName();
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean flag) {
super.addInformation(itemstack, player, list, flag);
if (Config.disableButterfly && type == EnumFlutterType.BUTTERFLY) list.add(ChatFormatting.RED + "Disabled");
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) {
@@ -107,7 +115,7 @@ public class ItemButterflyGE extends ItemGE {
@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
if (type != EnumFlutterType.BUTTERFLY) {
if (type != EnumFlutterType.BUTTERFLY || Config.disableButterfly) {
return false;
}
if (entityItem.worldObj.isRemote || entityItem.ticksExisted < 80) {