Mapper.java 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.util.ResourceLocation;
  8. import net.minecraft.util.SoundEvent;
  9. import net.minecraft.world.GameRules;
  10. import net.minecraftforge.registries.ForgeRegistries;
  11. public class Mapper
  12. {
  13. public static SoundEvent getSound(String name)
  14. {
  15. return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(name));
  16. }
  17. public static Enchantment getEnchantment(String name)
  18. {
  19. return ForgeRegistries.ENCHANTMENTS.getValue(new ResourceLocation(name));
  20. }
  21. public static Effect getPotion(String name)
  22. {
  23. return ForgeRegistries.POTIONS.getValue(new ResourceLocation(name));
  24. }
  25. public static IParticleData getParticle(String name)
  26. {
  27. return (IParticleData) ForgeRegistries.PARTICLE_TYPES.getValue(new ResourceLocation(name));
  28. }
  29. public static Item getItem(String name)
  30. {
  31. return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name));
  32. }
  33. public static Block getBlock(String name)
  34. {
  35. return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(name));
  36. }
  37. public static GameRules.RuleKey getGameRule(String name)
  38. {
  39. switch(name)
  40. {
  41. case "doFireTick": return GameRules.DO_FIRE_TICK;
  42. case "mobGriefing": return GameRules.MOB_GRIEFING;
  43. case "keepInventory": return GameRules.KEEP_INVENTORY;
  44. case "doMobSpawning": return GameRules.DO_MOB_SPAWNING;
  45. case "doMobLoot": return GameRules.DO_MOB_LOOT;
  46. case "doTileDrops": return GameRules.DO_TILE_DROPS;
  47. case "doEntityDrops": return GameRules.DO_ENTITY_DROPS;
  48. case "commandBlockOutput": return GameRules.COMMAND_BLOCK_OUTPUT;
  49. case "naturalRegeneration": return GameRules.NATURAL_REGENERATION;
  50. case "doDaylightCycle": return GameRules.DO_DAYLIGHT_CYCLE;
  51. case "logAdminCommands": return GameRules.LOG_ADMIN_COMMANDS;
  52. case "showDeathMessages": return GameRules.SHOW_DEATH_MESSAGES;
  53. case "randomTickSpeed": return GameRules.RANDOM_TICK_SPEED;
  54. case "sendCommandFeedback": return GameRules.SEND_COMMAND_FEEDBACK;
  55. case "reducedDebugInfo": return GameRules.REDUCED_DEBUG_INFO;
  56. case "spectatorsGenerateChunks": return GameRules.SPECTATORS_GENERATE_CHUNKS;
  57. case "spawnRadius": return GameRules.SPAWN_RADIUS;
  58. case "disableElytraMovementCheck": return GameRules.DISABLE_ELYTRA_MOVEMENT_CHECK;
  59. case "maxEntityCramming": return GameRules.MAX_ENTITY_CRAMMING;
  60. case "doWeatherCycle": return GameRules.DO_WEATHER_CYCLE;
  61. case "doLimitedCrafting": return GameRules.DO_LIMITED_CRAFTING;
  62. case "maxCommandChainLength": return GameRules.MAX_COMMAND_CHAIN_LENGTH;
  63. case "announceAdvancements": return GameRules.ANNOUNCE_ADVANCEMENTS;
  64. case "disableRaids": return GameRules.DISABLE_RAIDS;
  65. }
  66. return null;
  67. }
  68. }