package me.km.utils; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; import net.minecraft.particles.IParticleData; import net.minecraft.potion.Effect; import net.minecraft.state.IProperty; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.world.GameRules; import net.minecraftforge.registries.ForgeRegistries; public class Mapper { public static SoundEvent getSound(String name) { return ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(name)); } public static SoundCategory getSoundCategory(String name) { for(SoundCategory sc : SoundCategory.values()) { if(sc.getName().equals(name)) { return sc; } } return SoundCategory.MASTER; } public static Enchantment getEnchantment(String name) { return ForgeRegistries.ENCHANTMENTS.getValue(new ResourceLocation(name)); } public static Effect getPotion(String name) { return ForgeRegistries.POTIONS.getValue(new ResourceLocation(name)); } public static IParticleData getParticle(String name) { return (IParticleData) ForgeRegistries.PARTICLE_TYPES.getValue(new ResourceLocation(name)); } public static Item getItem(String name) { return ForgeRegistries.ITEMS.getValue(new ResourceLocation(name)); } public static Block getBlock(String name) { return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(name)); } public static GameRules.RuleKey getGameRule(String name) { switch(name) { case "doFireTick": return GameRules.DO_FIRE_TICK; case "mobGriefing": return GameRules.MOB_GRIEFING; case "keepInventory": return GameRules.KEEP_INVENTORY; case "doMobSpawning": return GameRules.DO_MOB_SPAWNING; case "doMobLoot": return GameRules.DO_MOB_LOOT; case "doTileDrops": return GameRules.DO_TILE_DROPS; case "doEntityDrops": return GameRules.DO_ENTITY_DROPS; case "commandBlockOutput": return GameRules.COMMAND_BLOCK_OUTPUT; case "naturalRegeneration": return GameRules.NATURAL_REGENERATION; case "doDaylightCycle": return GameRules.DO_DAYLIGHT_CYCLE; case "logAdminCommands": return GameRules.LOG_ADMIN_COMMANDS; case "showDeathMessages": return GameRules.SHOW_DEATH_MESSAGES; case "randomTickSpeed": return GameRules.RANDOM_TICK_SPEED; case "sendCommandFeedback": return GameRules.SEND_COMMAND_FEEDBACK; case "reducedDebugInfo": return GameRules.REDUCED_DEBUG_INFO; case "spectatorsGenerateChunks": return GameRules.SPECTATORS_GENERATE_CHUNKS; case "spawnRadius": return GameRules.SPAWN_RADIUS; case "disableElytraMovementCheck": return GameRules.DISABLE_ELYTRA_MOVEMENT_CHECK; case "maxEntityCramming": return GameRules.MAX_ENTITY_CRAMMING; case "doWeatherCycle": return GameRules.DO_WEATHER_CYCLE; case "doLimitedCrafting": return GameRules.DO_LIMITED_CRAFTING; case "maxCommandChainLength": return GameRules.MAX_COMMAND_CHAIN_LENGTH; case "announceAdvancements": return GameRules.ANNOUNCE_ADVANCEMENTS; case "disableRaids": return GameRules.DISABLE_RAIDS; case "doInsomnia": return GameRules.DO_INSOMNIA; case "doImmediateRespawn": return GameRules.DO_IMMEDIATE_RESPAWN; } return null; } public static IProperty getProperty(String name) { switch(name) { case "attached": return BlockStateProperties.ATTACHED; case "bottom": return BlockStateProperties.BOTTOM; case "conditional": return BlockStateProperties.CONDITIONAL; case "disarmed": return BlockStateProperties.DISARMED; case "drag": return BlockStateProperties.DRAG; case "enabled": return BlockStateProperties.ENABLED; case "extended": return BlockStateProperties.EXTENDED; case "eye": return BlockStateProperties.EYE; case "falling": return BlockStateProperties.FALLING; case "hanging": return BlockStateProperties.HANGING; case "has_bottle_0": return BlockStateProperties.HAS_BOTTLE_0; case "has_bottle_1": return BlockStateProperties.HAS_BOTTLE_1; case "has_bottle_2": return BlockStateProperties.HAS_BOTTLE_2; case "has_record": return BlockStateProperties.HAS_RECORD; case "has_book": return BlockStateProperties.HAS_BOOK; case "inverted": return BlockStateProperties.INVERTED; case "in_wall": return BlockStateProperties.IN_WALL; case "lit": return BlockStateProperties.LIT; case "locked": return BlockStateProperties.LOCKED; case "occupied": return BlockStateProperties.OCCUPIED; case "open": return BlockStateProperties.OPEN; case "persistent": return BlockStateProperties.PERSISTENT; case "powered": return BlockStateProperties.POWERED; case "short": return BlockStateProperties.SHORT; case "signal_fire": return BlockStateProperties.SIGNAL_FIRE; case "snowy": return BlockStateProperties.SNOWY; case "triggered": return BlockStateProperties.TRIGGERED; case "unstable": return BlockStateProperties.UNSTABLE; case "waterlogged": return BlockStateProperties.WATERLOGGED; case "horizontal_axis": return BlockStateProperties.HORIZONTAL_AXIS; case "axis": return BlockStateProperties.AXIS; case "up": return BlockStateProperties.UP; case "down": return BlockStateProperties.DOWN; case "north": return BlockStateProperties.NORTH; case "east": return BlockStateProperties.EAST; case "south": return BlockStateProperties.SOUTH; case "west": return BlockStateProperties.WEST; case "facing": return BlockStateProperties.FACING; case "facing_except_up": return BlockStateProperties.FACING_EXCEPT_UP; case "horizontal_facing": return BlockStateProperties.HORIZONTAL_FACING; case "face": return BlockStateProperties.FACE; case "attachment": return BlockStateProperties.BELL_ATTACHMENT; case "redstone_east": return BlockStateProperties.REDSTONE_EAST; case "redstone_north": return BlockStateProperties.REDSTONE_NORTH; case "redstone_south": return BlockStateProperties.REDSTONE_SOUTH; case "redstone_west": return BlockStateProperties.REDSTONE_WEST; case "double_block_half": return BlockStateProperties.DOUBLE_BLOCK_HALF; case "half": return BlockStateProperties.HALF; case "rail_shape": return BlockStateProperties.RAIL_SHAPE; case "rail_shape_straight": return BlockStateProperties.RAIL_SHAPE_STRAIGHT; case "age_0_1": return BlockStateProperties.AGE_0_1; case "age_0_2": return BlockStateProperties.AGE_0_2; case "age_0_3": return BlockStateProperties.AGE_0_3; case "age_0_5": return BlockStateProperties.AGE_0_5; case "age_0_7": return BlockStateProperties.AGE_0_7; case "age_0_15": return BlockStateProperties.AGE_0_15; case "age_0_25": return BlockStateProperties.AGE_0_25; case "bites": return BlockStateProperties.BITES_0_6; case "delay": return BlockStateProperties.DELAY_1_4; case "distance_1_7": return BlockStateProperties.DISTANCE_1_7; case "eggs": return BlockStateProperties.EGGS_1_4; case "hatch": return BlockStateProperties.HATCH_0_2; case "layers": return BlockStateProperties.LAYERS_1_8; case "level_0_3": return BlockStateProperties.LEVEL_0_3; case "level_0_8": return BlockStateProperties.LEVEL_0_8; case "level_1_8": return BlockStateProperties.LEVEL_1_8; case "level_0_15": return BlockStateProperties.LEVEL_0_15; case "moisture": return BlockStateProperties.MOISTURE_0_7; case "note": return BlockStateProperties.NOTE_0_24; case "pickles": return BlockStateProperties.PICKLES_1_4; case "power": return BlockStateProperties.POWER_0_15; case "stage": return BlockStateProperties.STAGE_0_1; case "distance_0_7": return BlockStateProperties.DISTANCE_0_7; case "rotation": return BlockStateProperties.ROTATION_0_15; case "part": return BlockStateProperties.BED_PART; case "chest_type": return BlockStateProperties.CHEST_TYPE; case "mode": return BlockStateProperties.COMPARATOR_MODE; case "hinge": return BlockStateProperties.DOOR_HINGE; case "instrument": return BlockStateProperties.NOTE_BLOCK_INSTRUMENT; case "piston_type": return BlockStateProperties.PISTON_TYPE; case "slab_type": return BlockStateProperties.SLAB_TYPE; case "stair_shape": return BlockStateProperties.STAIRS_SHAPE; case "structure_block_mode": return BlockStateProperties.STRUCTURE_BLOCK_MODE; case "leaves": return BlockStateProperties.BAMBOO_LEAVES; } return null; } }