Compare commits

..
2 Commits
Author SHA1 Message Date
Zereff06 834d7b9d4a add setting to config-> disable butterflies spawn
+ default disable is false
2023-03-09 11:34:07 +02:00
Zereff06 3d55aa887f bs 2023-03-09 00:14:54 +02:00
9 changed files with 23 additions and 61 deletions

No files matched your search

@@ -43,10 +43,6 @@ public class DefaultBeeModifier implements IBeeModifier {
return false;
}
public boolean isSelfUnlighted() {
return false;
}
public boolean isSunlightSimulated() {
return false;
}
@@ -54,17 +54,10 @@ public interface IBeeModifier {
boolean isSealed();
/**
* @return Boolean indicating if housing can ignore darkness/night. Cannot be used together with SelfUnlighted
* @return Boolean indicating if housing can ignore darkness/night
*/
boolean isSelfLighted();
/**
* @return Boolean indicating if housing can ignore lightness/day. Cannot be used together with SelfLighted
*/
default boolean isSelfUnlighted() {
return false;
}
/**
* @return Boolean indicating if housing can ignore not seeing the sky
*/
@@ -51,7 +51,7 @@ public class BeeHousingModifier implements IBeeModifier {
public float getProductionModifier(IBeeGenome genome, final float currentModifier) {
float modifierValue = 1.0f;
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
modifierValue += modifier.getProductionModifier(genome, modifierValue + currentModifier);
modifierValue *= modifier.getProductionModifier(genome, modifierValue * currentModifier);
}
return modifierValue;
}
@@ -94,16 +94,6 @@ public class BeeHousingModifier implements IBeeModifier {
return false;
}
@Override
public boolean isSelfUnlighted() {
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
if (modifier.isSelfUnlighted()) {
return true;
}
}
return false;
}
@Override
public boolean isSunlightSimulated() {
for (IBeeModifier modifier : beeHousing.getBeeModifiers()) {
@@ -248,7 +248,7 @@ public class Bee extends IndividualLiving implements IBee {
// / Night or darkness requires nocturnal species
if (world.isDaytime()) {
if (!canWorkDuringDay(beeModifier)) {
if (!canWorkDuringDay()) {
errorStates.add(EnumErrorCode.NOT_NIGHT);
}
} else {
@@ -258,7 +258,7 @@ public class Bee extends IndividualLiving implements IBee {
}
if (housing.getBlockLightValue() > Constants.APIARY_MIN_LEVEL_LIGHT) {
if (!canWorkDuringDay(beeModifier)) {
if (!canWorkDuringDay()) {
errorStates.add(EnumErrorCode.NOT_GLOOMY);
}
} else {
@@ -308,16 +308,12 @@ public class Bee extends IndividualLiving implements IBee {
return errorStates;
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean canWorkAtNight(IBeeModifier beeModifier) {
return (genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfLighted())
&& !(beeModifier.isSelfUnlighted() && beeModifier.isSelfLighted());
return genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfLighted();
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean canWorkDuringDay(IBeeModifier beeModifier) {
return (!genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfUnlighted())
&& !(beeModifier.isSelfUnlighted() && beeModifier.isSelfLighted());
private boolean canWorkDuringDay() {
return !genome.getPrimary().isNocturnal() || genome.getNocturnal();
}
private boolean canWorkUnderground(IBeeModifier beeModifier) {
@@ -455,11 +451,12 @@ public class Bee extends IndividualLiving implements IBee {
// / PRODUCTION
@Override
public ItemStack[] getProduceList() {
ArrayList<ItemStack> products = new ArrayList<>();
IAlleleBeeSpecies primary = genome.getPrimary();
IAlleleBeeSpecies secondary = genome.getSecondary();
ArrayList<ItemStack> products = new ArrayList<>(primary.getProductChances().keySet());
products.addAll(primary.getProductChances().keySet());
Set<ItemStack> secondaryProducts = secondary.getProductChances().keySet();
// Remove duplicates
@@ -478,13 +475,13 @@ public class Bee extends IndividualLiving implements IBee {
}
}
return products.toArray(new ItemStack[0]);
return products.toArray(new ItemStack[products.size()]);
}
@Override
public ItemStack[] getSpecialtyList() {
Set<ItemStack> specialties = genome.getPrimary().getSpecialtyChances().keySet();
return specialties.toArray(new ItemStack[0]);
return specialties.toArray(new ItemStack[specialties.size()]);
}
@Override
@@ -516,6 +513,7 @@ public class Bee extends IndividualLiving implements IBee {
float speed = genome.getSpeed();
float prodModifier = beeHousingModifier.getProductionModifier(genome, 1f)
* beeModeModifier.getProductionModifier(genome, 1f);
prodModifier /= 4f;
// / Primary Products
for (Map.Entry<ItemStack, Float> entry : primary.getProductChances().entrySet()) {
@@ -539,7 +537,7 @@ public class Bee extends IndividualLiving implements IBee {
}
}
ItemStack[] productsArray = products.toArray(new ItemStack[0]);
ItemStack[] productsArray = products.toArray(new ItemStack[products.size()]);
ChunkCoordinates housingCoordinates = housing.getCoordinates();
return genome.getFlowerProvider().affectProducts(
housing.getWorld(),
@@ -552,9 +550,9 @@ public class Bee extends IndividualLiving implements IBee {
public static float getFinalChance(float chance, float beeSpeed, float productionModifier, float t) {
chance *= 100f;
return (float) (2.8 * Math.pow(chance, 0.52)
* Math.pow((productionModifier + t), 0.52)
* Math.pow(beeSpeed, 0.37)) / 100.f;
return (float) (((1f + t / 6f) * Math.sqrt(chance) * 2f * (1f + beeSpeed)
+ Math.pow(productionModifier, Math.cbrt(chance))
- 3f) / 100f);
}
/* REPRODUCTION */
@@ -31,7 +31,7 @@ import forestry.mail.gui.GuiMailboxInfo;
public class Config {
public static boolean disableButterfly;
public static Boolean DISABLE_BUTTERFLY;
public static final String CATEGORY_COMMON = "common";
public static final String CATEGORY_FLUIDS = "fluids";
@@ -147,7 +147,7 @@ public class Config {
configCommon = new LocalizedConfiguration(configFileCommon, "1.2.0");
disableButterfly = configCommon.getBooleanLocalized("mobs", "disable.butterfly", false);
DISABLE_BUTTERFLY = configCommon.getBooleanLocalized("mobs", "disable.butterfly", false);
gameMode = configCommon
.getStringLocalized("difficulty", "game.mode", "EASY", new String[] { "OP, EASY, NORMAL, HARD" });
@@ -231,14 +231,10 @@ public abstract class BlockUtil {
private static Class<? extends Block> BW_MetaGenerated_WerkstoffBlocksClass;
private static Block BWBlocks;
private static Class<? extends Block> GTBlockMachines_Class;
private static Block GTBlockMachines;
private static final boolean bw = Loader.isModLoaded("bartworks");
private static final boolean gt = Loader.isModLoaded("gregtech");
private static boolean bw = Loader.isModLoaded("bartworks");
static {
if (bw) try {
// noinspection unchecked
BW_MetaGenerated_WerkstoffBlocksClass = (Class<? extends Block>) Class
.forName("com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_WerkstoffBlocks");
BWBlocks = (Block) Class.forName("com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader")
@@ -246,13 +242,6 @@ public abstract class BlockUtil {
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
if (gt) try {
// noinspection unchecked
GTBlockMachines_Class = (Class<? extends Block>) Class.forName("gregtech.common.blocks.GT_Block_Machines");
GTBlockMachines = (Block) Class.forName("gregtech.api.GregTech_API").getField("sBlockMachines").get(null);
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
public static ItemStack getItemStackFromBlockBelow(World world, int x, int y, int z,
@@ -271,10 +260,6 @@ public abstract class BlockUtil {
return new ItemStack(BWBlocks, 1, block.getDamageValue(world, x, y - depth, z));
}
if (gt && GTBlockMachines_Class.isInstance(block)) {
return new ItemStack(GTBlockMachines, 1, block.getDamageValue(world, x, y - depth, z));
}
return new ItemStack(block, 1, world.getBlockMetadata(x, y - depth, z));
}
}
@@ -23,7 +23,7 @@ public class ButterflySpawner implements ILeafTickHandler {
@Override
public boolean onRandomLeafTick(ITree tree, World world, int x, int y, int z, boolean isDestroyed) {
if (Config.disableButterfly) {
if (Config.DISABLE_BUTTERFLY) {
return false;
}
@@ -370,7 +370,7 @@ public class EntityButterfly extends EntityCreature implements IEntityButterfly
@Override
protected boolean canDespawn() {
if (Config.disableButterfly) {
if (Config.DISABLE_BUTTERFLY) {
this.setDead();
}
return ticksExisted > MAX_LIFESPAN;
@@ -92,7 +92,7 @@ public class ItemButterflyGE extends ItemGE {
@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");
if (Config.DISABLE_BUTTERFLY && type == EnumFlutterType.BUTTERFLY) list.add(ChatFormatting.RED + "Disabled");
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@@ -115,7 +115,7 @@ public class ItemButterflyGE extends ItemGE {
@Override
public boolean onEntityItemUpdate(EntityItem entityItem) {
if (type != EnumFlutterType.BUTTERFLY || Config.disableButterfly) {
if (type != EnumFlutterType.BUTTERFLY || Config.DISABLE_BUTTERFLY) {
return false;
}
if (entityItem.worldObj.isRemote || entityItem.ticksExisted < 80) {