| 1 | package net.minecraft.util;
|
| 2 |
|
| 3 | import org.apache.commons.lang3.Validate;
|
| 4 |
|
| 5 | public class ResourceLocation
|
| 6 | {
|
| 7 | protected final String resourceDomain;
|
| 8 | protected final String resourcePath;
|
| 9 |
|
| 10 | protected ResourceLocation(int p_i45928_1_, String... resourceName)
|
| 11 | {
|
| 12 | this.resourceDomain = org.apache.commons.lang3.StringUtils.isEmpty(resourceName[0]) ? "minecraft" : resourceName[0].toLowerCase();
|
| 13 | this.resourcePath = resourceName[1];
|
| 14 | Validate.notNull(this.resourcePath);
|
| 15 | }
|
| 16 |
|
| 17 | public ResourceLocation(String resourceName)
|
| 18 | {
|
| 19 | this(0, splitObjectName(resourceName));
|
| 20 | }
|
| 21 |
|
| 22 | public ResourceLocation(String resourceDomainIn, String resourcePathIn)
|
| 23 | {
|
| 24 | this(0, new String[] {resourceDomainIn, resourcePathIn});
|
| 25 | }
|
| 26 |
|
| 27 | /**
|
| 28 | * Splits an object name (such as minecraft:apple) into the domain and path parts and returns these as an array of
|
| 29 | * length 2. If no colon is present in the passed value the returned array will contain {null, toSplit}.
|
| 30 | */
|
| 31 | protected static String[] splitObjectName(String toSplit)
|
| 32 | {
|
| 33 | String[] astring = new String[] {null, toSplit};
|
| 34 | int i = toSplit.indexOf(58);
|
| 35 |
|
| 36 | if (i >= 0)
|
| 37 | {
|
| 38 | astring[1] = toSplit.substring(i + 1, toSplit.length());
|
| 39 |
|
| 40 | if (i > 1)
|
| 41 | {
|
| 42 | astring[0] = toSplit.substring(0, i);
|
| 43 | }
|
| 44 | }
|
| 45 |
|
| 46 | return astring;
|
| 47 | }
|
| 48 |
|
| 49 | public String getResourcePath()
|
| 50 | {
|
| 51 | return this.resourcePath;
|
| 52 | }
|
| 53 |
|
| 54 | public String getResourceDomain()
|
| 55 | {
|
| 56 | return this.resourceDomain;
|
| 57 | }
|
| 58 |
|
| 59 | public String toString()
|
| 60 | {
|
| 61 | return this.resourceDomain + ':' + this.resourcePath;
|
| 62 | }
|
| 63 |
|
| 64 | public boolean equals(Object p_equals_1_)
|
| 65 | {
|
| 66 | if (this == p_equals_1_)
|
| 67 | {
|
| 68 | return true;
|
| 69 | }
|
| 70 | else if (!(p_equals_1_ instanceof ResourceLocation))
|
| 71 | {
|
| 72 | return false;
|
| 73 | }
|
| 74 | else
|
| 75 | {
|
| 76 | ResourceLocation resourcelocation = (ResourceLocation)p_equals_1_;
|
| 77 | return this.resourceDomain.equals(resourcelocation.resourceDomain) && this.resourcePath.equals(resourcelocation.resourcePath);
|
| 78 | }
|
| 79 | }
|
| 80 |
|
| 81 | public int hashCode()
|
| 82 | {
|
| 83 | return 31 * this.resourceDomain.hashCode() + this.resourcePath.hashCode();
|
| 84 | }
|
| 85 | }
|
| 86 |
|