22
33import gregtech .api .unification .OreDictUnifier ;
44import gregtech .api .unification .material .Material ;
5+ import gregtech .api .unification .ore .OrePrefix ;
6+ import gregtech .api .unification .stack .UnificationEntry ;
57import gregtech .api .util .LocalizationUtils ;
68
79import net .minecraft .block .Block ;
1921import forestry .api .genetics .IGenome ;
2022import forestry .api .genetics .IMutationCondition ;
2123import forestry .core .tiles .TileUtil ;
24+ import org .jetbrains .annotations .NotNull ;
2225
2326import java .util .HashSet ;
2427import java .util .Set ;
2528
26- import static org .apache .commons .lang3 .StringUtils .capitalize ;
27-
2829public class MaterialMutationCondition implements IMutationCondition {
2930
30- private final Set <IBlockState > acceptedBlocks = new HashSet ();
31+ private final Set <IBlockState > acceptedBlocks = new HashSet <> ();
3132 private final String displayName ;
3233
33- public MaterialMutationCondition (Material material ) {
34+ public MaterialMutationCondition (@ NotNull Material material ) {
3435 this .displayName = LocalizationUtils .format ("gregtech.mutation.block_of" , material .getLocalizedName ());
35- String oredictName = "block" + capitalize ( material . getName () );
36+ String oreDictName = new UnificationEntry ( OrePrefix . block , material ). toString ( );
3637
37- for (ItemStack ore : OreDictUnifier .getAllWithOreDictionaryName (oredictName )) {
38+ for (ItemStack ore : OreDictUnifier .getAllWithOreDictionaryName (oreDictName )) {
3839 if (!ore .isEmpty ()) {
3940 Item oreItem = ore .getItem ();
4041 Block oreBlock = Block .getBlockFromItem (oreItem );
@@ -45,8 +46,10 @@ public MaterialMutationCondition(Material material) {
4546 }
4647 }
4748
48- public float getChance (World world , BlockPos pos , IAllele allele0 , IAllele allele1 , IGenome genome0 ,
49- IGenome genome1 , IClimateProvider climate ) {
49+ @ Override
50+ public float getChance (@ NotNull World world , @ NotNull BlockPos pos , @ NotNull IAllele allele0 ,
51+ @ NotNull IAllele allele1 , @ NotNull IGenome genome0 ,
52+ @ NotNull IGenome genome1 , @ NotNull IClimateProvider climate ) {
5053 TileEntity tile ;
5154 do {
5255 pos = pos .down ();
@@ -57,7 +60,8 @@ public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allel
5760 return this .acceptedBlocks .contains (blockState ) ? 1.0F : 0.0F ;
5861 }
5962
60- public String getDescription () {
63+ @ Override
64+ public @ NotNull String getDescription () {
6165 return LocalizationUtils .format ("for.mutation.condition.resource" , this .displayName );
6266 }
6367}
0 commit comments