mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-24 22:04:34 +00:00
#773 try to catch the cause of the apiculture config crash
This commit is contained in:
1 parent
44538c1e03
commit
b1db58b8a4
3 files changed
+22
-6
No files matched your search
@@ -10,7 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.flowers;
|
||||
|
||||
import java.util.Objects;
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
@@ -52,7 +52,7 @@ final class Flower implements IFlower {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(block);
|
||||
return Objects.hashCode(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,4 +74,10 @@ final class Flower implements IFlower {
|
||||
public void setWeight(double weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).add("block", block).add("meta", meta).add("weight", weight).toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,6 +48,7 @@ import forestry.api.genetics.IFlowerGrowthRule;
|
||||
import forestry.api.genetics.IFlowerRegistry;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.apiculture.BeeHousingModifier;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.vect.MutableVect;
|
||||
import forestry.core.vect.Vect;
|
||||
import forestry.plugins.PluginManager;
|
||||
@@ -110,6 +111,10 @@ public final class FlowerRegistry implements IFlowerRegistry {
|
||||
Flower newFlower = new Flower(block, meta, weight);
|
||||
|
||||
for (String flowerType : flowerTypes) {
|
||||
if (flowerType == null) {
|
||||
throw new NullPointerException("Tried to register flower with null type. " + block);
|
||||
}
|
||||
|
||||
Set<IFlower> flowers = this.registeredFlowers.get(flowerType);
|
||||
flowers.add(newFlower);
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
}
|
||||
Property property = config.get("beekeeping.flowers." + flowerType, "accepted", defaultAccepted);
|
||||
property.comment = acceptedFlowerMessage;
|
||||
parseAcceptedFlowers(property, flowerType);
|
||||
parseAcceptedFlowers(property.getStringList(), flowerType);
|
||||
|
||||
String[] defaultPlantable = defaultPlantableFlowers.get(flowerType);
|
||||
if (defaultPlantable == null) {
|
||||
@@ -429,6 +429,11 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
if (flowers != null) {
|
||||
for (IFlower flower : flowers) {
|
||||
String name = flower.getBlock().delegate.name();
|
||||
if (name == null) {
|
||||
Proxies.log.warning("Could not find name for flower: " + flower + " with type: " + flowerType);
|
||||
continue;
|
||||
}
|
||||
|
||||
int meta = flower.getMeta();
|
||||
if (flower.getMeta() != OreDictionary.WILDCARD_VALUE) {
|
||||
name = name + ':' + meta;
|
||||
@@ -1007,15 +1012,15 @@ public class PluginApiculture extends ForestryPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private static void parseAcceptedFlowers(Property property, String flowerType) {
|
||||
List<StackUtils.Stack> acceptedFlowerItemStacks = StackUtils.parseStackStrings(property.getStringList(), OreDictionary.WILDCARD_VALUE);
|
||||
private static void parseAcceptedFlowers(String[] acceptedFlowers, String flowerType) {
|
||||
List<StackUtils.Stack> acceptedFlowerItemStacks = StackUtils.parseStackStrings(acceptedFlowers, OreDictionary.WILDCARD_VALUE);
|
||||
for (StackUtils.Stack acceptedFlower : acceptedFlowerItemStacks) {
|
||||
Block acceptedFlowerBlock = acceptedFlower.getBlock();
|
||||
int meta = acceptedFlower.getMeta();
|
||||
if (acceptedFlowerBlock != null) {
|
||||
FlowerManager.flowerRegistry.registerAcceptableFlower(acceptedFlowerBlock, meta, flowerType);
|
||||
} else {
|
||||
Proxies.log.warning("No block found for '" + acceptedFlower + "' in config '" + property.getName() + "'.");
|
||||
Proxies.log.warning("No block found for '" + acceptedFlower + "' in apiculture config for '" + flowerType + "'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user