/** * Retrieve a read/write structure for the Difficulty enum in 1.7.2. * @return A modifier for Difficulty enum fields. */ public StructureModifier<Difficulty> getDifficulties() { // Convert to and from the wrapper return structureModifier.withType( EnumWrappers.getDifficultyClass(), EnumWrappers.getDifficultyConverter()); }
private PacketContainer createRespawnPacket(NativeGameMode gamemode) throws ReflectiveOperationException { PacketContainer respawn = new PacketContainer(RESPAWN); Difficulty difficulty = EnumWrappers.getDifficultyConverter().getSpecific(receiver.getWorld().getDifficulty()); //<= 1.13.1 int dimensionId = receiver.getWorld().getEnvironment().getId(); respawn.getIntegers().writeSafely(0, dimensionId); //> 1.13.1 if (MinecraftVersion.getCurrentVersion().compareTo(MinecraftVersion.AQUATIC_UPDATE) > 0) { try { respawn.getDimensions().writeSafely(0, dimensionId); } catch (NoSuchMethodError noSuchMethodError) { throw new ReflectiveOperationException("Unable to find dimension setter. " + "Your ProtocolLib version is incompatible with this plugin version in combination with " + "Minecraft 1.13.1. " + "Try to download an update of ProtocolLib.", noSuchMethodError); } } respawn.getDifficulties().write(0, difficulty); respawn.getGameModes().write(0, gamemode); respawn.getWorldTypeModifier().write(0, receiver.getWorld().getWorldType()); return respawn; }
associate(CLIENT_COMMAND_CLASS, ClientCommand.class, getClientCommandConverter()); associate(CHAT_VISIBILITY_CLASS, ChatVisibility.class, getChatVisibilityConverter()); associate(DIFFICULTY_CLASS, Difficulty.class, getDifficultyConverter()); associate(ENTITY_USE_ACTION_CLASS, EntityUseAction.class, getEntityUseActionConverter()); associate(GAMEMODE_CLASS, NativeGameMode.class, getGameModeConverter());