Mapper.java 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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.IParticleData;
  6. import net.minecraft.potion.Effect;
  7. import net.minecraft.state.IProperty;
  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.minecraft.world.GameRules;
  13. import net.minecraftforge.registries.ForgeRegistries;
  14. public class Mapper
  15. {
  16. public static SoundEvent getSound(String name)
  17. {
  18. return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(name));
  19. }
  20. public static SoundCategory getSoundCategory(String name)
  21. {
  22. for(SoundCategory sc : SoundCategory.values())
  23. {
  24. if(sc.getName().equals(name))
  25. {
  26. return sc;
  27. }
  28. }
  29. return SoundCategory.MASTER;
  30. }
  31. public static Enchantment getEnchantment(String name)
  32. {
  33. return ForgeRegistries.ENCHANTMENTS.getValue(new ResourceLocation(name));
  34. }
  35. public static Effect getPotion(String name)
  36. {
  37. return ForgeRegistries.POTIONS.getValue(new ResourceLocation(name));
  38. }
  39. public static IParticleData getParticle(String name)
  40. {
  41. return (IParticleData) ForgeRegistries.PARTICLE_TYPES.getValue(new ResourceLocation(name));
  42. }
  43. public static Item getItem(String name)
  44. {
  45. return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name));
  46. }
  47. public static Block getBlock(String name)
  48. {
  49. return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(name));
  50. }
  51. public static GameRules.RuleKey getGameRule(String name)
  52. {
  53. switch(name)
  54. {
  55. case "doFireTick": return GameRules.DO_FIRE_TICK;
  56. case "mobGriefing": return GameRules.MOB_GRIEFING;
  57. case "keepInventory": return GameRules.KEEP_INVENTORY;
  58. case "doMobSpawning": return GameRules.DO_MOB_SPAWNING;
  59. case "doMobLoot": return GameRules.DO_MOB_LOOT;
  60. case "doTileDrops": return GameRules.DO_TILE_DROPS;
  61. case "doEntityDrops": return GameRules.DO_ENTITY_DROPS;
  62. case "commandBlockOutput": return GameRules.COMMAND_BLOCK_OUTPUT;
  63. case "naturalRegeneration": return GameRules.NATURAL_REGENERATION;
  64. case "doDaylightCycle": return GameRules.DO_DAYLIGHT_CYCLE;
  65. case "logAdminCommands": return GameRules.LOG_ADMIN_COMMANDS;
  66. case "showDeathMessages": return GameRules.SHOW_DEATH_MESSAGES;
  67. case "randomTickSpeed": return GameRules.RANDOM_TICK_SPEED;
  68. case "sendCommandFeedback": return GameRules.SEND_COMMAND_FEEDBACK;
  69. case "reducedDebugInfo": return GameRules.REDUCED_DEBUG_INFO;
  70. case "spectatorsGenerateChunks": return GameRules.SPECTATORS_GENERATE_CHUNKS;
  71. case "spawnRadius": return GameRules.SPAWN_RADIUS;
  72. case "disableElytraMovementCheck": return GameRules.DISABLE_ELYTRA_MOVEMENT_CHECK;
  73. case "maxEntityCramming": return GameRules.MAX_ENTITY_CRAMMING;
  74. case "doWeatherCycle": return GameRules.DO_WEATHER_CYCLE;
  75. case "doLimitedCrafting": return GameRules.DO_LIMITED_CRAFTING;
  76. case "maxCommandChainLength": return GameRules.MAX_COMMAND_CHAIN_LENGTH;
  77. case "announceAdvancements": return GameRules.ANNOUNCE_ADVANCEMENTS;
  78. case "disableRaids": return GameRules.DISABLE_RAIDS;
  79. case "doInsomnia": return GameRules.DO_INSOMNIA;
  80. case "doImmediateRespawn": return GameRules.DO_IMMEDIATE_RESPAWN;
  81. }
  82. return null;
  83. }
  84. public static IProperty getProperty(String name)
  85. {
  86. switch(name)
  87. {
  88. case "attached": return BlockStateProperties.ATTACHED;
  89. case "bottom": return BlockStateProperties.BOTTOM;
  90. case "conditional": return BlockStateProperties.CONDITIONAL;
  91. case "disarmed": return BlockStateProperties.DISARMED;
  92. case "drag": return BlockStateProperties.DRAG;
  93. case "enabled": return BlockStateProperties.ENABLED;
  94. case "extended": return BlockStateProperties.EXTENDED;
  95. case "eye": return BlockStateProperties.EYE;
  96. case "falling": return BlockStateProperties.FALLING;
  97. case "hanging": return BlockStateProperties.HANGING;
  98. case "has_bottle_0": return BlockStateProperties.HAS_BOTTLE_0;
  99. case "has_bottle_1": return BlockStateProperties.HAS_BOTTLE_1;
  100. case "has_bottle_2": return BlockStateProperties.HAS_BOTTLE_2;
  101. case "has_record": return BlockStateProperties.HAS_RECORD;
  102. case "has_book": return BlockStateProperties.HAS_BOOK;
  103. case "inverted": return BlockStateProperties.INVERTED;
  104. case "in_wall": return BlockStateProperties.IN_WALL;
  105. case "lit": return BlockStateProperties.LIT;
  106. case "locked": return BlockStateProperties.LOCKED;
  107. case "occupied": return BlockStateProperties.OCCUPIED;
  108. case "open": return BlockStateProperties.OPEN;
  109. case "persistent": return BlockStateProperties.PERSISTENT;
  110. case "powered": return BlockStateProperties.POWERED;
  111. case "short": return BlockStateProperties.SHORT;
  112. case "signal_fire": return BlockStateProperties.SIGNAL_FIRE;
  113. case "snowy": return BlockStateProperties.SNOWY;
  114. case "triggered": return BlockStateProperties.TRIGGERED;
  115. case "unstable": return BlockStateProperties.UNSTABLE;
  116. case "waterlogged": return BlockStateProperties.WATERLOGGED;
  117. case "horizontal_axis": return BlockStateProperties.HORIZONTAL_AXIS;
  118. case "axis": return BlockStateProperties.AXIS;
  119. case "up": return BlockStateProperties.UP;
  120. case "down": return BlockStateProperties.DOWN;
  121. case "north": return BlockStateProperties.NORTH;
  122. case "east": return BlockStateProperties.EAST;
  123. case "south": return BlockStateProperties.SOUTH;
  124. case "west": return BlockStateProperties.WEST;
  125. case "facing": return BlockStateProperties.FACING;
  126. case "facing_except_up": return BlockStateProperties.FACING_EXCEPT_UP;
  127. case "horizontal_facing": return BlockStateProperties.HORIZONTAL_FACING;
  128. case "face": return BlockStateProperties.FACE;
  129. case "attachment": return BlockStateProperties.BELL_ATTACHMENT;
  130. case "redstone_east": return BlockStateProperties.REDSTONE_EAST;
  131. case "redstone_north": return BlockStateProperties.REDSTONE_NORTH;
  132. case "redstone_south": return BlockStateProperties.REDSTONE_SOUTH;
  133. case "redstone_west": return BlockStateProperties.REDSTONE_WEST;
  134. case "double_block_half": return BlockStateProperties.DOUBLE_BLOCK_HALF;
  135. case "half": return BlockStateProperties.HALF;
  136. case "rail_shape": return BlockStateProperties.RAIL_SHAPE;
  137. case "rail_shape_straight": return BlockStateProperties.RAIL_SHAPE_STRAIGHT;
  138. case "age_0_1": return BlockStateProperties.AGE_0_1;
  139. case "age_0_2": return BlockStateProperties.AGE_0_2;
  140. case "age_0_3": return BlockStateProperties.AGE_0_3;
  141. case "age_0_5": return BlockStateProperties.AGE_0_5;
  142. case "age_0_7": return BlockStateProperties.AGE_0_7;
  143. case "age_0_15": return BlockStateProperties.AGE_0_15;
  144. case "age_0_25": return BlockStateProperties.AGE_0_25;
  145. case "bites": return BlockStateProperties.BITES_0_6;
  146. case "delay": return BlockStateProperties.DELAY_1_4;
  147. case "distance_1_7": return BlockStateProperties.DISTANCE_1_7;
  148. case "eggs": return BlockStateProperties.EGGS_1_4;
  149. case "hatch": return BlockStateProperties.HATCH_0_2;
  150. case "layers": return BlockStateProperties.LAYERS_1_8;
  151. case "level_0_3": return BlockStateProperties.LEVEL_0_3;
  152. case "level_0_8": return BlockStateProperties.LEVEL_0_8;
  153. case "level_1_8": return BlockStateProperties.LEVEL_1_8;
  154. case "level_0_15": return BlockStateProperties.LEVEL_0_15;
  155. case "moisture": return BlockStateProperties.MOISTURE_0_7;
  156. case "note": return BlockStateProperties.NOTE_0_24;
  157. case "pickles": return BlockStateProperties.PICKLES_1_4;
  158. case "power": return BlockStateProperties.POWER_0_15;
  159. case "stage": return BlockStateProperties.STAGE_0_1;
  160. case "distance_0_7": return BlockStateProperties.DISTANCE_0_7;
  161. case "rotation": return BlockStateProperties.ROTATION_0_15;
  162. case "part": return BlockStateProperties.BED_PART;
  163. case "chest_type": return BlockStateProperties.CHEST_TYPE;
  164. case "mode": return BlockStateProperties.COMPARATOR_MODE;
  165. case "hinge": return BlockStateProperties.DOOR_HINGE;
  166. case "instrument": return BlockStateProperties.NOTE_BLOCK_INSTRUMENT;
  167. case "piston_type": return BlockStateProperties.PISTON_TYPE;
  168. case "slab_type": return BlockStateProperties.SLAB_TYPE;
  169. case "stair_shape": return BlockStateProperties.STAIRS_SHAPE;
  170. case "structure_block_mode": return BlockStateProperties.STRUCTURE_BLOCK_MODE;
  171. case "leaves": return BlockStateProperties.BAMBOO_LEAVES;
  172. }
  173. return null;
  174. }
  175. }