Merge remote-tracking branch 'origin/mc-1.12' into 1.12

This commit is contained in:
Nedelosk committed 2018-01-05 16:42:56 +01:00
commit f78e21e31a
4 files changed
+48 -27

No files matched your search

Executable → Regular
+2 -2
View File
@@ -1,11 +1,11 @@
mcversion=1.12.2
forgeversion=14.23.1.2577
forgeversion=14.23.1.2582
mcp_mappings=snapshot_20170918
curse_project_id=59751
tesla_version=1.0.60
tesla_mcversion=1.12
jei_version=4.8.0.103
jei_version=4.8.5.138
jei_mcversion=1.12.2
ic2_version=2.8.24-ex112
@@ -10,12 +10,13 @@
******************************************************************************/
package forestry.arboriculture.blocks;
import com.google.common.base.MoreObjects;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import com.google.common.base.Optional;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
@@ -23,6 +24,7 @@ import forestry.core.blocks.properties.PropertyAllele;
import forestry.core.config.Constants;
public class PropertyTree extends PropertyAllele<IAlleleTreeSpecies> {
private static final Map<String, IAlleleTreeSpecies> namesMap = new HashMap<>();
public PropertyTree(String name) {
super(name);
@@ -33,16 +35,6 @@ public class PropertyTree extends PropertyAllele<IAlleleTreeSpecies> {
return IAlleleTreeSpecies.class;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("name", this.name).add("clazz", IAlleleTreeSpecies.class).add("values", this.getAllowedValues()).toString();
}
@Override
public int hashCode() {
return 31 * IAlleleTreeSpecies.class.hashCode() + this.name.hashCode();
}
@Override
public List<IAlleleTreeSpecies> getAllowedValues() {
List<IAlleleTreeSpecies> trees = new ArrayList<>();
@@ -59,4 +51,16 @@ public class PropertyTree extends PropertyAllele<IAlleleTreeSpecies> {
return value.getUID().replace(Constants.MOD_ID + ".tree", "").toLowerCase(Locale.ENGLISH);
}
@Override
public Optional<IAlleleTreeSpecies> parseValue(String value) {
if (namesMap.isEmpty()) {
List<IAlleleTreeSpecies> allowedValues = getAllowedValues();
for (IAlleleTreeSpecies allowedValue : allowedValues) {
String propertyName = getName(allowedValue);
namesMap.put(propertyName, allowedValue);
}
}
return Optional.fromNullable(namesMap.get(value));
}
}
@@ -12,6 +12,7 @@ package forestry.core.blocks.properties;
import java.util.List;
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
@@ -30,6 +31,20 @@ public abstract class PropertyAllele<A extends IAlleleProperty<A>> implements IP
return this.name;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("name", this.name)
.add("clazz", getValueClass())
.add("values", this.getAllowedValues())
.toString();
}
@Override
public final int hashCode() {
return 31 * getValueClass().hashCode() + this.name.hashCode();
}
@Override
public Optional<A> parseValue(String value) {
IAllele allele = AlleleManager.alleleRegistry.getAllele(value);
@@ -10,18 +10,19 @@
******************************************************************************/
package forestry.lepidopterology.blocks;
import com.google.common.base.MoreObjects;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import forestry.api.arboriculture.IAlleleTreeSpecies;
import com.google.common.base.Optional;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.lepidopterology.IAlleleButterflyCocoon;
import forestry.core.blocks.properties.PropertyAllele;
public class PropertyCocoon extends PropertyAllele<IAlleleButterflyCocoon> {
private static final Map<String, IAlleleButterflyCocoon> namesMap = new HashMap<>();
public PropertyCocoon(String name) {
super(name);
@@ -32,16 +33,6 @@ public class PropertyCocoon extends PropertyAllele<IAlleleButterflyCocoon> {
return IAlleleButterflyCocoon.class;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("name", this.name).add("clazz", IAlleleButterflyCocoon.class).add("values", this.getAllowedValues()).toString();
}
@Override
public int hashCode() {
return 31 * IAlleleTreeSpecies.class.hashCode() + this.name.hashCode();
}
@Override
public List<IAlleleButterflyCocoon> getAllowedValues() {
List<IAlleleButterflyCocoon> trees = new ArrayList<>();
@@ -58,4 +49,15 @@ public class PropertyCocoon extends PropertyAllele<IAlleleButterflyCocoon> {
return value.getCocoonName();
}
@Override
public Optional<IAlleleButterflyCocoon> parseValue(String value) {
if (namesMap.isEmpty()) {
List<IAlleleButterflyCocoon> allowedValues = getAllowedValues();
for (IAlleleButterflyCocoon allowedValue : allowedValues) {
String propertyName = getName(allowedValue);
namesMap.put(propertyName, allowedValue);
}
}
return Optional.fromNullable(namesMap.get(value));
}
}