Mapper.java 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. package me.km.utils;
  2. import net.minecraft.block.Block;
  3. import net.minecraft.enchantment.Enchantment;
  4. import net.minecraft.item.Item;
  5. import net.minecraft.particles.ParticleType;
  6. import net.minecraft.potion.Effect;
  7. import net.minecraft.state.Property;
  8. import net.minecraft.state.properties.BlockStateProperties;
  9. import net.minecraft.util.ResourceLocation;
  10. import net.minecraft.util.SoundCategory;
  11. import net.minecraft.util.SoundEvent;
  12. import net.minecraftforge.registries.ForgeRegistries;
  13. public class Mapper {
  14. public static SoundEvent getSound(String name) {
  15. return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(name));
  16. }
  17. public static SoundCategory getSoundCategory(String name) {
  18. for(SoundCategory sc : SoundCategory.values()) {
  19. if(sc.getName().equals(name)) {
  20. return sc;
  21. }
  22. }
  23. return SoundCategory.MASTER;
  24. }
  25. public static Enchantment getEnchantment(String name) {
  26. return ForgeRegistries.ENCHANTMENTS.getValue(new ResourceLocation(name));
  27. }
  28. public static Effect getPotion(String name) {
  29. return ForgeRegistries.POTIONS.getValue(new ResourceLocation(name));
  30. }
  31. public static ParticleType getParticle(String name) {
  32. return ForgeRegistries.PARTICLE_TYPES.getValue(new ResourceLocation(name));
  33. }
  34. public static Item getItem(String name) {
  35. return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name));
  36. }
  37. public static Block getBlock(String name) {
  38. return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(name));
  39. }
  40. public static Property getProperty(String name) {
  41. switch(name) {
  42. case "attached":
  43. return BlockStateProperties.ATTACHED;
  44. case "bottom":
  45. return BlockStateProperties.BOTTOM;
  46. case "conditional":
  47. return BlockStateProperties.CONDITIONAL;
  48. case "disarmed":
  49. return BlockStateProperties.DISARMED;
  50. case "drag":
  51. return BlockStateProperties.DRAG;
  52. case "enabled":
  53. return BlockStateProperties.ENABLED;
  54. case "extended":
  55. return BlockStateProperties.EXTENDED;
  56. case "eye":
  57. return BlockStateProperties.EYE;
  58. case "falling":
  59. return BlockStateProperties.FALLING;
  60. case "hanging":
  61. return BlockStateProperties.HANGING;
  62. case "has_bottle_0":
  63. return BlockStateProperties.HAS_BOTTLE_0;
  64. case "has_bottle_1":
  65. return BlockStateProperties.HAS_BOTTLE_1;
  66. case "has_bottle_2":
  67. return BlockStateProperties.HAS_BOTTLE_2;
  68. case "has_record":
  69. return BlockStateProperties.HAS_RECORD;
  70. case "has_book":
  71. return BlockStateProperties.HAS_BOOK;
  72. case "inverted":
  73. return BlockStateProperties.INVERTED;
  74. case "in_wall":
  75. return BlockStateProperties.IN_WALL;
  76. case "lit":
  77. return BlockStateProperties.LIT;
  78. case "locked":
  79. return BlockStateProperties.LOCKED;
  80. case "occupied":
  81. return BlockStateProperties.OCCUPIED;
  82. case "open":
  83. return BlockStateProperties.OPEN;
  84. case "persistent":
  85. return BlockStateProperties.PERSISTENT;
  86. case "powered":
  87. return BlockStateProperties.POWERED;
  88. case "short":
  89. return BlockStateProperties.SHORT;
  90. case "signal_fire":
  91. return BlockStateProperties.SIGNAL_FIRE;
  92. case "snowy":
  93. return BlockStateProperties.SNOWY;
  94. case "triggered":
  95. return BlockStateProperties.TRIGGERED;
  96. case "unstable":
  97. return BlockStateProperties.UNSTABLE;
  98. case "waterlogged":
  99. return BlockStateProperties.WATERLOGGED;
  100. case "horizontal_axis":
  101. return BlockStateProperties.HORIZONTAL_AXIS;
  102. case "axis":
  103. return BlockStateProperties.AXIS;
  104. case "up":
  105. return BlockStateProperties.UP;
  106. case "down":
  107. return BlockStateProperties.DOWN;
  108. case "north":
  109. return BlockStateProperties.NORTH;
  110. case "east":
  111. return BlockStateProperties.EAST;
  112. case "south":
  113. return BlockStateProperties.SOUTH;
  114. case "west":
  115. return BlockStateProperties.WEST;
  116. case "facing":
  117. return BlockStateProperties.FACING;
  118. case "facing_except_up":
  119. return BlockStateProperties.FACING_EXCEPT_UP;
  120. case "horizontal_facing":
  121. return BlockStateProperties.HORIZONTAL_FACING;
  122. case "face":
  123. return BlockStateProperties.FACE;
  124. case "attachment":
  125. return BlockStateProperties.BELL_ATTACHMENT;
  126. case "redstone_east":
  127. return BlockStateProperties.REDSTONE_EAST;
  128. case "redstone_north":
  129. return BlockStateProperties.REDSTONE_NORTH;
  130. case "redstone_south":
  131. return BlockStateProperties.REDSTONE_SOUTH;
  132. case "redstone_west":
  133. return BlockStateProperties.REDSTONE_WEST;
  134. case "double_block_half":
  135. return BlockStateProperties.DOUBLE_BLOCK_HALF;
  136. case "half":
  137. return BlockStateProperties.HALF;
  138. case "rail_shape":
  139. return BlockStateProperties.RAIL_SHAPE;
  140. case "rail_shape_straight":
  141. return BlockStateProperties.RAIL_SHAPE_STRAIGHT;
  142. case "age_0_1":
  143. return BlockStateProperties.AGE_0_1;
  144. case "age_0_2":
  145. return BlockStateProperties.AGE_0_2;
  146. case "age_0_3":
  147. return BlockStateProperties.AGE_0_3;
  148. case "age_0_5":
  149. return BlockStateProperties.AGE_0_5;
  150. case "age_0_7":
  151. return BlockStateProperties.AGE_0_7;
  152. case "age_0_15":
  153. return BlockStateProperties.AGE_0_15;
  154. case "age_0_25":
  155. return BlockStateProperties.AGE_0_25;
  156. case "bites":
  157. return BlockStateProperties.BITES_0_6;
  158. case "delay":
  159. return BlockStateProperties.DELAY_1_4;
  160. case "distance_1_7":
  161. return BlockStateProperties.DISTANCE_1_7;
  162. case "eggs":
  163. return BlockStateProperties.EGGS_1_4;
  164. case "hatch":
  165. return BlockStateProperties.HATCH_0_2;
  166. case "layers":
  167. return BlockStateProperties.LAYERS_1_8;
  168. case "level_0_3":
  169. return BlockStateProperties.LEVEL_0_3;
  170. case "level_0_8":
  171. return BlockStateProperties.LEVEL_0_8;
  172. case "level_1_8":
  173. return BlockStateProperties.LEVEL_1_8;
  174. case "level_0_15":
  175. return BlockStateProperties.LEVEL_0_15;
  176. case "moisture":
  177. return BlockStateProperties.MOISTURE_0_7;
  178. case "note":
  179. return BlockStateProperties.NOTE_0_24;
  180. case "pickles":
  181. return BlockStateProperties.PICKLES_1_4;
  182. case "power":
  183. return BlockStateProperties.POWER_0_15;
  184. case "stage":
  185. return BlockStateProperties.STAGE_0_1;
  186. case "distance_0_7":
  187. return BlockStateProperties.DISTANCE_0_7;
  188. case "rotation":
  189. return BlockStateProperties.ROTATION_0_15;
  190. case "part":
  191. return BlockStateProperties.BED_PART;
  192. case "chest_type":
  193. return BlockStateProperties.CHEST_TYPE;
  194. case "mode":
  195. return BlockStateProperties.COMPARATOR_MODE;
  196. case "hinge":
  197. return BlockStateProperties.DOOR_HINGE;
  198. case "instrument":
  199. return BlockStateProperties.NOTE_BLOCK_INSTRUMENT;
  200. case "piston_type":
  201. return BlockStateProperties.PISTON_TYPE;
  202. case "slab_type":
  203. return BlockStateProperties.SLAB_TYPE;
  204. case "stair_shape":
  205. return BlockStateProperties.STAIRS_SHAPE;
  206. case "structure_block_mode":
  207. return BlockStateProperties.STRUCTURE_BLOCK_MODE;
  208. case "leaves":
  209. return BlockStateProperties.BAMBOO_LEAVES;
  210. }
  211. return null;
  212. }
  213. }