This commit is contained in:
nossr50
2023-12-16 17:45:17 -08:00
parent 9e1f5b44a6
commit dd04ee48b9
7 changed files with 32 additions and 8 deletions

View File

@@ -22,6 +22,9 @@ import java.util.HashSet;
public final class BlockUtils {
public static final String SHORT_GRASS = "SHORT_GRASS";
public static final String GRASS = "GRASS";
private BlockUtils() {
}
@@ -38,6 +41,21 @@ public final class BlockUtils {
blockState.setMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS, new BonusDropMeta(1, mcMMO.p));
}
/**
* Util method for compatibility across Minecraft versions, grabs the {@link Material} enum for short_grass
*
* @return the {@link Material} enum for short_grass
*/
public static Material getShortGrass() {
if (Material.getMaterial(SHORT_GRASS) != null) {
return Material.getMaterial(SHORT_GRASS);
} else if (Material.getMaterial(GRASS) != null) {
return Material.getMaterial(GRASS);
} else {
throw new UnsupportedOperationException("Unable to find short grass material");
}
}
/**
* Set up the state for a block to be seen as unnatural and cleanup any unwanted metadata from the block
* @param block target block